Explorar el Código

1.修改iOS Apex Drivers离线。

Pen Li hace 7 años
padre
commit
a7ce7d54ea

+ 3 - 0
Redant Drivers/Apex And Drivers/Base.lproj/Localizable.strings

@@ -18,6 +18,8 @@
 "auth_error"="Can not login, user or password may not correct.";
 "ver_low"="Current App version is too low, please update.";
 
+"sorry" = "Sorry,there is something wrong";
+
 /**
  NavigatonVC
  */
@@ -55,6 +57,7 @@
 "update_upload_failed_tips" = "upload the photos failed,would you like to retry or do it background?";
 "Background" = "Background";
 "Retry" = "Retry";
+"offline_update_success" = "Update successful, you will find it in upload list.";
 "update_success" = "Update successful";
 "update_photo_success" = "Status update successful, the photos and signatures will upload in the background, you can check them from upload list.";
 

+ 1 - 0
Redant Drivers/Apex And Drivers/Detail/Action Selection/RADetailActionSelectionModel.h

@@ -12,5 +12,6 @@
 
 @property (nonatomic,copy) NSString *actionTitle;
 @property (nonatomic,assign) NSInteger actionID;
+@property (nonatomic,assign) NSInteger actionIndex;
 
 @end

+ 3 - 1
Redant Drivers/Apex And Drivers/Detail/RAOrderDetailViewController+TableViewDataSource.m

@@ -309,7 +309,7 @@
         
         NSDictionary *json = [RADataProvider reportOrder:self.orderID
                                                     type:self.orderType
-                                              actionType:model.actionID
+                                              actionType:model.actionSubType
                                              actionIndex:model.index
                                               actionName:model.actionTitle
                                                    toURL:model.url
@@ -392,6 +392,8 @@
     vc.actionID = model.actionID;
     vc.actionTitle = model.actionTitle;
     vc.orderType2 = self.orderType2;
+    vc.actionIdx = model.actionIndex;
+    
     [self.navigationController pushViewController:vc animated:YES];
 
 }

+ 20 - 11
Redant Drivers/Apex And Drivers/Offline/RAOfflineHandler.m

@@ -541,7 +541,7 @@ static dispatch_semaphore_t _lock;
     
     NSDate *date = [NSDate date];
     NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
-    formatter.dateFormat = @"MM/DD/YYYY HH:mm";
+    formatter.dateFormat = @"MM/dd/YYYY HH:mm";
     
     return [formatter stringFromDate:date];
 }
@@ -756,6 +756,7 @@ static dispatch_semaphore_t _lock;
 //    NSString *paramPath = [upDir stringByAppendingPathComponent:@"params.json"];
 //    [self _writeJson:mParams toPath:paramPath];
     
+    NSString *zipF = nil;
     if (photos.count > 0) {
         // 生成图片目录
         NSString *imageDir = [upDir stringByAppendingPathComponent:@"images"];
@@ -772,7 +773,7 @@ static dispatch_semaphore_t _lock;
                 BOOL move = [fm moveItemAtPath:path toPath:toPath error:&err];
                 if (!move) {
                     
-                    NSString *msg = @"Sorry,there is something error";
+                    NSString *msg = NSLocalizedString(@"sorry", nil);
                     if (err) {
                         msg = err.localizedDescription;
                     }
@@ -786,14 +787,16 @@ static dispatch_semaphore_t _lock;
                 
             }
         }
+        
+        // 压缩目录
+        NSString *zip = [self _zipDir:upDir];
+        
+        // 删除目录
+        [fm removeItemAtPath:upDir error:nil];
+        
+        zipF = zip;
     }
     
-    // 压缩目录
-    NSString *zip = [self _zipDir:upDir];
-    
-    // 删除目录
-    [fm removeItemAtPath:upDir error:nil];
-    
     Unlock();
     
     // 创建Task
@@ -803,14 +806,21 @@ static dispatch_semaphore_t _lock;
                                    @"name" : title,
                                    @"time" : time,
                                    @"url" : URL_UPLOAD,
-                                   @"file" : zip,
                                    @"params" : mParams
                                    } mutableCopy];
+    if (zipF) {
+        [task setObject:zipF forKey:@"file"];
+    } else {
+        [task setObject:@(YES) forKey:@"noFile"];
+    }
     
     // 提交Task
     AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
     [appDelegate.uploadManager addTask:task];
     
