历史记录

This commit is contained in:
clovejunti 2024-11-10 00:05:40 +08:00
parent 25a620143a
commit 3928627ed2
8 changed files with 132 additions and 13 deletions

View File

@ -424,6 +424,47 @@ namespace DeviceRepair.DataAccess.Data
return (dtReturn); return (dtReturn);
} }
/// <summary>
/// 对象转换为字典
/// </summary>
/// <param name="obj">待转化的对象</param>
/// <returns></returns>
public Dictionary<string, string> ObjectToMap(object obj)
{
Dictionary<string, string> map = new Dictionary<string, string>(); //
Type t = obj.GetType(); // 获取对象对应的类, 对应的类型string
PropertyInfo[] pi = t.GetProperties(BindingFlags.Public | BindingFlags.Instance); // 获取当前type公共属性io
foreach (PropertyInfo p in pi)
{
MethodInfo m = p.GetGetMethod();
if (m != null && m.IsPublic)
{
// 进行判NULL处理
if (m.Invoke(obj, new object[] { }) != null)
{
map.Add(p.Name, m.Invoke(obj, new object[] { }).ToString()); // 向字典添加元素
}
}
}
return map;
}
public bool CompareDictionaries(Dictionary<string, string> d1, Dictionary<string, string> d2)
{
//比较d2>=d1
if (d1.Count != d2.Count) return false;
foreach (string key in d1.Keys)
{
if (!d2.ContainsKey(key)) return false;
if (d1[key]?.Trim() != d2[key].Trim()) return false;
}
return true;
}
#endregion #endregion
} }
} }

View File

