コード例 #1
0
        //---------------------------------------------------------------------------------------//

        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session[Consts.STRSSN_LabClient] != null)
            {
                LabClientSession labClientSession = (LabClientSession)Session[Consts.STRSSN_LabClient];

                Banner.Title       = labClientSession.bannerTitle;
                Statusbar.Version  = STR_Version + labClientSession.statusVersion;
                Navmenu.PhotoUrl   = labClientSession.navmenuPhotoUrl;
                Navmenu.CameraUrl  = labClientSession.labCameraUrl;
                Feedback.MailtoUrl = labClientSession.mailtoUrl;
            }
        }
コード例 #2
0
        //---------------------------------------------------------------------------------------//
        protected void Page_Load(object sender, EventArgs e)
        {
            const String methodName = "Page_Load";
            Logfile.WriteCalled(logLevel, STR_ClassName, methodName);

            /*
             * Get the LabClientSession information from the session
             */
            this.labClientSession = (LabClientSession)Session[Consts.STRSSN_LabClient];

            if (!IsPostBack)
            {
                 /*
                  * Update LabInfo text and url if specified
                  */
                if (this.labClientSession.LabInfoText != null && this.labClientSession.LabInfoUrl != null)
                {
                    lblMoreInfo.Text = STR_ForMoreInfoSee;
                    lnkMoreInfo.Text = this.labClientSession.LabInfoText;
                    lnkMoreInfo.NavigateUrl = this.labClientSession.LabInfoUrl;
                }

                /*
                 * Don't display the extra information
                 */
                litSetupInfo.Visible = false;
                lnkbtnSetupInfo.Text = STR_More;
                litStatusInfo.Visible = false;
                lnkbtnStatusInfo.Text = STR_More;
                litResultsInfo.Visible = false;
                lnkbtnResultsInfo.Text = STR_More;
            }
            else
            {
                /*
                 * Clear labels
                 */
                lblMoreInfo.Text = null;
                lnkMoreInfo.Text = null;
            }
        }
