/// <summary> /// 保存实体修改记录 /// </summary> /// <param name="newEntity">修改前的实体对象</param> /// <param name="oldEntity">修改后的实体对象</param> /// <param name="tableName">表名称</param> public void UpdateEntityLog(BaseUserLogOnEntity newEntity, BaseUserLogOnEntity oldEntity, string tableName = null) { if (string.IsNullOrEmpty(tableName)) { tableName = BaseUserEntity.TableName + "_LOG"; } BaseModifyRecordManager manager = new BaseModifyRecordManager(this.UserInfo, tableName); foreach (var property in typeof(BaseUserLogOnEntity).GetProperties()) { var oldValue = Convert.ToString(property.GetValue(oldEntity, null)); var newValue = Convert.ToString(property.GetValue(newEntity, null)); var fieldDescription = property.GetCustomAttributes(typeof(FieldDescription), false).FirstOrDefault() as FieldDescription; //不记录创建人、修改人、没有修改的记录 if (!fieldDescription.NeedLog || oldValue == newValue) { continue; } var record = new BaseModifyRecordEntity(); record.ColumnCode = property.Name.ToUpper(); record.ColumnDescription = fieldDescription.Text; record.NewValue = newValue; record.OldValue = oldValue; record.TableCode = this.CurrentTableName.ToUpper(); record.TableDescription = FieldExtensions.ToDescription(typeof(BaseUserLogOnEntity), "TableName"); record.RecordKey = oldEntity.Id.ToString(); record.IPAddress = Utilities.GetIPAddress(true); manager.Add(record, true, false); } }
public void UpdateModifyRecord(HRCheckInEntity oldShow, HRCheckInEntity newShow, string tableName = null) { if (string.IsNullOrEmpty(tableName)) { tableName = this.CurrentTableName + "_LOG"; } BaseModifyRecordManager manager = new BaseModifyRecordManager(DbHelper, this.UserInfo, tableName); foreach (var property in typeof(HRCheckInEntity).GetProperties()) { var fieldDescription = property.GetCustomAttributes(typeof(FieldDescription), false).FirstOrDefault() as FieldDescription; var oldValue = Convert.ToString(property.GetValue(oldShow, null)); var newValue = Convert.ToString(property.GetValue(newShow, null)); if (!fieldDescription.NeedLog || oldValue == newValue) { continue; } var record = new BaseModifyRecordEntity(); record.ColumnCode = property.Name.ToUpper(); record.ColumnDescription = fieldDescription.Text; record.NewValue = newValue; record.OldValue = oldValue; record.TableCode = HRCheckInEntity.TableName.ToUpper(); record.TableDescription = FieldExtensions.ToDescription(typeof(HRCheckInEntity), "TableName"); record.RecordKey = oldShow.Id.ToString(); record.IPAddress = Utilities.GetIPAddress(true); record.CreateBy = UserInfo.RealName; record.CreateOn = DateTime.Now; BaseSequenceManager sequenceManager = new BaseSequenceManager(UserInfo); // 序列产生的ID 添加到TAB_EMPLOYEE表 record.Id = int.Parse(sequenceManager.GetOracleSequence("ZTOA")); manager.Add(record, false, false); } }