public void AddOrUpdateWarning(string name, string tag, string message, ISystemMessageData data) { AddOrUpdate(name, tag, message, data, MessageStatus.Warning); }
public void AddOrUpdateError(string name, string tag, string message, ISystemMessageData data) { AddOrUpdate(name, tag, message, data, MessageStatus.Error); }
public void AddOrUpdate(string name, string tag, string message, ISystemMessageData data, MessageStatus status) { using (var db = _dbFactory.GetRWDb()) { var query = db.SystemMessages.GetAll().Where(m => m.Name == name); if (String.IsNullOrEmpty(tag)) { query = query.Where(m => String.IsNullOrEmpty(tag)); } else { query = query.Where(m => m.Tag == tag); } var existMissingOrder = query.FirstOrDefault(); if (existMissingOrder == null) { existMissingOrder = new Core.Entities.SystemMessage() { Name = name, Tag = tag, CreateDate = _time.GetAppNowTime() }; db.SystemMessages.Add(existMissingOrder); } existMissingOrder.UpdateDate = _time.GetAppNowTime(); existMissingOrder.Message = message; existMissingOrder.Data = data != null?JsonHelper.Serialize(data) : null; existMissingOrder.Status = (int)status; db.Commit(); } }