Browse Source

hmlg scan order 1.20, TestFlight
clean cache model data after server changed
modify server setting,remove login dialog,add local data download information

Ray Zhang 3 năm trước cách đây
mục cha
commit
7d062097ec

+ 4 - 4
RedAnt ERP Mobile/HMLG Scan Order.xcodeproj/project.pbxproj

@@ -2717,7 +2717,7 @@
 				ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
 				CODE_SIGN_IDENTITY = "iPhone Developer";
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
-				CURRENT_PROJECT_VERSION = 51446;
+				CURRENT_PROJECT_VERSION = 51447;
 				DEVELOPMENT_TEAM = HXWLAA5YN5;
 				FRAMEWORK_SEARCH_PATHS = (
 					"$(inherited)",
@@ -2734,7 +2734,7 @@
 					"$(PROJECT_DIR)/ScanApiSDK-10.2.227-2/lib",
 					"$(PROJECT_DIR)/GoogleAnalytics/GoogleAnalytics/Libraries",
 				);
-				MARKETING_VERSION = 1.19;
+				MARKETING_VERSION = 1.20;
 				OTHER_LDFLAGS = (
 					"$(inherited)",
 					"-ObjC",
@@ -2761,7 +2761,7 @@
 				ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
 				CODE_SIGN_IDENTITY = "iPhone Developer";
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
-				CURRENT_PROJECT_VERSION = 51446;
+				CURRENT_PROJECT_VERSION = 51447;
 				DEVELOPMENT_TEAM = HXWLAA5YN5;
 				FRAMEWORK_SEARCH_PATHS = (
 					"$(inherited)",
@@ -2778,7 +2778,7 @@
 					"$(PROJECT_DIR)/ScanApiSDK-10.2.227-2/lib",
 					"$(PROJECT_DIR)/GoogleAnalytics/GoogleAnalytics/Libraries",
 				);
-				MARKETING_VERSION = 1.19;
+				MARKETING_VERSION = 1.20;
 				OTHER_LDFLAGS = (
 					"$(inherited)",
 					"-ObjC",

+ 4 - 2
RedAnt ERP Mobile/HMLG Scan Order/MainViewController.m

@@ -827,7 +827,7 @@
 //#ifdef BUILD_HOMER
     NSString* versionNum = [NSString stringWithFormat:@"%@ %@ Build %@",COMPANY_SHORT_NAME,version,build];
 //#endif
-    
+    [self initAppDelegate]; // 初始化scan order 参数
     [self initMenuItems];
     self.homeViewController =[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"ScanHomeViewController"];
 //    self.categoryViewController =[ [UIStoryboard storyboardWithName:@"ERP_Mobile_Search" bundle:nil] instantiateViewControllerWithIdentifier:@"CategoryViewController"];
@@ -912,7 +912,7 @@
     self.labelVer.text=versionNum;
     
     
-    [self initAppDelegate]; // 初始化scan order 参数
+
     
     //    UIApplication * app = [UIApplication sharedApplication];
     //    AppDelegate *appDelegate = (AppDelegate *)[app delegate];
@@ -3169,6 +3169,8 @@
                 self.labelServer.text = [addressDic objectForKey:@"show_name"];
 
             }
+            
+            [RADataProvider updateTemplate:self];
         };
         [self.navigationController pushViewController:servervc animated:true];
     }

+ 4 - 2
RedAnt ERP Mobile/HMLG Scan Order/ScanHomeViewController.m

@@ -22,10 +22,12 @@
     
     self.table.layer.borderColor = [UIColor darkGrayColor].CGColor;
     self.table.layer.borderWidth = 1.0;
-    [self loadNewsList];
+//    [self loadNewsList];
     // Do any additional setup after loading the view.
 }
