protected void Page_Load(object sender, EventArgs e)
    {
        // Register chat webservice
        AbstractCMSPage cmsPage = Page as AbstractCMSPage;

        if (cmsPage != null)
        {
            ChatScriptHelper.RegisterChatAJAXProxy(cmsPage);
        }

        // Insert script references
        ChatScriptHelper.RegisterChatManager(Page);
        ChatScriptHelper.RegisterChatNotificationManager(Page);
        ScriptHelper.RegisterJQueryTemplates(Page);
        ScriptHelper.RegisterScriptFile(Page, "~/CMSWebParts/Chat/ChatNotification_files/ChatNotification.js");

        btnRemoveAllNotifications.OnClientClick = "ChatManager.RemoveAllNotifications(); return false;";
        btnShow.Text  = ResHelper.GetString("chat.notification.bubble.show");
        btnClose.Text = ResHelper.GetString("chat.notification.bubble.close");

        // Prepare and run startup script
        ScriptHelper.RegisterStartupScript(Page, typeof(string), "ChatNotification_" + ClientID, BuildStartupScript(), true);

        imgChatRoomsPrompt.ImageUrl = GetImageUrl("CMSModules/CMS_Chat/message_information24.png");
    }
コード例 #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Get information about chat room this window has been opened for.
        int roomId = QueryHelper.GetInteger("windowroomid", 0);

        try
        {
            ChatUserHelper.VerifyChatUserHasJoinRoomRights(roomId);
        }
        catch (ChatServiceException)
        {
            DisplayError();

            return;
        }
        ChatRoomInfo room = ChatRoomInfoProvider.GetChatRoomInfo(roomId);

        if (room == null)
        {
            DisplayError();

            return;
        }

        // Script references insertion
        ScriptHelper.RegisterJQuery(Page);
        ChatScriptHelper.RegisterChatManager(Page);
        ChatScriptHelper.RegisterChatNotificationManager(Page);
        ScriptHelper.RegisterScriptFile(Page, "~/CMSScripts/jquery/jquery-resize.js");
        ScriptHelper.RegisterScriptFile(Page, "~/CMSModules/Chat/Pages/Scripts/ChatRoomWindow.js");

        SetWebpartsUp(room.ChatRoomIsSupport);
        lblTitle.Text = HTMLHelper.HTMLEncode(room.ChatRoomDisplayName) + " – " + GetString(room.ChatRoomIsSupport ? "chat.title.support" : "chat.title.privateconversation");
        string json = JsonConvert.SerializeObject(
            new
        {
            roomId,
            pnlChatRoomWindowClientId = pnlChatRoomWindow.ClientID,
            pnlTopClientId            = pnlTop.ClientID,
            pnlBottomClientId         = pnlBottom.ClientID,
            ChatRoomMessagesClientId  = ChatRoomMessagesElem.ClientID,
            btnCloseClientId          = btnCloseWindow.ClientID,
            isSupport = room.ChatRoomIsSupport,
            notificationManagerOptions = new
            {
                eventName   = "newmessage",
                soundFile   = ChatSettingsProvider.EnableSoundSupportChat ? ResolveUrl("~/CMSModules/Chat/CMSPages/Sound/Chat_message.mp3") : String.Empty,
                notifyTitle = GetString("chat.general.newmessages")
            },
            title = lblTitle.Text
        },
            new JsonSerializerSettings {
            StringEscapeHandling = StringEscapeHandling.EscapeHtml
        }
            );
        string startupScript = String.Format("ChatSupportWindow({0});", json);

        ScriptHelper.RegisterStartupScript(Page, typeof(string), "ChatSupportWindow", startupScript, true);
    }
コード例 #3
0
    protected void Page_PreRender(object sender, EventArgs e)
    {
        if (!Visible || !ChatProtectionHelper.IsSupportChatPanelEnabled() || MembershipContext.SignOutPending)
        {
            Visible = false;

            return;
        }

        // Script references insertion
        ChatScriptHelper.RegisterChatSupportManager(Page);
        ChatScriptHelper.RegisterChatNotificationManager(Page);
        ScriptHelper.RegisterScriptFile(Page, "~/CMSModules/Chat/Controls/SupportChatHeader.js");

        // Create and launch startup script.
        ScriptHelper.RegisterStartupScript(Page, typeof(string), "SupportChatHeader_" + ClientID, GetStartupScript(), true);
    }
