diff --git a/Model/Services/SOCClientService.cs b/Model/Services/SOCClientService.cs index d2ba4a1..d337255 100644 --- a/Model/Services/SOCClientService.cs +++ b/Model/Services/SOCClientService.cs @@ -375,46 +375,46 @@ namespace SparkClient.Model.Services // 启动任务接口 - // SocResultEntity entity = await CollectImagesAsync(); + SocResultEntity entity = await CollectImagesAsync(); // 成功 - // Logger.Debug($"entity :{entity.Status} {entity.ToString()} "); - // if (entity.Status != StatusCodes.Success) - // { - // // 启动任务失败 - // return new SocResultEntity { Status = entity.Status, Images = new List() }; - // } - - // 读取图片接口 - // List imageNames = await RetrieveImageAsync(savePath); - var cts = new CancellationTokenSource(); - Task startImage = CollectImagesAsyncNotAwait(); - Task> downloadImage = RetrieveImageAsync(savePath, cts.Token); - await startImage; - var entity = startImage.Result; - if (entity.StatusCode != 200) - { - //downloadImage怎么取消并终止 - cts.Cancel(); - return new SocResultEntity { Status = StatusCodes.DeviceNotFound, Images = new List() }; - } - if (entity.Content == null) - { - //downloadImage怎么取消并终止 - cts.Cancel(); - return new SocResultEntity { Status = StatusCodes.DeviceNotFound, Images = new List() }; - } - - List imageNames = new List(); - try + Logger.Debug($"entity :{entity.Status} {entity.ToString()} "); + if (entity.Status != StatusCodes.Success) { - await downloadImage; - imageNames = downloadImage.Result; - } - catch (Exception e) - { - Logger.Error($"Error in Await downloadImage: {e.Message}"); + // 启动任务失败 + return new SocResultEntity { Status = entity.Status, Images = new List() }; } + // 读取图片接口 + List imageNames = await RetrieveImageAsync(savePath); + // var cts = new CancellationTokenSource(); + // Task startImage = CollectImagesAsyncNotAwait(); + // Task> downloadImage = RetrieveImageAsync(savePath, cts.Token); + // await startImage; + // var entity = startImage.Result; + // if (entity.StatusCode != 200) + // { + // //downloadImage怎么取消并终止 + // cts.Cancel(); + // return new SocResultEntity { Status = StatusCodes.DeviceNotFound, Images = new List() }; + // } + // if (entity.Content == null) + // { + // //downloadImage怎么取消并终止 + // cts.Cancel(); + // return new SocResultEntity { Status = StatusCodes.DeviceNotFound, Images = new List() }; + // } + // + // List imageNames = new List(); + // try + // { + // await downloadImage; + // imageNames = downloadImage.Result; + // } + // catch (Exception e) + // { + // Logger.Error($"Error in Await downloadImage: {e.Message}"); + // } + // 采集状态接口 string acquisitionStatus = await CollectStatusAsync(); // 成功 @@ -430,7 +430,7 @@ namespace SparkClient.Model.Services // 图片文件读取失败 return new SocResultEntity { Status = StatusCodes.ImageFileReadFailure, Images = new List() }; } - return new SocResultEntity { Status = "S000", Images = imageNames, DeviceId = entity.Content.device_id}; + return new SocResultEntity { Status = "S000", Images = imageNames, DeviceId = entity.DeviceId}; } catch (Exception e) {