Elsinore

User Forum

www.screenconnect.com
Welcome Guest Search | Active Topics | Log In | Register

Tag as favorite
Email alert any time host joins a session?
bigdessert
#1 Posted : Sunday, March 13, 2011 4:33:03 AM
Rank: Advanced Member
Joined: 9/14/2010
Posts: 458
Location: Minnesota
Would this be an easy code addition?
Alternatively just monitor unattended session joining?
Could you at least point me in the direction of testing if a host joins the session and I will try to do the rest with email?
Jake Morgan
#2 Posted : Tuesday, March 15, 2011 4:19:39 PM
Rank: Administration
Joined: 4/9/2010
Posts: 858
The most effective place to do this would be tapping into the Session Manager service, but we don't really provide a method for this at the current time. You can however modify the host page to do send the email when a join button is clicked. I'll see if I can put together some code in a little while.
Jake Morgan
#3 Posted : Monday, March 21, 2011 7:25:53 PM
Rank: Administration
Joined: 4/9/2010
Posts: 858
Add a page method in the Host.aspx.cs file similar to the one in this post called SendNotificationEmail:
http://forum.screenconne...for-Guests.aspx#post620

Then in your Host.aspx file, change the onSessionClick function from this:

Code:
        function onSessionClick(event) {
            var dataCommand = getEventDataCommand(event);

            if (dataCommand.commandName == "Join")
                launchers[0].launch(dataCommand.dataItem.ClientLaunchParameters);
            else if (dataCommand.commandName == "End")
                PageMethods.EndSession(dataCommand.dataItem.ClientLaunchParameters.SessionID, onEndSessionSuccess);
        }


To this:

Code:
        function onSessionClick(event) {
            var dataCommand = getEventDataCommand(event);

            if (dataCommand.commandName == "Join") {
                PageMethods.SendNotificationEmail();
                launchers[0].launch(dataCommand.dataItem.ClientLaunchParameters);
            } else if (dataCommand.commandName == "End")
                PageMethods.EndSession(dataCommand.dataItem.ClientLaunchParameters.SessionID, onEndSessionSuccess);
        }


And that'll send an email when the Join button is clicked. You'll probably want to customize the subject, body, etc of the email.
bigdessert
#4 Posted : Monday, March 21, 2011 10:55:21 PM
Rank: Advanced Member
Joined: 9/14/2010
Posts: 458
Location: Minnesota
Thanks for the help, the page method goes in fine, but when adding the pagemethod to the onSessionClick function the page loads with my javascript spinners just keep spinning and never populate the sessions. Using 2.0 latest stable.
Jake Morgan
#5 Posted : Tuesday, March 22, 2011 3:42:46 PM
Rank: Administration
Joined: 4/9/2010
Posts: 858
I just tried and it worked. Did you put the SendNotificationEmail in Host.aspx.cs and not Guest.aspx.cs? Have you looked for javascript errors using Firefox's error console or an equivalent?
bigdessert
#6 Posted : Tuesday, March 22, 2011 5:30:05 PM
Rank: Advanced Member
Joined: 9/14/2010
Posts: 458
Location: Minnesota
Here is my host.aspx.cs also no errors in firebug console.

Code:
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.Services;
using System.Reflection;
using System.Net.Mail;
using System.Linq;
using System.Security.Cryptography;

using WebResources = global::Resources.Default;

namespace Elsinore.ScreenConnect
{
    public partial class HostPage : ThemeablePage
    {
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            WebExtensions.RegisterEnum<ProcessType>(this.ClientScript);
            WebExtensions.RegisterEnumStrings<ProcessType>(this.ClientScript, Resources.Default.ResourceManager, "ProcessType.{0}");
            WebExtensions.RegisterEnum<SessionEventType>(this.ClientScript);
            WebExtensions.RegisterEnumStrings<SessionEventType>(this.ClientScript, Resources.Default.ResourceManager, "SessionStatus.{0}");
            WebExtensions.RegisterEnum<InvitationType>(this.ClientScript);
            WebExtensions.RegisterEnumStrings<InvitationType>(this.ClientScript, Resources.Default.ResourceManager, "InvitationType.{0}");
        }

        [WebMethod]
        public static object GetActiveSessionInfos()
        {
            var administrationRole = WebExtensions.GetLocationRole(ServerConstants.AdministrationPageName);
            var relayUri = ServerExtensions.GetRelayUri(ConfigurationManager.AppSettings, HttpContext.Current.Request.Url, true, false);
            var currentUser = HttpContext.Current.User;
            var isAdministrator = currentUser.IsInRole(administrationRole);

