|
|
|
@ -266,8 +266,8 @@ namespace SparkClient.Model.Services |
|
|
|
{ |
|
|
|
{ |
|
|
|
var response = await SendGetRequestImageAsync(url,sendCode); |
|
|
|
var response = await SendGetRequestImageAsync(url,sendCode); |
|
|
|
int status = (int)response.StatusCode; |
|
|
|
int status = (int)response.StatusCode; |
|
|
|
if(token.IsCancellationRequested) |
|
|
|
|
|
|
|
token.ThrowIfCancellationRequested(); |
|
|
|
token.ThrowIfCancellationRequested(); |
|
|
|
switch (status) |
|
|
|
switch (status) |
|
|
|
{ |
|
|
|
{ |
|
|
|
case 200: |
|
|
|
case 200: |
|
|
|
@ -383,21 +383,16 @@ namespace SparkClient.Model.Services |
|
|
|
// 启动任务失败 |
|
|
|
// 启动任务失败 |
|
|
|
return new SocResultEntity { Status = entity.Status, Images = new List<string>() }; |
|
|
|
return new SocResultEntity { Status = entity.Status, Images = new List<string>() }; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 读取图片接口 |
|
|
|
// 读取图片接口 |
|
|
|
List<string> imageNames = await RetrieveImageAsync(savePath); |
|
|
|
List<string> imageNames = await RetrieveImageAsync(savePath); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// var cts = new CancellationTokenSource(); |
|
|
|
// var cts = new CancellationTokenSource(); |
|
|
|
// Task<HttpSendResult> startImage = CollectImagesAsyncNotAwait(); |
|
|
|
// Task<HttpSendResult> startImage = CollectImagesAsyncNotAwait(); |
|
|
|
// Task<List<string>> downloadImage = RetrieveImageAsync(savePath, cts.Token); |
|
|
|
// Task<List<string>> downloadImage = RetrieveImageAsync(savePath, cts.Token); |
|
|
|
// await startImage; |
|
|
|
// await startImage; |
|
|
|
// var entity = startImage.Result; |
|
|
|
// var entity = startImage.Result; |
|
|
|
// if (entity.StatusCode != 200) |
|
|
|
// if (entity.StatusCode != 200 || entity.Content == null) |
|
|
|
// { |
|
|
|
|
|
|
|
// //downloadImage怎么取消并终止 |
|
|
|
|
|
|
|
// cts.Cancel(); |
|
|
|
|
|
|
|
// return new SocResultEntity { Status = StatusCodes.DeviceNotFound, Images = new List<string>() }; |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
// if (entity.Content == null) |
|
|
|
|
|
|
|
// { |
|
|
|
// { |
|
|
|
// //downloadImage怎么取消并终止 |
|
|
|
// //downloadImage怎么取消并终止 |
|
|
|
// cts.Cancel(); |
|
|
|
// cts.Cancel(); |
|
|
|
@ -410,20 +405,20 @@ namespace SparkClient.Model.Services |
|
|
|
// await downloadImage; |
|
|
|
// await downloadImage; |
|
|
|
// imageNames = downloadImage.Result; |
|
|
|
// imageNames = downloadImage.Result; |
|
|
|
// } |
|
|
|
// } |
|
|
|
// catch (Exception e) |
|
|
|
// catch (OperationCanceledException e) |
|
|
|
// { |
|
|
|
// { |
|
|
|
// Logger.Error($"Error in Await downloadImage: {e.Message}"); |
|
|
|
// Logger.Error($"Error in Await downloadImage: {e.Message}"); |
|
|
|
// } |
|
|
|
// } |
|
|
|
|
|
|
|
|
|
|
|
// 采集状态接口 |
|
|
|
// // 采集状态接口 |
|
|
|
string acquisitionStatus = await CollectStatusAsync(); |
|
|
|
// string acquisitionStatus = await CollectStatusAsync(); |
|
|
|
// 成功 |
|
|
|
// // 成功 |
|
|
|
if (acquisitionStatus != StatusCodes.Success) |
|
|
|
// if (acquisitionStatus != StatusCodes.Success) |
|
|
|
{ |
|
|
|
// { |
|
|
|
Logger.Debug($"acquisitionStatus != StatusCodes.Success : {acquisitionStatus}"); |
|
|
|
// Logger.Debug($"acquisitionStatus != StatusCodes.Success : {acquisitionStatus}"); |
|
|
|
// 采集状态失败 |
|
|
|
// // 采集状态失败 |
|
|
|
return new SocResultEntity { Status = acquisitionStatus, Images = new List<string>() }; |
|
|
|
// return new SocResultEntity { Status = acquisitionStatus, Images = new List<string>() }; |
|
|
|
} |
|
|
|
// } |
|
|
|
if (imageNames.Count == 0) |
|
|
|
if (imageNames.Count == 0) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Logger.Debug("imageNames.Count == 0"); |
|
|
|
Logger.Debug("imageNames.Count == 0"); |
|
|
|
|