コード例 #3
0
        //---------------------------------------------------------------------------------------//
        /// <summary>
        /// This method gets called before any other Page_Init() or Page_Load() methods.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Init(object sender, EventArgs e)
        {
            const String methodName = "Page_Init";
            Logfile.WriteCalled(logLevel, STR_ClassName, methodName);

            /*
             * Get the LabClientSession information from the session
             */
            this.labClientSession = (LabClientSession)Session[Consts.STRSSN_LabClient];

            /*
             * Check if the LabClient session doesn't exists
             */
            if (this.labClientSession == null)
            {
                try
                {
                    /*
                     * Log the caller's IP address and hostname
                     */
                    String hostname;
                    try
                    {
                        IPHostEntry ipHostEntry = Dns.GetHostEntry(Request.UserHostAddress);
                        hostname = ipHostEntry.HostName;
                    }
                    catch
                    {
                        hostname = STRLOG_CannotResolveToHostName;
                    }
                    Logfile.Write(Logfile.Level.Info, String.Format(STRLOG_UserHost_arg2, Request.UserHostAddress, hostname));

                    /*
                     * Get configuration information
                     */
                    ConfigProperties configProperties = Global.ConfigProperties;

                    /*
                     * Get query string values ignoring case when comparing strings
                     */
                    int couponId = 0;
                    String passkey = null;
                    NameValueCollection collection = HttpUtility.ParseQueryString(Request.Url.Query);
                    foreach (String key in collection)
                    {
                        if (key.Equals(Consts.STRQRY_CouponId, StringComparison.OrdinalIgnoreCase) == true)
                        {
                            /* Used with Batch ServiceBroker */
                            couponId = Int32.Parse(collection.Get(key));
                        }
                        else if (key.Equals(Consts.STRQRY_Coupon_Id, StringComparison.OrdinalIgnoreCase) == true)
                        {
                            /* Used with Merged ServiceBroker */
                            couponId = Int32.Parse(collection.Get(key));
                        }
                        else if (key.Equals(Consts.STRQRY_Passkey, StringComparison.OrdinalIgnoreCase) == true)
                        {
                            passkey = collection.Get(key);
                        }
                        else if (key.Equals(Consts.STRQRY_ServiceUrl, StringComparison.OrdinalIgnoreCase) == true)
                        {
                            configProperties.ServiceUrl = collection.Get(key);
                        }
                        else if (key.Equals(Consts.STRQRY_LabServerId, StringComparison.OrdinalIgnoreCase) == true)
                        {
                            configProperties.LabServerId = collection.Get(key);
                        }
                        else if (key.Equals(Consts.STRCFG_MultiSubmit, StringComparison.OrdinalIgnoreCase) == true)
                        {
                            bool value;
                            if (Boolean.TryParse(collection.Get(key), out value) == true)
                            {
                                configProperties.MultiSubmit = value;
                            }
                        }
                    }

                    /*
                     * Check if session has timed out
                     */
                    if (couponId == 0)
                    {
                        throw new HttpException();
                    }

                    /*
                     * Create a ServiceBroker proxy and add authorisation information
                     */
                    ServiceBrokerAPI serviceBrokerAPI = new ServiceBrokerAPI(configProperties.ServiceUrl);
                    serviceBrokerAPI.LabServerId = configProperties.LabServerId;
                    serviceBrokerAPI.CouponId = couponId;
                    serviceBrokerAPI.CouponPasskey = passkey;

                    /*
                     * Create an instance of the LabClientSession and fill in
                     */
                    labClientSession = new LabClientSession();
                    labClientSession.ServiceBrokerAPI = serviceBrokerAPI;
                    labClientSession.MultiSubmit = configProperties.MultiSubmit;
                    labClientSession.FeedbackEmailUrl = configProperties.FeedbackEmail;

                    /*
                     * Set LabClientSession information in the session for access by the web pages
                     */
                    Session[Consts.STRSSN_LabClient] = labClientSession;

                    Logfile.Write(Logfile.Level.Fine, String.Format(STRLOG_RequestParams_arg5,
                            serviceBrokerAPI.CouponId, serviceBrokerAPI.CouponPasskey,
                            configProperties.ServiceUrl, configProperties.LabServerId, configProperties.MultiSubmit));

                    /*
                     * Get the lab status
                     */
                    Logfile.Write(Logfile.Level.Info, STRLOG_GettingLabStatus);
                    LabStatus labStatus = serviceBrokerAPI.GetLabStatus();
                    Logfile.Write(Logfile.Level.Info, String.Format(STRLOG_LabStatus_arg2, labStatus.Online, labStatus.LabStatusMessage));

                    /*
                     * Get information from the lab configuration xml file
                     */
                    String xmlLabConfiguration = serviceBrokerAPI.GetLabConfiguration();
                    this.labClientSession.ParseLabConfiguration(xmlLabConfiguration);
                }
                catch (HttpException)
                {
                    Response.Redirect(Consts.STRURL_Expired);
                }
                catch (Exception ex)
                {
                    Logfile.WriteError(ex.ToString());
                }
            }

            Logfile.WriteCompleted(logLevel, STR_ClassName, methodName);
        }
コード例 #4
0
        //---------------------------------------------------------------------------------------//
        protected void Page_Load(object sender, EventArgs e)
        {
            const String methodName = "Page_Load";
            Logfile.WriteCalled(logLevel, STR_ClassName, methodName);

            this.labClientSession = (LabClientSession)Session[LabConsts.STRSSN_LabClient];
            if (this.labClientSession != null)
            {
                this.lblTitle.Text = this.labClientSession.Title;
                this.lblVersion.Text = this.labClientSession.Version;

                /*
                 * Navmenu photo
                 */
                String url = this.labClientSession.NavmenuPhotoUrl;
                if (url == null || url.Trim().Length == 0)
                {
                    url = STR_DefaultNavMenuPhotoUrl;
                }
                this.imgNavmenuPhoto.ImageUrl = url;

                /*
                 * Feedback email url
                 */
                if (this.labClientSession.FeedbackEmailUrl != null)
                {
                    this.urlFeedbackEmail.NavigateUrl = String.Format(STR_UrlFeedbackEmail_arg, this.labClientSession.FeedbackEmailUrl);
                }

                /*
                 * Lab camera url
                 */
                url = this.labClientSession.LabCameraUrl;
                if (url != null && url.Trim().Length > 0)
                {
                    aCamera.HRef = url;
                }
                this.liCamera.Visible = (url != null);
            }

            Logfile.WriteCompleted(logLevel, STR_ClassName, methodName);
        }
