|
|
|
@ -222,7 +222,7 @@ public class GradingLoadingVM : BaseViewModel,IDisposable |
|
|
|
|
SOCClientService.Service.OpenPump(false); |
|
|
|
|
return -100; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Diamond diamond = new Diamond(); |
|
|
|
|
string circleSql = $"SELECT VALUE FROM CUTTER_CONFIG WHERE KEY = 'half_circle'"; |
|
|
|
|
DataTable circleTable = DataBaseHelper.ExecuteQuery(circleSql); |
|
|
|
@ -295,82 +295,98 @@ public class GradingLoadingVM : BaseViewModel,IDisposable |
|
|
|
|
|
|
|
|
|
private async Task<int> ReslutGen(Task<DiaResult> detectTask) |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
CompleteProgressQuicklyAsync(); |
|
|
|
|
|
|
|
|
|
if (detectTask.Result != null) |
|
|
|
|
bool hasErr = false; |
|
|
|
|
try |
|
|
|
|
{ |
|
|
|
|
switch (detectTask.Result.Status) |
|
|
|
|
CompleteProgressQuicklyAsync(); |
|
|
|
|
|
|
|
|
|
if (detectTask.Result != null) |
|
|
|
|
{ |
|
|
|
|
case StatusCodes.AlgorithmFailed: |
|
|
|
|
new MessageBox().Show(MultilingualHelper.getString("AlgorithmFailed")); |
|
|
|
|
return -1; |
|
|
|
|
case StatusCodes.ImageFileReadFailure: |
|
|
|
|
new MessageBox().Show(MultilingualHelper.getString("ImageFileReadFailure")); |
|
|
|
|
return -1; |
|
|
|
|
case StatusCodes.JsonParseFailure: |
|
|
|
|
switch (detectTask.Result.Status) |
|
|
|
|
{ |
|
|
|
|
case StatusCodes.AlgorithmFailed: |
|
|
|
|
new MessageBox().Show(MultilingualHelper.getString("AlgorithmFailed")); |
|
|
|
|
hasErr = true; |
|
|
|
|
return -1; |
|
|
|
|
case StatusCodes.ImageFileReadFailure: |
|
|
|
|
new MessageBox().Show(MultilingualHelper.getString("ImageFileReadFailure")); |
|
|
|
|
hasErr = true; |
|
|
|
|
return -1; |
|
|
|
|
case StatusCodes.JsonParseFailure: |
|
|
|
|
new MessageBox().Show(MultilingualHelper.getString("JsonParseFailure")); |
|
|
|
|
hasErr = true; |
|
|
|
|
return -1; |
|
|
|
|
case StatusCodes.NoDiamond: |
|
|
|
|
new MessageBox().Show(MultilingualHelper.getString("NoDiamond")); |
|
|
|
|
hasErr = true; |
|
|
|
|
return -1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Progress = (100.00); |
|
|
|
|
|
|
|
|
|
string strParam = JsonConvert.SerializeObject(detectTask.Result); |
|
|
|
|
//Logger.Info("序列化字符串:" + strParam); |
|
|
|
|
AlgorithmResultEntity parameter = JsonConvert.DeserializeObject<AlgorithmResultEntity>(strParam); |
|
|
|
|
if (parameter == null && _isCancel == false) |
|
|
|
|
{ |
|
|
|
|
new MessageBox().Show(MultilingualHelper.getString("JsonParseFailure")); |
|
|
|
|
hasErr = true; |
|
|
|
|
return -1; |
|
|
|
|
case StatusCodes.NoDiamond: |
|
|
|
|
new MessageBox().Show(MultilingualHelper.getString("NoDiamond")); |
|
|
|
|
return -1; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Progress = (100.00); |
|
|
|
|
parameter.DiamondCode = _diamondCode; |
|
|
|
|
parameter.Standard = getStandardName(); |
|
|
|
|
parameter.Shape = _diamnondType.Split(" ")[0]; |
|
|
|
|
parameter.CrownType = _diamnondType.Split(" ")[1]; |
|
|
|
|
parameter.PavType = _diamnondType.Split(" ")[2]; |
|
|
|
|
|
|
|
|
|
string strParam = JsonConvert.SerializeObject(detectTask.Result); |
|
|
|
|
//Logger.Info("序列化字符串:" + strParam); |
|
|
|
|
AlgorithmResultEntity parameter = JsonConvert.DeserializeObject<AlgorithmResultEntity>(strParam); |
|
|
|
|
if (parameter == null && _isCancel == false) |
|
|
|
|
{ |
|
|
|
|
new MessageBox().Show(MultilingualHelper.getString("JsonParseFailure")); |
|
|
|
|
return -1; |
|
|
|
|
} |
|
|
|
|
try |
|
|
|
|
{ |
|
|
|
|
string parameterJson = JsonConvert.SerializeObject(parameter); |
|
|
|
|
parameterJson = JToken.Parse(parameterJson).ToString(); |
|
|
|
|
string outputPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "logs", "result"); |
|
|
|
|
if (!Directory.Exists(outputPath)) |
|
|
|
|
Directory.CreateDirectory(outputPath); |
|
|
|
|
string outputFilePath = $"{outputPath}/{_diamondCode}-{DateTime.Now:yyyyMMdd_HHmmss}.json"; |
|
|
|
|
using (var file = File.Create(outputFilePath)) |
|
|
|
|
using (StreamWriter stream = new StreamWriter(file)) |
|
|
|
|
{ |
|
|
|
|
stream.Write(parameterJson); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
catch (Exception ex) |
|
|
|
|
{ |
|
|
|
|
Logger.Error("output输出失败:" + ex.Message); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
parameter.DiamondCode = _diamondCode; |
|
|
|
|
parameter.Standard = getStandardName(); |
|
|
|
|
parameter.Shape = _diamnondType.Split(" ")[0]; |
|
|
|
|
parameter.CrownType = _diamnondType.Split(" ")[1]; |
|
|
|
|
parameter.PavType = _diamnondType.Split(" ")[2]; |
|
|
|
|
Parameter = parameter; |
|
|
|
|
if (_isCancel == true) |
|
|
|
|
{ |
|
|
|
|
SOCClientService.Service.OpenPump(false); |
|
|
|
|
return -100; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
try |
|
|
|
|
{ |
|
|
|
|
string parameterJson = JsonConvert.SerializeObject(parameter); |
|
|
|
|
parameterJson = JToken.Parse(parameterJson).ToString(); |
|
|
|
|
string outputPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "logs", "result"); |
|
|
|
|
if (!Directory.Exists(outputPath)) |
|
|
|
|
Directory.CreateDirectory(outputPath); |
|
|
|
|
string outputFilePath = $"{outputPath}/{_diamondCode}-{DateTime.Now:yyyyMMdd_HHmmss}.json"; |
|
|
|
|
using (var file = File.Create(outputFilePath)) |
|
|
|
|
using (StreamWriter stream = new StreamWriter(file)) |
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
if (parameter.status == StatusCodes.Recheck) |
|
|
|
|
{ |
|
|
|
|
stream.Write(parameterJson); |
|
|
|
|
new MessageBox().Show(MultilingualHelper.getString("Recheck")); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
catch (Exception ex) |
|
|
|
|
{ |
|
|
|
|
Logger.Error("output输出失败:" + ex.Message); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Parameter = parameter; |
|
|
|
|
if (_isCancel == true) |
|
|
|
|
{ |
|
|
|
|
SOCClientService.Service.OpenPump(false); |
|
|
|
|
return -100; |
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
if (parameter.status == StatusCodes.Recheck) |
|
|
|
|
|
|
|
|
|
return -10; |
|
|
|
|
} |
|
|
|
|
finally |
|
|
|
|
{ |
|
|
|
|
string strSafeSpace = ConfigurationHelper.ReadConfigValue("SafeSpaceReservation"); |
|
|
|
|
if (hasErr || "0".Equals(strSafeSpace)) |
|
|
|
|
{ |
|
|
|
|
new MessageBox().Show(MultilingualHelper.getString("Recheck")); |
|
|
|
|
DiamondSelectVM.HandleAlgorithmFailure(ImagePaths, _diamondCode); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return -10; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private async Task CompleteProgressSlowlyAsync() |
|
|
|
|