public static string GetRichmessage(string richMsgID) { if (string.IsNullOrEmpty(richMsgID)) { return(null); } if (_richMsgCache.Contains(richMsgID)) { object obj = _richMsgCache[richMsgID]; if (NULL.Equals(obj)) { return(null); } return(obj as string); } string richMsg = _richMsgManager.GetRichMessage(richMsgID); CacheItemPolicy policy = new CacheItemPolicy(); policy.AbsoluteExpiration = DateTime.Now.AddHours(24); if (richMsg == null) { _richMsgCache.Set(richMsgID, NULL, policy); } else { _richMsgCache.Set(richMsgID, richMsg, policy); } return(richMsg); }
public void DispatchMail(Message msg) { int defaultMailLength = 0; string richMessage = null; if (string.IsNullOrEmpty(msg.RichMessageID)) { richMessage = _richMsgManager.GetRichMessage(richMessage); } defaultMailLength = MSGorillaMailGenerator.CreateTextMessageMail(msg, richMessage, "somebody").Length; try { //Owner if (msg.Owner != null) { foreach (string owner in msg.Owner) { MailStore.MailStore store = GetMailStore(owner); int boxID = GetMailBoxID(owner, "Inbox/Own"); store.AddMailMessage(msg.ID, defaultMailLength - "somebody".Length + owner.Length, msg.Importance, boxID); } } } catch (Exception e) { Trace.TraceError(e.Message); Trace.TraceError(e.StackTrace); } try { //Mention if (msg.AtUser != null) { foreach (string userid in msg.AtUser) { MailStore.MailStore store = GetMailStore(userid); int boxID = GetMailBoxID(userid, "Inbox/Mention"); store.AddMailMessage(msg.ID, defaultMailLength - "somebody".Length + userid.Length, msg.Importance, boxID); } } } catch (Exception e) { Trace.TraceError(e.Message); Trace.TraceError(e.StackTrace); } try { //Home/Group foreach (string userid in GetGroupFollower(msg.Group, msg.User)) { MailStore.MailStore store = GetMailStore(userid); int boxID = GetMailBoxID(userid, "Inbox/Home/" + GetGroupDisplayName(msg.Group)); store.AddMailMessage(msg.ID, defaultMailLength - "somebody".Length + userid.Length, msg.Importance, boxID); } } catch (Exception e) { Trace.TraceError(e.Message); Trace.TraceError(e.StackTrace); } try { //Topic/Topics if (msg.TopicName != null) { foreach (var topicName in msg.TopicName) { Topic topic = _topicManager.FindTopicByName(topicName, msg.Group); List <FavouriteTopic> whoLikesTopic = null; using (var ctx = new MSGorillaEntities()) { whoLikesTopic = ctx.FavouriteTopics.Where(fa => fa.TopicID == topic.Id).ToList(); } foreach (var fa in whoLikesTopic) { string userid = fa.Userid; MailStore.MailStore store = GetMailStore(userid); int boxID = GetMailBoxID(userid, string.Format("Inbox/Topic/{0}({1})", topic.Name, GetGroupDisplayName(topic.GroupID))); store.AddMailMessage(msg.ID, defaultMailLength - "somebody".Length + userid.Length, msg.Importance, boxID); } } } } catch (Exception e) { Trace.TraceError(e.Message); Trace.TraceError(e.StackTrace); } }
public string GetRichMessage(string richMsgID) { return(_richMsgManager.GetRichMessage(richMsgID)); }