            using (var sessionManager = ServerExtensions.SessionManagerChannelFactory.CreateChannel())
            {
                return sessionManager.GetSessions().Select(s => new
                {
                    IsMySession = currentUser.Identity.Name == s.Host,
                    Host = s.Host,
                    InvitationType = s.InvitationType,
                    MostRelevantHostEventType = s.GetMostRelevantEventType(ProcessType.Host),
                    MostRelevantGuestEventType = s.GetMostRelevantEventType(ProcessType.Guest),
                    ClientLaunchParameters = new ClientLaunchParameters()
                    {
                        ProcessType = ProcessType.Host,
                        Host = relayUri.Host,
                        Port = relayUri.Port,
                        SessionID = s.SessionID,
                        EncryptionKey = s.EncryptionKey,
                        ApplicationTitle = Resources.Default.Client_ApplicationTitle,
                        SessionTitle = s.Tag,
                        CanEndSession = (s.InvitationType != InvitationType.Self && (isAdministrator || currentUser.Identity.Name == s.Host))
                    }
                });
            }
        }

        [WebMethod]
        public static void EndSession(Guid sessionID)
        {
            using (var sessionManager = ServerExtensions.SessionManagerChannelFactory.CreateChannel())
                sessionManager.AddSessionEvent(sessionID, ProcessType.Host, SessionEventType.EndedSession, null);
        }

        [WebMethod]
        public static Guid CreateSession(InvitationType invitationType, string tag)
        {
            using (var sessionManager = ServerExtensions.SessionManagerChannelFactory.CreateChannel())
            {
                var session = sessionManager.CreateSession(invitationType, tag, HttpContext.Current.User.Identity.Name);

                if (invitationType == InvitationType.Email)
                {
                    try
                    {
                        var webServerUri = ServerExtensions.GetWebServerUri(ConfigurationManager.AppSettings, HttpContext.Current.Request.Url, true, false);
                        var sessionGuestUrl = WebExtensions.GetUrl(webServerUri.Uri.ToString(), ServerConstants.SessionIDParameterName, session.SessionID);

                        var mailMessage = new MailMessage();
                        mailMessage.To.Add(session.Tag);
                        mailMessage.Subject = string.Format(WebResources.CreateSessionPanel_EmailSubject, session.Host, sessionGuestUrl);
                        mailMessage.Body = string.Format(WebResources.CreateSessionPanel_EmailBody, session.Host, sessionGuestUrl);

                        var client = new SmtpClient();
                        client.Send(mailMessage);
                    }
                    catch
                    {
                        sessionManager.AddSessionEvent(session.SessionID, ProcessType.Host, SessionEventType.EndedSession, null);
                        throw;
                    }
                }

                return session.SessionID;
            }
        }

        [WebMethod]
        public static string GetGuestUrl()
        {
            return ServerExtensions.GetWebServerUri(ConfigurationManager.AppSettings, HttpContext.Current.Request.Url, true, false).Uri.ToString();
        }

        [WebMethod]
        public static string GetInstallerUrl(string sessionTitle)
        {
            var asymmetricKeyString = ConfigurationManager.AppSettings[ServerConstants.AsymmetricKeyKey].AssertNonNull();
            var asymmetricKey = Convert.FromBase64String(asymmetricKeyString);
            var rsa = new RSACryptoServiceProvider();
            rsa.ImportCspBlob(asymmetricKey);
            var asymmetricPublicKey = rsa.ExportCspBlob(false); // very critical this be false

            var relayUri = ServerExtensions.GetRelayUri(ConfigurationManager.AppSettings, HttpContext.Current.Request.Url, true, false);

            var clientLaunchParameters = new ClientLaunchParameters()
            {
                ProcessType = ProcessType.Guest,
                Host = relayUri.Host,
                Port = relayUri.Port,
                EncryptionKey = asymmetricPublicKey,
                ApplicationTitle = Resources.Default.Client_ApplicationTitle,
                SessionTitle = sessionTitle,
                CanEndSession = false
            };

            var serviceName = Extensions.GetFullyQualifiedServiceName(Constants.GuestServiceName, clientLaunchParameters);
            var arguments = "\"" + ClientLaunchParameters.ToQueryString(clientLaunchParameters) + "\"";

            var statements = new TransformInstallerHandler.TransformStatement[] {
                new TransformInstallerHandler.TransformStatement("Property", "ProductName", "Value", serviceName),
                new TransformInstallerHandler.TransformStatement("ServiceInstall", "ServiceInstall", "Arguments", arguments),
            };

            return TransformInstallerHandler.GetUrl("Bin/Elsinore.ScreenConnect.GuestClient.msi", statements);
        }
        [WebMethod]
            public static void SendNotificationEmail()
            {
            var mailMessage = new System.Net.Mail.MailMessage();
            mailMessage.To.Add("tim@datacommus.com");
            mailMessage.Subject = "DCBLUE Session Activity";
            mailMessage.Body = "Someone has clicked a join button.";

            var client = new SmtpClient();
            client.Send(mailMessage);
            }
    }
}