コード例 #5
0
        //-------------------------------------------------------------------------------------------------//
        protected void Page_Load(object sender, EventArgs e)
        {
            const String methodName = "Page_Load";
            Logfile.WriteCalled(logLevel, STR_ClassName, methodName);

            /*
             * Get the LabClientSession information from the session
             */
            this.labClientSession = (LabClientSession)Session[Consts.STRSSN_LabClient];

            if (!IsPostBack)
            {
                /*
                 * Not a postback, initialise page controls
                 */
                this.ShowMessageInfo(null);
                this.PopulateCompletedIds();
                this.btnSave.Enabled = false;
                this.lblResultsTableValue.Visible = false;
            }
        }
コード例 #6
0
        //-------------------------------------------------------------------------------------------------//
        protected void Page_Load(object sender, EventArgs e)
        {
            const String methodName = "Page_Load";
            Logfile.WriteCalled(logLevel, STR_ClassName, methodName);

            /*
             * Get the LabClientSession information from the session
             */
            this.labClientSession = (LabClientSession)Session[Consts.STRSSN_LabClient];

            if (!IsPostBack)
            {
                /*
                 * Not a postback, initialise page controls
                 */
                this.ShowMessageInfo(null);
                this.PopulateSubmittedIds();
            }

            /*
             * Refresh the LabServer status
             */
            this.Refresh();
        }
コード例 #7
0
        //---------------------------------------------------------------------------------------//
        protected void Page_Load(object sender, EventArgs e)
        {
            const String methodName = "Page_Load";
            Logfile.WriteCalled(logLevel, STR_ClassName, methodName);

            /*
             * Get the LabClientSession information from the session
             */
            this.labClientSession = (LabClientSession)Session[Consts.STRSSN_LabClient];

            if (!IsPostBack)
            {
                /*
                 * Not a postback, initialise page controls
                 */
                this.ShowMessageInfo(null);
                this.PopulatePage();

                /*
                 * Check if an experiment has been submitted
                 */
                int[] submittedIds = this.labClientSession.SubmittedIds;
                if (submittedIds != null)
                {
                    if (submittedIds.Length == 1)
                    {
                        /*
                         * Show the one that has been submitted
                         */
                        this.ShowMessageInfo(String.Format(STR_ExperimentNumberHasBeenSubmitted_arg, submittedIds[0]));
                    }
                    else if (submittedIds.Length > 1)
                    {
                        /*
                         * More than one has been submitted, show them all
                         */
                        String arg = "";
                        for (int i = 0; i < submittedIds.Length; i++)
                        {
                            if (i > 0)
                            {
                                arg += ", ";
                            }
                            arg += submittedIds[i].ToString();
                        }
                        this.ShowMessageInfo(String.Format(STR_ExperimentNumbersHaveBeenSubmitted_arg, arg));
                    }
                }
                else
                {
                    this.btnSubmit.Enabled = true;
                }
            }

            Logfile.WriteCompleted(logLevel, STR_ClassName, methodName);
        }
