fix auto save bug

master
Tongg 9 months ago
parent 66e5acb593
commit 2fc4606c01
  1. 73
      ViewModel/Grading/GradingResultVM.cs

@ -283,44 +283,53 @@ public class GradingResultVM : BaseViewModel
[Log] [Log]
private void SaveToCsv() private void SaveToCsv()
{ {
string strBaseUrl = AppDomain.CurrentDomain.BaseDirectory; try
string filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory,"csv", "histroy.csv"); {
Measurements info = algorithmResult.measurements; string strBaseUrl = AppDomain.CurrentDomain.BaseDirectory;
string line = string filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "csv", "histroy.csv");
$"{DiamondCode}," + Measurements info = algorithmResult.measurements;
$"{Wight}(ct)," + string line =
$"{FormatDouble_A2(info.M1)}(mm)," + $"{DiamondCode}," +
$"{FormatDouble_A2(info.M2)}(mm)," + $"{Wight}(ct)," +
$"{FormatDouble_A2(info.M3)}(mm)," + $"{FormatDouble_A2(info.M1)}(mm)," +
$"{FormatDouble_P2(info.TABLE)}%," + $"{FormatDouble_A2(info.M2)}(mm)," +
$"{FormatDouble_P2(info.CROWN_HEIGHT)}%," + $"{FormatDouble_A2(info.M3)}(mm)," +
$"{FormatDouble_P2(info.PAV_DEPTH)}%," + $"{FormatDouble_P2(info.TABLE)}%," +
$"{FormatDouble_P2(info.TOTAL_DEPTH)}%," + $"{FormatDouble_P2(info.CROWN_HEIGHT)}%," +
$"{FormatDouble_A2(info.CROWN_ANGLE)}°," + $"{FormatDouble_P2(info.PAV_DEPTH)}%," +
$"{FormatDouble_A2(info.PAV_ANGLE)}°," + $"{FormatDouble_P2(info.TOTAL_DEPTH)}%," +
$"{FormatDouble_A2(info.CULET_SIZE)}(mm)," + $"{FormatDouble_A2(info.CROWN_ANGLE)}°," +
$"{FormatDouble_A2(info.GIRDLE)}%," + $"{FormatDouble_A2(info.PAV_ANGLE)}°," +
$"{calGirdleName(info)}," + $"{FormatDouble_A2(info.CULET_SIZE)}(mm)," +
$"," + $"{FormatDouble_A2(info.GIRDLE)}%," +
$"," + $"{calGirdleName(info)}," +
$"{GetGradeEnName(GetGradeOrder(CutLevelTotal))}"; $"," +
if (File.Exists(filePath)) { $"," +
using (var writer = new StreamWriter(filePath,true)) $"{GetGradeEnName(GetGradeOrder(CutLevelTotal))}";
if (File.Exists(filePath))
{ {
using (var writer = new StreamWriter(filePath, true))
{
writer.WriteLine(line); writer.WriteLine(line);
}
} }
} else
else
{
File.Create(filePath).Close();
string header = "Diamond Code,Wight,Measurement1, Measurement2, Measurement3, Table, Crown Height,Pavilion Depth, Total Depth,Crown Angle, Pavilion Angle,Culet Size, Girdle Percent,Girdle Name, POL or Pol/ Sym,SYM,CUT - PROP";
using (var writer = new StreamWriter(filePath, true))
{ {
writer.WriteLine(header); File.Create(filePath).Close();
writer.WriteLine(line); string header =
"Diamond Code,Wight,Measurement1, Measurement2, Measurement3, Table, Crown Height,Pavilion Depth, Total Depth,Crown Angle, Pavilion Angle,Culet Size, Girdle Percent,Girdle Name, POL or Pol/ Sym,SYM,CUT - PROP";
using (var writer = new StreamWriter(filePath, true))
{
writer.WriteLine(header);
writer.WriteLine(line);
}
} }
} }
catch (Exception ex)
{
Logger.Error($"Auto Save Error: {ex.Message}");
}
} }
private void saveTempDS(string selValue) private void saveTempDS(string selValue)

Loading…
Cancel
Save