コード例 #1
0
    void UIFormControl_OnBeforeDataRetrieval(object sender, EventArgs e)
    {
        // Set site id and other data if the room is new
        if ((UIContext.EditedObject == null) || (((ChatRoomInfo)UIContext.EditedObject).ChatRoomID <= 0))
        {
            IDataContainer data = UIFormControl.Data;
            data["ChatRoomCreatedByChatUserID"] = ChatUserHelper.GetChatUserFromCMSUser().ChatUserID;
            data["ChatRoomCreatedWhen"]         = DateTime.Now; // GETDATE() will be used on SQL Server side
            data["ChatRoomSiteID"] = SiteID;

            Guid guid = Guid.NewGuid();
            data["ChatRoomGUID"] = guid;

            EditingFormControl passwordEditingControl = UIFormControl.FieldEditingControls["chatroompassword"];
            string             password = passwordEditingControl.Value.ToString();
            passwordEditingControl.Value = ChatRoomHelper.GetRoomPasswordHash(password, guid);
        }
        else
        {
            ChatRoomInfo       room           = UIContext.EditedObject as ChatRoomInfo;
            EditingFormControl enabledControl = UIFormControl.FieldEditingControls["chatroomenabled"];
            bool enabled = (bool)enabledControl.Value;
            if (room.ChatRoomEnabled != enabled)
            {
                if (enabled)
                {
                    ChatRoomHelper.EnableChatRoom(room.ChatRoomID);
                }
                else
                {
                    ChatRoomHelper.DisableChatRoom(room.ChatRoomID);
                }
            }
        }
    }
コード例 #2
0
ファイル: List.ascx.cs プロジェクト: itymofieiev/Kentico9
    void Grid_OnAction(string actionName, object actionArgument)
    {
        int chatRoomID = ValidationHelper.GetInteger(actionArgument, 0);

        switch (actionName)
        {
        case "edit":
            SelectedItemID = chatRoomID;

            // Parent page will handle editing
            RaiseOnEdit();

            break;

        case "safedelete":
        case "approve":
            ChatRoomInfo room = ChatRoomInfoProvider.GetChatRoomInfo(chatRoomID);

            ((CMSChatPage)Page).CheckModifyPermission(room.ChatRoomSiteID);

            if (actionName == "safedelete")
            {
                ChatRoomInfoProvider.SafeDelete(chatRoomID);
            }
            else
            {
                if (room.ChatRoomEnabled)
                {
                    ChatRoomHelper.DisableChatRoom(chatRoomID);
                }
                else
                {
                    ChatRoomHelper.EnableChatRoom(chatRoomID);
                }
            }

            break;
        }
    }