コード例 #8
0
        //---------------------------------------------------------------------------------------//

        private void ParseLabConfiguration(LabClientSession labClientSession, string xmlLabConfiguration)
        {
            const string STRLOG_MethodName = "ParseLabConfiguration";

            Logfile.WriteCalled(STRLOG_ClassName, STRLOG_MethodName);

            try
            {
                Logfile.Write(STRLOG_LoadingLabConfiguration);

                //
                // Load the lab configuration from an XML string
                //
                XmlDocument xmlDocument = XmlUtilities.GetXmlDocument(xmlLabConfiguration);

                //
                // Save a copy of the lab configuration XML node
                //
                XmlNode xmlNode = XmlUtilities.GetXmlRootNode(xmlDocument, Consts.STRXML_labConfiguration);
                XmlNode xmlNodeLabConfiguration = xmlNode.Clone();
                labClientSession.xmlNodeLabConfiguration = xmlNodeLabConfiguration;

                Logfile.Write(STRLOG_ParsingLabConfiguration);

                //
                // Get information from the lab configuration node
                //
                labClientSession.bannerTitle     = XmlUtilities.GetXmlValue(xmlNodeLabConfiguration, Consts.STRXMLPARAM_title, false);
                labClientSession.statusVersion   = XmlUtilities.GetXmlValue(xmlNodeLabConfiguration, Consts.STRXMLPARAM_version, false);
                labClientSession.navmenuPhotoUrl = XmlUtilities.GetXmlValue(xmlNodeLabConfiguration, Consts.STRXML_navmenuPhoto_image, false);
                labClientSession.labCameraUrl    = XmlUtilities.GetXmlValue(xmlNodeLabConfiguration, Consts.STRXML_labCamera_url, true);
                labClientSession.labInfoText     = XmlUtilities.GetXmlValue(xmlNodeLabConfiguration, Consts.STRXML_labInfo_text, true);
                labClientSession.labInfoUrl      = XmlUtilities.GetXmlValue(xmlNodeLabConfiguration, Consts.STRXML_labInfo_url, true);

                Logfile.Write(STRLOG_Title + labClientSession.bannerTitle);
                Logfile.Write(STRLOG_Version + labClientSession.statusVersion);
                Logfile.Write(STRLOG_PhotoUrl + labClientSession.navmenuPhotoUrl);
                Logfile.Write(STRLOG_LabCameraUrl + labClientSession.labCameraUrl);
                Logfile.Write(STRLOG_LabInfoText + labClientSession.labInfoText);
                Logfile.Write(STRLOG_LabInfoUrl + labClientSession.labInfoUrl);

                //
                // These are mandatory
                //
                xmlNode = XmlUtilities.GetXmlNode(xmlNodeLabConfiguration, Consts.STRXML_configuration, false);
                labClientSession.xmlNodeConfiguration = xmlNode.Clone();
                xmlNode = XmlUtilities.GetXmlNode(xmlNodeLabConfiguration, Consts.STRXML_experimentSpecification, false);
                labClientSession.xmlNodeSpecification = xmlNode.Clone();

                //
                // These are optional and depend on the LabServer implementation
                //
                xmlNode = XmlUtilities.GetXmlNode(xmlNodeLabConfiguration, Consts.STRXML_validation, true);
                if (xmlNode != null)
                {
                    labClientSession.xmlNodeValidation = xmlNode.Clone();
                }
            }
            catch (Exception ex)
            {
                Logfile.WriteError(ex.Message);
                throw;
            }

            Logfile.WriteCompleted(STRLOG_ClassName, STRLOG_MethodName);
        }
