using System; using System.Collections.Generic; using Library; using LitJson; using System.Linq; using System.Data; using MySystem.PxcModels; namespace MySystem { public class MessageCenterService { public readonly static MessageCenterService Instance = new MessageCenterService(); private MessageCenterService() { } public void Start() { try { dosomething(); } catch (Exception ex) { function.WriteLog(DateTime.Now.ToString() + ":" + ex.ToString(), "消息中心队列异常"); } } public void dosomething() { while (true) { string data = RedisDbconn.Instance.RPop("MsgPersonalQueue"); if (!string.IsNullOrEmpty(data)) { try { WebCMSEntities db = new WebCMSEntities(); MsgPersonal msg = Newtonsoft.Json.JsonConvert.DeserializeObject(data); db.MsgPersonal.Add(msg); db.SaveChanges(); db.Dispose(); } catch (Exception ex) { function.WriteLog(DateTime.Now.ToString() + "\r\n" + ex.ToString(), "消息中心队列异常"); } } } } } }