|
@@ -28,16 +28,18 @@
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
- [self loadTasks];
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
self.newtaskStatus = TaskStatusWait;
|
|
self.newtaskStatus = TaskStatusWait;
|
|
|
- self.autoStart = true;
|
|
|
|
|
|
|
+// self.autoStart = true;
|
|
|
self.maxThread = 3;
|
|
self.maxThread = 3;
|
|
|
self.removeError=true;
|
|
self.removeError=true;
|
|
|
self.removeFinish = true;
|
|
self.removeFinish = true;
|
|
|
|
|
|
|
|
self.operation_queue = [NSOperationQueue new];
|
|
self.operation_queue = [NSOperationQueue new];
|
|
|
self.operation_queue.maxConcurrentOperationCount = self.maxThread;
|
|
self.operation_queue.maxConcurrentOperationCount = self.maxThread;
|
|
|
|
|
+
|
|
|
|
|
+ [self loadTasks];
|
|
|
// self.backgroundColor = [UIColor clearColor];
|
|
// self.backgroundColor = [UIColor clearColor];
|
|
|
}
|
|
}
|
|
|
return self;
|
|
return self;
|
|
@@ -146,21 +148,38 @@
|
|
|
{
|
|
{
|
|
|
[self stopAllTasks];
|
|
[self stopAllTasks];
|
|
|
|
|
|
|
|
- NSMutableArray* arr = [[NSUserDefaults standardUserDefaults] objectForKey:@"upload_queue"];
|
|
|
|
|
- if(arr!=nil)
|
|
|
|
|
- self.arr_queue=arr;
|
|
|
|
|
- else
|
|
|
|
|
- self.arr_queue= [[NSMutableArray alloc] init];
|
|
|
|
|
|
|
+ NSMutableArray* arr = [[[NSUserDefaults standardUserDefaults] objectForKey:@"upload_queue"] mutableCopy];
|
|
|
|
|
+ if(arr==nil)
|
|
|
|
|
+ self.arr_queue = [NSMutableArray new];
|
|
|
|
|
|
|
|
- for(NSMutableDictionary* task in arr)
|
|
|
|
|
|
|
+ for(NSDictionary* task in arr)
|
|
|
{
|
|
{
|
|
|
-// if([task[@"status"] intValue]==TaskStatusStart)
|
|
|
|
|
-// task[@"status"]=[NSNumber numberWithInteger:TaskStatusWait];
|
|
|
|
|
- NSMutableDictionary *new_task = [task mutableCopy];
|
|
|
|
|
|
|
+ NSMutableDictionary* newtask =[task mutableCopy];
|
|
|
|
|
+ [self.arr_queue addObject:newtask];
|
|
|
if(self.autoStart&&[task[@"status"] intValue]!=TaskStatusError&&[task[@"status"] intValue]!=TaskStatusFinish)
|
|
if(self.autoStart&&[task[@"status"] intValue]!=TaskStatusError&&[task[@"status"] intValue]!=TaskStatusFinish)
|
|
|
- [self startTask:new_task];
|
|
|
|
|
|
|
+ [self startTask:newtask];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// NSDictionary* ddd = arr[0] ;
|
|
|
|
|
+// NSMutableDictionary* eee = [ddd mutableCopy];
|
|
|
|
|
+//
|
|
|
|
|
+// eee=[NSMutableDictionary dictionaryWithDictionary:ddd];
|
|
|
|
|
+// if(arr!=nil)
|
|
|
|
|
+// self.arr_queue=arr;
|
|
|
|
|
+// else
|
|
|
|
|
+// self.arr_queue= [[NSMutableArray alloc] init];
|
|
|
|
|
+//
|
|
|
|
|
+// for(__strong NSMutableDictionary* task in arr)
|
|
|
|
|
+// {
|
|
|
|
|
+//
|
|
|
|
|
+// task=[NSMutableDictionary dictionaryWithDictionary:task];
|
|
|
|
|
+//// if([task[@"status"] intValue]==TaskStatusStart)
|
|
|
|
|
+//// task[@"status"]=[NSNumber numberWithInteger:TaskStatusWait];
|
|
|
|
|
+// // NSMutableDictionary *new_task = [task mutableCopy];
|
|
|
|
|
+// if(self.autoStart&&[task[@"status"] intValue]!=TaskStatusError&&[task[@"status"] intValue]!=TaskStatusFinish)
|
|
|
|
|
+// [self startTask:task];
|
|
|
|
|
+// }
|
|
|
|
|
+
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
-(void) stopAllTasks
|
|
-(void) stopAllTasks
|
|
@@ -196,7 +215,7 @@
|
|
|
}
|
|
}
|
|
|
-(void) startTask:(NSMutableDictionary*) task
|
|
-(void) startTask:(NSMutableDictionary*) task
|
|
|
{
|
|
{
|
|
|
- __block NSMutableDictionary* block_task = task;
|
|
|
|
|
|
|
+ /*__block*/ NSMutableDictionary* block_task = task;
|
|
|
__weak typeof(self) weakSelf = self;
|
|
__weak typeof(self) weakSelf = self;
|
|
|
|
|
|
|
|
if([task[@"status"] intValue]==TaskStatusStart||[task[@"status"] intValue]==TaskStatusWait)
|
|
if([task[@"status"] intValue]==TaskStatusStart||[task[@"status"] intValue]==TaskStatusWait)
|
|
@@ -222,6 +241,8 @@
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}];
|
|
}];
|
|
|
|
|
+ NSMutableDictionary* ddd=[NSMutableDictionary new];
|
|
|
|
|
+ ddd[@"aaa"]=@"bbb";
|
|
|
task[@"operation"] = operation;
|
|
task[@"operation"] = operation;
|
|
|
task[@"status"] = [NSNumber numberWithInt:self.newtaskStatus] ;
|
|
task[@"status"] = [NSNumber numberWithInt:self.newtaskStatus] ;
|
|
|
[self.operation_queue addOperation:operation];
|
|
[self.operation_queue addOperation:operation];
|