コード例 #9
0
        //---------------------------------------------------------------------------------------//

        protected void Page_Init(object sender, EventArgs e)
        {
            const string STRLOG_MethodName = "Page_Init";

            Logfile.WriteCalled(STRLOG_ClassName, STRLOG_MethodName);

            //
            // This method gets called before any other Page_Init() or Page_Load() methods.
            //

            //
            // Get query string values for coupon ID and passkey
            //
            string query         = Request.Url.Query;
            string queryCouponId = HttpUtility.ParseQueryString(query).Get(Consts.STRQRY_CouponID);
            string queryPasskey  = HttpUtility.ParseQueryString(query).Get(Consts.STRQRY_Passkey);

            //
            // Check if this is new LabClient session
            //
            if (Session[Consts.STRSSN_LabClient] != null && queryCouponId != null)
            {
                //
                // Remove the existing session because this is a new LabClient launch
                //
                Logfile.Write(STRLOG_SessionExistsRemovingSession);
                Session.Remove(Consts.STRSSN_LabClient);
            }

            if (Session[Consts.STRSSN_LabClient] == null)
            {
                if (queryCouponId == null)
                {
                    //
                    // Session has timed out
                    //
                    Logfile.Write(STRLOG_SessionNotExist);
                    Response.Redirect(Consts.STRURL_Expired);
                }

                //
                // Carry out one-time initialisation for all LabClient instances
                //
                Logfile.Write(STR_Initialising);

                //
                // Log the caller's IP address and hostname
                //
                HttpRequest httpRequest = this.Request;
                string      logMessage  = STRLOG_UserHostAddress + httpRequest.UserHostAddress +
                                          Logfile.STRLOG_Spacer + STRLOG_UserHostName;
                try
                {
                    IPHostEntry ipHostEntry = Dns.GetHostEntry(httpRequest.UserHostAddress);
                    logMessage += ipHostEntry.HostName;
                }
                catch
                {
                    logMessage += STRLOG_CannotResolveToHostName;
                }
                Logfile.Write(logMessage);

                //
                // Get query string values - the query string parameters are NOT case-sensensitive (good)
                //
                string queryServiceUrl  = HttpUtility.ParseQueryString(query).Get(Consts.STRQRY_ServiceURL);
                string queryLabServerId = HttpUtility.ParseQueryString(query).Get(Consts.STRQRY_LabServerID);
                string queryMultiSubmit = HttpUtility.ParseQueryString(query).Get(Consts.STRQRY_MultiSubmit);

                //
                // Create a LabClient session information instance
                //
                LabClientSession labClientSession = new LabClientSession();

                //
                // Create ServiceBroker interface with authorisation information
                //
                LabClientToSbAPI serviceBroker = new LabClientToSbAPI(queryCouponId, queryPasskey, queryServiceUrl, queryLabServerId);
                labClientSession.labClientToSbAPI = serviceBroker;

                //
                // Get the lab status and lab configuration
                //
                try
                {
                    //
                    // Get the lab status
                    //
                    Logfile.Write(STRLOG_GettingLabStatus);

                    LabStatus labStatus = serviceBroker.GetLabStatus();

                    logMessage = STRLOG_Online + labStatus.online.ToString() +
                                 Logfile.STRLOG_Spacer + STRLOG_LabStatusMessage + labStatus.labStatusMessage;
                    Logfile.Write(logMessage);

                    //
                    // Get the XML lab configuration string
                    //
                    Logfile.Write(STRLOG_GettingLabConfiguration);

                    string xmlLabConfiguration = serviceBroker.GetLabConfiguration();
                    if (xmlLabConfiguration != null)
                    {
                        // Save information from the lab configuration string
                        ParseLabConfiguration(labClientSession, xmlLabConfiguration);
                    }
                }
                catch (Exception ex)
                {
                    if (ex.InnerException != null)
                    {
                        Logfile.Write(ex.InnerException.Message);
                    }
                    else
                    {
                        Logfile.WriteError(ex.Message);
                    }
                }

                //
                // Get feedback email URL
                //
                labClientSession.mailtoUrl = STR_MailTo + Utilities.GetAppSetting(Consts.STRCFG_FeedbackEmail);

                //
                // Determine if multiple submission is enabled
                //
                try
                {
                    if (queryMultiSubmit == null)
                    {
                        //
                        // Querystring parameter is not specified, try getting it from the application's configuration file
                        //
                        labClientSession.multiSubmit = Convert.ToBoolean(Utilities.GetAppSetting(Consts.STRCFG_MultiSubmit));
                    }
                    else
                    {
                        labClientSession.multiSubmit = Convert.ToBoolean(queryMultiSubmit);
                    }
                }
                catch
                {
                    labClientSession.multiSubmit = false;
                }
                Logfile.Write(STRLOG_MultiSubmit + labClientSession.multiSubmit.ToString());

                Session[Consts.STRSSN_LabClient] = labClientSession;
            }

            Logfile.WriteCompleted(STRLOG_ClassName, STRLOG_MethodName);
        }