|
@@ -83,10 +83,18 @@
|
|
|
AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
|
|
AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
|
|
|
appDelegate.address = [addressDic objectForKey:@"serverAddress"];
|
|
appDelegate.address = [addressDic objectForKey:@"serverAddress"];
|
|
|
|
|
|
|
|
- [self updateTemplate];
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+// [self updateTemplate];
|
|
|
|
|
+
|
|
|
|
|
+ [ActiveViewController Notify:@"ScanHomeViewController," Message:@"RA_NOTIFICATION_RELOAD_DATA"];
|
|
|
|
|
+ [self.navigationController popViewControllerAnimated:false];
|
|
|
if(self.returnValue)
|
|
if(self.returnValue)
|
|
|
self.returnValue();
|
|
self.returnValue();
|
|
|
- [self.navigationController popViewControllerAnimated:true];
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
@@ -108,124 +116,146 @@
|
|
|
[userDefaults setValue:value forKey:key];
|
|
[userDefaults setValue:value forKey:key];
|
|
|
[userDefaults synchronize];
|
|
[userDefaults synchronize];
|
|
|
}
|
|
}
|
|
|
--(void) updateTemplate
|
|
|
|
|
-{
|
|
|
|
|
-
|
|
|
|
|
-// if(self.internalTextField.text.length>0)
|
|
|
|
|
- {
|
|
|
|
|
- AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
|
|
|
|
|
- NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
|
|
|
|
|
- NSString *documents = [paths objectAtIndex:0];
|
|
|
|
|
-
|
|
|
|
|
- [RAUtils deletefiles:[documents stringByAppendingPathComponent:@"download"]];
|
|
|
|
|
-
|
|
|
|
|
-// NSString* file_name=[appDelegate.downloadurl lastPathComponent];
|
|
|
|
|
-
|
|
|
|
|
- dispatch_async(dispatch_get_global_queue(0, 0), ^{
|
|
|
|
|
-
|
|
|
|
|
- NSData* download_data = [NSData dataWithContentsOfURL:[NSURL URLWithString:appDelegate.downloadurl]];
|
|
|
|
|
- dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- if(download_data!=nil)
|
|
|
|
|
- {
|
|
|
|
|
- NSString* file_name=[appDelegate.downloadurl lastPathComponent];
|
|
|
|
|
- NSString* path = [documents stringByAppendingPathComponent:file_name];
|
|
|
|
|
- [RAUtils saveData:download_data toPath:path];
|
|
|
|
|
-
|
|
|
|
|
- ZipArchive* zip = [[ZipArchive alloc] init];
|
|
|
|
|
- NSString* unZipTo=[documents stringByAppendingPathComponent:@"download"];
|
|
|
|
|
-// NSFileManager* fileManager=[NSFileManager defaultManager];
|
|
|
|
|
-// [fileManager removeItemAtPath:unZipTo error:nil];
|
|
|
|
|
-// NSString *unZipTo = [temp stringByAppendingPathComponent:unziplocation];
|
|
|
|
|
- //
|
|
|
|
|
- // NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
|
|
|
|
|
- // NSString *documentPath = ([paths count] > 0) ? [paths objectAtIndex:0] : nil;
|
|
|
|
|
- //NSString* zipFile = [documentPath stringByAppendingString:@"/images.zip"] ;
|
|
|
|
|
- // NSString* unZipTo = img_cache;//[documentPath stringByAppendingString:@"/images"] ;
|
|
|
|
|
-
|
|
|
|
|
- DebugLog(@"path: %@",unZipTo);
|
|
|
|
|
- if( [zip UnzipOpenFile:path Password:nil] ){
|
|
|
|
|
- BOOL result = [zip UnzipFileTo:unZipTo overWrite:YES];
|
|
|
|
|
- if( NO==result )
|
|
|
|
|
- {
|
|
|
|
|
- // int aaa=0;
|
|
|
|
|
- //解压失败
|
|
|
|
|
-
|
|
|
|
|
- [zip UnzipCloseFile];
|
|
|
|
|
- //文件损坏,删除文件重试
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- NSFileManager* fileManager=[NSFileManager defaultManager];
|
|
|
|
|
- //debug
|
|
|
|
|
- // BOOL blDele= [fileManager removeItemAtPath:zipFile error:nil];
|
|
|
|
|
- [fileManager removeItemAtPath:path error:nil];
|
|
|
|
|
- [fileManager removeItemAtPath:unZipTo error:nil];
|
|
|
|
|
-
|
|
|
|
|
- [RAUtils message_alert:@"Can not unzip template file, please try download again." title:@"Warrning" controller:self];
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
- {
|
|
|
|
|
- [zip UnzipCloseFile];
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- NSFileManager *fileManager = [NSFileManager defaultManager];
|
|
|
|
|
- [fileManager removeItemAtPath:path error:nil];
|
|
|
|
|
- [RAUtils message_alert:@"Update template file successful." title:@"Message" controller:self];
|
|
|
|
|
-
|
|
|
|
|
-// [RADataProvider encrypt_scan_models];
|
|
|
|
|
- NSMutableDictionary *templateDic = [NSMutableDictionary dictionary];
|
|
|
|
|
- NSString* datetime= [RAUtils current_date_time];
|
|
|
|
|
- templateDic[@"updatetime"]= datetime;
|
|
|
|
|
- [self setUserDefaultsValue:templateDic forKey:@"ScanTemplate"];
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
|
|
|
|
|
- [main_vc scanLogin];
|
|
|
|
|
-// [OLDataProvider guestLogin];
|
|
|
|
|
- [RADataProvider load_scan_models];
|
|
|
|
|
-// [self loadTemplate];
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
- //[zip UnzipCloseFile];
|
|
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
- {
|
|
|
|
|
- //打开文件失败,通常是文件路径有问题或密码错误。
|
|
|
|
|
- [RAUtils message_alert:@"Can not unzip template file, please contact the Administrator." title:@"Warrning" controller:self];
|
|
|
|
|
-
|
|
|
|
|
- // NSFileManager *fileManager = [NSFileManager defaultManager];
|
|
|
|
|
- // [fileManager removeItemAtPath:zipFile error:nil];
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-// [iSalesDB cache_img:downloadimg_data filename:file_name saveTo:img_url];
|
|
|
|
|
|
|
+//-(void) updateTemplate
|
|
|
|
|
+//{
|
|
|
|
|
+//
|
|
|
|
|
+//// if(self.internalTextField.text.length>0)
|
|
|
|
|
+// {
|
|
|
|
|
+// AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
|
|
|
|
|
+// NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
|
|
|
|
|
+// NSString *documents = [paths objectAtIndex:0];
|
|
|
|
|
+//
|
|
|
|
|
+// [RAUtils deletefiles:[documents stringByAppendingPathComponent:@"download"]];
|
|
|
|
|
+// RASingleton.sharedInstance.scan_list = nil;
|
|
|
|
|
+// [RADataProvider load_scan_models];
|
|
|
|
|
+//// NSString* file_name=[appDelegate.downloadurl lastPathComponent];
|
|
|
|
|
+//
|
|
|
|
|
+// __block UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Update local data" completion:^{
|
|
|
|
|
+// dispatch_async(dispatch_get_global_queue(0, 0), ^{
|
|
|
|
|
+//
|
|
|
|
|
+//
|
|
|
|
|
+//
|
|
|
|
|
+//
|
|
|
|
|
+//
|
|
|
|
|
+// NSData* download_data = [NSData dataWithContentsOfURL:[NSURL URLWithString:appDelegate.downloadurl]];
|
|
|
|
|
+// dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
|
+// [waitalert dismissViewControllerAnimated:false completion:^{
|
|
|
|
|
+// if(download_data!=nil)
|
|
|
|
|
+// {
|
|
|
|
|
+// NSString* file_name=[appDelegate.downloadurl lastPathComponent];
|
|
|
|
|
+// NSString* path = [documents stringByAppendingPathComponent:file_name];
|
|
|
|
|
+// [RAUtils saveData:download_data toPath:path];
|
|
|
|
|
+//
|
|
|
|
|
+// ZipArchive* zip = [[ZipArchive alloc] init];
|
|
|
|
|
+// NSString* unZipTo=[documents stringByAppendingPathComponent:@"download"];
|
|
|
|
|
+// // NSFileManager* fileManager=[NSFileManager defaultManager];
|
|
|
|
|
+// // [fileManager removeItemAtPath:unZipTo error:nil];
|
|
|
|
|
+// // NSString *unZipTo = [temp stringByAppendingPathComponent:unziplocation];
|
|
|
|
|
+// //
|
|
|
|
|
+// // NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
|
|
|
|
|
+// // NSString *documentPath = ([paths count] > 0) ? [paths objectAtIndex:0] : nil;
|
|
|
|
|
+// //NSString* zipFile = [documentPath stringByAppendingString:@"/images.zip"] ;
|
|
|
|
|
+// // NSString* unZipTo = img_cache;//[documentPath stringByAppendingString:@"/images"] ;
|
|
|
|
|
+//
|
|
|
|
|
+// DebugLog(@"path: %@",unZipTo);
|
|
|
|
|
+// if( [zip UnzipOpenFile:path Password:nil] ){
|
|
|
|
|
+// BOOL result = [zip UnzipFileTo:unZipTo overWrite:YES];
|
|
|
|
|
+// if( NO==result )
|
|
|
|
|
+// {
|
|
|
|
|
+// // int aaa=0;
|
|
|
|
|
+// //解压失败
|
|
|
|
|
+//
|
|
|
|
|
+// [zip UnzipCloseFile];
|
|
|
|
|
+// //文件损坏,删除文件重试
|
|
|
|
|
+//
|
|
|
|
|
+//
|
|
|
|
|
+// NSFileManager* fileManager=[NSFileManager defaultManager];
|
|
|
|
|
+// //debug
|
|
|
|
|
+// // BOOL blDele= [fileManager removeItemAtPath:zipFile error:nil];
|
|
|
|
|
+// [fileManager removeItemAtPath:path error:nil];
|
|
|
|
|
+// [fileManager removeItemAtPath:unZipTo error:nil];
|
|
|
|
|
+//
|
|
|
|
|
+// [RAUtils message_alert:@"Can not unzip template file, please try download again." title:@"Warrning" controller:self];
|
|
|
|
|
+//
|
|
|
|
|
+//
|
|
|
|
|
+//
|
|
|
|
|
+//
|
|
|
|
|
+// }
|
|
|
|
|
+// else
|
|
|
|
|
+// {
|
|
|
|
|
+// [zip UnzipCloseFile];
|
|
|
|
|
+//
|
|
|
|
|
+//
|
|
|
|
|
+// NSFileManager *fileManager = [NSFileManager defaultManager];
|
|
|
|
|
+// [fileManager removeItemAtPath:path error:nil];
|
|
|
|
|
+//// [RAUtils message_alert:@"Update template file successful." title:@"Message" controller:self];
|
|
|
//
|
|
//
|
|
|
-// UIImage * img =[UIImage imageWithData:downloadimg_data];
|
|
|
|
|
-// cell.imageView.image=img;
|
|
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
- [RAUtils message_alert:@"Can not update template file, you can update manually in the setting." title:@"Warrning" controller:self];
|
|
|
|
|
-// cell.imageView.image=[UIImage imageNamed:@"notfound_s"];
|
|
|
|
|
-
|
|
|
|
|
- });
|
|
|
|
|
-
|
|
|
|
|
- });
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-// NSData* downloadimg_data = [NSData dataWithContentsOfURL:[NSURL URLWithString:appDelegate.downloadurl]];
|
|
|
|
|
-// [RADataProvider downloadFileOffset:0 Param:nil from:appDelegate.downloadurl method:@"post" toPath:[documents stringByAppendingPathComponent:file_name] progressHandler:nil completionHandler:^(NSMutableDictionary *result) {
|
|
|
|
|
-// int i=0; ;
|
|
|
|
|
|
|
+//
|
|
|
|
|
+// // [RADataProvider encrypt_scan_models];
|
|
|
|
|
+// NSMutableDictionary *templateDic = [NSMutableDictionary dictionary];
|
|
|
|
|
+// NSString* datetime= [RAUtils current_date_time];
|
|
|
|
|
+// templateDic[@"updatetime"]= datetime;
|
|
|
|
|
+// [self setUserDefaultsValue:templateDic forKey:@"ScanTemplate"];
|
|
|
|
|
+//
|
|
|
|
|
+//
|
|
|
|
|
+// MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
|
|
|
|
|
+// [main_vc scanLogin];
|
|
|
|
|
+// // [OLDataProvider guestLogin];
|
|
|
|
|
+// [RADataProvider load_scan_models];
|
|
|
|
|
+// // [self loadTemplate];
|
|
|
|
|
+//
|
|
|
|
|
+//
|
|
|
|
|
+// [RAUtils message_alert:@"Update template file successful." title:@"Message" controller:self action_handler:^(UIAlertAction * _Nonnull action) {
|
|
|
|
|
+// [self.navigationController popViewControllerAnimated:false];
|
|
|
|
|
+// } completion:nil];
|
|
|
|
|
+//
|
|
|
|
|
+//
|
|
|
|
|
+// }
|
|
|
|
|
+// //[zip UnzipCloseFile];
|
|
|
|
|
+// }
|
|
|
|
|
+// else
|
|
|
|
|
+// {
|
|
|
|
|
+// //打开文件失败,通常是文件路径有问题或密码错误。
|
|
|
|
|
+// [RAUtils message_alert:@"Can not unzip template file, please contact the Administrator." title:@"Warrning" controller:self];
|
|
|
|
|
+//
|
|
|
|
|
+// // NSFileManager *fileManager = [NSFileManager defaultManager];
|
|
|
|
|
+// // [fileManager removeItemAtPath:zipFile error:nil];
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+//
|
|
|
|
|
+// // [iSalesDB cache_img:downloadimg_data filename:file_name saveTo:img_url];
|
|
|
|
|
+// //
|
|
|
|
|
+// // UIImage * img =[UIImage imageWithData:downloadimg_data];
|
|
|
|
|
+// // cell.imageView.image=img;
|
|
|
|
|
+// }
|
|
|
|
|
+// else
|
|
|
|
|
+// [RAUtils message_alert:@"Can not update template file, you can update manually in the setting." title:@"Warrning" controller:self];
|
|
|
|
|
+//
|
|
|
|
|
+//
|
|
|
|
|
+//
|
|
|
|
|
+// }];
|
|
|
|
|
+//
|
|
|
|
|
+//
|
|
|
|
|
+//
|
|
|
|
|
+// // cell.imageView.image=[UIImage imageNamed:@"notfound_s"];
|
|
|
|
|
+//
|
|
|
|
|
+// });
|
|
|
|
|
+//
|
|
|
|
|
+// });
|
|
|
// }];
|
|
// }];
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
-}
|
|
|
|
|
|
|
+//
|
|
|
|
|
+//
|
|
|
|
|
+//
|
|
|
|
|
+//
|
|
|
|
|
+//
|
|
|
|
|
+//
|
|
|
|
|
+//// NSData* downloadimg_data = [NSData dataWithContentsOfURL:[NSURL URLWithString:appDelegate.downloadurl]];
|
|
|
|
|
+//// [RADataProvider downloadFileOffset:0 Param:nil from:appDelegate.downloadurl method:@"post" toPath:[documents stringByAppendingPathComponent:file_name] progressHandler:nil completionHandler:^(NSMutableDictionary *result) {
|
|
|
|
|
+//// int i=0; ;
|
|
|
|
|
+//// }];
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+//}
|
|
|
|
|
|
|
|
- (IBAction)onSelectServer:(id)sender {
|
|
- (IBAction)onSelectServer:(id)sender {
|
|
|
|
|
|