and my host.aspx

Code:
<%@ Page Language="C#" CodeFile="Host.aspx.cs" Inherits="Elsinore.ScreenConnect.HostPage" MasterPageFile="~/Default.master" %>

<%@ Import Namespace="DR=Resources.Default" %>
<asp:Content runat="server" ContentPlaceHolderID="Main">
    <div class="HostPanel">
        <input type="button" value="<%= DR.HostPanel_HostInvitationButtonText %>" onclick="showCreateSessionDialog();" />
        <h2 runat="server" innerhtml="<%$ Resources:Default, HostPanel.HostInvitationHeader %>" />
        <div>
            <table class="DataTable" cellspacing="0">
                <thead>
                    <tr>
                        <th>
                            &nbsp;
                        </th>
                        <th runat="server" innerhtml="<%$ Resources:Default, HostSessionTable.HostHeader %>" />
                        <th runat="server" innerhtml="<%$ Resources:Default, HostSessionTable.InvitationHeader %>" />
                        <th runat="server" innerhtml="<%$ Resources:Default, HostSessionTable.StatusHeader %>" />
                    </tr>
                </thead>
                <tbody id="hostInvitationSessionsTableBody" onclick="onSessionClick(event);">
                    <tr class="EmptyRow">
                        <td colspan="4">
                            <img src="Images/LargeActivityIndicator.gif" />
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
        <input type="button" value="<%= DR.HostPanel_GuestInvitationButtonText %>" onclick="showBuildInstallerDialog();" />
        <h2 runat="server" innerhtml="<%$ Resources:Default, HostPanel.GuestInvitationHeader %>" />
        <div>
            <table class="DataTable" cellspacing="0">
                <thead>
                    <tr>
                        <th>
                            &nbsp;
                        </th>
                        <th runat="server" innerhtml="<%$ Resources:Default, HostSessionTable.LabelHeader %>" />
                        <th runat="server" innerhtml="<%$ Resources:Default, HostSessionTable.StatusHeader %>" />
                    </tr>
                </thead>
                <tbody id="guestInvitationSessionsTableBody" onclick="onSessionClick(event);">
                    <tr class="EmptyRow">
                        <td colspan="3">
                            <img src="Images/LargeActivityIndicator.gif" />
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
    </div>
