public virtual void Insert(CommandLog log) { if (log == null) throw new ArgumentNullException("log"); var meta = this.Converter(log); this._logData.Insert(meta); log.Id = meta.Id; }
public virtual void Update(long id, CommandLog log) { if (log == null) throw new ArgumentNullException("log"); var meta = this._logData.GetByID(id); if (meta == null) throw new BaseException("没有这个指令数据"); meta = this.Converter(log, meta); this._logData.Update(meta); }
/// <summary> /// 转换器 /// </summary> /// <param name="log"></param> /// <param name="meta"></param> /// <returns></returns> protected CommandLogMeta Converter(CommandLog log, CommandLogMeta meta = null) { if (meta == null) { meta = new CommandLogMeta(); meta.CreateTime = DateTime.Now; } meta.CreatorId = log.Creator != null ? log.Creator.Id : string.Empty; meta.CreatorJson = JsonConvert.SerializeObject(log.Creator); meta.CreatorType = log.Creator != null ? log.Creator.Type : string.Empty; meta.DeviceId = log.Device != null ? log.Device.Id : string.Empty; meta.DeviceJson = JsonConvert.SerializeObject(log.Device); meta.DeviceType = log.Device != null ? log.Device.Type : string.Empty; meta.Enabled = log.Enabled; meta.Statement = log.Statement; meta.Status = log.Status; meta.UpdateTime = DateTime.Now; return meta; }