|
|
@@ -29,9 +29,7 @@
|
|
|
|
|
|
- (void)initManager
|
|
|
{
|
|
|
- _maxUploadingNumber = 1;
|
|
|
- _uploadingModelArr = [NSMutableArray new];
|
|
|
-
|
|
|
+
|
|
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(uploadTaskFinishedNoti:) name:nasUploadTaskExeEnd object:nil];
|
|
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(uploadTaskErrorNoti:) name:nasUploadTaskExeError object:nil];
|
|
|
}
|
|
|
@@ -120,10 +118,6 @@
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- if(!_fileModelDataArr){
|
|
|
- _fileModelDataArr = [NSMutableArray new];
|
|
|
- }
|
|
|
-
|
|
|
_isNewAddTaskType = YES;
|
|
|
|
|
|
self.curUploadModelNumbers = indexPathsForSelectedItems.count;
|
|
|
@@ -243,13 +237,12 @@
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- _fileModelDataArr = [NSMutableArray arrayWithArray:totalArr[0]];
|
|
|
+ NSMutableArray* uploadTaskArr = [NSMutableArray arrayWithArray:totalArr[0]];
|
|
|
|
|
|
//多任务同时进行模式
|
|
|
- [[nasMixUploadManager shareManager] addDownloadWithModels:_fileModelDataArr];
|
|
|
- [_fileModelDataArr removeAllObjects];
|
|
|
-
|
|
|
- // [self beginUploadFileFun];
|
|
|
+ if(uploadTaskArr.count >0){
|
|
|
+ [[nasMixUploadManager shareManager] addDownloadWithModels:uploadTaskArr];
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
#pragma mark 上传完成
|
|
|
@@ -261,7 +254,6 @@
|
|
|
|
|
|
model.curUploadStateType = uploadStateDone;
|
|
|
[self nasUploadFileChangeingOneFileFunBy:model];
|
|
|
- [self uploadFileDoneOneFunWith:model];
|
|
|
[self deleteCacheDataBy:model];
|
|
|
}
|
|
|
|
|
|
@@ -274,321 +266,10 @@
|
|
|
|
|
|
model.curUploadStateType = uploadStateFail;
|
|
|
[self nasUploadFileChangeingOneFileFunBy:model];
|
|
|
- [self uploadFileFailOneFunWith:model];
|
|
|
[self deleteCacheDataBy:model];
|
|
|
}
|
|
|
|
|
|
|
|
|
-- (void)beginUploadFileFun
|
|
|
-{
|
|
|
-// if(_isUploadIngType && _reUploadIngSelectIndex <= 0){
|
|
|
-// return;
|
|
|
-// }
|
|
|
-
|
|
|
- BOOL isCanUseCellular = [HWDataManager getBoolWithKey:stringKeyAddSn(Const_file_Transfe_canUse_Cellular_all)];
|
|
|
- if(!isCanUseCellular){//不允许流量上传
|
|
|
- //
|
|
|
- if([AFNetworkReachabilityManager sharedManager].networkReachabilityStatus == AFNetworkReachabilityStatusReachableViaWWAN){
|
|
|
- mainBlock(^{
|
|
|
- [[NSNotificationCenter defaultCenter] postNotificationName:uploadFileSuspendAllNotification object:nil];
|
|
|
- [[iToast makeText:NSLocalizedString(@"File_Transfer_By_Cellular_tip",nil)] show];
|
|
|
- });
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- if(ksharedAppDelegate.DisabledFileTransferType){
|
|
|
- if(ksharedAppDelegate.isImageNewFor130){
|
|
|
- [[iToast makeText:NSLocalizedString(@"File_Transfer_Disable_tip",nil)] show];
|
|
|
- }
|
|
|
- else{
|
|
|
- [[iToast makeText:NSLocalizedString(@"File_Transfer_Disable_tip2",nil)] show];
|
|
|
- }
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- if(_isSuspendType)
|
|
|
- {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- _isUploadIngType = YES;
|
|
|
-
|
|
|
-
|
|
|
- if(_uploadingModelArr.count >= _maxUploadingNumber){
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- _curUploadFileDataModel.imageData = nil;
|
|
|
- _curUploadFileDataModel.videoData = nil;
|
|
|
- _curUploadFileDataModel = nil;
|
|
|
-
|
|
|
- if(_fileModelDataArr.count == 0 && _uploadingModelArr.count == 0){
|
|
|
- [self didUploadAllTaskDoneFun];
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- if(_reUploadIngSelectIndex > 0 && _reUploadIngSelectIndex < _fileModelDataArr.count){
|
|
|
- _curUploadFileDataModel = _fileModelDataArr[_reUploadIngSelectIndex];
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- _curUploadFileDataModel = _fileModelDataArr.firstObject;
|
|
|
- }
|
|
|
-
|
|
|
- //做个异常处理
|
|
|
- if(_databaseArr.count == 3 && _isNewAddTaskType){
|
|
|
- NSMutableArray *uploadIngArr = _databaseArr[0];
|
|
|
- if(_fileModelDataArr.count != uploadIngArr.count){
|
|
|
- _databaseArr[0] = [NSMutableArray arrayWithArray:_fileModelDataArr];
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if(!_curUploadFileDataModel){
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- if(_curUploadFileDataModel.curUploadFileType == uploadFileTypeImage){
|
|
|
- NSString*pathStr = [cachesFileManager getFilePathWithName:_curUploadFileDataModel.filename type:_curUploadFileDataModel.curUploadFileType];
|
|
|
- _curUploadFileDataModel.imageData = [NSData dataWithContentsOfFile:pathStr];
|
|
|
-
|
|
|
- if(_curUploadFileDataModel.imageData && _curUploadFileDataModel.imageData.length >0){
|
|
|
- if(_curUploadFileDataModel.totalBytes == 0){
|
|
|
- _curUploadFileDataModel.totalBytes = _curUploadFileDataModel.imageData.length;
|
|
|
- }
|
|
|
-
|
|
|
- [self beginGotoUploadDataFun];
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
- else{
|
|
|
- if([cachesFileManager checkFileIsSaveState:_curUploadFileDataModel.filename withType:uploadFileTypeVideo]){
|
|
|
- [self beginGotoUploadDataFun];
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if(!_curUploadFileDataModel.asset){
|
|
|
- NSString *curLocalIdentifier = _curUploadFileDataModel.localIdentifier;
|
|
|
- PHFetchResult *fetchResult = [PHAsset fetchAssetsWithLocalIdentifiers:@[curLocalIdentifier] options:nil];
|
|
|
- PHAsset *asset = fetchResult.firstObject;
|
|
|
- _curUploadFileDataModel.asset = asset;
|
|
|
- }
|
|
|
-
|
|
|
- if(!_curUploadFileDataModel.asset){
|
|
|
- self.curUploadFileDataModel.curUploadStateType = uploadStateFail;
|
|
|
- [self nasUploadFileChangeingOneFileFunBy:self.curUploadFileDataModel];
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- KWeakSelf
|
|
|
- if(_curUploadFileDataModel.curUploadFileType == uploadFileTypeImage)
|
|
|
- {
|
|
|
- if(!_curUploadFileDataModel.imageData || _curUploadFileDataModel.imageData.length == 0){
|
|
|
- [[PHImageManager defaultManager] requestImageDataForAsset:_curUploadFileDataModel.asset options:nil resultHandler:^(NSData * _Nullable imageData, NSString * _Nullable dataUTI, UIImageOrientation orientation, NSDictionary * _Nullable info) {
|
|
|
- // 直接得到最终的 NSData 数据
|
|
|
- if (imageData) {
|
|
|
- self->_curUploadFileDataModel.imageData = imageData;
|
|
|
- [weakSelf afterGetImageDataFun];
|
|
|
- }
|
|
|
- else{
|
|
|
- weakSelf.curUploadFileDataModel.curUploadStateType = uploadStateFail;
|
|
|
- [weakSelf nasUploadFileChangeingOneFileFunBy:weakSelf.curUploadFileDataModel];
|
|
|
- }
|
|
|
- }];
|
|
|
- }
|
|
|
- }
|
|
|
- else if(_curUploadFileDataModel.curUploadFileType == uploadFileTypeVideo){
|
|
|
-
|
|
|
- //第一帧图片
|
|
|
- [[PHImageManager defaultManager] requestImageDataForAsset:_curUploadFileDataModel.asset options:nil resultHandler:^(NSData * _Nullable imageData, NSString * _Nullable dataUTI, UIImageOrientation orientation, NSDictionary * _Nullable info) {
|
|
|
- // 直接得到最终的 NSData 数据
|
|
|
- if (imageData) {
|
|
|
- weakSelf.curUploadFileDataModel.imageData = imageData;
|
|
|
- [weakSelf afterGetImageDataInVideoFun];
|
|
|
- }
|
|
|
- }];
|
|
|
-
|
|
|
- //真正的视频数据
|
|
|
- PHVideoRequestOptions *options = [[PHVideoRequestOptions alloc] init];
|
|
|
- options.version = PHVideoRequestOptionsVersionOriginal;
|
|
|
- [[PHImageManager defaultManager] requestAVAssetForVideo:_curUploadFileDataModel.asset options:options resultHandler:^(AVAsset *asset, AVAudioMix *audioMix, NSDictionary *info) {
|
|
|
- if ([asset isKindOfClass:[AVURLAsset class]]) {
|
|
|
-
|
|
|
- AVURLAsset* urlAsset = (AVURLAsset*)asset;
|
|
|
-
|
|
|
- BOOL isSuc = [cachesFileManager copyVideoItemAtPath:[urlAsset.URL path] fileName:self->_curUploadFileDataModel.filename error:nil];
|
|
|
-
|
|
|
- if (isSuc) {
|
|
|
- [weakSelf afterGetVideoDataFun];
|
|
|
- }
|
|
|
- else{
|
|
|
- self->_curUploadFileDataModel.curUploadStateType = uploadStateFail;
|
|
|
- [weakSelf nasUploadFileChangeingOneFileFunBy:self->_curUploadFileDataModel];
|
|
|
- }
|
|
|
- }
|
|
|
- else{
|
|
|
- weakSelf.curUploadFileDataModel.curUploadStateType = uploadStateFail;
|
|
|
- [weakSelf nasUploadFileChangeingOneFileFunBy:weakSelf.curUploadFileDataModel];
|
|
|
- }
|
|
|
- }];
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-#pragma mark 根据 asset 获取到图片数据
|
|
|
-- (void)afterGetImageDataFun
|
|
|
-{
|
|
|
- [cachesFileManager getFileNameWithContent:_curUploadFileDataModel.imageData fileName:_curUploadFileDataModel.filename type:uploadFileTypeImage];
|
|
|
-
|
|
|
- [self beginGotoUploadDataFun];
|
|
|
-}
|
|
|
-
|
|
|
-#pragma mark 处理视频第一帧
|
|
|
-- (void)afterGetImageDataInVideoFun
|
|
|
-{
|
|
|
- [cachesFileManager getFileNameWithContent:_curUploadFileDataModel.imageData fileName:_curUploadFileDataModel.videoFirstImageName type:uploadFileTypeImage];
|
|
|
-}
|
|
|
-
|
|
|
-#pragma mark 处理视频数据
|
|
|
-- (void)afterGetVideoDataFun
|
|
|
-{
|
|
|
- [self beginGotoUploadDataFun];
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-#pragma mark 开始上传
|
|
|
-- (void)beginGotoUploadDataFun{
|
|
|
-
|
|
|
- [self checkFileUploadStateFun];
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-#pragma mark 检测文件是否上传过 或者云机里存在文件了
|
|
|
-- (void)checkFileUploadStateFun
|
|
|
-{
|
|
|
- NSMutableDictionary*paraDict = [NSMutableDictionary new];
|
|
|
-
|
|
|
- if(_curUploadFileDataModel.savePath){
|
|
|
- NSString *absPath = [[NSString alloc] initWithFormat:@"%@%@",_curUploadFileDataModel.savePath,_curUploadFileDataModel.filename];
|
|
|
- [paraDict setValue:absPath forKey:@"absPath"];
|
|
|
-
|
|
|
- NSNumber *totalBytesNumber = [NSNumber numberWithLong:_curUploadFileDataModel.totalBytes];
|
|
|
- [paraDict setValue:totalBytesNumber forKey:@"fileSize"];
|
|
|
- }
|
|
|
-
|
|
|
- KWeakSelf
|
|
|
- [[netWorkManager shareInstance] cloudPhoneGETCallBackCode:@"isFileExist" Parameters:paraDict success:^(id _Nonnull responseObject) {
|
|
|
-
|
|
|
- frpFileExistModel *model = [[frpFileExistModel alloc] initWithDictionary:responseObject error:nil];
|
|
|
- if(model && model.status == 0){
|
|
|
- [weakSelf checkFileUploadStateFunAfterNetWith:model];
|
|
|
- }
|
|
|
- else{
|
|
|
- [weakSelf checkFileUploadStateFunAfterNetWith:nil];
|
|
|
- }
|
|
|
- } failure:^(NSError * _Nonnull error) {
|
|
|
- HLog(@"%@",error)
|
|
|
- [weakSelf checkFileUploadStateFunAfterNetWith:nil];
|
|
|
- }];
|
|
|
-
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-- (void)checkFileUploadStateFunAfterNetWith:(frpFileExistModel*)model
|
|
|
-{
|
|
|
- if(!model){
|
|
|
- [self beginUploadFileFun];
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- _curUploadFileDataModel.didUploadBytes = 0;
|
|
|
- _curUploadFileDataModel.taskId = model.data.taskId;
|
|
|
-
|
|
|
- if(!model.data.exist){//未上传过
|
|
|
- [self realUploadAfterCheckFileUploadStateFun];
|
|
|
- }
|
|
|
- else if(model.data.isComplete){//上传过了 并且文件上传完了
|
|
|
- //判断下文件创建长度是否一致 一致则是上传完了 不一致 重新上传一个 可能是同名的文件而已
|
|
|
-// if(model.data.size >= _curUploadFileDataModel.totalBytes){//上传完了
|
|
|
-// HLog(@"222");
|
|
|
-// }
|
|
|
-// else{
|
|
|
-//
|
|
|
-// }
|
|
|
-
|
|
|
- [self handleTaskDidUploadWith:_curUploadFileDataModel];
|
|
|
-
|
|
|
- }
|
|
|
- else{//上传过了 未上传完成
|
|
|
- _curUploadFileDataModel.didUploadBytes = model.data.size;
|
|
|
- [self realUploadAfterCheckFileUploadStateFun];
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-#pragma mark 文件上传在云机已经存在
|
|
|
-- (void)handleTaskDidUploadWith:(uploadFileDataModel*)didUploadModel
|
|
|
-{
|
|
|
- mainBlock(^{
|
|
|
- [[iToast makeText:NSLocalizedString(@"File_upload_file_already_exists",nil)] show];
|
|
|
- });
|
|
|
-
|
|
|
- NSMutableArray *delArr = [NSMutableArray new];
|
|
|
- [delArr addObject:didUploadModel];
|
|
|
-
|
|
|
- [[nasUploadFileManager shareInstance] deleteUploadFileRecordBy:delArr withDelCache:NO complete:^(BOOL isSuccess) {
|
|
|
- if (isSuccess) {
|
|
|
-
|
|
|
- }
|
|
|
- }];
|
|
|
-}
|
|
|
-
|
|
|
-#pragma mark 检测文件是否上传过 或者云机里存在文件了
|
|
|
-- (void)realUploadAfterCheckFileUploadStateFun
|
|
|
-{
|
|
|
-
|
|
|
- BOOL isNewTask = YES;
|
|
|
- for (uploadFileDataModel *preModel in _uploadingModelArr) {
|
|
|
- if(preModel.bg_id.integerValue == _curUploadFileDataModel.bg_id.integerValue){
|
|
|
- isNewTask = NO;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- [_fileModelDataArr removeObject:_curUploadFileDataModel];
|
|
|
- if(isNewTask){
|
|
|
- [_uploadingModelArr addObject:_curUploadFileDataModel];
|
|
|
- }
|
|
|
- else{
|
|
|
- [self beginUploadFileFun];
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- __block uploadFileDataModel *curUploadModel = [_curUploadFileDataModel copy];
|
|
|
- _curUploadFileDataModel = nil;
|
|
|
-
|
|
|
- KWeakSelf
|
|
|
- [[nasUploadManager shareInstance] beginUploadDataBy:curUploadModel success:^(id _Nonnull responseObject) {
|
|
|
- HLog(@"beginGotoUploadDataFun 接收到上传完成")
|
|
|
- frpUploadModel *model = [[frpUploadModel alloc] initWithDictionary:responseObject error:nil];
|
|
|
- if(model && model.position == curUploadModel.totalBytes){
|
|
|
- curUploadModel.curUploadStateType = uploadStateDone;
|
|
|
- [weakSelf nasUploadFileChangeingOneFileFunBy:curUploadModel];
|
|
|
- [weakSelf uploadFileDoneOneFunWith:curUploadModel];
|
|
|
- [weakSelf deleteCacheDataBy:curUploadModel];
|
|
|
- }
|
|
|
-
|
|
|
- } faild:^(NSError * _Nonnull error) {
|
|
|
- curUploadModel.curUploadStateType = uploadStateFail;
|
|
|
- [weakSelf nasUploadFileChangeingOneFileFunBy:curUploadModel];
|
|
|
- [weakSelf uploadFileFailOneFunWith:curUploadModel];
|
|
|
- [weakSelf deleteCacheDataBy:curUploadModel];
|
|
|
- }];
|
|
|
-
|
|
|
- [self beginUploadFileFun];
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
#pragma mark 上传完成 清理缓存
|
|
|
- (void)deleteCacheDataBy:(uploadFileDataModel*)uploadFileDataMod
|
|
|
{
|
|
|
@@ -602,19 +283,15 @@
|
|
|
uploadFileDataMod = nil;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
#pragma mark 更新数据状态
|
|
|
- (void)nasUploadFileChangeingOneFileFunBy:(uploadFileDataModel*)dataModel
|
|
|
{
|
|
|
|
|
|
if(dataModel.curUploadStateType == uploadStateDone){
|
|
|
- //[_fileModelDataArr removeObject:dataModel];
|
|
|
[self handleDatabaseArrDeleteObjectInUploading:dataModel];
|
|
|
[self handleDatabaseArrAddObjectInDone:dataModel];
|
|
|
}
|
|
|
else if(dataModel.curUploadStateType == uploadStateFail){
|
|
|
- //[_fileModelDataArr removeObject:dataModel];
|
|
|
|
|
|
//删除操作导致的失败
|
|
|
NSMutableArray *ingArr = _databaseArr[0];
|
|
|
@@ -693,42 +370,10 @@
|
|
|
[lock unlock];
|
|
|
}
|
|
|
|
|
|
-#pragma mark 上传完成一个任务
|
|
|
-- (void)uploadFileDoneOneFunWith:(uploadFileDataModel*)dataModel
|
|
|
-{
|
|
|
- @synchronized (self) {
|
|
|
- for (uploadFileDataModel*uploadingModel in _uploadingModelArr) {
|
|
|
- if(uploadingModel.bg_id.intValue == dataModel.bg_id.intValue
|
|
|
- && [uploadingModel.filename isEqualToString:dataModel.filename]){
|
|
|
- [_uploadingModelArr removeObject:uploadingModel];
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- [self beginUploadFileFun];
|
|
|
-}
|
|
|
-
|
|
|
-#pragma mark 上传失败一个任务
|
|
|
-- (void)uploadFileFailOneFunWith:(uploadFileDataModel*)dataModel
|
|
|
-{
|
|
|
- @synchronized (self) {
|
|
|
- for (uploadFileDataModel*uploadingModel in _uploadingModelArr) {
|
|
|
- if(uploadingModel.bg_id.intValue == dataModel.bg_id.intValue
|
|
|
- && [uploadingModel.filename isEqualToString:dataModel.filename]){
|
|
|
- [_uploadingModelArr removeObject:uploadingModel];
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- [self beginUploadFileFun];
|
|
|
-}
|
|
|
-
|
|
|
#pragma mark 上传完成所有任务
|
|
|
- (void)didUploadAllTaskDoneFun
|
|
|
{
|
|
|
self->_isUploadIngType = NO;
|
|
|
- self->_curUploadFileDataModel = nil;
|
|
|
[[NSNotificationCenter defaultCenter] postNotificationName:uploadFileAllTaskDoneNotification object:nil];
|
|
|
}
|
|
|
|
|
|
@@ -832,45 +477,12 @@
|
|
|
}
|
|
|
|
|
|
//是否在删除上传中的任务
|
|
|
- if(_fileModelDataArr && _fileModelDataArr.count >0)
|
|
|
- {
|
|
|
- for (uploadFileDataModel *curUploadFileDataMod in _fileModelDataArr)
|
|
|
- {
|
|
|
- if(curUploadFileDataMod.bg_id.integerValue == uploadFileDataMod.bg_id.integerValue){
|
|
|
- [_fileModelDataArr removeObject:curUploadFileDataMod];
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if(!isDelUploadingModel){
|
|
|
- if(_uploadingModelArr && _uploadingModelArr.count >0)
|
|
|
- {
|
|
|
- for (uploadFileDataModel *curUploadFileDataMod in _uploadingModelArr)
|
|
|
- {
|
|
|
- if(curUploadFileDataMod.bg_id.integerValue == uploadFileDataMod.bg_id.integerValue){
|
|
|
- isDelUploadingModel = YES;
|
|
|
- [[nasUploadManager shareInstance] cancelUploadTaskFun];
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if(isDelUploadingModel){
|
|
|
- if(!_uploadingModelArr || _uploadingModelArr.count ==0){
|
|
|
- _isUploadIngType = NO;
|
|
|
+ if(uploadFileDataMod.curUploadStateType == uploadStateUploading){
|
|
|
+ [[nasMixUploadManager shareManager] cancelUploadTaskFunWith:uploadFileDataMod];
|
|
|
}
|
|
|
|
|
|
- if(_fileModelDataArr.count >=1){
|
|
|
- [self beginUploadFileFun];
|
|
|
- }
|
|
|
- else{
|
|
|
- _curUploadFileDataModel = nil;
|
|
|
- _isSuspendType = NO;
|
|
|
- }
|
|
|
}
|
|
|
+
|
|
|
|
|
|
uploadFileDataModel *RefreshUploadFileDataMod = nil;
|
|
|
if(delArr.count >= 1){
|
|
|
@@ -960,10 +572,7 @@
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- if(!_fileModelDataArr){
|
|
|
- _fileModelDataArr = [NSMutableArray new];
|
|
|
- }
|
|
|
-
|
|
|
+
|
|
|
//1.修改状态从失败改为上传中
|
|
|
for (uploadFileDataModel * model in Arr) {
|
|
|
model.curUploadStateType = uploadStateUploading;
|
|
|
@@ -977,19 +586,6 @@
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //判断是否是新任务
|
|
|
- BOOL isNewTask = YES;
|
|
|
- for (uploadFileDataModel *preModel in _fileModelDataArr) {
|
|
|
- if(preModel.bg_id.integerValue == model.bg_id.integerValue){
|
|
|
- isNewTask = NO;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //添加到等待上传列表
|
|
|
- if(isNewTask){
|
|
|
- [_fileModelDataArr insertObject:model atIndex:0];
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
//2、保存到数控库
|
|
|
@@ -997,50 +593,48 @@
|
|
|
|
|
|
}];
|
|
|
|
|
|
-
|
|
|
- //开始上传
|
|
|
- [self beginUploadFileFun];
|
|
|
+ //重新开始上传
|
|
|
+ [[nasMixUploadManager shareManager] addDownloadWithModels:Arr];
|
|
|
|
|
|
}
|
|
|
|
|
|
//暂停上传 当 isSuspendAll为NO时候 传指定暂停哪一个
|
|
|
- (void)suspendUploadFileFun:(BOOL)isSuspendAll withModel:(uploadFileDataModel*)model
|
|
|
{
|
|
|
- [[nasUploadManager shareInstance] cancelUploadTaskFun];
|
|
|
+ //[[nasUploadManager shareInstance] cancelUploadTaskFun];
|
|
|
+
|
|
|
+ if (isSuspendAll) {
|
|
|
+ [[nasMixUploadManager shareManager] cancelUploadAllTaskFun];
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ [[nasMixUploadManager shareManager] cancelUploadTaskFunWith:model];
|
|
|
+ }
|
|
|
|
|
|
- [self deleteUploadingTaskBy:isSuspendAll withModel:model];
|
|
|
+
|
|
|
+ [self suspendUploadingTaskBy:isSuspendAll withModel:model];
|
|
|
}
|
|
|
|
|
|
-#pragma mark 删除任务
|
|
|
-- (void)deleteUploadingTaskBy:(BOOL)isDeleteAll withModel:(uploadFileDataModel*)model
|
|
|
+#pragma mark 暂停任务
|
|
|
+- (void)suspendUploadingTaskBy:(BOOL)isDeleteAll withModel:(uploadFileDataModel*)model
|
|
|
{
|
|
|
- if(isDeleteAll){
|
|
|
- [_fileModelDataArr removeAllObjects];
|
|
|
- [_uploadingModelArr removeAllObjects];
|
|
|
+ NSMutableArray *uploadingArr = [NSMutableArray new];
|
|
|
+ if(!isDeleteAll){
|
|
|
+ if(model){
|
|
|
+ [uploadingArr addObject:model];
|
|
|
+ }
|
|
|
}
|
|
|
- else{
|
|
|
-
|
|
|
+ else
|
|
|
+ {
|
|
|
+ uploadingArr = _databaseArr[0];
|
|
|
+ }
|
|
|
+
|
|
|
+ if(uploadingArr.count > 0){
|
|
|
//更新数据库
|
|
|
- [uploadFileDataModel bg_saveOrUpdateArrayAsync:@[model] complete:^(BOOL isSuccess) {
|
|
|
+ [uploadFileDataModel bg_saveOrUpdateArrayAsync:uploadingArr complete:^(BOOL isSuccess) {
|
|
|
|
|
|
}];
|
|
|
-
|
|
|
-
|
|
|
- for (uploadFileDataModel *preModel in _fileModelDataArr) {
|
|
|
- if(preModel.bg_id.integerValue == model.bg_id.integerValue){
|
|
|
- [_fileModelDataArr removeObject:preModel];
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- for (uploadFileDataModel *preModel in _uploadingModelArr) {
|
|
|
- if(preModel.bg_id.integerValue == model.bg_id.integerValue){
|
|
|
- [_uploadingModelArr removeObject:preModel];
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- [self beginUploadFileFun];
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
@end
|