private FetchDataItem CreateMailBodyDataItem(MailMessage mail) { FetchDataItem item = new FetchDataItem(FetchDataItemType.Body); string mailEnvelope = MSGorillaMailGenerator.CreateTextMessageMail(mail.MSGorillaMessageID, this.User); StringBuilder sb = new StringBuilder("{"); sb.Append(mailEnvelope.Length); sb.Append("}\r\n"); sb.Append(mailEnvelope); //sb.Append("\r\n"); item.Text = sb.ToString(); //Console.WriteLine("================={0}=======================", item.Text.Length); return(item); }
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); } }