fix: images scan bug

master
Tongg 8 months ago
parent bbdd362372
commit 6003cfb342
  1. 35
      Model/Services/SOCClientService.cs
  2. 16
      ViewModel/Grading/GradingLoadingVM.cs

@ -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");

@ -197,7 +197,19 @@ public class GradingLoadingVM : BaseViewModel,IDisposable
//通知页面可以播放图片 //通知页面可以播放图片
LoadDefaultImages(); LoadDefaultImages();
await processImage; await processImage;
await Task.Delay(1000);
// // 采集状态接口
// string acquisitionStatus = await SOCClientService.Service.CollectStatusAsync();
// // 成功
// if (acquisitionStatus != StatusCodes.Success)
// {
// Logger.Debug($"acquisitionStatus != StatusCodes.Success : {acquisitionStatus}");
// _progressCts.Cancel();
// new MessageBox().Show(
// MultilingualHelper.getString(StatusCodes.GetConstantNameByValue(acquisitionStatus)));
// return -1;
// }
if (!("ok".Equals(processImage.Result.Status) || "S000".Equals(processImage.Result.Status))) if (!("ok".Equals(processImage.Result.Status) || "S000".Equals(processImage.Result.Status)))
{ {
_progressCts.Cancel(); _progressCts.Cancel();
@ -422,7 +434,7 @@ public class GradingLoadingVM : BaseViewModel,IDisposable
finally finally
{ {
string strSafeSpace = ConfigurationHelper.ReadConfigValue("SafeSpaceReservation"); string strSafeSpace = ConfigurationHelper.ReadConfigValue("SafeSpaceReservation");
if (hasErr || "0".Equals(strSafeSpace)) if (hasErr || "0".Equals(strSafeSpace) || Parameter.Status == StatusCodes.Recheck)
{ {
DiamondSelectVM.HandleAlgorithmFailure(ImagePaths, _diamondCode, _diamnondType); DiamondSelectVM.HandleAlgorithmFailure(ImagePaths, _diamondCode, _diamnondType);
} }

Loading…
Cancel
Save