|
|
@@ -10,7 +10,7 @@
|
|
|
#import "AESCrypt.h"
|
|
|
#import "AppDelegate.h"
|
|
|
|
|
|
-//NSLock *dblock ;
|
|
|
+NSLock *dblock ;
|
|
|
int count_dbconn;
|
|
|
//int count_tmpdbconn;
|
|
|
@implementation iSalesDB
|
|
|
@@ -358,9 +358,8 @@ void decryptfield (sqlite3_context *context, int argc, sqlite3_value **argv) {
|
|
|
{
|
|
|
|
|
|
|
|
|
- // if(dblock==nil)
|
|
|
- // dblock= [[NSLock alloc] init];
|
|
|
- // [dblock lock];
|
|
|
+
|
|
|
+ [dblock lock];
|
|
|
|
|
|
sqlite3* db = nil;
|
|
|
|
|
|
@@ -370,7 +369,7 @@ void decryptfield (sqlite3_context *context, int argc, sqlite3_value **argv) {
|
|
|
|
|
|
DebugLog(@"DB path:%@",database_path);
|
|
|
count_dbconn++;
|
|
|
- NSLog(@"current dbconn: %d",count_dbconn);
|
|
|
+ NSLog(@"OPEN DB current dbconn: %d",count_dbconn);
|
|
|
if (sqlite3_open([database_path UTF8String], &db) != SQLITE_OK) {
|
|
|
|
|
|
DebugLog(@"sqlite3_open failed. msg:%s",sqlite3_errmsg(db));
|
|
|
@@ -388,8 +387,8 @@ void decryptfield (sqlite3_context *context, int argc, sqlite3_value **argv) {
|
|
|
|
|
|
sqlite3_close(db);
|
|
|
count_dbconn--;
|
|
|
- NSLog(@"current dbconn: %d",count_dbconn);
|
|
|
- // [dblock unlock];
|
|
|
+ NSLog(@"CLOSE DB current dbconn: %d",count_dbconn);
|
|
|
+ [dblock unlock];
|
|
|
|
|
|
|
|
|
|
|
|
@@ -404,13 +403,14 @@ void decryptfield (sqlite3_context *context, int argc, sqlite3_value **argv) {
|
|
|
// NSString *database_path = [documents stringByAppendingPathComponent:DBNAME];
|
|
|
|
|
|
// DebugLog(@"DB path:%@",database_path);
|
|
|
- count_dbconn++;
|
|
|
+ //count_dbconn++;
|
|
|
|
|
|
NSLog(@"current dbconn: %d",count_dbconn);
|
|
|
if (sqlite3_open([path UTF8String], &db) != SQLITE_OK) {
|
|
|
|
|
|
DebugLog(@"sqlite3_open failed. msg:%s",sqlite3_errmsg(db));
|
|
|
- [iSalesDB close_db:db];
|
|
|
+ sqlite3_close(db);
|
|
|
+ //[iSalesDB close_db:db];
|
|
|
}
|
|
|
|
|
|
return db;
|
|
|
@@ -616,14 +616,15 @@ void decryptfield (sqlite3_context *context, int argc, sqlite3_value **argv) {
|
|
|
// end move;
|
|
|
|
|
|
|
|
|
+ if(dblock==nil)
|
|
|
+ dblock= [[NSLock alloc] init];
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
+// [iSalesDB execSql:@"PRAGMA journal_mode = DELETE;"];
|
|
|
|
|
|
sqlite3 *db = [self get_db];
|
|
|
|
|
|
- [self execSql:@"PRAGMA journal_mode = WAL;" db:db];
|
|
|
+ // [self execSql:@"PRAGMA journal_mode = WAL;" db:db];
|
|
|
|
|
|
NSString* create_model=@"CREATE TABLE IF NOT EXISTS model ( _id INTEGER, name VARCHAR(20,0), description VARCHAR(20,0), product_id INTEGER, color VARCHAR(20,0), legcolor VARCHAR(20,0), availability INTEGER, incoming_stock INTEGER, ETA DATE, demension VARCHAR(20,0), seat_height VARCHAR(20,0), material VARCHAR(20,0), box_dim VARCHAR(20,0), volume VARCHAR(20,0), weight VARCHAR(20,0), model_set VARCHAR(20,0), load_ability VARCHAR(20,0), default_category VARCHAR(20,0), category VARCHAR(100,0), fabric_content VARCHAR(20,0), assembling VARCHAR(20,0), made_in VARCHAR(20,0), special_remarks VARCHAR(20,0), stockUom integer, fashion VARCHAR(20,0), isnew integer, property_field VARCHAR(20,0), property_display VARCHAR(20,0), selector_field VARCHAR(20,0), selector_display VARCHAR(20,0), product_group VARCHAR(20,0), packaging VARCHAR(20,0), closeout integer ,best_seller integer,bundle_item text,alert VARCHAR(20,0),PRIMARY KEY(_id));";
|
|
|
|
|
|
@@ -651,7 +652,7 @@ void decryptfield (sqlite3_context *context, int argc, sqlite3_value **argv) {
|
|
|
NSString* create_offline_wish=@"CREATE TABLE IF NOT EXISTS offline_wishlist ( _id INTEGER PRIMARY KEY, product_id INTEGER);";
|
|
|
|
|
|
|
|
|
- NSString* create_offline_contact=@"CREATE TABLE IF NOT EXISTS offline_contact (_id INTEGER, country VARCHAR(40,0), company_name VARCHAR(40,0), contact_id VARCHAR(20,0), addr_1 text, addr_2 text, addr_3 text, addr_4 text, zipcode varchar(20,0), state VARCHAR(40,0), city VARCHAR(40,0), first_name VARCHAR(40,0), last_name VARCHAR(40,0), phone VARCHAR(40,0), fax VARCHAR(40,0), email VARCHAR(40,0), notes text, price_type VARCHAR(40,0), sales_rep VARCHAR(40,0), type VARCHAR(40,0), create_time timestamp default (datetime('now', 'localtime')), editable integer, contact_name VARCHAR(40,0), addr text, Sales_Order_Customer integer, Sales_Order_Freight_Bill_To integer, Sales_Order_Ship_From integer, Sales_Order_Merchandise_Bill_To integer, Contact_Return_To integer, Sales_Order_Ship_To integer,img_0 TEXT,img_1 TEXT,img_2 TEXT,related_cid VARCHAR(20,0), PRIMARY KEY(_id),sync_data text );";
|
|
|
+ NSString* create_offline_contact=@"CREATE TABLE IF NOT EXISTS offline_contact (_id INTEGER, country VARCHAR(40,0), company_name VARCHAR(40,0), contact_id VARCHAR(20,0), addr_1 text, addr_2 text, addr_3 text, addr_4 text, zipcode varchar(20,0), state VARCHAR(40,0), city VARCHAR(40,0), first_name VARCHAR(40,0), last_name VARCHAR(40,0), phone VARCHAR(40,0), fax VARCHAR(40,0), email VARCHAR(40,0), notes text, price_type VARCHAR(40,0), sales_rep VARCHAR(40,0), type VARCHAR(40,0), create_time timestamp default (datetime('now', 'localtime')), editable integer, contact_name VARCHAR(40,0), addr text, Sales_Order_Customer integer, Sales_Order_Freight_Bill_To integer, Sales_Order_Ship_From integer, Sales_Order_Merchandise_Bill_To integer, Contact_Return_To integer, Sales_Order_Ship_To integer,img_0 TEXT,img_1 TEXT,img_2 TEXT,related_cid VARCHAR(20,0),sync_data text, PRIMARY KEY(_id) );";
|
|
|
|
|
|
NSString* create_contact_image=@"CREATE TABLE IF NOT EXISTS contact_image ( _id INTEGER PRIMARY KEY, name VARCHAR(20), url VARCHAR(256), contact_id VARCHAR(20));";
|
|
|
|