|
@@ -298,10 +298,10 @@
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
[self deleteResultFields];
|
|
[self deleteResultFields];
|
|
|
|
|
+ [self updateResultDisplayFields];
|
|
|
|
|
|
|
|
return YES;
|
|
return YES;
|
|
|
|
|
|
|
|
-
|
|
|
|
|
DebugLog (@"bottom of initializeDb");
|
|
DebugLog (@"bottom of initializeDb");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -665,29 +665,55 @@
|
|
|
return fields;
|
|
return fields;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// 数据库初始化完成之后或数据库更新之后删除
|
|
|
|
|
|
|
+// 数据库更新之后 和 数据库初始化完成 删除
|
|
|
+ (void)deleteResultFields {
|
|
+ (void)deleteResultFields {
|
|
|
|
|
|
|
|
- NSString *key = @"delete_result_fields";
|
|
|
|
|
- BOOL delete = [[NSUserDefaults standardUserDefaults] boolForKey:key];
|
|
|
|
|
- if (!delete) {
|
|
|
|
|
-
|
|
|
|
|
- NSString *booking_sql = @"delete from fields_info where behavior = 1 and function_name = 'Ocean Booking' and name in ('booking_no','shipper','consignee','po_no','f_etd,m_eta','place_of_receipt_uncode','place_of_delivery_uncode');";
|
|
|
|
|
-
|
|
|
|
|
- NSString *bl_sql = @"delete from fields_info where behavior = 1 and function_name = 'Ocean B/L info.' and name in ('last_status_315_code','shipper,consignee','h_bol,etd','eta,po_no','place_of_receipt_un','place_of_delivery_un');";
|
|
|
|
|
-
|
|
|
|
|
- NSString *cn_sql = @"delete from fields_info where behavior = 1 and function_name = 'Container detail' and name in ('shipper','consignee','ctnr','file_no','po_no','etd','eta','fport_of_loading_un','mport_of_discharge_un');";
|
|
|
|
|
-
|
|
|
|
|
- sqlite3 *db = [self get_db];
|
|
|
|
|
-
|
|
|
|
|
- [self execSql:booking_sql db:db];
|
|
|
|
|
- [self execSql:bl_sql db:db];
|
|
|
|
|
- [self execSql:cn_sql db:db];
|
|
|
|
|
-
|
|
|
|
|
- sqlite3_close(db);
|
|
|
|
|
-
|
|
|
|
|
- [[NSUserDefaults standardUserDefaults] setValue:@(YES) forKey:key];
|
|
|
|
|
|
|
+ NSString *booking_sql = @"delete from fields_info where behavior = 1 and function_name = 'Ocean Booking' and name in ('booking_no','shipper','consignee','po_no','f_etd,m_eta','place_of_receipt_uncode','place_of_delivery_uncode');";
|
|
|
|
|
+
|
|
|
|
|
+ NSString *bl_sql = @"delete from fields_info where behavior = 1 and function_name = 'Ocean B/L info.' and name in ('last_status_315_code','shipper,consignee','h_bol,etd','eta,po_no','place_of_receipt_un','place_of_delivery_un');";
|
|
|
|
|
+
|
|
|
|
|
+ NSString *cn_sql = @"delete from fields_info where behavior = 1 and function_name = 'Container detail' and name in ('shipper','consignee','ctnr','file_no','po_no','etd','eta','fport_of_loading_un','mport_of_discharge_un');";
|
|
|
|
|
+
|
|
|
|
|
+ sqlite3 *db = [self get_db];
|
|
|
|
|
+
|
|
|
|
|
+ [self execSql:booking_sql db:db];
|
|
|
|
|
+ [self execSql:bl_sql db:db];
|
|
|
|
|
+ [self execSql:cn_sql db:db];
|
|
|
|
|
+
|
|
|
|
|
+ sqlite3_close(db);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
++ (void)updateResultDisplayFields {
|
|
|
|
|
+
|
|
|
|
|
+ __block NSMutableArray *users = [NSMutableArray array];
|
|
|
|
|
+
|
|
|
|
|
+ NSString *user_sql = @"select distinct user from fields_info;";
|
|
|
|
|
+ [self jk_sync_query:user_sql completion:^(sqlite3_stmt *stmt, long *count) {
|
|
|
|
|
+
|
|
|
|
|
+ char *user_ch = (char *)sqlite3_column_text(stmt, 0);
|
|
|
|
|
+ NSString *user = [NSString stringWithUTF8String:user_ch];
|
|
|
|
|
+
|
|
|
|
|
+ [users addObject:user];
|
|
|
|
|
+
|
|
|
|
|
+ } failure:^(NSString *error) {
|
|
|
|
|
+
|
|
|
|
|
+ }];
|
|
|
|
|
+
|
|
|
|
|
+ NSArray *functions = @[@"Ocean Booking", @"Ocean B/L info.", @"Container detail"];
|
|
|
|
|
+ NSUInteger maxDisplay = 3;
|
|
|
|
|
+
|
|
|
|
|
+ sqlite3 *db = [self get_db];
|
|
|
|
|
+
|
|
|
|
|
+ for (NSString *user in users) {
|
|
|
|
|
+
|
|
|
|
|
+ for (NSString *function in functions) {
|
|
|
|
|
+
|
|
|
|
|
+ NSString *sql = [NSString stringWithFormat:@"update fields_info set show = 0 where behavior = 1 and show = 1 and user = '%@' and function_name = '%@' and name in (select name from fields_info where function_name='%@' and user = '%@' and behavior=1 and show=1 order by priority,aname limit %d offset %lu);", user, function, function, user, INT_MAX, maxDisplay];
|
|
|
|
|
+
|
|
|
|
|
+ [self execSql:sql db:db];
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
+ sqlite3_close(db);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@end
|
|
@end
|