|
|
|
@ -16,6 +16,7 @@ using Microsoft.Data.Sqlite; |
|
|
|
|
using SparkClient.Model.Entity; |
|
|
|
|
using SparkClient.Model.Services; |
|
|
|
|
using MessageBox = System.Windows.MessageBox; |
|
|
|
|
using System.Runtime.CompilerServices; |
|
|
|
|
|
|
|
|
|
namespace SparkClient.ViewModel.Grading; |
|
|
|
|
|
|
|
|
@ -112,46 +113,82 @@ public class DiamondSelectVM : BaseViewModel |
|
|
|
|
/// <param name="param"></param> |
|
|
|
|
public async void StartGrading(object param) |
|
|
|
|
{ |
|
|
|
|
if (param != null) |
|
|
|
|
LoadingDialog loading = new LoadingDialog(); |
|
|
|
|
try |
|
|
|
|
{ |
|
|
|
|
LoadingDialog loading = new LoadingDialog(); |
|
|
|
|
var progressTask = Task.Run(() => Application.Current.Dispatcher.Invoke(() => loading.ShowDialog())); |
|
|
|
|
await Task.Run(async () => |
|
|
|
|
if (param != null) |
|
|
|
|
{ |
|
|
|
|
for (int i = 0; i <= 100; i++) |
|
|
|
|
var progressTask = Task.Run(() => Application.Current.Dispatcher.Invoke(() => loading.ShowDialog())); |
|
|
|
|
await Task.Run(async () => |
|
|
|
|
{ |
|
|
|
|
// 模拟耗时操作 |
|
|
|
|
//System.Threading.Thread.Sleep(50); // 休眠50毫秒 |
|
|
|
|
await Task.Delay(5); |
|
|
|
|
bool isEnd = false; |
|
|
|
|
int progress = 0; |
|
|
|
|
// 更新进度条的值(需要在UI线程上执行) |
|
|
|
|
loading.Dispatcher.Invoke(() => |
|
|
|
|
loading.Dispatcher.Invoke(async () => |
|
|
|
|
{ |
|
|
|
|
loading.setValue(i); |
|
|
|
|
for (int i = 0; i <= 97; i++) |
|
|
|
|
{ |
|
|
|
|
if (isEnd) |
|
|
|
|
{ |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
// 模拟耗时操作 |
|
|
|
|
//System.Threading.Thread.Sleep(50); // 休眠50毫秒 |
|
|
|
|
await Task.Delay(1000); |
|
|
|
|
loading.setValue(i); |
|
|
|
|
progress = i; |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
SocResultEntity socResolt = new SocResultEntity(); |
|
|
|
|
AlgorithmResultEntity parameter = new AlgorithmResultEntity(); |
|
|
|
|
parameter.Standard = "IGI 2024"; |
|
|
|
|
string value = param.ToString()??""; |
|
|
|
|
if (value!= null && value.Split(" ").Length==3) |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
SocResultEntity socResolt = new SocResultEntity(); |
|
|
|
|
AlgorithmResultEntity parameter = new AlgorithmResultEntity(); |
|
|
|
|
parameter.Standard = "IGI 2024"; |
|
|
|
|
string value = param.ToString() ?? ""; |
|
|
|
|
if (value != null && value.Split(" ").Length == 3) |
|
|
|
|
{ |
|
|
|
|
parameter.Shape = value.Split(" ")[0]; |
|
|
|
|
parameter.CrownType = value.Split(" ")[1]; |
|
|
|
|
parameter.PavType = value.Split(" ")[2]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 启动soc |
|
|
|
|
socResolt = await DoSoc(); |
|
|
|
|
// 启动算法 |
|
|
|
|
parameter = await DoAlgorithm(socResolt, parameter.Shape, parameter.CrownType); |
|
|
|
|
|
|
|
|
|
parameter.Standard = "IGI 2024"; |
|
|
|
|
parameter.Shape = value.Split(" ")[0]; |
|
|
|
|
parameter.CrownType = value.Split(" ")[1]; |
|
|
|
|
parameter.PavType = value.Split(" ")[2]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 启动soc |
|
|
|
|
socResolt = await DoSoc(); |
|
|
|
|
// 启动算法 |
|
|
|
|
parameter = await DoAlgorithm(socResolt, parameter.Shape, parameter.CrownType); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
parameter.DiamondCode = DiamondCode; |
|
|
|
|
GradingResult(parameter); |
|
|
|
|
}); |
|
|
|
|
await Task.Delay(5); |
|
|
|
|
loading.Close(); |
|
|
|
|
parameter.DiamondCode = DiamondCode; |
|
|
|
|
isEnd = true; |
|
|
|
|
//GradingResult(parameter); |
|
|
|
|
await loading.Dispatcher.Invoke(async () => |
|
|
|
|
{ |
|
|
|
|
for (int i = progress; progress <= 100; i++) |
|
|
|
|
{ |
|
|
|
|
Random random = new Random(); int minValue = 50; int maxValue = 150; // 生成50到150之间的随机整数 |
|
|
|
|
int randomNumber = random.Next(minValue, maxValue + 1); |
|
|
|
|
await Task.Delay(randomNumber); |
|
|
|
|
loading.setValue(i); |
|
|
|
|
if (loading.ProgressBar.Value == 98) |
|
|
|
|
{ |
|
|
|
|
GradingResult(parameter); |
|
|
|
|
} |
|
|
|
|
if(loading.ProgressBar.Value >= 100) |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
loading.Close(); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
finally { |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|