コード例 #1
0
ファイル: TopicController.cs プロジェクト: fudanyi/MSGorilla
        public ActionResult Index(string topic, string group = null)
        {
            string      myid = this.Session["userid"].ToString();
            UserProfile me   = _accManager.FindUser(myid);

            ViewBag.Myid = me.Userid;
            ViewBag.Me   = me;

            ViewBag.FeedCategory = "topicline";

            Topic t = null;

            if (string.IsNullOrEmpty(group))
            {
                t = _topicManager.FindTopicByName(topic, MembershipHelper.JoinedGroup(myid));
            }
            else
            {
                t = _topicManager.FindTopicByName(topic, group);
            }
            if (t == null)
            {
                ViewBag.TopicId       = -1;
                ViewBag.Topic         = "";
                ViewBag.FeedId        = "";
                ViewBag.IsLiked       = false;
                ViewBag.Group         = "";
                ViewBag.GroupName     = "";
                ViewBag.PerfChartName = "";
            }
            else
            {
                var g = _groupManag.GetGroupByID(t.GroupID);
                ViewBag.TopicId       = t.Id;
                ViewBag.Topic         = t.Name;
                ViewBag.FeedId        = t.Name;
                ViewBag.IsLiked       = _topicManager.IsFavouriteTopic(me.Userid, t.Id) ? 1 : 0;
                ViewBag.Group         = group;
                ViewBag.GroupName     = g.DisplayName;
                ViewBag.PerfChartName = group + "_" + t.Name;
                //ViewBag.PerfChartName = "perf_chart_test";
            }

            return(View());
        }
コード例 #2
0
        public DisplayMessagePagination TopicLine(string topic, int count = 25, [FromUri] string[] group = null, string token = null)
        {
            string me = whoami();
            var    t  = _topicManager.FindTopicByName(topic, MembershipHelper.CheckJoinedGroup(whoami(), group));

            if (t == null)
            {
                return(null);
            }

            TableContinuationToken tok = Utils.String2Token(token);

            if (tok == null)
            {
                _topicManager.clearUnreadMsgCountOfFavouriteTopic(me, t.Id);
            }
            return(CreateDisplayMsgPag(_messageManager.TopicLine(t.Id.ToString(), count, tok)));
        }
コード例 #3
0
        public ActionResult AddFavouriteTopic(string topic, string group = null)
        {
            string me = whoami();
            Topic  t  = null;

            if (string.IsNullOrEmpty(group))
            {
                t = _topicManager.FindTopicByName(topic, MembershipHelper.JoinedGroup(me));
            }
            else
            {
                MembershipHelper.CheckMembership(group, me);
                t = _topicManager.FindTopicByName(topic, group);
            }

            if (t == null)
            {
                throw new TopicNotFoundException();
            }
            _topicManager.AddFavouriteTopic(whoami(), t.Id);
            return(new ActionResult());
        }
コード例 #4
0
        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);
            }
        }