/// <summary> /// 获取明细 /// </summary> /// <param name="id"></param> /// <returns></returns> public DataTable GetDetailList(int id) { SysLogDetailsDal detailDal = new SysLogDetailsDal(); List <SysLogDetails> list = detailDal.GetList(t => t.SyslogId == id).Cast <SysLogDetails>().ToList(); return(ConvertHelper.ToDataTable(list)); }
/// <summary> /// 添加 /// </summary> /// <param name="ctx"></param> /// <param name="model"></param> /// <param name="entry"></param> /// <returns></returns> internal bool Add(BPMSEntities ctx, SysLog model, DbEntityEntry entry) { /// 资源 /// http://www.cnblogs.com/oppoic/p/ef_dbpropertyvalues_toobject_clone_setvalues_changetracker_entries.html List <SysLogDetails> logDetailList = new List <SysLogDetails>(); bool rlt = true; model.ID = GetNewID(); var location = IPHelper.GetLocation(); model.IPAddress = location.GetIPAddress.ToString(); model.IPAddressName = location.ToString(); model.CreateDate = DateTime.Now; model.CreateUserId = model.CreateUserId; model.CreateUserName = model.CreateUserName; if (!Insert(ctx, model)) { rlt = false; } if (rlt == true && entry != null) { IEnumerable <string> propertyNames = null; if (model.OperationType == EOperationType.新增.GetHashCode() || model.OperationType == EOperationType.除.GetHashCode()) { propertyNames = entry.CurrentValues.PropertyNames; } else if (model.OperationType == EOperationType.修改.GetHashCode()) { propertyNames = entry.CurrentValues.PropertyNames.Where(t => entry.Property(t).IsModified); } foreach (var propertyName in propertyNames) { SysLogDetails logDetail = new SysLogDetails(); logDetail.ID = GetNewID("SysLogDetails"); logDetail.SyslogId = model.ID; logDetail.FieldName = propertyName; logDetail.FieldText = DatabasePDMHelper.GetColumnName(model.TableName, propertyName); logDetail.NewValue = entry.Property(propertyName).CurrentValue.ToString(); logDetail.OldValue = entry.Property(propertyName).OriginalValue.ToString(); logDetailList.Add(logDetail); } SysLogDetailsDal detailDal = new SysLogDetailsDal(); if (!detailDal.Insert(ctx, logDetailList)) { rlt = false; } } return(rlt); }