</asp:Content>
<asp:Content runat="server" ContentPlaceHolderID="DeclareScript">
    <script type="text/javascript">

        var launchers;

        function buildHostInvitationRow(row) {
            row.className = (row.dataItem.IsMySession ? "MySession" : "OtherSession");

            var invitation = String.format("{0}: {1}", InvitationTypeStrings[row.dataItem.InvitationType], row.dataItem.ClientLaunchParameters.SessionTitle);

            var buttonCell = this.addCell(row, null, "white-space: nowrap;");
            var hostCell = this.addCell(row, null, null, row.dataItem.Host);
            var invitationCell = this.addCell(row, null, null, invitation);
            var statusCell = this.addCell(row);

            this.addElement(buttonCell, "INPUT", { type: "button", commandName: "Join", value: <%= DR.HostSessionTable_JoinButtonText.ToClientString() %> });
            this.addNonBreakingSpace(buttonCell);
            this.addElement(buttonCell, "INPUT", { type: "button", commandName: "End", disabled: !row.dataItem.ClientLaunchParameters.CanEndSession, value: <%= DR.HostSessionTable_EndButtonText.ToClientString() %> });

            this.addStatusPanel(statusCell, row.dataItem);
        }

        function buildGuestInvitationRow(row) {
            var buttonCell = this.addCell(row);
            var labelCell = this.addCell(row, null, null, row.dataItem.ClientLaunchParameters.SessionTitle);
            var statusCell = this.addCell(row);

            this.addElement(buttonCell, "INPUT", { type: "button", commandName: "Join", value: <%= DR.HostSessionTable_JoinButtonText.ToClientString() %> });
            this.addStatusPanel(statusCell, row.dataItem);
        }

        function buildEmptyHostInvitationRow(row) {
            row.className = "EmptyRow";
            this.addCell(row, { colSpan: 4, innerHTML: <%= DR.HostPanel_HostInvitationEmptyMessage.ToClientString() %> });
        }

        function buildEmptyGuestInvitationRow(row) {
            row.className = "EmptyRow";
            this.addCell(row, { colSpan: 3, innerHTML: <%= DR.HostPanel_GuestInvitationEmptyMessage.ToClientString() %> });
        }

        function addStatusPanel(container, dataItem) {
            var statusPanel = this.addElement(container, "DIV", null, "position: relative; top: 0px; width: 300px; height: 40px; margin: 0px;");

            var backgroundImageSrc = (dataItem.MostRelevantHostEventType == SessionEventType.Connected && dataItem.MostRelevantGuestEventType == SessionEventType.Connected ? "Images/FlowLeft.gif" : null);
            this.connectNodes(statusPanel, 7, 75, 75, dataItem.MostRelevantHostEventType, backgroundImageSrc);
            this.connectNodes(statusPanel, 7, 150, 75, dataItem.MostRelevantGuestEventType, backgroundImageSrc);

            this.addEndPointPanel(statusPanel, 0, 150, ProcessTypeStrings[ProcessType.Host], dataItem.MostRelevantHostEventType);
            this.addEndPointPanel(statusPanel, 150, 150, ProcessTypeStrings[ProcessType.Guest], dataItem.MostRelevantGuestEventType);

            this.addNodePanel(statusPanel, 100, 100, "Images/RelayEnabled.png", null, null);
        }

        function addEndPointPanel(statusPanel, left, width, processTypeString, sessionEventType) {
            var imageSrc = (sessionEventType == SessionEventType.Connected || sessionEventType == SessionEventType.SelectedSession ? "Images/EndPointEnabled.png" : "Images/EndPointDisabled.png");
            this.addNodePanel(statusPanel, left, width, imageSrc, processTypeString, SessionEventTypeStrings[sessionEventType]);
        }

        function addNodePanel(statusPanel, left, width, imageSrc, title, status) {
            var nodePanel = this.addElement(statusPanel, "DIV");
            nodePanel.style.position = "absolute";
            nodePanel.style.left = left + "px";
            nodePanel.style.width = width + "px";
            nodePanel.style.textAlign = "center";

            this.addElement(nodePanel, "IMG", { src: imageSrc });

            if (title) {
                this.addElement(nodePanel, "BR");
                this.addTextNode(nodePanel, title);

                if (status) {
                    this.addTextNode(nodePanel, ": ");
                    this.addTextNode(nodePanel,status);
                }
            }
        }

        function connectNodes(statusPanel, top, left, width, sessionEventType, backgroundImageSrc) {
            var pipePanel = this.addElement(statusPanel, "DIV", null, "position: absolute; height: 6px; border: 1px solid #bbb;");
            pipePanel.style.top = top + "px";
            pipePanel.style.left = left + "px";
            pipePanel.style.width = width + "px";
            pipePanel.style.backgroundColor = (sessionEventType == SessionEventType.Connected ? "LightGreen" : "LightGrey");

            if (backgroundImageSrc)
                pipePanel.style.backgroundImage = "url(" + backgroundImageSrc + ")";
        }

        function poll() {
            PageMethods.GetActiveSessionInfos(window.onGetActiveSessionInfosSuccess);
            window.setTimeout("poll();", <%= ServerConstants.WebPollInterval.ToClientString() %>);
        }

        function onGetActiveSessionInfosSuccess(asis, autoJoinSessionID) {
            rebuildTable("hostInvitationSessionsTableBody", filterArray(asis, function (asi) { return asi.InvitationType != InvitationType.Self; }), buildHostInvitationRow, buildEmptyHostInvitationRow);
            rebuildTable("guestInvitationSessionsTableBody", filterArray(asis, function (asi) { return asi.InvitationType == InvitationType.Self; }), buildGuestInvitationRow, buildEmptyGuestInvitationRow);

            if (autoJoinSessionID) {
                var asi = this.findArrayElement(asis, function (asi) { return asi.ClientLaunchParameters.SessionID == autoJoinSessionID; });

                if (asi)
                    window.launchers[0].launch(asi.ClientLaunchParameters);
            }
        }

        function onEndSessionSuccess() {
            PageMethods.GetActiveSessionInfos(window.onGetActiveSessionInfosSuccess);
        }

        function onCreateSessionSuccess(sessionID, autoJoin) {
            PageMethods.GetActiveSessionInfos(window.onGetActiveSessionInfosSuccess, null, autoJoin ? sessionID : null);
        }

        function addLabeledRadioButton(container, labelText, groupName, value, checked) {
            var id = groupName + value;
            var panel = this.addElement(container, "DIV", null, "margin: 0px;");
            this.addElement(panel, "INPUT", { id: id, type: "radio", value: value, name: groupName, checked: checked });
            this.addNonBreakingSpace(panel);
            this.addElement(panel, "LABEL", { htmlFor: id }, null, labelText);
            return panel;
        }

        function showCreateSessionDialog() {
            var settings = this.loadSettings();

            var invitationTypeInfos = new Object();
            invitationTypeInfos[InvitationType.Listed] = [ "Images/ListedSession.png", <%= DR.CreateSessionPanel_ListedHeading.ToClientString() %>, <%= DR.CreateSessionPanel_ListedDescription.ToClientString() %>, <%= DR.CreateSessionPanel_ListedStatement.ToClientString() %>, <%= DR.CreateSessionPanel_ListedTagLabel.ToClientString() %>, <%= DR.CreateSessionPanel_ListedInstructions.ToClientString() %>, <%= DR.CreateSessionPanel_ListedTagDefault.ToClientString() %>, true, false, 25, <%= DR.CreateSessionPanel_ListedVisible %> ];
            invitationTypeInfos[InvitationType.Code] = [ "Images/CodeSession.png", <%= DR.CreateSessionPanel_CodeHeading.ToClientString() %>, <%= DR.CreateSessionPanel_CodeDescription.ToClientString() %>, <%= DR.CreateSessionPanel_CodeStatement.ToClientString() %>, <%= DR.CreateSessionPanel_CodeTagLabel.ToClientString() %>, <%= DR.CreateSessionPanel_CodeInstructions.ToClientString() %>, <%= DR.CreateSessionPanel_CodeTagDefault.ToClientString() %>, true, true, 10, <%= DR.CreateSessionPanel_CodeVisible %> ];
            invitationTypeInfos[InvitationType.Email] = [ "Images/EmailSession.png", <%= DR.CreateSessionPanel_EmailHeading.ToClientString() %>, <%= DR.CreateSessionPanel_EmailDescription.ToClientString() %>, <%= DR.CreateSessionPanel_EmailStatement.ToClientString() %>, <%= DR.CreateSessionPanel_EmailTagLabel.ToClientString() %>, <%= DR.CreateSessionPanel_EmailInstructions.ToClientString() %>, <%= DR.CreateSessionPanel_EmailTagDefault.ToClientString() %>, false, false, 25, <%= DR.CreateSessionPanel_EmailVisible %> ];

            var outerPanel = this.createElement("DIV", null, "padding: 15px;");
            var panel1 = this.addElement(outerPanel, "DIV", null, "margin: 0px;");
            var panel2 = this.addElement(outerPanel, "DIV", null, "margin: 0px;");

            Sys.UI.DomElement.setVisible(panel1, settings.invitationType == null);            
            Sys.UI.DomElement.setVisible(panel2, settings.invitationType != null);            

            this.addElement(panel1, "H2", null, null, <%= DR.CreateSessionPanel_ChooseTypeMessage.ToClientString() %>);

            for (var i in invitationTypeInfos) {
                if (invitationTypeInfos[i][10]) {
                    var typePanel = this.addElement(panel1, "DIV", null, "height: 90px; margin: 0px;");
                    var img = this.addElement(typePanel, "IMG", { src: invitationTypeInfos[i][0] }, "float: left; clear: left; width: 72px; height: 72px;");
                    var descriptionPanel = this.addElement(typePanel, "DIV", null, "float: left; margin: 0px 15px; width: 240px;");
                    this.addElement(typePanel, "INPUT", { type: "button", commandName: "Select", dataItem: i, value: ">" }, "float: left; font-size: 30pt; width: 60px; height: 60px;");

                    this.addElement(descriptionPanel, "H3", null, "margin: 0px;", invitationTypeInfos[i][1]);
                    this.addElement(descriptionPanel, "P", null, "margin-top: 5px;", invitationTypeInfos[i][2]);            
                }
            }

            var typeRememberPanel = this.addElement(panel1, "DIV", null, "clear: both; margin: 0px 0px 0px 40px;");
            this.addLabeledRadioButton(typeRememberPanel, <%= DR.CreateSessionPanel_TypeRememberAskMessage.ToClientString() %>, "TypeRemember", 0, settings.invitationType == null);
            this.addLabeledRadioButton(typeRememberPanel, <%= DR.CreateSessionPanel_TypeRememberStoreMessage.ToClientString() %>, "TypeRemember", 1);
            var previousTypeLabeledButton = this.addLabeledRadioButton(typeRememberPanel, <%= DR.CreateSessionPanel_TypeRememberPreviousMessage.ToClientString() %>, "TypeRemember", 2, settings.invitationType != null);
            Sys.UI.DomElement.setVisible(previousTypeLabeledButton, settings.invitationType != null);            

            var panel2Image = this.addElement(panel2, "IMG", null, "float: left; width: 72px; height: 72px;");
            var panel2Content = this.addElement(panel2, "DIV", null, "float: left; margin-left: 15px; width: 309px;");

            var mainHeading = this.addElement(panel2Content, "H2");
            var mainStatementParagraph = this.addElement(panel2Content, "P");

            var mainInputParagraph = this.addElement(panel2Content, "P", null, "margin-left: 15px;");
            var mainLabel = this.addElement(mainInputParagraph, "LABEL",  { htmlFor: "tagBox" }, "font-size: 12pt;");
            this.addNonBreakingSpace(mainInputParagraph);
            var textBox = this.addElement(mainInputParagraph, "INPUT", { type: "text", id: "tagBox", onkeypress: function (event) { return handleKeyPressForSubmit(event, "createButton"); } }, "font-size: 12pt;")
            var errorLabel = this.addElement(mainInputParagraph, "SPAN", { className: "FailureLabel" });
            this.addNonBreakingSpace(errorLabel);
            this.addTextNode(errorLabel, "*");
            this.addNonBreakingSpace(mainInputParagraph);
            var generateButton = this.addElement(mainInputParagraph, "INPUT", { type: "button", value: <%= DR.CreateSessionPanel_GenerateButtonText.ToClientString() %> }, "font-size: 12pt;");

            var mainInstructionsParagraph = this.addElement(panel2Content, "P");

            var urlParagraph = this.addElement(panel2Content, "P", null, "margin-left: 15px; font-size: 11pt;");
            PageMethods.GetGuestUrl(function(url) { window.setElementText(urlParagraph, url); });

            var autoJoinParagraph = this.addElement(panel2Content, "P");
            var autoJoinBox = this.addElement(autoJoinParagraph, "INPUT", { type: "checkbox", id: "autoJoinBox", checked: settings.autoJoin == null || settings.autoJoin })
            this.addNonBreakingSpace(autoJoinParagraph);
            this.addElement(autoJoinParagraph, "LABEL", { htmlFor: "autoJoinBox" }, null, <%= DR.CreateSessionPanel_AutoJoinMessage.ToClientString() %>);

            var createButtonParagraph = this.addElement(panel2Content, "P");
            this.addElement(createButtonParagraph, "INPUT", { type: "button", id: "createButton", value: <%= DR.CreateSessionPanel_ButtonText.ToClientString() %>, commandName: "Create" }, "font-size: 14pt;")

            var backParagraph = this.addElement(panel2Content, "P");
            this.addElement(backParagraph, "A", { href: "#", commandName: "Back" }, null, <%= DR.CreateSessionPanel_ChooseDifferentTypeMessage.ToClientString() %>);
    
            var selectedInvitationType;

            var setInvitationType = function(invitationType) {
                selectedInvitationType = invitationType;
                panel2Image.src = invitationTypeInfos[invitationType][0];
                window.setElementText(mainHeading, String.format(<%= DR.CreateSessionPanel_CreateTypeHeading.ToClientString() %>, invitationTypeInfos[invitationType][1]));
                window.setElementText(mainStatementParagraph, invitationTypeInfos[invitationType][3]);
                window.setElementText(mainLabel, invitationTypeInfos[invitationType][4]);
                window.setElementText(mainInstructionsParagraph, invitationTypeInfos[invitationType][5]);
                Sys.UI.DomElement.setVisible(urlParagraph, invitationTypeInfos[invitationType][7]);
                Sys.UI.DomElement.setVisible(generateButton, invitationTypeInfos[invitationType][8] && <%= DR.CreateSessionPanel_GenerateButtonVisible %>);
                textBox.size = invitationTypeInfos[invitationType][9];
                textBox.value = invitationTypeInfos[invitationType][6];
                Sys.UI.DomElement.setVisible(errorLabel, false);            
            }
            
            generateButton.onclick = function () {
                var mask = <%= DR.CreateSessionPanel_GenerateMask.ToClientString() %>;
                var code = new Sys.StringBuilder();

                for (var i = 0; mask[i]; i++) {
                    var maskChar = mask.charAt(i);

                    if (maskChar == "#")
                        code.append(getRandomChar(48, 58));
                    else if (maskChar == "A")
                        code.append(getRandomChar(65, 91));
                    else
                        code.append(maskChar);
                }

                textBox.value = code;
            };

            outerPanel.onclick = function(event) {
                var dataCommand = window.getEventDataCommand(event);

                if (dataCommand.commandName == "Select") {
                    Sys.UI.DomElement.setVisible(panel1, false);
                    Sys.UI.DomElement.setVisible(panel2, true);
                    setInvitationType(dataCommand.dataItem);
                    textBox.focus();
                    textBox.select();

                    var typeRememberButtons = document.getElementsByName("TypeRemember");

                    if (typeRememberButtons[0].checked)
                        delete settings.invitationType;
                    else if (typeRememberButtons[1].checked)
                        settings.invitationType = selectedInvitationType;

                    window.saveSettings(settings);
                } else if (dataCommand.commandName == "Back") {
                    Sys.UI.DomElement.setVisible(panel1, true);
                    Sys.UI.DomElement.setVisible(panel2, false);
                    return false;
                } else if (dataCommand.commandName == "Create") {
                    var tag = textBox.value.trim();

                    if (tag.length == 0) {
                        Sys.UI.DomElement.setVisible(errorLabel, true);
                        textBox.focus();
                    } else {
                        Sys.UI.DomElement.setVisible(errorLabel, false);
                        settings.autoJoin = autoJoinBox.checked;

                        PageMethods.CreateSession(selectedInvitationType, textBox.value, window.onCreateSessionSuccess, null, autoJoinBox.checked);

                        window.saveSettings(settings);
                        window.hideModalDialog();
                    }
                }

                return true;
            };

            this.showModalDialog(outerPanel, 450, 400, <%= DR.CreateSessionPanel_Heading.ToClientString() %>, <%= DR.DialogPanel_CancelButtonText.ToClientString() %>, null);

            if (settings.invitationType != null) {
                setInvitationType(settings.invitationType);
                textBox.focus();
            }
        }

        function showBuildInstallerDialog() {
            var panel = this.createElement("DIV", null, "padding: 15px;");
            this.addElement(panel, "P", null, null, <%= DR.BuildInstallerPanel_Paragraph1Message.ToClientString() %>);
            this.addElement(panel, "P", null, null, <%= DR.BuildInstallerPanel_Paragraph2Message.ToClientString() %>);

            var textBoxParagraph = this.addElement(panel, "P");
            var textBox = this.addElement(textBoxParagraph, "INPUT", { type: "text", value: <%= DR.BuildInstallerPanel_LabelDefault.ToClientString() %> }, "width: 100%;");
            
            this.addElement(panel, "P", null, null, <%= DR.BuildInstallerPanel_Paragraph3Message.ToClientString() %>);
            this.addElement(panel, "P", null, null, <%= DR.BuildInstallerPanel_Paragraph4Message.ToClientString() %>);

            var button = this.addElement(panel, "INPUT", { type: "button", value: <%= DR.BuildInstallerPanel_DownloadButtonText.ToClientString() %> }, "font-size: 14pt;");

            button.onclick = function() {
                PageMethods.GetInstallerUrl(textBox.value, window.launchDownload);
            };

            this.showModalDialog(panel, 450, 350, <%= DR.BuildInstallerPanel_Heading.ToClientString() %>, <%= DR.DialogPanel_CloseButtonText.ToClientString() %>, null);
        }

        function onSessionClick(event) {
            var dataCommand = getEventDataCommand(event);

            if (dataCommand.commandName == "Join")
                PageMethods.SendNotificationEmail();
                launchers[0].launch(dataCommand.dataItem.ClientLaunchParameters);
            else if (dataCommand.commandName == "End")
                PageMethods.EndSession(dataCommand.dataItem.ClientLaunchParameters.SessionID, onEndSessionSuccess);
        }

    </script>
