Explorar o código

修改crash保存信息的数据结构

Pen Li %!s(int64=9) %!d(string=hai) anos
pai
achega
d9ab2d5956

BIN=BIN
RedAnt ERP Mobile/RedAnt ERP Mobile.xcworkspace/xcuserdata/macmini1.xcuserdatad/UserInterfaceState.xcuserstate


+ 2 - 0
RedAnt ERP Mobile/common/CommonEditor/CommonEditorViewController.h

@@ -76,6 +76,8 @@
 
 
 //control cell event;
 //control cell event;
 
 
+@property (nonatomic,copy) NSString *class_name;
+
 - (void)start_urgency_timer;
 - (void)start_urgency_timer;
 - (void)cancel_urgency_timer;
 - (void)cancel_urgency_timer;
 
 

+ 38 - 21
RedAnt ERP Mobile/common/CommonEditor/CommonEditorViewController.m

@@ -46,11 +46,10 @@
 @end
 @end
 @interface CommonEditorViewController ()
 @interface CommonEditorViewController ()
 
 
-
-@property (nonatomic,copy) NSString *class_name;
-
 @property (nonatomic,copy) NSString *urgency_timer_name;
 @property (nonatomic,copy) NSString *urgency_timer_name;
 
 
+@property (nonatomic,assign) int level;
+
 @end
 @end
 
 
 @implementation CommonEditorViewController
 @implementation CommonEditorViewController
@@ -70,6 +69,17 @@
     return _urgency_timer_name;
     return _urgency_timer_name;
 }
 }
 
 