-
+- (void) reload_data {
+    [self loadNewsList];
+}
 /*
 #pragma mark - Navigation
 

+ 12 - 0
RedAnt ERP Mobile/HMLG Scan Order/ScanSearchViewController.m

@@ -102,6 +102,18 @@
     [ref addTarget:self action:@selector(manually_refresh) forControlEvents:UIControlEventValueChanged];
     [self.tableview addSubview:ref];
     self.tableview.alwaysBounceVertical = YES;
+    
+    
+    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(clear) name:@"Clear" object:nil];
+}
+-(void)clear
+{
+    [self.modellist removeAllObjects];
+    [self.tableview reloadData];
+    
+}
+- (void)dealloc {
+    [[NSNotificationCenter defaultCenter] removeObserver:self];
 }
 -(void)manually_refresh
 {

+ 12 - 2
RedAnt ERP Mobile/HMLG Scan Order/ServerSettingViewController.m

@@ -245,10 +245,16 @@
         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(), ^{
                     
@@ -256,8 +262,7 @@
                         if(download_data!=nil)
                         {
                             
-                            [RAUtils deletefiles:[documents stringByAppendingPathComponent:@"download"]];
-                            
+
                             NSString* file_name=[appDelegate.downloadurl lastPathComponent];
                             NSString* path = [documents stringByAppendingPathComponent:file_name];
                             [RAUtils saveData:download_data toPath:path];
@@ -335,6 +340,8 @@
                         }
                         else
                             [RAUtils message_alert:@"Can not download template file, please check your server setting or contact the Administrator." title:@"Warrning" controller:self];
+                        
+                        [ActiveViewController Notify:@"ScanSearchViewController" Message:@"Clear"];
                     }];
                     
                    
@@ -482,6 +489,9 @@
                 self.internalText = [addressDic objectForKey:@"serverAddress"];
 
             }
+            
+            
+            [self onUpdateClick:nil];
         };
         [self.navigationController pushViewController:servervc animated:true];
         

+ 148 - 118
RedAnt ERP Mobile/HMLG Scan Order/SetupServerViewController.m

@@ -83,10 +83,18 @@
                 AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
                 appDelegate.address = [addressDic objectForKey:@"serverAddress"];
                 
-                [self updateTemplate];
+                
+                
+                
+//                [self updateTemplate];
+                
+                [ActiveViewController Notify:@"ScanHomeViewController," Message:@"RA_NOTIFICATION_RELOAD_DATA"];
+                [self.navigationController popViewControllerAnimated:false];
                 if(self.returnValue)
                     self.returnValue();
-                [self.navigationController popViewControllerAnimated:true];
+                
+                
+
 
             }
             else
@@ -108,124 +116,146 @@
     [userDefaults setValue:value forKey:key];
     [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 {
     

+ 1 - 1
RedAnt ERP Mobile/HMLG Scan Order/config.h

@@ -210,7 +210,7 @@
 #endif
 
 #define URL_SERVER_LIST BASE_URL@"offlineorder_isales.php"
-#define URL_SCAN_NEWS BASE_URL@"offlineorder_isales.php"
+#define URL_SCAN_NEWS @"offlineorder_isales.php"
 #define URL_SERVER_CHECK @"offlineorder_isales.php"
 #define URL_SIGN_UP @"offlineorder_isales.php"
 #define URL_CHECK_STOCK @"offlineorder_isales.php"

+ 1 - 1
RedAnt ERP Mobile/common/Functions/MainViewController.m

@@ -2039,7 +2039,7 @@
 -(void)initMenuItems
 {
     
-    
+    return;
     
     UIApplication * app = [UIApplication sharedApplication];
     AppDelegate *appDelegate = (AppDelegate *)[app delegate];

+ 22 - 3
RedAnt ERP Mobile/common/data_provider/RADataProvider.m

@@ -8,6 +8,7 @@
 
 #import "RADataProvider.h"
 #import "ZipArchive.h"
+#import "ActiveViewController.h"
 @implementation RADataProvider
 
 #ifdef SCANNER_ORDER
@@ -16,6 +17,9 @@
 {
 //    NSMutableArray* arr = [NSMutableArray new];
     
+    
+    if(keyword.length==0)
+        keyword=@"";
     int count = 0;
     NSMutableDictionary * ret = [NSMutableDictionary new];
     ret[@"result"]=@2;
@@ -135,7 +139,9 @@
        NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init];
        [dateFormatter setDateFormat:@"yyyy-MM-dd"];
 //    2022-07-14。1.17
-NSDate * ddate =[dateFormatter dateFromString:@"2022-07-14"];
+    //    2022-07-14。1.19
+    
+NSDate * ddate =[dateFormatter dateFromString:@"2022-07-1"];
     
 //    bool review=[cdate earlierDate:ddate];
     NSTimeInterval secondsInterval= [cdate timeIntervalSinceDate:ddate];
@@ -156,7 +162,8 @@ NSDate * ddate =[dateFormatter dateFromString:@"2022-07-14"];
         NSString *documents = [paths objectAtIndex:0];
         
         [RAUtils deletefiles:[documents stringByAppendingPathComponent:@"download"]];
-        
+        RASingleton.sharedInstance.scan_list = nil;
+        [RADataProvider load_scan_models];
         __block UIAlertController * waitalert = [RAUtils waiting_alert:vc title:@"Update local data" completion:^{
             dispatch_async(dispatch_get_global_queue(0, 0), ^{
                 
@@ -164,6 +171,7 @@ NSDate * ddate =[dateFormatter dateFromString:@"2022-07-14"];
                 dispatch_async(dispatch_get_main_queue(), ^{
                     
                     [waitalert dismissViewControllerAnimated:false completion:^{
+                        
                         if(download_data!=nil)
                         {
                             NSString* file_name=[appDelegate.downloadurl lastPathComponent];
@@ -226,6 +234,7 @@ NSDate * ddate =[dateFormatter dateFromString:@"2022-07-14"];
                                     
                                     
                                     [RADataProvider load_scan_models];
+                                    
         //                            [self loadTemplate];
                                     
                                     
@@ -251,6 +260,9 @@ NSDate * ddate =[dateFormatter dateFromString:@"2022-07-14"];
                             [RAUtils message_alert:@"Can not update template file, you can update manually in the setting." title:@"Warrning" controller:vc];
         //                    cell.imageView.image=[UIImage imageNamed:@"notfound_s"];
                         
+                        
+                        [ActiveViewController Notify:@"ScanSearchViewController" Message:@"Clear"];
+                        
                     }];
                     
                     
@@ -385,7 +397,14 @@ NSDate * ddate =[dateFormatter dateFromString:@"2022-07-14"];
     
     NSMutableDictionary* param = [NSMutableDictionary new];
     param[@"_method"]=@"offlineNews";
-    [self request_interface:URL_SCAN_NEWS parameters:param err_record_url:nil completionHandler:result retry:0];
+    AppDelegate *appDelegate = nil;
+    
+    appDelegate=(AppDelegate*)[[UIApplication sharedApplication] delegate];
+    if(appDelegate.address==nil)
+        return;
+    NSString* url = [appDelegate.address stringByAppendingPathComponent:URL_SCAN_NEWS];
+    param[@"site_name"]=[RADataProvider getSiteName];
+    [self request_interface:url parameters:param err_record_url:nil completionHandler:result retry:0];
 }
 
 +(void)request_scan_stock:(NSMutableDictionary*)param completionHandler:(resultHandler)result

+ 1 - 1
RedAnt ERP Mobile/iSales-CONTRAST/config.h

@@ -17,7 +17,7 @@
 #define RA_NOTIFICATION
 
 # ifdef DEBUG
-#define test_server
+//#define test_server
 # endif
 
 #define exception_switch 1