Jelajahi Sumber

160913
New: clear sync data on server when sync complete.
Bug fix: sync log UI not showing when no order uploading or force download.

Ray Zhang 9 tahun lalu
induk
melakukan
76f9cd8453

TEMPAT SAMPAH
RedAnt ERP Mobile/RedAnt ERP Mobile.xcworkspace/xcuserdata/Ray.xcuserdatad/UserInterfaceState.xcuserstate


+ 128 - 0
RedAnt ERP Mobile/RedAnt ERP Mobile.xcworkspace/xcuserdata/Ray.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist

@@ -115,5 +115,133 @@
             landmarkType = "5">
          </BreakpointContent>
       </BreakpointProxy>
+      <BreakpointProxy
+         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         <BreakpointContent
+            shouldBeEnabled = "No"
+            ignoreCount = "0"
+            continueAfterRunningActions = "No"
+            filePath = "iSales-NPD/AppDelegate.m"
+            timestampString = "495424202.635324"
+            startingColumnNumber = "9223372036854775807"
+            endingColumnNumber = "9223372036854775807"
+            startingLineNumber = "1655"
+            endingLineNumber = "1655"
+            landmarkName = "-download_offline:checkdiskspace:"
+            landmarkType = "5">
+         </BreakpointContent>
+      </BreakpointProxy>
+      <BreakpointProxy
+         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         <BreakpointContent
+            shouldBeEnabled = "No"
+            ignoreCount = "0"
+            continueAfterRunningActions = "No"
+            filePath = "iSales-NPD/AppDelegate.m"
+            timestampString = "495423719.062096"
+            startingColumnNumber = "9223372036854775807"
+            endingColumnNumber = "9223372036854775807"
+            startingLineNumber = "1295"
+            endingLineNumber = "1295"
+            landmarkName = "-check_offline:useInternalAddress:parentvc:"
+            landmarkType = "5">
+         </BreakpointContent>
+      </BreakpointProxy>
+      <BreakpointProxy
+         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         <BreakpointContent
+            shouldBeEnabled = "No"
+            ignoreCount = "0"
+            continueAfterRunningActions = "No"
+            filePath = "common/Functions/offline/OLDataProvider.m"
+            timestampString = "495427044.963462"
+            startingColumnNumber = "9223372036854775807"
+            endingColumnNumber = "9223372036854775807"
+            startingLineNumber = "2297"
+            endingLineNumber = "2297"
+            landmarkName = "+offline_requestcart:"
+            landmarkType = "5">
+         </BreakpointContent>
+      </BreakpointProxy>
+      <BreakpointProxy
+         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         <BreakpointContent
+            shouldBeEnabled = "No"
+            ignoreCount = "0"
+            continueAfterRunningActions = "No"
+            filePath = "common/Functions/offline/OLDataProvider.m"
+            timestampString = "495427143.381863"
+            startingColumnNumber = "9223372036854775807"
+            endingColumnNumber = "9223372036854775807"
+            startingLineNumber = "2412"
+            endingLineNumber = "2412"
+            landmarkName = "+offline_requestcart:"
+            landmarkType = "5">
+         </BreakpointContent>
+      </BreakpointProxy>
+      <BreakpointProxy
+         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         <BreakpointContent
+            shouldBeEnabled = "Yes"
+            ignoreCount = "0"
+            continueAfterRunningActions = "No"
+            filePath = "common/Functions/offline/OLDataProvider.m"
+            timestampString = "495427163.726952"
+            startingColumnNumber = "9223372036854775807"
+            endingColumnNumber = "9223372036854775807"
+            startingLineNumber = "2176"
+            endingLineNumber = "2176"
+            landmarkName = "+model_subtotal:count:db:compute_part:"
+            landmarkType = "5">
+         </BreakpointContent>
+      </BreakpointProxy>
+      <BreakpointProxy
+         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         <BreakpointContent
+            shouldBeEnabled = "Yes"
+            ignoreCount = "0"
+            continueAfterRunningActions = "No"
+            filePath = "common/Functions/offline/OLDataProvider.m"
+            timestampString = "495428376.474109"
+            startingColumnNumber = "9223372036854775807"
+            endingColumnNumber = "9223372036854775807"
+            startingLineNumber = "2278"
+            endingLineNumber = "2278"
+            landmarkName = "+model_subtotal:count:db:compute_part:"
+            landmarkType = "5">
+         </BreakpointContent>
+      </BreakpointProxy>
+      <BreakpointProxy
+         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         <BreakpointContent
+            shouldBeEnabled = "No"
+            ignoreCount = "0"
+            continueAfterRunningActions = "No"
+            filePath = "common/Functions/offline/OLDataProvider.m"
+            timestampString = "495428915.704664"
+            startingColumnNumber = "9223372036854775807"
+            endingColumnNumber = "9223372036854775807"
+            startingLineNumber = "3344"
+            endingLineNumber = "3344"
+            landmarkName = "+model_bundle:db:count:"
+            landmarkType = "5">
+         </BreakpointContent>
+      </BreakpointProxy>
+      <BreakpointProxy
+         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         <BreakpointContent
+            shouldBeEnabled = "Yes"
+            ignoreCount = "0"
+            continueAfterRunningActions = "No"
+            filePath = "common/Functions/offline/OLDataProvider.m"
+            timestampString = "495429018.103658"
+            startingColumnNumber = "9223372036854775807"
+            endingColumnNumber = "9223372036854775807"
+            startingLineNumber = "3348"
+            endingLineNumber = "3348"
+            landmarkName = "+model_bundle:db:count:"
+            landmarkType = "5">
+         </BreakpointContent>
+      </BreakpointProxy>
    </Breakpoints>
 </Bucket>