</asp:Content>
<asp:Content runat="server" ContentPlaceHolderID="RunScript">
    <script type="text/javascript">
        this.launchers = getSortedLaunchers();
        this.poll();
    </script>
</asp:Content>
Jake Morgan
#7 Posted : Tuesday, March 22, 2011 5:36:54 PM
Rank: Administration
Joined: 4/9/2010
Posts: 858
You missed the added curly braces in the onSessionClick function.
bigdessert
#8 Posted : Tuesday, March 22, 2011 5:44:03 PM
Rank: Advanced Member
Joined: 9/14/2010
Posts: 458
Location: Minnesota
Thanks, that helped my eyes are not very good lately...... still not getting the email though. Where does it get the email server configuration from?
Jake Morgan
#9 Posted : Tuesday, March 22, 2011 5:53:34 PM
Rank: Administration
Joined: 4/9/2010
Posts: 858
It uses the same method as creating email sessions. What you configured on the administration page.
bigdessert
#10 Posted : Tuesday, March 22, 2011 6:36:02 PM
Rank: Advanced Member
Joined: 9/14/2010
Posts: 458
Location: Minnesota
Let me just put it this way, if I send a test email from my administration page it works just fine.
bigdessert
#11 Posted : Tuesday, March 22, 2011 7:20:37 PM
Rank: Advanced Member
Joined: 9/14/2010
Posts: 458
Location: Minnesota
working now....after giving it some time....not sure why. Thanks for the help.
bigdessert
#12 Posted : Wednesday, March 23, 2011 1:07:18 AM
Rank: Advanced Member
Joined: 9/14/2010
Posts: 458
Location: Minnesota
one more quick question regarding this. How hard is it to pass the "invitation" section to the email method? for instance
Quote:
Code: 123
Email: info@domain.com
Listed: TEST