コード例 #4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        PageTitle title = PageTitle;

        passwordPromptElem.TitleText = ResHelper.GetString("chat.password");

        // Script references insertion
        ScriptHelper.RegisterJQuery(Page);
        ChatScriptHelper.RegisterChatNotificationManager(Page);
        ScriptHelper.RegisterScriptFile(Page, "~/CMSScripts/jquery/jquery-resize.js");
        ScriptHelper.RegisterScriptFile(Page, "~/CMSModules/Chat/CMSPages/Scripts/ChatRoomWindow.js");

        // Get information about chat room this window has been opened for.
        int roomID = QueryHelper.GetInteger("windowroomid", 0);

        try
        {
            ChatUserHelper.VerifyChatUserHasJoinRoomRights(roomID);
        }
        catch (ChatServiceException)
        {
            DisplayError();

            return;
        }

        ChatRoomInfo room = ChatRoomInfoProvider.GetChatRoomInfo(roomID);

        if (room == null)
        {
            DisplayError();

            return;
        }

        string pnlChatRoomWindowCssClass = " ChatPopupWindow";

        // Disable irrelevant controls
        if (room.ChatRoomIsOneToOne)
        {
            ChatMessageSendElem.HideUserPicker();
            pnlChatRoomWindowCssClass += " IsOneToOne";

            // Set appropriate window title
            string pageTitle = ResHelper.GetString(room.ChatRoomIsSupport ? "chat.title.support" : "chat.title.privateconversation");
            Page.Header.Title = title.TitleText = pageTitle;
        }
        else
        {
            Page.Header.Title = title.TitleText = room.ChatRoomDisplayName;
        }

        SetWebpartsUp();

        if (room.ChatRoomIsSupport)
        {
            pnlChatRoomWindowCssClass += " IsSupport";
            if (ChatSettingsProvider.IsSupportMailEnabledAndValid)
            {
                pnlSupportSendMail.Visible     = true;
                hplSupportSendMail.NavigateUrl = ChatSettingsProvider.SupportMailDialogURL + "?roomid=" + roomID;
                hplSupportSendMail.Target      = "_blank";
            }
        }
        pnlChatRoomWindow.CssClass += pnlChatRoomWindowCssClass;
        JavaScriptSerializer sr = new JavaScriptSerializer();

        string json = sr.Serialize(
            new
        {
            roomID   = roomID,
            password = room.HasPassword,
            pnlChatRoomPasswordPrompt       = '#' + pnlChatRoomPasswordPrompt.ClientID,
            txtChatRoomPasswordPromptInput  = '#' + txtChatRoomPasswordPromptInput.ClientID,
            btnChatRoomPasswordPromptSubmit = '#' + btnChatRoomPasswordPromptSubmit.ClientID,
            isOneToOne                 = room.IsWhisperRoom,
            isCustomerSupport          = room.ChatRoomIsSupport,
            hplSupportSendMailClientID = room.ChatRoomIsSupport ? '#' + hplSupportSendMail.ClientID : "",
            pnlPasswordPromptError     = '#' + pnlChatRoomsPromptPasswordError.ClientID,
            pnlChatRoomWindow          = '#' + pnlChatRoomWindow.ClientID,
            ChatRoomMessagesClientID   = ChatRoomMessagesElem.ClientID,
            btnClose = "#" + btnCloseWindow.ClientID,
            notificationManagerOptions = new
            {
                eventName   = "newmessage",
                soundFile   = ChatSettingsProvider.EnableSoundLiveChat ? ResolveUrl("~/CMSModules/Chat/CMSPages/Sound/Chat_message.mp3") : String.Empty,
                notifyTitle = ResHelper.GetString("chat.general.newmessages")
            }
        }
            );


        string startupScript = String.Format("ChatRoomWindow({0});", json);

        ScriptHelper.RegisterStartupScript(Page, typeof(string), "ChatRoomWindow_" + ClientID, startupScript, true);
    }