From 6003cfb342f836f518fba4b578d1e57acfa30dc3 Mon Sep 17 00:00:00 2001 From: Tongg Date: Mon, 14 Apr 2025 17:16:14 +0800 Subject: [PATCH] fix: images scan bug --- Model/Services/SOCClientService.cs | 35 ++++++++++++--------------- ViewModel/Grading/GradingLoadingVM.cs | 16 ++++++++++-- 2 files changed, 29 insertions(+), 22 deletions(-) diff --git a/Model/Services/SOCClientService.cs b/Model/Services/SOCClientService.cs index d337255..1284edc 100644 --- a/Model/Services/SOCClientService.cs +++ b/Model/Services/SOCClientService.cs @@ -266,8 +266,8 @@ namespace SparkClient.Model.Services { var response = await SendGetRequestImageAsync(url,sendCode); int status = (int)response.StatusCode; - if(token.IsCancellationRequested) - token.ThrowIfCancellationRequested(); + + token.ThrowIfCancellationRequested(); switch (status) { case 200: @@ -383,21 +383,16 @@ namespace SparkClient.Model.Services // 启动任务失败 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) + // if (entity.StatusCode != 200 || entity.Content == null) // { // //downloadImage怎么取消并终止 // cts.Cancel(); @@ -410,20 +405,20 @@ namespace SparkClient.Model.Services // await downloadImage; // imageNames = downloadImage.Result; // } - // catch (Exception e) + // catch (OperationCanceledException e) // { // Logger.Error($"Error in Await downloadImage: {e.Message}"); // } - // 采集状态接口 - string acquisitionStatus = await CollectStatusAsync(); - // 成功 - if (acquisitionStatus != StatusCodes.Success) - { - Logger.Debug($"acquisitionStatus != StatusCodes.Success : {acquisitionStatus}"); - // 采集状态失败 - return new SocResultEntity { Status = acquisitionStatus, Images = new List() }; - } + // // 采集状态接口 + // string acquisitionStatus = await CollectStatusAsync(); + // // 成功 + // if (acquisitionStatus != StatusCodes.Success) + // { + // Logger.Debug($"acquisitionStatus != StatusCodes.Success : {acquisitionStatus}"); + // // 采集状态失败 + // return new SocResultEntity { Status = acquisitionStatus, Images = new List() }; + // } if (imageNames.Count == 0) { Logger.Debug("imageNames.Count == 0"); diff --git a/ViewModel/Grading/GradingLoadingVM.cs b/ViewModel/Grading/GradingLoadingVM.cs index 3175067..55f1f1e 100644 --- a/ViewModel/Grading/GradingLoadingVM.cs +++ b/ViewModel/Grading/GradingLoadingVM.cs @@ -197,7 +197,19 @@ public class GradingLoadingVM : BaseViewModel,IDisposable //通知页面可以播放图片 LoadDefaultImages(); 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))) { _progressCts.Cancel(); @@ -422,7 +434,7 @@ public class GradingLoadingVM : BaseViewModel,IDisposable finally { string strSafeSpace = ConfigurationHelper.ReadConfigValue("SafeSpaceReservation"); - if (hasErr || "0".Equals(strSafeSpace)) + if (hasErr || "0".Equals(strSafeSpace) || Parameter.Status == StatusCodes.Recheck) { DiamondSelectVM.HandleAlgorithmFailure(ImagePaths, _diamondCode, _diamnondType); }