Also if possible the username of the logged in user?
bigdessert
#13 Posted : Wednesday, March 23, 2011 2:30:05 AM
Rank: Advanced Member
Joined: 9/14/2010
Posts: 458
Location: Minnesota
I got the current logged in user by using the following, but the "tag" is not declared globally.....any way to pass tag to my mail method?
Code:
mailMessage.Body = HttpContext.Current.User.Identity.Name + "has joined session" + tag + ".";

Jake Morgan
#14 Posted : Wednesday, March 23, 2011 2:41:18 AM
Rank: Administration
Joined: 4/9/2010
Posts: 858
make your method take an argument like so:

Code:
[WebMethod]
        public static void SendNotificationEmail(string tag)
        {


and in your javascript pass the argument:

Code:
if (dataCommand.commandName == "Join") {
                PageMethods.SendNotificationEmail(dataCommand.dataItem.ClientLaunchParameters.SessionTitle);
                launchers[0].launch(dataCommand.dataItem.ClientLaunchParameters);

bigdessert
#15 Posted : Wednesday, March 23, 2011 3:05:01 AM
Rank: Advanced Member
Joined: 9/14/2010
Posts: 458
Location: Minnesota
Thanks that got things working and in the right direction for the host, but I also thought it would be nice to know when a guest clicks a join button.

For the sake of anyone else looking to do something similar here is a mini howto.

To get guest email alerts whenever a guest clicks a join button from the guest page or joins via an email link do the following:

Guest.aspx around line 98 changed
Code:
    function beginJoinSession(sessionInfo)
    {
        PageMethods.SelectSession(sessionInfo.ClientLaunchParameters.SessionID);
        this.joinSessionID = sessionInfo.ClientLaunchParameters.SessionID;


to
Code:

    function beginJoinSession(sessionInfo)
    {
        PageMethods.SendNotificationEmail(sessionInfo);
        PageMethods.SelectSession(sessionInfo.ClientLaunchParameters.SessionID);
        this.joinSessionID = sessionInfo.ClientLaunchParameters.SessionID;


Guest.aspx.cs added this method after line 81

Code:
    [WebMethod]
        public static void SendNotificationEmail(Session session)
        {
        var mailMessage = new System.Net.Mail.MailMessage();
        mailMessage.To.Add("you@email.com");
        mailMessage.Subject = "GUEST Session Activity";
        mailMessage.Body = "A Guest has joined a session labelled: " + session.Tag;

        var client = new SmtpClient();
        client.Send(mailMessage);
        }


To get email alerts whenever a host joins a session do the following:

Host.aspx around line 351 changed

Code:
    if (dataCommand.commandName == "Join")
        launchers[0].launch(dataCommand.dataItem.ClientLaunchParameters);
    else if (dataCommand.commandName == "End")


to
Code:

    if (dataCommand.commandName == "Join"){
        PageMethods.SendNotificationEmail(dataCommand.dataItem.ClientLaunchParameters.SessionTitle);
        launchers[0].launch(dataCommand.dataItem.ClientLaunchParameters);
    } else if (dataCommand.commandName == "End")


Host.aspx.cs added this method after line 144

Code:
    [WebMethod]
        public static void SendNotificationEmail(string tag)
        {
        var mailMessage = new System.Net.Mail.MailMessage();
        mailMessage.To.Add("you@email.com");
        mailMessage.Subject = "HOST Session Activity";
        mailMessage.Body = HttpContext.Current.User.Identity.Name + " has joined the session labelled: " + tag;

        var client = new SmtpClient();
        client.Send(mailMessage);
        }
promptcare
#16 Posted : Thursday, September 15, 2011 2:36:30 AM
Rank: Advanced Member
Joined: 9/15/2011
Posts: 78
Location: ON, Canada
This is great! Thanks, Tim and Jake.

I have one residual question. I want notifications when a Guest connects. I've setup up a Listed session called "Test". I am getting the notification email but there is nothing where a "session.Tag" would be.

Now, between when the above info was written and the current version, things look different. I only added the line "PageMethods.SendNotificationEmail(sessionInfo);" at line 89 of the Guest.aspx and it worked to this extent.


FWIW, I have it set up to send the email to my cell phone's TXT address (supported by a lot of carriers) e.g. 1234567890@txt.bell.ca and am merging the subject and body to subject-only. (But, if I leave it the old way, I get the same results without the "session.tag"). Hardly a deal breaker but it would be nice....


EDIT: I'd had some issues so uninstalled SC and installed the latest build. There is no Guest.cs file to edit.
Users browsing this topic
Guest
Tag as favorite
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.