|
@@ -10300,7 +10300,7 @@
|
|
|
|
|
|
|
|
// 保存信息
|
|
// 保存信息
|
|
|
|
|
|
|
|
- NSString *save_pdf_sql = [NSString stringWithFormat:@"insert into offline_pdf (tearsheets_id,pdf_path,create_user,tear_note,tear_name,model_info,configureParams) values ((select ifnull(max(tearsheets_id),0) from offline_pdf) + 1,'%@','%@','%@','%@','%@','%@');",pdf_path,create_user,tear_note,tear_name,model_info,configureParams];
|
|
|
|
|
|
|
+ NSString *save_pdf_sql = [NSString stringWithFormat:@"insert into offline_pdf (tearsheets_id,pdf_path,create_user,tear_note,tear_name,model_info,configureParams,is_local) values ((select ifnull(max(tearsheets_id),0) from offline_pdf) + 1,'%@','%@','%@','%@','%@','%@',1);",pdf_path,create_user,tear_note,tear_name,model_info,configureParams];
|
|
|
|
|
|
|
|
int result = [iSalesDB execSql:save_pdf_sql];
|
|
int result = [iSalesDB execSql:save_pdf_sql];
|
|
|
|
|
|
|
@@ -10598,6 +10598,31 @@
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
++ (void)offline_removePDFWithName:(NSString *)name {
|
|
|
|
|
+
|
|
|
|
|
+ NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
|
|
|
|
|
+ NSString *cachefolder = [paths objectAtIndex:0];
|
|
|
|
|
+ NSString *pdfFolder = [cachefolder stringByAppendingPathComponent:@"pdf_cache"];
|
|
|
|
|
+ NSString *path = [pdfFolder stringByAppendingPathComponent:name];
|
|
|
|
|
+
|
|
|
|
|
+ NSFileManager *fileManager = [NSFileManager defaultManager];
|
|
|
|
|
+ [fileManager removeItemAtPath:path error:nil];
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
++ (void)offline_clear_PDFCache {
|
|
|
|
|
+ NSFileManager *fileManager = [NSFileManager defaultManager];
|
|
|
|
|
+ NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
|
|
|
|
|
+ NSString *cachefolder = [paths objectAtIndex:0];
|
|
|
|
|
+ NSString *pdfFolder = [cachefolder stringByAppendingPathComponent:@"pdf_cache"];
|
|
|
|
|
+
|
|
|
|
|
+ NSArray *pdf_files = [fileManager contentsOfDirectoryAtPath:pdfFolder error:nil];
|
|
|
|
|
+
|
|
|
|
|
+ for (NSString *path in pdf_files) {
|
|
|
|
|
+ [self offline_removePDFWithName:[path lastPathComponent]];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
+ (NSData *)offline_removePDF:(NSMutableDictionary *)params {
|
|
+ (NSData *)offline_removePDF:(NSMutableDictionary *)params {
|
|
|
|
|
|
|
|
NSMutableDictionary *dic = [NSMutableDictionary dictionary];
|
|
NSMutableDictionary *dic = [NSMutableDictionary dictionary];
|
|
@@ -10613,8 +10638,25 @@
|
|
|
return [RAUtils dict2data:dic];
|
|
return [RAUtils dict2data:dic];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ NSString *is_local_sql = [NSString stringWithFormat:@"select is_local,pdf_path from offline_pdf where tearsheets_id = %d and create_user = '%@';",tearsheetsId,[self translateSingleQuote:user]];
|
|
|
|
|
+
|
|
|
|
|
+ __block int is_local = 0;
|
|
|
|
|
+ __block NSString *path = @"";
|
|
|
|
|
+ [iSalesDB jk_query:is_local_sql completion:^(sqlite3_stmt *stmt, NSMutableDictionary *container, long *count) {
|
|
|
|
|
+
|
|
|
|
|
+ is_local = sqlite3_column_int(stmt, 0);
|
|
|
|
|
+ path = [self textAtColumn:1 statement:stmt];
|
|
|
|
|
+ }];
|
|
|
|
|
+
|
|
|
NSString *sql = [NSString stringWithFormat:@"update offline_pdf set is_delete = 1 where tearsheets_id = %d and create_user = '%@';",tearsheetsId,[self translateSingleQuote:user]];
|
|
NSString *sql = [NSString stringWithFormat:@"update offline_pdf set is_delete = 1 where tearsheets_id = %d and create_user = '%@';",tearsheetsId,[self translateSingleQuote:user]];
|
|
|
|
|
|
|
|
|
|
+ if (is_local == 1) {
|
|
|
|
|
+ sql = [NSString stringWithFormat:@"delete from offline_pdf where tearsheets_id = %d and create_user = '%@';",tearsheetsId,[self translateSingleQuote:user]];
|
|
|
|
|
+
|
|
|
|
|
+ // 删除文件
|
|
|
|
|
+ [self offline_removePDFWithName:path];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
|
|
|
int result = [iSalesDB execSql:sql];
|
|
int result = [iSalesDB execSql:sql];
|
|
|
|
|
|