コード例 #1
0
        protected void PushChanges(string chatMessageKey)
        {
            var sessions = Db.SQL <SavedSession>("SELECT s FROM SavedSession s").Select(x => x.SessionId).ToList();

            Session.ScheduleTask(sessions, (Session s, string sessionId) =>
            {
                StandalonePage master = s.Data as StandalonePage;

                if (master?.CurrentPage is ChatGroupPage)
                {
                    ChatGroupPage page = (ChatGroupPage)master.CurrentPage;

                    if (page.Data.Equals(this.Data))
                    {
                        if (page.ChatMessagePages.Count >= _maxMsgs)
                        {
                            page.ChatMessagePages.RemoveAt(0);
                        }

                        page.ChatMessagePages.Add(Self.GET <Json>("/chatter/partials/chatmessages/" + chatMessageKey));
                        s.CalculatePatchAndPushOnWebSocket();
                    }
                }
            });
        }
コード例 #2
0
ファイル: MainHandlers.cs プロジェクト: minh0583/starCounter
        protected void RegisterPartials()
        {
            Handle.GET("/chatter/partials/chatgroups/{?}", (string chatGroupId) =>
            {
                var page = new ChatGroupPage
                {
                    Html = "/Chatter/ViewModels/ChatGroupPage.html"
                };

                page.RefreshData(chatGroupId);

                return(page);
            });

            Handle.GET("/chatter/partials/chatmessages/{?}", (string objectId) =>
            {
                var message = DbHelper.FromID(DbHelper.Base64DecodeObjectID(objectId)) as ChatMessage;
                var page    = new ChatMessagePage
                {
                    Data        = message,
                    PreviewText = Self.GET("/chatter/partials/chatattachmenttextpreview/" + objectId)
                };
                page.RefreshData(objectId);
                return(page);
            });

            Handle.GET("/chatter/partials/chatgroups", () =>
            {
                var page = new LobbyPage
                {
                    Html = "/Chatter/ViewModels/LobbyPage.html"
                };

                page.RefreshData();

                return(page);
            });

            Handle.GET("/chatter/partials/people/{?}", (string personId) =>
            {
                var page = new PersonPage();

                page.RefreshData(personId);

                return(page);
            });

            Handle.GET("/chatter/partials/systemuser/{?}", (string systemUserId) =>
            {
                var page = new SystemUserPage();
                page.RefreshData(systemUserId);
                return(page);
            });

            #region Draft handlers
            Handle.GET("/chatter/partials/chatdraftannouncements/{?}", (string relationId) =>
            {
                var page = new ChatMessagePage
                {
                    Html = "/Chatter/ViewModels/ChatMessageDraft.html"
                };
                var relation = (Relation)DbHelper.FromID(DbHelper.Base64DecodeObjectID(relationId));
                page.RefreshData(relation.ToWhat.GetObjectID());
                page.SetDraft(relation);
                return(page);
            });
            #endregion

            #region Custom application handlers
            Handle.GET("/chatter/partials/chatmessages-draft/{?}", (string chatMessageId) =>
            {
                var chatMessage = (ChatMessage)DbHelper.FromID(DbHelper.Base64DecodeObjectID(chatMessageId));
                var relation    = new ChatMessageTextRelation
                {
                    Concept = chatMessage
                };

                var page = new ChatAttachmentPage
                {
                    SubPage = Self.GET("/chatter/partials/chatdraftannouncements/" + relation.GetObjectID())
                };
                return(page);
            });
            Handle.GET("/chatter/partials/chatattachmenttextpreview/{?}", (string chatMessageId) =>
            {
                var chatMessage = (ChatMessage)DbHelper.FromID(DbHelper.Base64DecodeObjectID(chatMessageId));
                if (chatMessage.IsDraft)
                {
                    return(new Json());
                }

                var textRelation = Db.SQL <ChatMessageTextRelation>(@"Select m from Simplified.Ring6.ChatMessageTextRelation m Where m.ToWhat = ?", chatMessage).First;
                //if (textRelation?.Content?.Deleted == true) return new Json();
                var chatMessageTextId = textRelation?.Content?.GetObjectID();
                if (chatMessageTextId == null)
                {
                    return(new Json());
                }

                var page = new ChatMessageTextPreviewPage();
                page.RefreshData(chatMessageTextId);
                return(page);
            });
            Handle.GET("/chatter/partials/chatattachments/{?}", (string textRelationId) =>
            {
                var textRelation = DbHelper.FromID(DbHelper.Base64DecodeObjectID(textRelationId)) as ChatMessageTextRelation;
                if (textRelation == null)
                {
                    return(new Json());
                }

                var page = new ChatMessageTextPage();
                page.AddNew(textRelation);
                return(page);
            });
            Handle.GET("/chatter/partials/chatwarnings/{?}", (string textRelationId) =>
            {
                var textRelation = DbHelper.FromID(DbHelper.Base64DecodeObjectID(textRelationId)) as ChatMessageTextRelation;
                if (textRelation == null)
                {
                    return(new Json());
                }

                var page = new ChatMessageTextWarningPage();
                page.RefreshData(textRelation);
                return(page);
            });
            #endregion
        }