master
sunhonglei 11 months ago
parent 174d0245c5
commit b18833aca8
  1. 38
      ViewModel/Configuration/LevelConfigVM.cs
  2. 2
      ViewModel/Grading/GradingResultVM.cs

@ -1,25 +1,22 @@
using EncryptFileTool.Entity; using EncryptFileTool.Entity;
using HandyControl.Controls; using HandyControl.Controls;
using log4net;
using Newtonsoft.Json; using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using NPOI.SS.Formula.Functions;
using SharpDX;
using SparkClient.Model.Helper; using SparkClient.Model.Helper;
using System; using SparkClient.ViewModel.Grading;
using System.Data; using System.Data;
using System.Drawing;
using System.IO; using System.IO;
using System.Linq.Expressions;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data; using System.Windows.Data;
using System.Windows.Input; using System.Windows.Input;
using MessageBox = SparkClient.Views.Dialog.MessageBox;
namespace SparkClient.ViewModel.Configuration; namespace SparkClient.ViewModel.Configuration;
public class LevelConfigVM : BaseViewModel public class LevelConfigVM : BaseViewModel
{ {
private static readonly ILog Logger = LogManager.GetLogger(typeof(GradingResultVM));
public ICommand ChangeShapeModelCommand { get; } public ICommand ChangeShapeModelCommand { get; }
public ICommand ChangeInstituteModelCommand { get; } public ICommand ChangeInstituteModelCommand { get; }
public ICommand LoadLevelConfigCommand { get; } public ICommand LoadLevelConfigCommand { get; }
@ -107,6 +104,8 @@ public class LevelConfigVM : BaseViewModel
} }
private void setStandardList(DataTable gradeList, DataTable standardList) private void setStandardList(DataTable gradeList, DataTable standardList)
{
try
{ {
Style cellStyle = new Style(typeof(TextBlock)); Style cellStyle = new Style(typeof(TextBlock));
Setter setSellStyle = new Setter(TextBlock.HorizontalAlignmentProperty, HorizontalAlignment.Center); Setter setSellStyle = new Setter(TextBlock.HorizontalAlignmentProperty, HorizontalAlignment.Center);
@ -146,7 +145,8 @@ public class LevelConfigVM : BaseViewModel
if (standardList != null) if (standardList != null)
{ {
var standardRules = standardList.AsEnumerable().GroupBy(r => r["RULE_ID"].ToString()); var standardRules = standardList.AsEnumerable().GroupBy(r => r["RULE_ID"].ToString());
foreach (var ruleStandardList in standardRules) { foreach (var ruleStandardList in standardRules)
{
var standards = ruleStandardList.AsEnumerable().GroupBy(r => r[STANDARD_NAME].ToString()); var standards = ruleStandardList.AsEnumerable().GroupBy(r => r[STANDARD_NAME].ToString());
foreach (var standard in standards) foreach (var standard in standards)
{ {
@ -201,7 +201,8 @@ public class LevelConfigVM : BaseViewModel
var arr = value.Split("\r\n", 2); var arr = value.Split("\r\n", 2);
rowInfo.Add(arr[0]); rowInfo.Add(arr[0]);
if (arr.Length > 1) { if (arr.Length > 1)
{
rowInfo.Add(arr[1]); rowInfo.Add(arr[1]);
} }
else else
@ -283,6 +284,8 @@ public class LevelConfigVM : BaseViewModel
} }
string ruleId = ruleStandardList.Key; string ruleId = ruleStandardList.Key;
string prefix = ""; string prefix = "";
if (ruleId != null && !string.IsNullOrEmpty(ruleId))
{
string ta = ruleId.Substring(ruleId.Length - 2); string ta = ruleId.Substring(ruleId.Length - 2);
if (ruleId.StartsWith("GB")) if (ruleId.StartsWith("GB"))
{ {
@ -299,6 +302,7 @@ public class LevelConfigVM : BaseViewModel
prefix = "[台宽比=" + ruleId.Substring(ruleId.Length - 2) + "] "; prefix = "[台宽比=" + ruleId.Substring(ruleId.Length - 2) + "] ";
} }
} }
}
rowInfo.Insert(0, prefix + standard.Key); rowInfo.Insert(0, prefix + standard.Key);
var showRow = StandardList.NewRow(); var showRow = StandardList.NewRow();
showRow.ItemArray = rowInfo.ToArray(); showRow.ItemArray = rowInfo.ToArray();
@ -308,6 +312,12 @@ public class LevelConfigVM : BaseViewModel
} }
} }
} }
catch (Exception ex)
{
new MessageBox().Show($"{MultilingualHelper.getString("ApplicationError")}{ex.Message}");
Logger.Error($"全局异常捕获:{ex.Message}", ex);
}
}
private DataGridColumn GetDataGridColumn(string Header,string Binding,int lineCount = 2) private DataGridColumn GetDataGridColumn(string Header,string Binding,int lineCount = 2)
{ {
//Style cellStyle = new Style(typeof(TextBlock)); //Style cellStyle = new Style(typeof(TextBlock));
@ -449,7 +459,7 @@ public class LevelConfigVM : BaseViewModel
} }
catch (Exception ex) { catch (Exception ex) {
DataBaseHelper.rollback(); DataBaseHelper.rollback();
Console.WriteLine(ex.Message); Logger.Error($"全局异常捕获:{ex.Message}", ex);
Growl.Error(save_fail_message); Growl.Error(save_fail_message);
} }
} }
@ -467,6 +477,8 @@ public class LevelConfigVM : BaseViewModel
/// </summary> /// </summary>
/// <param name="param"></param> /// <param name="param"></param>
public void LoadLevelConfig(object param) public void LoadLevelConfig(object param)
{
try
{ {
InstitutesEnabled = false; InstitutesEnabled = false;
ShapesEnabled = false; ShapesEnabled = false;
@ -532,6 +544,12 @@ public class LevelConfigVM : BaseViewModel
setStandardList(gradeInfos, standardInfos); setStandardList(gradeInfos, standardInfos);
} }
} }
catch (Exception ex)
{
new MessageBox().Show($"{MultilingualHelper.getString("ApplicationError")}{ex.Message}");
Logger.Error($"全局异常捕获:{ex.Message}", ex);
}
}
/// <summary> /// <summary>
/// 切换规则响应 /// 切换规则响应

@ -654,7 +654,7 @@ public class GradingResultVM : BaseViewModel
return; return;
} }
} }
if (!File.Exists(getFilePath())) if (!Directory.Exists(getFilePath()))
{ {
new MessageBox().Show(MultilingualHelper.getString("FilePathNotExists")); new MessageBox().Show(MultilingualHelper.getString("FilePathNotExists"));
return; return;

Loading…
Cancel
Save