/// <summary> /// 创建新的 MD_MessageLog 对象。 /// </summary> /// <param name="id">ID 属性的初始值。</param> public static MD_MessageLog CreateMD_MessageLog(global::System.Guid id) { MD_MessageLog mD_MessageLog = new MD_MessageLog(); mD_MessageLog.ID = id; return(mD_MessageLog); }
/// <summary> /// 更新消息状态,写入发送记录 /// </summary> /// <param name="msg"></param> public static void SaveMessageLog(MessageEntity msg, string sendType, string exception) { using (MSGEntities db = new MSGEntities()) { MD_Message md = db.MD_Message.SingleOrDefault(o => o.ID == msg.ID); if (md == null) { throw new Exception(string.Format("消息{0}不存在。", msg.ID)); } md.IsSended = md.IsSended.Value || msg.IsSended; MD_MessageLog log = db.MD_MessageLog.SingleOrDefault(o => o.MessageID == msg.ID && o.SendType.Equals(sendType)); if (log == null) { log = new MD_MessageLog(); log.ID = Guid.NewGuid(); log.MessageID = msg.ID; log.SendType = sendType; db.MD_MessageLog.AddObject(log); } log.IsSuccess = msg.IsSended; log.Exception = exception; log.SendTime = DateTime.Now; db.SaveChanges(); } }
/// <summary> /// 用于向 MD_MessageLog EntitySet 添加新对象的方法,已弃用。请考虑改用关联的 ObjectSet<T> 属性的 .Add 方法。 /// </summary> public void AddToMD_MessageLog(MD_MessageLog mD_MessageLog) { base.AddObject("MD_MessageLog", mD_MessageLog); }