csv 内容变更

master
sunhonglei 4 months ago
parent 3cad516085
commit a3a532091f
  1. 85
      ViewModel/Grading/GradingResultVM.cs

@ -284,28 +284,29 @@ public class GradingResultVM : BaseViewModel
{ {
string strBaseUrl = AppDomain.CurrentDomain.BaseDirectory; string strBaseUrl = AppDomain.CurrentDomain.BaseDirectory;
string filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory,"csv", "histroy.csv"); string filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory,"csv", "histroy.csv");
Measurements info = algorithmResult.measurements;
string line =
$"{DiamondCode}," +
$"{Wight}(ct)," +
$"{FormatDouble_A2(info.M1)}(mm)," +
$"{FormatDouble_A2(info.M2)}(mm)," +
$"{FormatDouble_A2(info.M3)}(mm)," +
$"{FormatDouble_P2(info.TABLE)}%," +
$"{FormatDouble_P2(info.CROWN_HEIGHT)}%," +
$"{FormatDouble_P2(info.PAV_DEPTH)}%," +
$"{FormatDouble_P2(info.TOTAL_DEPTH)}%," +
$"{FormatDouble_A2(info.CROWN_ANGLE)}°," +
$"{FormatDouble_A2(info.PAV_ANGLE)}°," +
$"{FormatDouble_A2(info.CULET_SIZE)}(mm)," +
$"{FormatDouble_A2(info.GIRDLE)}%," +
$"{calGirdleName(info)}," +
$"," +
$"," +
$"{GetGradeEnName(GetGradeOrder(CutLevelTotal))}";
if (File.Exists(filePath)) { if (File.Exists(filePath)) {
using (var writer = new StreamWriter(filePath,true)) using (var writer = new StreamWriter(filePath,true))
{ {
Measurements info = algorithmResult.measurements;
string line =
$"{DiamondCode}," +
$"{Wight}(ct)," +
$"{FormatDouble_A(info.M1)}(mm)," +
$"{FormatDouble_A(info.M2)}(mm)," +
$"{FormatDouble_A(info.M3)}(mm)," +
$"{FormatDouble_P(info.TABLE)}%," +
$"{FormatDouble_P(info.CROWN_HEIGHT)}%," +
$"{FormatDouble_P(info.PAV_DEPTH)}%," +
$"{FormatDouble_P(info.TOTAL_DEPTH)}%," +
$"{FormatDouble_A(info.CROWN_ANGLE)}°," +
$"{FormatDouble_A(info.PAV_ANGLE)}°," +
$"{FormatDouble_A(info.CULET_SIZE)}(mm)," +
$"{FormatDouble_P(info.GIRDLE)}%," +
$"{calGirdleName(info)}," +
$"," +
$"," +
$"{GetGradeEnName(GetGradeOrder(CutLevelTotal))}";
writer.WriteLine(line); writer.WriteLine(line);
} }
} }
@ -313,25 +314,6 @@ public class GradingResultVM : BaseViewModel
{ {
File.Create(filePath).Close(); 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"; 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";
Measurements info = algorithmResult.measurements;
string line =
$"{DiamondCode}," +
$"{Wight}(ct)," +
$"{FormatDouble_A(info.M1)}(mm)," +
$"{FormatDouble_A(info.M2)}(mm)," +
$"{FormatDouble_A(info.M3)}(mm)," +
$"{FormatDouble_P(info.TABLE)}%," +
$"{FormatDouble_P(info.CROWN_HEIGHT)}%," +
$"{FormatDouble_P(info.PAV_DEPTH)}%," +
$"{FormatDouble_P(info.TOTAL_DEPTH)}%," +
$"{FormatDouble_A(info.CROWN_ANGLE)}°," +
$"{FormatDouble_A(info.PAV_ANGLE)}°," +
$"{FormatDouble_A(info.CULET_SIZE)}(mm)," +
$"{FormatDouble_P(info.GIRDLE)}%," +
$"{calGirdleName(info)}," +
$"," +
$"," +
$"{GetGradeEnName(GetGradeOrder(CutLevelTotal))}";
using (var writer = new StreamWriter(filePath, true)) using (var writer = new StreamWriter(filePath, true))
{ {
writer.WriteLine(header); writer.WriteLine(header);
@ -1316,17 +1298,17 @@ public class GradingResultVM : BaseViewModel
col = 0; col = 0;
dataRow = sheet.CreateRow(row); dataRow = sheet.CreateRow(row);
Measurements info = algorithmResult.measurements; Measurements info = algorithmResult.measurements;
dataRow.CreateCell(col++).SetCellValue($"{FormatDouble_A(info.M1)}(mm)"); dataRow.CreateCell(col++).SetCellValue($"{FormatDouble_A2(info.M1)}(mm)");
dataRow.CreateCell(col++).SetCellValue($"{FormatDouble_A(info.M2)}(mm)"); dataRow.CreateCell(col++).SetCellValue($"{FormatDouble_A2(info.M2)}(mm)");
dataRow.CreateCell(col++).SetCellValue($"{FormatDouble_A(info.M3)}(mm)"); dataRow.CreateCell(col++).SetCellValue($"{FormatDouble_A2(info.M3)}(mm)");
dataRow.CreateCell(col++).SetCellValue($"{FormatDouble_P(info.TABLE)}%"); dataRow.CreateCell(col++).SetCellValue($"{FormatDouble_P2(info.TABLE)}%");
dataRow.CreateCell(col++).SetCellValue($"{FormatDouble_P(info.CROWN_HEIGHT)}%"); dataRow.CreateCell(col++).SetCellValue($"{FormatDouble_P2(info.CROWN_HEIGHT)}%");
dataRow.CreateCell(col++).SetCellValue($"{FormatDouble_P(info.PAV_DEPTH)}%"); dataRow.CreateCell(col++).SetCellValue($"{FormatDouble_P2(info.PAV_DEPTH)}%");
dataRow.CreateCell(col++).SetCellValue($"{FormatDouble_P(info.TOTAL_DEPTH)}%"); dataRow.CreateCell(col++).SetCellValue($"{FormatDouble_P2(info.TOTAL_DEPTH)}%");
dataRow.CreateCell(col++).SetCellValue($"{FormatDouble_A(info.CROWN_ANGLE)}°"); dataRow.CreateCell(col++).SetCellValue($"{FormatDouble_A2(info.CROWN_ANGLE)}°");
dataRow.CreateCell(col++).SetCellValue($"{FormatDouble_A(info.PAV_ANGLE)}°"); dataRow.CreateCell(col++).SetCellValue($"{FormatDouble_A2(info.PAV_ANGLE)}°");
dataRow.CreateCell(col++).SetCellValue($"{FormatDouble_A(info.CULET_SIZE)}(mm)"); dataRow.CreateCell(col++).SetCellValue($"{FormatDouble_A2(info.CULET_SIZE)}(mm)");
dataRow.CreateCell(col++).SetCellValue($"{FormatDouble_P(info.GIRDLE)}%"); dataRow.CreateCell(col++).SetCellValue($"{FormatDouble_P2(info.GIRDLE)}%");
// 腰部厚度英文 // 腰部厚度英文
dataRow.CreateCell(col++).SetCellValue($"{calGirdleName(info)}"); dataRow.CreateCell(col++).SetCellValue($"{calGirdleName(info)}");
dataRow.CreateCell(col++).SetCellValue($""); dataRow.CreateCell(col++).SetCellValue($"");
@ -1541,6 +1523,11 @@ public class GradingResultVM : BaseViewModel
return (Math.Floor(value * 10) / 10).ToString(digitsFormat); return (Math.Floor(value * 10) / 10).ToString(digitsFormat);
} }
[Log] [Log]
private string FormatDouble_A2(double value)
{
return (Math.Floor(value * 100) / 100).ToString("f2");
}
[Log]
private async Task DatFile(string filePath) private async Task DatFile(string filePath)
{ {
//File.Create(filePath + ".dat").Close(); //File.Create(filePath + ".dat").Close();

Loading…
Cancel
Save