+- (int)level {
+    if (_level == -1) {
+        AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
+        
+        id count = [appDelegate.urgencyDic objectForKey:@"count"];
+        
+        _level = count == nil ? 0 : [count integerValue];
+    }
+    return _level;
+}
+
 - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
 - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
 {
 {
     self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
     self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
@@ -124,22 +134,30 @@
 
 
 - (void)start_urgency_timer {
 - (void)start_urgency_timer {
     
     
+    __weak typeof(self) weakSelf = self;
+    
     AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
     AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
+
+    [appDelegate.urgencyDic setValue:appDelegate.user forKey:@"user"];
+    [appDelegate.urgencyDic setValue:[NSNumber numberWithBool:appDelegate.offline_mode] forKey:@"offline_mode"];
     
     
-    [[JKTimerManager sharedTimerManager] scheduledDispatchTimerWithName:self.urgency_timer_name timeInterval:10 queue:nil repeats:YES action:^{
+    [[JKTimerManager sharedTimerManager] scheduledDispatchTimerWithName:self.urgency_timer_name timeInterval:1 queue:nil repeats:YES action:^{
         
         
+        NSMutableDictionary *urgencyDic = [NSMutableDictionary dictionary];
+
         NSLog(@"timer start....");
         NSLog(@"timer start....");
-        [appDelegate.urgencyDic setValue:appDelegate.user forKey:@"user"];
-        [appDelegate.urgencyDic setValue:[NSNumber numberWithBool:appDelegate.offline_mode] forKey:@"offline_mode"];
-        [appDelegate.urgencyDic setValue:self.content_data_download forKey:[NSString stringWithFormat:@"%@_changed_data",self.class_name]];
         
         
+        [urgencyDic setValue:weakSelf.content_data_download forKey:[NSString stringWithFormat:@"%@_restored_data",self.class_name]];
         
         
+        [urgencyDic setValue:weakSelf.class_name forKey:@"class_name"];
+
         
         
-        if ([self.class_name isEqualToString:@"CustomerEditViewController"]) {
+        
+        if ([weakSelf.class_name isEqualToString:@"CustomerEditViewController"]) {
             // CustomerEditViewController
             // CustomerEditViewController
             __block NSString *contact_id = @"";
             __block NSString *contact_id = @"";
             
             
-            [self.content_data_download enumerateKeysAndObjectsUsingBlock:^(id  _Nonnull key, id  _Nonnull obj, BOOL * _Nonnull stop) {
+            [weakSelf.content_data_download enumerateKeysAndObjectsUsingBlock:^(id  _Nonnull key, id  _Nonnull obj, BOOL * _Nonnull stop) {
                 
                 
                 // section_0
                 // section_0
                 if ([key isEqualToString:@"section_0"]) {
                 if ([key isEqualToString:@"section_0"]) {
@@ -158,28 +176,27 @@
                 }
                 }
 
 
             }];
             }];
-            [appDelegate.urgencyDic setValue:self.class_name forKey:@"firt_class_name"];
-            [appDelegate.urgencyDic setValue:contact_id forKey:@"contact_id"];
+
+            [urgencyDic setValue:contact_id forKey:@"contact_id"];
             
             
             
             
-        } else if ([self.class_name isEqualToString:@"CreateOrderViewController"]) {
+        } else if ([weakSelf.class_name isEqualToString:@"CreateOrderViewController"]) {
             // CreateOrderViewController
             // CreateOrderViewController
-            [appDelegate.urgencyDic setValue:self.class_name forKey:@"firt_class_name"];
+
             
             
-            [appDelegate.urgencyDic setValue:appDelegate.order_code forKey:@"order_code"];
+            [urgencyDic setValue:appDelegate.order_code forKey:@"order_code"];
 
 
-            [appDelegate.urgencyDic setValue:[NSNumber numberWithInt:appDelegate.order_status ] forKey:@"order_status"];
+            [urgencyDic setValue:[NSNumber numberWithInt:appDelegate.order_status ] forKey:@"order_status"];
             
             
-            [appDelegate.urgencyDic setValue:appDelegate.order_customer_id forKey:@"order_customer_id"];
+            [urgencyDic setValue:appDelegate.order_customer_id forKey:@"order_customer_id"];
             
             
-        } else if ([self.class_name isEqualToString:@"AddressEditorViewController"]) {
+        } else if ([weakSelf.class_name isEqualToString:@"AddressEditorViewController"]) {
             // AddressEditorViewController
             // AddressEditorViewController
             
             
-            [appDelegate.urgencyDic setValue:self.class_name forKey:@"second_class_name"];
         }
         }
         
         
-        
-        
+        [appDelegate.urgencyDic setValue:urgencyDic forKey:[NSString stringWithFormat:@"level_%d",weakSelf.level]];
+        [appDelegate.urgencyDic setValue:[NSNumber numberWithInteger:weakSelf.level + 1] forKey:@"count"];
         
         
     }];
     }];
 }
 }
@@ -207,7 +224,7 @@
     if(!self.disable_dropdown_refresh)
     if(!self.disable_dropdown_refresh)
         [self.editorTable addSubview:ref];
         [self.editorTable addSubview:ref];
     
     
-    
+    self.level = -1;
     
     
     if (!self.changed_data) {
     if (!self.changed_data) {
         self.changed_data = [[NSMutableDictionary alloc] init];
         self.changed_data = [[NSMutableDictionary alloc] init];

+ 96 - 95
RedAnt ERP Mobile/iSales-NPD/AppDelegate.m

@@ -532,7 +532,7 @@ void UncaughtExceptionHandler(NSException *exception) {
     [self readUrgencyCache];
     [self readUrgencyCache];
     
     
     NSLog(@"urgencyDic: %@",self.urgencyDic);
     NSLog(@"urgencyDic: %@",self.urgencyDic);
-    if (self.urgencyDic.allKeys.count) {
+    if (self.urgencyDic.allKeys.count > 2) {
         
         
         MainViewController *mainVC = [self.window.rootViewController.childViewControllers lastObject];
         MainViewController *mainVC = [self.window.rootViewController.childViewControllers lastObject];
         UIStoryboard *mainStoryBoard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
         UIStoryboard *mainStoryBoard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
@@ -547,96 +547,106 @@ void UncaughtExceptionHandler(NSException *exception) {
             return;
             return;
         }
         }
         
         
-        NSString *firstClassName = [self.urgencyDic objectForKey:@"firt_class_name"];
-        
-        NSString *changed_data_key = [NSString stringWithFormat:@"%@_changed_data",firstClassName];
-        NSMutableDictionary *changed_data = [self.urgencyDic objectForKey:changed_data_key];
-        
-        if ([firstClassName isEqualToString:@"CustomerEditViewController"]) {
-            // CustomerEditViewController
-           
-            NSString *contact_id = [self.urgencyDic objectForKey:@"contact_id"];
-            
-            NSMutableDictionary *params = [NSMutableDictionary dictionary];
-            
-            [params setValue:contact_id forKey:@"contact_id"];
-            CustomerEditViewController * cuseditVC =[mainStoryBoard instantiateViewControllerWithIdentifier:@"CustomerEditViewController"];
-            
-            cuseditVC.bnewcustomer=false;
-            cuseditVC.url_type = URL_RESTORE;
-            cuseditVC.request_url=URL_EDIT_CUSTOMER;
-            
-            cuseditVC.params = params;
-            cuseditVC.content_data_download = changed_data;
-            
-//            cuseditVC.delegate=self;
-            
-            
-            [[mainVC navigationController] setNavigationBarHidden:NO animated:NO];
-            [mainVC.navigationController pushViewController:cuseditVC animated:false];
-            
-            
-            
-        } else if ([firstClassName isEqualToString:@"CreateOrderViewController"]) {
-            // CreateOrderViewController
-            
-            NSString *order_code = [self.urgencyDic objectForKey:@"order_code"];
-            int order_status = [[self.urgencyDic objectForKey:@"order_status"] intValue];
-            NSString *order_customer_id = [self.urgencyDic objectForKey:@"order_customer_id"];
-            
-            self.order_customer_id = order_customer_id;
-            
-            // 首先通过order code 打开订单
-            NSDictionary* order_json = [iSalesNetwork open_Order:order_code];
-            
-            dispatch_async(dispatch_get_main_queue(), ^{
-//                [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
-                if([[order_json valueForKey:@"result"] intValue]==2)
-                {
+        id count = [self.urgencyDic objectForKey:@"count"];
+        int level_count = count ? [count integerValue] : 0;
 
 
-                    self.order_code = order_code;
-                    self.order_status = order_status;
-                    [self SetSo:order_code];
-                    
-                    
-                    self.customerInfo = [iSalesNetwork request_CustomerInfo:order_customer_id].mutableCopy;
-                    
-                    self.contact_id=[self.customerInfo valueForKey:@"customer_cid"];
-                    
-                    [mainVC reloadOrder:true immediately:false];
-                    [mainVC reloadCart:true immediately:false];
-                    
-                    
-                }
-                else
-                {
-                    [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Open Order" controller:mainVC] ;
-                }
-            });
-
-            
-            
-            // 再place order
+        if (!level_count) {
+            return;
+        }
+        
+        for (int i = 0; i < level_count; i++) {
             
             
-            NSMutableDictionary *params = [NSMutableDictionary dictionary];
-
-            CreateOrderViewController * orderinfoVC =[mainStoryBoard instantiateViewControllerWithIdentifier:@"CreateOrderViewController"];
+            NSString *level_key = [NSString stringWithFormat:@"level_%d",i];
             
             
-            orderinfoVC.disable_dropdown_refresh=true;
-            orderinfoVC.url_type = URL_RESTORE;
-            orderinfoVC.request_url=URL_CARTDELIVERY;
-            orderinfoVC.params = params;
-            orderinfoVC.content_data_download = changed_data;
-            orderinfoVC.resumeOrder = YES;
+            NSDictionary *urgencyDic = [self.urgencyDic objectForKey:level_key];
             
             
-            [mainVC.navigationController pushViewController:orderinfoVC animated:true];
+            NSString *className = [urgencyDic objectForKey:@"class_name"];
             
             
+            NSString *restored_data_key = [NSString stringWithFormat:@"%@_restored_data",className];
             
             
-            NSString *second_class_name = [self.urgencyDic objectForKey:@"second_class_name"];
-            NSString *second_changed_data_key = [NSString stringWithFormat:@"%@_changed_data",second_class_name];
-            NSMutableDictionary *second_changed_data = [self.urgencyDic objectForKey:second_changed_data_key];
+            NSMutableDictionary *restored_data = [urgencyDic objectForKey:restored_data_key];
             
             
-            if ([second_class_name isEqualToString:@"AddressEditorViewController"]) {
+            if ([className isEqualToString:@"CustomerEditViewController"]) {
+                // CustomerEditViewController
+                
+                NSString *contact_id = [urgencyDic objectForKey:@"contact_id"];
+                
+                NSMutableDictionary *params = [NSMutableDictionary dictionary];
+                
+                [params setValue:contact_id forKey:@"contact_id"];
+                CustomerEditViewController * cuseditVC =[mainStoryBoard instantiateViewControllerWithIdentifier:@"CustomerEditViewController"];
+                
+                cuseditVC.bnewcustomer=false;
+                cuseditVC.url_type = URL_RESTORE;
+                cuseditVC.request_url=URL_EDIT_CUSTOMER;
+                
+                cuseditVC.params = params;
+                cuseditVC.content_data_download = restored_data;
+                
+                //            cuseditVC.delegate=self;
+                
+                
+                [[mainVC navigationController] setNavigationBarHidden:NO animated:NO];
+                [mainVC.navigationController pushViewController:cuseditVC animated:false];
+                
+                
+                
+            } else if ([className isEqualToString:@"CreateOrderViewController"]) {
+                // CreateOrderViewController
+                
+                NSString *order_code = [urgencyDic objectForKey:@"order_code"];
+                int order_status = [[urgencyDic objectForKey:@"order_status"] intValue];
+                NSString *order_customer_id = [urgencyDic objectForKey:@"order_customer_id"];
+                
+                self.order_customer_id = order_customer_id;
+                
+                // 首先通过order code 打开订单
+                NSDictionary* order_json = [iSalesNetwork open_Order:order_code];
+                
+                dispatch_async(dispatch_get_main_queue(), ^{
+                    //                [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
+                    if([[order_json valueForKey:@"result"] intValue]==2)
+                    {
+                        
+                        self.order_code = order_code;
+                        self.order_status = order_status;
+                        [self SetSo:order_code];
+                        
+                        
+                        self.customerInfo = [iSalesNetwork request_CustomerInfo:order_customer_id].mutableCopy;
+                        
+                        self.contact_id=[self.customerInfo valueForKey:@"customer_cid"];
+                        
+                        [mainVC reloadOrder:true immediately:false];
+                        [mainVC reloadCart:true immediately:false];
+                        
+                        
+                    }
+                    else
+                    {
+                        [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Open Order" controller:mainVC] ;
+                    }
+                });
+                
+                
+                
+                // 再place order
+                
+                NSMutableDictionary *params = [NSMutableDictionary dictionary];
+                
+                CreateOrderViewController * orderinfoVC =[mainStoryBoard instantiateViewControllerWithIdentifier:@"CreateOrderViewController"];
+                
+                orderinfoVC.disable_dropdown_refresh=true;
+                orderinfoVC.url_type = URL_RESTORE;
+                orderinfoVC.request_url=URL_CARTDELIVERY;
+                orderinfoVC.params = params;
+                orderinfoVC.content_data_download = restored_data;
+                orderinfoVC.resumeOrder = YES;
+                
+                [mainVC.navigationController pushViewController:orderinfoVC animated:true];
+                
+                
+            } else  if ([className isEqualToString:@"AddressEditorViewController"]) {
                 // AddressEditorViewController
                 // AddressEditorViewController
                 
                 
                 AddressEditorViewController * addressVC =[mainStoryBoard instantiateViewControllerWithIdentifier:@"AddressEditorViewController"];
                 AddressEditorViewController * addressVC =[mainStoryBoard instantiateViewControllerWithIdentifier:@"AddressEditorViewController"];
@@ -644,25 +654,16 @@ void UncaughtExceptionHandler(NSException *exception) {
                 addressVC.url_type = URL_RESTORE;
                 addressVC.url_type = URL_RESTORE;
                 addressVC.request_url=URL_ADDRESS_EDOTOR;
                 addressVC.request_url=URL_ADDRESS_EDOTOR;
                 
                 
-                
-                
-                
                 NSMutableDictionary * params= [[NSMutableDictionary alloc] init];
                 NSMutableDictionary * params= [[NSMutableDictionary alloc] init];
                 
                 
                 params[@"is_subaction"]=@"true";
                 params[@"is_subaction"]=@"true";
-//                params[@"subaction_tag"]= [NSString stringWithFormat:@"%ld",(long)sender.tag];
                 addressVC.params = params;
                 addressVC.params = params;
-                addressVC.content_data_download = second_changed_data;
-                
+                addressVC.content_data_download = restored_data;
                 
                 
-//                addressVC.from = indexPath;
                 
                 
                 [mainVC.navigationController pushViewController:addressVC animated:true];
                 [mainVC.navigationController pushViewController:addressVC animated:true];
                 
                 
-            }
-
-            
-        } else {
+            }// class_name
             
             
         }
         }