//---------------------------------------------------------------------------------------//
        private LabServerWebService GetLabServer(sbAuthHeader sbHeader)
        {
            const string STRLOG_MethodName = "GetLabServer";

            Logfile.WriteCalled(STRLOG_ClassName, STRLOG_MethodName);

            long couponId = sbHeader.couponID;
            string couponPasskey = sbHeader.couponPassKey;

            Logfile.Write(" Coupon Id: " + couponId.ToString());
            Logfile.Write(" Coupon Passkey: " + couponPasskey);

            LabServerWebService labServer = null;
            try
            {
                //
                // Get settings from Application's configuration file
                //
                string labserverId = couponId.ToString();

                Logfile.Write(" Labserver Id: " + labserverId);

                string labServerUrl = Utilities.GetAppSetting(labserverId);
                string sbGuid = Utilities.GetAppSetting(Consts.STRCFG_ServiceBrokerGuid);
                string sbToLsPasskey = Utilities.GetAppSetting(Consts.STRCFG_SbToLsPasskey);

                Logfile.Write(" ServiceBroker Guid: " + sbGuid);
                Logfile.Write(" Labserver Url: " + labServerUrl);
                Logfile.Write(" SBtoLS Passkey: " + sbToLsPasskey);

                //
                // Create LabServer interface
                //
                labServer = new LabServerWebService();
                labServer.Url = labServerUrl;

                //
                // Create and fill in authorisation information
                //
                AuthHeader authHeader = new AuthHeader();
                authHeader.identifier = sbGuid;
                authHeader.passKey = sbToLsPasskey;
                labServer.AuthHeaderValue = authHeader;
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
                throw;
            }

            Logfile.WriteCompleted(STRLOG_ClassName, STRLOG_MethodName);

            return labServer;
        }
        public void Notify(int experimentID)
        {
            const string STRLOG_MethodName = "Notify";

            string logMessage = STRLOG_ExperimentId + experimentID.ToString();

            Logfile.WriteCalled(STRLOG_ClassName, STRLOG_MethodName, logMessage);

            bool success = false;

            try
            {
                //
                // Check LabServer's header information is valid
                //
                if (sbHeader == null)
                {
                    throw new ArgumentNullException("sbHeader");
                }
                if (sbHeader.couponPassKey == null)
                {
                    throw new ArgumentNullException("couponPassKey");
                }

                //
                // Determine LabServer
                //
                string strLabServerId = sbHeader.couponID.ToString("X");
                string strCsvLabServer = Utilities.GetAppSetting(strLabServerId);
                string[] strSplit = strCsvLabServer.Split(new char[] { ',' });
                if (strSplit.Length < 3)
                {
                    throw new ArgumentException("CSV LabServer string has insufficient parameters");
                }

                //
                // Check for valid passkey
                //
                if (sbHeader.couponPassKey.Equals(strSplit[0].Trim(), StringComparison.OrdinalIgnoreCase) == false)
                {
                    throw new ArgumentException("couponPassKey is invalid");
                }

                //
                // Create LabServer interface
                //
                string labserverUrl = strSplit[1].Trim();

                LabServerWebService labServer = new LabServerWebService();
                labServer.Url = labserverUrl;

                //
                // Create and fill in authorisation information
                //
                string sbGuid = Utilities.GetAppSetting(Consts.STRCFG_ServiceBrokerGuid);
                string sbToLsPasskey = strSplit[2].Trim();

                AuthHeader authHeader = new AuthHeader();
                authHeader.identifier = sbGuid;
                authHeader.passKey = sbToLsPasskey;
                labServer.AuthHeaderValue = authHeader;

                //
                // Retrieve result from LabServer
                //
                LabExperimentStatus labExperimentStatus = labServer.GetExperimentStatus(experimentID);
                if ((labExperimentStatus != null) && (labExperimentStatus.statusReport != null) &&
                    (labExperimentStatus.statusReport.statusCode >= (int)StatusCodes.Completed) &&
                    (labExperimentStatus.statusReport.statusCode != (int)StatusCodes.Unknown))
                {
                    ResultReport resultReport = labServer.RetrieveResult(experimentID);
                }

                success = true;
            }
            catch (Exception ex)
            {
                Logfile.WriteError(ex.Message);
            }

            logMessage = STRLOG_Success + success.ToString();

            Logfile.WriteCompleted(STRLOG_ClassName, STRLOG_MethodName, logMessage);
        }