@ -284,6 +284,31 @@ namespace DeviceRepair.DataAccess.Device
.First(x => x.AutoID == Data.AutoID); .First(x => x.AutoID == Data.AutoID);
if (Item == null) if (Item == null)
throw new ArgumentException($"没有获取到设备编号为:【{Data.EquipmentID}】的设备信息!"); throw new ArgumentException($"没有获取到设备编号为:【{Data.EquipmentID}】的设备信息!");
Dictionary<string, string> dc1 = ObjectToMap(Data);
Dictionary<string, string> dc2 = ObjectToMap(Item);
if (dc1.ContainsKey("UsingDate")) dc1.Remove("UsingDate");
if (dc2.ContainsKey("UsingDate")) dc2.Remove("UsingDate");
if (dc1.ContainsKey("CreatDate")) dc1.Remove("CreatDate");
if (dc2.ContainsKey("CreatDate")) dc2.Remove("CreatDate");
if (dc1.ContainsKey("CreatUser")) dc1.Remove("CreatUser");
if (dc2.ContainsKey("CreatUser")) dc2.Remove("CreatUser");
if (dc1.ContainsKey("ChangeDate")) dc1.Remove("ChangeDate");
if (dc2.ContainsKey("ChangeDate")) dc2.Remove("ChangeDate");
if (dc1.ContainsKey("ChangeUser")) dc1.Remove("ChangeUser");
if (dc2.ContainsKey("ChangeUser")) dc2.Remove("ChangeUser");
if (dc1.ContainsKey("GUID")) dc1.Remove("GUID");
if (dc2.ContainsKey("GUID")) dc2.Remove("GUID");
var ud1 = (Data.UsingDate ?? "");
ud1 = ud1.Length > 8 ? ud1.Substring(0, 7) : ud1;
var ud2 = (Item.UsingDate ?? "");
ud2 = ud2.Length > 8 ? ud2.Substring(0, 7) : ud2;
if (CompareDictionaries(dc1, dc2) && ud1 == ud2)
{
throw new Exception("当前数据无更改!");
}
var dataHistory = new DeviceDataHistory var dataHistory = new DeviceDataHistory
{ {

View File

@ -172,12 +172,17 @@ namespace DeviceRepair.DataAccess
DataSet dsDatas = new DataSet("Datas"); DataSet dsDatas = new DataSet("Datas");
try try
{ {
int vEnumType = 0; int vEnumType = -1;
if (ApiParameters.ContainsKey("EnumType") && !string.IsNullOrEmpty(ApiParameters["EnumType"] + "")) if (ApiParameters.ContainsKey("EnumType") && !string.IsNullOrEmpty(ApiParameters["EnumType"] + ""))
{ {
int.TryParse((ApiParameters["EnumType"] + ""), out vEnumType); int.TryParse((ApiParameters["EnumType"] + ""), out vEnumType);
} }
if (vEnumType == -1)
{
throw new Exception("请选择字段类型!");
}
string FieldText = ""; string FieldText = "";
if (ApiParameters.ContainsKey("FieldText")) if (ApiParameters.ContainsKey("FieldText"))
{ {
@ -222,25 +227,33 @@ namespace DeviceRepair.DataAccess
DataSet dsDatas = new DataSet("Datas"); DataSet dsDatas = new DataSet("Datas");
try try
{ {
int vEnumType = 0; int vEnumType = -1;
string EnumType = string.Empty; string EnumType = string.Empty;
if (ApiParameters.ContainsKey("FieldCode") && !string.IsNullOrEmpty(ApiParameters["FieldCode"] + "")) if (ApiParameters.ContainsKey("FieldCode") && !string.IsNullOrEmpty(ApiParameters["FieldCode"] + ""))
{ {
int.TryParse((ApiParameters["FieldCode"] + ""), out vEnumType); int.TryParse((ApiParameters["FieldCode"] + ""), out vEnumType);
} }
if (vEnumType == -1)
{
throw new Exception("请选择字段类型!");
}
switch (vEnumType) switch (vEnumType)
{ {
case 0:
EnumType = "SymptomlDistinction";
break;
case 1: case 1:
EnumType = "MAINTENANCE"; EnumType = "MAINTENANCE";
break; break;
case 2: case 2:
EnumType = "ACCESSORIES";
break;
case 3:
EnumType = "WHEREFAILUREOCCURRED"; EnumType = "WHEREFAILUREOCCURRED";
break; break;
case 3:
EnumType = "ACCESSORIES";
break;
default: default:
EnumType = "SymptomlDistinction";
break; break;
} }

View File

@ -186,6 +186,7 @@ namespace DeviceRepair.DataAccess.SysCommon
{ {
try try
{ {
EnumOperationType OpsType = EnumOperationType.Add;
DateTime CurrentDate = DateTime.Now; DateTime CurrentDate = DateTime.Now;
if (!ApiParameters.ContainsKey("OPERATORAUTOID")) if (!ApiParameters.ContainsKey("OPERATORAUTOID"))
@ -213,18 +214,25 @@ namespace DeviceRepair.DataAccess.SysCommon
&& x.FieldText.Equals(Item.FieldText, StringComparison.CurrentCultureIgnoreCase))) && x.FieldText.Equals(Item.FieldText, StringComparison.CurrentCultureIgnoreCase)))
throw new Exception($"已存在名称为【{Item.FieldText}】的数据,无法重复添加!"); throw new Exception($"已存在名称为【{Item.FieldText}】的数据,无法重复添加!");
if (devMain.Insertable(Item).ExecuteCommand() != 1) Item.AutoID = devMain.Insertable(Item).ExecuteReturnIdentity();
if (Item.AutoID == 0)
throw new Exception($"执行自定义字段新增失败!"); throw new Exception($"执行自定义字段新增失败!");
devMain.CommitTran(); devMain.CommitTran();
} }
else else
{ {
OpsType = EnumOperationType.Change;
/* 修改 */ /* 修改 */
var old = devMain.Queryable<FieldsInfo>().Single(x => x.AutoID == Item.AutoID); var old = devMain.Queryable<FieldsInfo>().Single(x => x.AutoID == Item.AutoID);
if (old == null) if (old == null)
throw new Exception($"传入的修改对象出错,主键编号为【{Item.AutoID}】的数据不存在!"); throw new Exception($"传入的修改对象出错,主键编号为【{Item.AutoID}】的数据不存在!");
if (old.FieldText == Item.FieldText && old.FieldType == Item.FieldType && old.FieldValue == Item.FieldValue)
{
throw new Exception("当前数据无更改!");
}
his = new FieldDataHistory his = new FieldDataHistory
{ {
FieldID = old.AutoID, FieldID = old.AutoID,
@ -268,7 +276,7 @@ namespace DeviceRepair.DataAccess.SysCommon
GUID = Guid.NewGuid(), GUID = Guid.NewGuid(),
FieldAutoID = Item.AutoID, FieldAutoID = Item.AutoID,
FieldHisGuid = Item.GUID, FieldHisGuid = Item.GUID,
}, Item.AutoID == 0 ? EnumOperationType.Add : EnumOperationType.Change, "FieldLog", CurrentDate); }, OpsType, "FieldLog", CurrentDate);
} }
catch catch
{ {

View File

@ -112,6 +112,33 @@ namespace DeviceRepair.DataAccess.Tag
if (tag.TagFormStatus == "C") if (tag.TagFormStatus == "C")
throw new Exception($"TagNo.{Model.AutoID}的数据已被修改!"); throw new Exception($"TagNo.{Model.AutoID}的数据已被修改!");
Dictionary<string, string> dc1 = ObjectToMap(Model);
Dictionary<string, string> dc2 = ObjectToMap(tag);
if (dc1.ContainsKey("CreateBy"))
dc1.Remove("CreateBy");
if (dc1.ContainsKey("CreatOn"))
dc1.Remove("CreatOn");
if (dc2.ContainsKey("CreateBy"))
dc2.Remove("CreateBy");
if (dc2.ContainsKey("CreatOn"))
dc2.Remove("CreatOn");
if (dc2.ContainsKey("CreatorName"))
dc2.Remove("CreatorName");
if (dc2.ContainsKey("ModifyBy"))
dc2.Remove("ModifyBy");
if (dc2.ContainsKey("ModifyOn"))
dc2.Remove("ModifyOn");
if (dc2.ContainsKey("ModifyName"))
dc2.Remove("ModifyName");
if (dc2.ContainsKey("TagFormStatus"))
dc2.Remove("TagFormStatus");
if (CompareDictionaries(dc1, dc2))
{
throw new Exception("当前操作无更改!");
}
operationType = EnumOperationType.Change; operationType = EnumOperationType.Change;
/* 插入历史记录 */ /* 插入历史记录 */

View File

@ -185,7 +185,7 @@ namespace TsSFCDevice.Client.Biz.His
/// <summary> /// <summary>
/// 路径 /// 路径
/// </summary> /// </summary>
[HistoryGridField(Description = "路径", ShowSequence = 22)] [HistoryGridField(Description = "父级分类字段", ShowSequence = 22)]
[JsonProperty("Route", NullValueHandling = NullValueHandling.Ignore)] [JsonProperty("Route", NullValueHandling = NullValueHandling.Ignore)]
public string Route { get; set; } public string Route { get; set; }

View File

@ -24,7 +24,12 @@ namespace TsSFCDevice.Client.Launch.Device
public Page_DriveInfoEdit(string caption = null, View_DriveInfomationModel Model = null) public Page_DriveInfoEdit(string caption = null, View_DriveInfomationModel Model = null)
{ {
InitializeComponent(); InitializeComponent();
if (!string.IsNullOrEmpty(caption))
{
txt_EquipmentName.Enabled = false;
}
Caption = caption ?? "新增"; Caption = caption ?? "新增";
CurrentModel = Model ?? new View_DriveInfomationModel(); CurrentModel = Model ?? new View_DriveInfomationModel();
layoutControlGroup1.ViewInfo.OwnerILayoutControl.AllowCustomizationMenu = false; layoutControlGroup1.ViewInfo.OwnerILayoutControl.AllowCustomizationMenu = false;
} }

View File

@ -10,13 +10,13 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<File Include="bin/DeviceRepair.DataAccess.dll"> <File Include="bin/DeviceRepair.DataAccess.dll">
<publishTime>11/07/2024 15:42:33</publishTime> <publishTime>11/09/2024 21:55:48</publishTime>
</File> </File>
<File Include="bin/DeviceRepair.Models.dll"> <File Include="bin/DeviceRepair.Models.dll">
<publishTime>11/07/2024 15:42:32</publishTime> <publishTime>11/09/2024 13:22:12</publishTime>
</File> </File>
<File Include="bin/DeviceRepair.Utils.dll"> <File Include="bin/DeviceRepair.Utils.dll">
<publishTime>11/07/2024 15:42:32</publishTime> <publishTime>11/09/2024 13:22:13</publishTime>
</File> </File>
<File Include="bin/HttpHelper.dll"> <File Include="bin/HttpHelper.dll">
<publishTime>06/12/2023 14:20:18</publishTime> <publishTime>06/12/2023 14:20:18</publishTime>
@ -76,7 +76,7 @@
<publishTime>05/28/2024 22:39:54</publishTime> <publishTime>05/28/2024 22:39:54</publishTime>
</File> </File>
<File Include="bin/TsSFCDeviceSvc.dll"> <File Include="bin/TsSFCDeviceSvc.dll">
<publishTime>11/07/2024 15:42:36</publishTime> <publishTime>11/09/2024 21:55:50</publishTime>
</File> </File>
<File Include="MainService.asmx"> <File Include="MainService.asmx">
<publishTime>07/21/2024 00:35:30</publishTime> <publishTime>07/21/2024 00:35:30</publishTime>