コード例 #1
0
        //-------------------------------------------------------------------------------------------------//
        /// <summary>
        /// 
        /// </summary>
        public ExperimentsDB(DBConnection dbConnection)
        {
            const string methodName = "ExperimentsDB";
            Logfile.WriteCalled(logLevel, STR_ClassName, methodName);

            try
            {
                /*
                 * Check that parameters are valid
                 */
                if (dbConnection == null)
                {
                    throw new ArgumentNullException(DBConnection.ClassName);
                }

                /*
                 * Initialise locals
                 */
                this.sqlConnection = dbConnection.GetConnection();
            }
            catch (Exception ex)
            {
                Logfile.WriteError(ex.Message);
                throw;
            }

            Logfile.WriteCompleted(logLevel, STR_ClassName, methodName);
        }
コード例 #2
0
        //-------------------------------------------------------------------------------------------------//
        /// <summary>
        /// 
        /// </summary>
        public ConfigProperties()
        {
            const string methodName = "ConfigProperties";
            Logfile.WriteCalled(logLevel, STR_ClassName, methodName);

            try
            {
                /*
                 * Create an instance of the database connection
                 */
                String sqlConnectionString = AppSetting.GetStringAppSetting(LabConsts.STRCFG_SqlConnection);
                this.dbConnection = new DBConnection(sqlConnectionString);

                /*
                 * Get the ServiceBroker Guid
                 */
                this.serviceBrokerGuid = AppSetting.GetStringAppSetting(LabConsts.STRCFG_ServiceBrokerGuid);

                /*
                 * Get LabClient authentication
                 */
                this.authenticating = AppSetting.GetBoolAppSetting(LabConsts.STRCFG_Authenticating, true);
                this.logAuthentication = AppSetting.GetBoolAppSetting(LabConsts.STRCFG_LogAuthentication, false);

                /*
                 * Get coupon Id and passkey for LabClient authentication
                 */
                this.couponId = AppSetting.GetLongAppSetting(LabConsts.STRCFG_CouponId);
                this.couponPasskey = AppSetting.GetStringAppSetting(LabConsts.STRCFG_CouponPasskey);

                /*
                 * Get the LabServer service information
                 */
                char[] splitterCharArray = new char[] { LabConsts.CHRCSV_SplitterChar };
                this.labServerInfos = new Dictionary<String, LabServerInfo>();
                for (int i = 0; true; i++)
                {
                    /*
                     * Get the LabServer info if it exists
                     */
                    String[] splitLabServerInfo;
                    try
                    {
                        String csvLabServerInfo = AppSetting.GetAppSetting(String.Format(LabConsts.STRCFG_LabServer_arg, i));
                        splitLabServerInfo = csvLabServerInfo.Split(splitterCharArray);
                    }
                    catch
                    {
                        break;
                    }

                    /*
                     * Extract guid and check
                     */
                    String guid = splitLabServerInfo[LabConsts.INDEX_LabServerGuid];
                    if (guid == null || guid.Trim().Length == 0)
                    {
                        throw new ArgumentNullException(STRERR_LabServerGuid);
                    }
                    guid = guid.Trim().ToUpper();

                    /*
                     * Extract service url and check
                     */
                    String serviceUrl = splitLabServerInfo[LabConsts.INDEX_LabServerUrl];
                    if (serviceUrl == null || serviceUrl.Trim().Length == 0)
                    {
                        throw new ArgumentNullException(STRERR_LabServerServiceUrl);
                    }
                    serviceUrl = serviceUrl.Trim();

                    /*
                     * Extract the outgoing passkey and check
                     */
                    String outPasskey = splitLabServerInfo[LabConsts.INDEX_LabServerOutPasskey];
                    if (outPasskey == null || outPasskey.Trim().Length == 0)
                    {
                        throw new ArgumentNullException(STRERR_LabServerOutPasskey);
                    }
                    outPasskey = outPasskey.Trim();

                    /*
                     * Extract the incoming passkey and check
                     */
                    String inPasskey = splitLabServerInfo[LabConsts.INDEX_LabServerInPasskey];
                    if (inPasskey == null || inPasskey.Trim().Length == 0)
                    {
                        throw new ArgumentNullException(STRERR_LabServerInPasskey);
                    }
                    inPasskey = inPasskey.Trim();

                    /*
                     * Store information
                     */
                    this.labServerInfos.Add(guid, new LabServerInfo(guid, serviceUrl, outPasskey, inPasskey));

                    Logfile.Write(String.Format(STRLOG_LabServerInfo_arg5, i, guid, serviceUrl, outPasskey, inPasskey));
                }
            }
            catch (Exception ex)
            {
                Logfile.WriteError(ex.Message);
                throw;
            }

            Logfile.WriteCompleted(logLevel, STR_ClassName, methodName);
        }