|
|
@@ -39,7 +39,13 @@ int count_dbconn;
|
|
|
return NO;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+void offline_dirty(sqlite3_context *context, int argc, sqlite3_value **argv) {
|
|
|
+ AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
|
|
|
+ NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];
|
|
|
+ [defaults removeObjectForKey:@"Need_Sync"];
|
|
|
+ [defaults setBool:true forKey:@"Need_Sync"];
|
|
|
+ [defaults synchronize];
|
|
|
+}
|
|
|
void encryptfield (sqlite3_context *context, int argc, sqlite3_value **argv) {
|
|
|
assert(argc == 1);
|
|
|
switch (sqlite3_value_type(argv[0])){
|
|
|
@@ -113,6 +119,7 @@ void decryptfield (sqlite3_context *context, int argc, sqlite3_value **argv) {
|
|
|
int nResult = 0;
|
|
|
nResult=sqlite3_create_function(db, "decrypt", -1, SQLITE_ANY, 0, decryptfield, 0, 0);
|
|
|
nResult=sqlite3_create_function(db, "encrypt", -1, SQLITE_ANY, 0, encryptfield, 0, 0);
|
|
|
+ nResult=sqlite3_create_function(db, "offline_dirty", -1, SQLITE_ANY, 0, offline_dirty, 0, 0);
|
|
|
// sqlite3_create_function(database, "yourAwesome", 4, SQLITE_UTF8, NULL, &yourAwesomeFunc, NULL, NULL);
|
|
|
// nResult = sqlite3_create_function(db, "containi", -1, SQLITE_ANY, 0, icuContainiFunc, 0, 0);
|
|
|
return nResult;
|
|
|
@@ -683,6 +690,8 @@ void decryptfield (sqlite3_context *context, int argc, sqlite3_value **argv) {
|
|
|
|
|
|
NSString* create_offline_salesrep=@"CREATE TABLE IF NOT EXISTS offline_salesrep ( _id INTEGER PRIMARY KEY, name text, code text,salesrep_id integer);";
|
|
|
|
|
|
+ NSString* create_order_trigger=@"CREATE TRIGGER if not exists offline_order_insert after insert on offline_order BEGIN select offline_dirty(''); select encrypt('abc'); END;";
|
|
|
+
|
|
|
//
|
|
|
|
|
|
AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
|
|
|
@@ -722,6 +731,7 @@ void decryptfield (sqlite3_context *context, int argc, sqlite3_value **argv) {
|
|
|
[self execSql:create_bundle db:db];
|
|
|
[self execSql:create_catalog db:db];
|
|
|
[self execSql:create_errlog db:db];
|
|
|
+ [self execSql:create_order_trigger db:db];
|
|
|
|
|
|
|
|
|
|