|
@@ -1,4 +1,6 @@
|
|
|
|
|
|
+using System.Linq;
|
|
|
+
|
|
|
namespace etoy
|
|
|
{
|
|
|
class CmdCheckDataIntegrity : Command
|
|
@@ -163,6 +165,7 @@ namespace etoy
|
|
|
AddException(new Exception($"配置表({table.Name}), 表结构未含PrimaryKey的字段. {table.Path}"));
|
|
|
|
|
|
// Cells 合法性检测
|
|
|
+ var primaryKeys = new HashSet<string>();
|
|
|
for (int i = 0, rowCount = table.Rows.Count; i < rowCount; i++)
|
|
|
{
|
|
|
var row = table.Rows[i];
|
|
@@ -174,7 +177,14 @@ namespace etoy
|
|
|
int excelRow = cell.Row + 1;
|
|
|
int excelCol = cell.Column + 1;
|
|
|
string fieldType = cell.FieldInfo.FieldType;
|
|
|
-
|
|
|
+ if (cell.FieldInfo.IsPrimaryKey)
|
|
|
+ { // 主键
|
|
|
+ if (!primaryKeys.Add(cell.Value))
|
|
|
+ {
|
|
|
+ AddException(new Exception($"配置表({table.Name}) 主键重复 字段内容: ({cell.Value}) 与 字段类型: ({fieldType})。 {table.Path} (行: {excelRow}, 列: {excelCol})"));
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
bool valid;
|
|
|
if (cell.FieldInfo.IsRepeated)
|
|
@@ -220,6 +230,7 @@ namespace etoy
|
|
|
AddException(new Exception($"配置表({table.Name}) 字段内容: ({cell.Value}) 与 字段类型: ({fieldType}) 转换失败。 {table.Path} (行: {excelRow}, 列: {excelCol})"));
|
|
|
}
|
|
|
}
|
|
|
+ primaryKeys.Clear();
|
|
|
}
|
|
|
}
|
|
|
}
|