+ 5 - 1
RedAnt ERP Mobile/common/Functions/offline/OLDataProvider.m

@@ -6386,7 +6386,7 @@
         }
     }
     
-    NSString*     sqlQuery=[NSString stringWithFormat:@"SELECT o._id,o.so_id,o.status,o.sales_rep,o.create_by,decrypt(c.company_name),o.create_time,o.total_price,o.customer_contact,o.erpOrderStatus from offline_order o left join offline_contact c on o.customer_cid=c.contact_id where %@ order by o.create_time desc limit %d offset %d" ,where, limit, offset];
+    NSString*     sqlQuery=[NSString stringWithFormat:@"SELECT o._id,o.so_id,o.status,o.sales_rep,o.create_by,decrypt(c.company_name),o.create_time,o.total_price,o.customer_contact,o.erpOrderStatus,o.order_id is null from offline_order o left join offline_contact c on o.customer_cid=c.contact_id where %@ order by o.create_time desc limit %d offset %d" ,where, limit, offset];
     
     DebugLog(@"order list sql: %@",sqlQuery);
     
@@ -6444,6 +6444,9 @@
             
             NSString* nsstatus = [self orderStatus:status erpStatus:erpStatus];
             
+            
+            int offline_edit = sqlite3_column_int(statement, 9);
+            
             //            ": "JH",
             //            "": "$8307.00",
             //            "": "MOB1608050001",
@@ -6468,6 +6471,7 @@
             item[@"orderStatus"]= [NSString stringWithFormat:@"%d",status];
             item[@"order_status"]= nsstatus;
             item[@"order_code"]= nssoid;//[NSString stringWithFormat:@"%d",order_id];
+            item[@"offline_edit"] = [NSNumber numberWithInt:offline_edit];
             // item[@"model_count"]
             
             

+ 8 - 2
RedAnt ERP Mobile/common/Functions/order/OrderListViewController.m

@@ -1221,14 +1221,20 @@ commitEditingStyle:(UITableViewCellEditingStyle)editingStyle  forRowAtIndexPath:
     
     if(indexPath.row==self.content_data.count)
         return UITableViewCellEditingStyleNone;