+    // 删除Edit文件
+    [self deleteEditJsonFileForOrder:orderId withActionIndex:idx];
+    
     // 判断是否完成order 所有操作
     BOOL finish = [self isLastActionForOrder:orderId];
     if (finish) {
@@ -872,8 +882,7 @@ static dispatch_semaphore_t _lock;
     }
     
     return @{
-             @"result" : @(RESULT_TRUE),
-             @"err_msg" : [NSString stringWithFormat:@"%@ %@ is submitted,you will find it in upload list.",title,orderId]
+             @"result" : @(RESULT_TRUE)
              };
 }
 

+ 29 - 8
Redant Drivers/Apex And Drivers/Update/RAOrderEditViewController.m

@@ -358,12 +358,7 @@
 
 #pragma mark - Private
 
-- (void)submitSuccessWithPhoto:(BOOL)photo {
-    
-    NSString *msg = NSLocalizedString(@"update_success", nil);
-    if (photo) {
-        msg = NSLocalizedString(@"update_photo_success", nil);
-    }
+- (void)submitSuccessWithMsg:(NSString *)msg {
     
     UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:nil message:msg preferredStyle:UIAlertControllerStyleAlert];
     
@@ -381,6 +376,16 @@
     [self presentViewController:alertVC animated:YES completion:nil];
 }
 
+- (void)submitSuccessWithPhoto:(BOOL)photo {
+    
+    NSString *msg = NSLocalizedString(@"update_success", nil);
+    if (photo) {
+        msg = NSLocalizedString(@"update_photo_success", nil);
+    }
+    
+    [self submitSuccessWithMsg:msg];
+}
+
 #pragma mark - Tap Action
 
 - (IBAction)tapToResignFirstResponder:(UITapGestureRecognizer *)sender {
@@ -431,8 +436,24 @@
             
             [hud dismiss:^{
                 
-                NSString *msg = [json objectForKey:@"err_msg"];
-                [weakSelf showAlertTilte:NSLocalizedString(@"Warning", nil) message:msg];
+                int result = [[json objectForKey:@"result"] intValue];
+                
+                NSString *msg = NSLocalizedString(@"sorry", nil);
+                if (result == RESULT_TRUE) {
+                    
+                    msg = NSLocalizedString(@"offline_update_success", nil);
+                    
+                    [weakSelf submitSuccessWithMsg:msg];
+                    
+                } else {
+                    msg = [json objectForKey:@"err_msg"];
+                    if (msg == nil) {
+                        msg = NSLocalizedString(@"sorry", nil);
+                    }
+                    
+                    [weakSelf showAlert:msg];
+                }
+
             }];
         }
         else { // 在线

+ 2 - 0
Redant Drivers/Apex And Drivers/en.lproj/Localizable.strings

@@ -18,6 +18,7 @@
 "auth_error"="Can not login, user or password may not correct.";
 "ver_low"="Current App version is too low, please update.";
 
+"sorry" = "Sorry,there is something wrong";
 
 /**
  NavigatonVC
@@ -56,6 +57,7 @@
 "update_upload_failed_tips" = "upload the photos failed,would you like to retry or do it background?";
 "Background" = "Background";
 "Retry" = "Retry";
+"offline_update_success" = "Update successful, you will find it in upload list.";
 "update_success" = "Update successful";
 "update_photo_success" = "Status update successful, the photos and signatures will upload in the background, you can check them from upload list.";
 

+ 2 - 0
Redant Drivers/Apex And Drivers/zh-Hans.lproj/Localizable.strings

@@ -18,6 +18,7 @@
 "auth_error"="用户名或密码错误";
 "ver_low"="当前应用版本较低,请更新";
 
+"sorry" = "对不起,发生未知错误.";
 
 /**
  NavigatonVC
@@ -56,6 +57,7 @@
 "update_upload_failed_tips" = "上传图片失败,是否重试或者将任务提交到后台上传?";
 "Background" = "后台上传";
 "Retry" = "重试";
+"offline_update_success" = "提交成功,你在上传列表可以看到它。";
 "update_success" = "提交成功";
 "update_photo_success" = "提交成功,照片和签名将在后台上传,你可以在上传列表中找到它们。";