Kaynağa Gözat

RA Image
上传添加错误消息
remove task 添加异常处理。

Ray Zhang 9 yıl önce
ebeveyn
işleme
e5a213f88c

BIN
RA Image/RA Image.xcodeproj/project.xcworkspace/xcuserdata/ray.xcuserdatad/UserInterfaceState.xcuserstate


+ 1 - 1
RA Image/RA Image/UploadCell.m

@@ -59,7 +59,7 @@
     _errorMsg = errorMsg;
     if (errorMsg.length) {
         self.errorLabel.hidden = NO;
-        self.errorLabel.text = [NSString stringWithFormat:@"Error:%@",errorMsg];
+        self.errorLabel.text = errorMsg;
     } else {
         self.errorLabel.hidden = YES;
         self.errorLabel.text = nil;

+ 2 - 1
RA Image/RA Image/UploadViewController.m

@@ -114,6 +114,7 @@
         cell.progress=progress;
         cell.name=item_json[@"file"];
         cell.state=  status;
+        cell.errorMsg = item_json[@"msg"];
         
         RAUploadOperation* op = item_json[@"operation"];
         op.updateUI=^(){
@@ -144,7 +145,7 @@
             cell.progress=progress;
             cell.name=item_json[@"file"];
             cell.state=  status;
-            
+            cell.errorMsg = item_json[@"msg"];
             
         };
         //

+ 1 - 2
RA Image/RA Image/const.h

@@ -30,8 +30,7 @@
 #define UIColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]
 //#define UIColorFromRGBA(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF000000) >> 32))/255.0 green:((float)((rgbValue & 0xFF0000) >> 16))/255.0 blue:((float)((rgbValue & 0xFF00) >> 8))/255.0 alpha:((float)(rgbValue & 0xFF))/255.0]
 
-
-
+#define RESULT_BARCODE_ERROR			 -50
 
 
 #define TV_BG 0xccffff

+ 10 - 1
common/upload/RAUploadManager.m

@@ -120,7 +120,16 @@
     NSError* error = nil;
     [fmanager removeItemAtPath:[self filePath:task] error:&error];
     
-    [[self mutableArrayValueForKey:@"arr_queue"] removeObject:task];
+    @try {
+        [[self mutableArrayValueForKey:@"arr_queue"] removeObject:task];
+    } @catch (NSException *exception) {
+        NSLog(@"%@\n%@",exception.name,exception.reason);
+    } @finally {
+        
+    }
+    
+    
+    
 //    if (self.delegate && [self.delegate respondsToSelector:@selector(uploadManager:didRemoveTasks:)]) {
 //        [self.delegate uploadManager:self didRemoveTasks:@[task]];
 //    }

+ 5 - 2
common/upload/RAUploadOperation.m

@@ -11,6 +11,7 @@
 #import <UIKit/UIKit.h>
 #import "AppDelegate.h"
 #import "RAUtils.h"
+#import "const.h"
 
 @interface RAUploadOperation ()
 {
@@ -102,13 +103,15 @@
         if(r==2)
         {
             block_task[@"status"]=[NSNumber numberWithInt:TaskStatusFinish];
+            block_task[@"msg"]=@"upload successful";
         }
         else
         {
-            if([block_task[@"retry"] intValue]>=_maxRetry)
+            if([block_task[@"retry"] intValue]>=_maxRetry|| r==RESULT_BARCODE_ERROR)
             {
                 block_task[@"status"]=[NSNumber numberWithInt:TaskStatusError];
                 block_task[@"progress"]=[NSNumber numberWithDouble:0.0];
+                block_task[@"msg"]=[@"error: " stringByAppendingString:result[@"msg"]];
                 
             }
             else
@@ -117,7 +120,7 @@
                 block_task[@"status"]=[NSNumber numberWithInt:TaskStatusWait];
                 block_task[@"progress"]=[NSNumber numberWithDouble:0.0];
                 
-                
+                block_task[@"msg"]=result[@"upload failed, retry..."];
                 
                 RAUploadOperation* operation = [[RAUploadOperation alloc] initWithTaskinfo:block_task retry:_maxRetry];
                 operation.updateUI= self.updateUI;