-    
+    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+    bool offline_edit =[[self.content_data[indexPath.row] valueForKey:@"offline_edit"] boolValue];
     
     NSString* order_status= [self.content_data[indexPath.row] valueForKey:@"order_status"];
     
     if(![order_status isEqualToString:@"Saved Order"]&&! [order_status isEqualToString:@"Quote Saved"])
         return UITableViewCellEditingStyleNone;
     else
-        return UITableViewCellEditingStyleDelete;
+    {
+        if(appDelegate.offline_mode==false||offline_edit)
+            return UITableViewCellEditingStyleDelete;
+        else
+            return UITableViewCellEditingStyleNone;
+    }
 }
 /*
  #pragma mark - Navigation

+ 1 - 0
RedAnt ERP Mobile/common/data_provider/iSalesNetwork.h

@@ -53,6 +53,7 @@
 
 +(NSDictionary*) check_Offline:(NSString* )ver  useInternalAddress:(bool)buseinternaladdress vid:(NSString*) vid;
 +(NSDictionary*) download_Offline:(NSString* )vid;
++(NSDictionary*) finish_download_Offline:(NSString* )vid;
 
 +(NSDictionary*) add_toCart:(NSString* ) item_id count:(int) count;
 +(NSDictionary*) add_toCart_byName:(NSString* ) model_name;

+ 33 - 1
RedAnt ERP Mobile/common/data_provider/iSalesNetwork.m

@@ -2166,7 +2166,39 @@ repeat:
     NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
     return jsobj;
 }
-
++(NSDictionary*) finish_download_Offline:(NSString* )vid
+{
+    if(![self IsNetworkAvailable])
+        return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
+    
+    NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
+    //    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+    
+    //    if(appDelegate.user!=nil)
+    //        [params setValue:appDelegate.user forKey:@"user"];
+    //    //    if(appDelegate.contact_id!=nil)
+    //    //        [params setValue:appDelegate.contact_id forKey:@"contactId"];
+    //    if(appDelegate.password!=nil)
+    //        [params setValue:appDelegate.password forKey:@"password"];
+    [params setValue:vid forKey:@"downSerial"];
+    NSData* json=[self get_json:URL_FINISH_DOWNLOAD_OFFLINE parameters:params];
+    if(json==nil)
+        return nil;
+    NSError *error=nil;
+    NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
+    //    int result = [[jsobj valueForKey:@"result"] intValue];
+    //
+    //    if (result==2)
+    //    {
+    //
+    ////        appDelegate.cart_count = [[jsobj valueForKey:@"cart_count"] intValue];
+    ////        //appDelegate.wish_count =[[jsobj valueForKey:@"count"] intValue];
+    ////        //    appDelegate.port_count =[[jsobj valueForKey:@"portfolio_count"] intValue];
+    ////
+    ////        [appDelegate update_count_mark];
+    //    }
+    return jsobj;
+}
 +(NSDictionary*) download_Offline:(NSString* )vid
 {
     if(![self IsNetworkAvailable])

+ 0 - 1
RedAnt ERP Mobile/iSales-NPD/AppDelegate.h

@@ -134,5 +134,4 @@
 
 @property (nonatomic,strong) NSMutableDictionary *urgencyDic;///<程序闪退需要保存的数据
 
-
 @end

+ 55 - 0
RedAnt ERP Mobile/iSales-NPD/AppDelegate.m

@@ -1219,6 +1219,12 @@ void UncaughtExceptionHandler(NSException *exception) {
         
         //        NSString* vid=@"31f4d59d-c229-47e3-9270-e15425777186";
         NSString* downSerial=[json valueForKey:@"downSerial"];
+        
+        [defaults removeObjectForKey:@"downSerial"];
+        [defaults setValue:downSerial forKey:@"downSerial"];
+        
+        [defaults synchronize];
+        
         //                        sleep(3);
         //UIAlertView * waitalert1 = [RAUtils waiting_alert:@"Please wait..." title:@"Server is preparing data for you"];
         
@@ -1290,7 +1296,30 @@ void UncaughtExceptionHandler(NSException *exception) {
     bool forcedownload = [defaults boolForKey:@"Forcedownload"];
     
     if(forcedownload)
+    {
         [self download_offline:ver useInternalAddress:buseinternaladdress];
+        SyncControlPanelViewController * syncVC =[ [UIStoryboard storyboardWithName:@"OLM" bundle:nil] instantiateViewControllerWithIdentifier:@"SyncControlPanelViewController"];
+        syncVC.action_string=@"Download";
+        UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:syncVC] ;
+        
+        
+        
+        
+        
+        //    [self hackModalSheetSize:CGSizeMake(450, 200) ofVC:navi];
+        
+        navi.modalPresentationStyle = UIModalTransitionStyleCrossDissolve;//有三种状态,自己看看是哪种
+        [parent presentViewController:navi animated:YES completion:^{
+            
+            //        navi.view.superview.bounds = CGRectMake(0, 0, 480, 320);
+            
+            NSLog(@"about present.........");
+            
+            //   self.btop = false;
+            //  <#code#>
+        }];
+
+    }
     else
     {
         NSArray* arr_order=nil;
@@ -1343,7 +1372,22 @@ void UncaughtExceptionHandler(NSException *exception) {
             
         }
         else
+        {
             [self upload_offline:ver useInternalAddress:buseinternaladdress orderid:nil];
+            SyncControlPanelViewController * syncVC =[ [UIStoryboard storyboardWithName:@"OLM" bundle:nil] instantiateViewControllerWithIdentifier:@"SyncControlPanelViewController"];
+            syncVC.action_string=@"Download";
+            UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:syncVC] ;
+            navi.modalPresentationStyle = UIModalTransitionStyleCrossDissolve;//有三种状态,自己看看是哪种
+            [parent presentViewController:navi animated:YES completion:^{
+                
+                //        navi.view.superview.bounds = CGRectMake(0, 0, 480, 320);
+                
+                NSLog(@"about present.........");
+                
+                //   self.btop = false;
+                //  <#code#>
+            }];
+        }
         
     }
     
@@ -1600,7 +1644,18 @@ void UncaughtExceptionHandler(NSException *exception) {
                 [defaults removeObjectForKey:@"vid"];
                 [defaults setValue:self.vid forKey:@"vid"];
                 [defaults removeObjectForKey:@"Forcedownload"];
+                NSString * downSerial = [defaults valueForKey:@"downSerial"];
+                [defaults removeObjectForKey:@"downSerial"];
+                
                 [defaults synchronize];
+                dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+                    
+                    
+                    
+                    NSDictionary* editor_json = [iSalesNetwork finish_download_Offline:downSerial];
+                    
+
+                });
             }
             
             dispatch_async(dispatch_get_main_queue(), ^{

+ 4 - 0
RedAnt ERP Mobile/iSales-NPD/config.h

@@ -134,6 +134,7 @@
 
 
 #define  URL_DOWNLOAD_OFFLINE  @"http://192.168.0.126:8080/site/offline/downloadDatas.htm"
+#define  URL_FINISH_DOWNLOAD_OFFLINE  @"http://192.168.0.126:8080/site/offline/confirmVersion.htm"
 
 #else
 
@@ -237,6 +238,9 @@
 
 #define  URL_DOWNLOAD_OFFLINE  @"https://www.newpacificdirect.com/offline/downloadDatas.htm"
 
+#define  URL_FINISH_DOWNLOAD_OFFLINE  @"https://www.newpacificdirect.com/offline/confirmVersion.htm"
+#define  URL_UPLOAD_OFFLINE  @"https://www.newpacificdirect.com/offline/uploadOfflineData.htm"
+
 #endif
 
 #endif