コード例 #1
0
        protected void Load(string dbHandle, ConfigDB db)
        {
            _clientName = ConfigurationManager.AppSettings["ClientName"];
            LoadMetaData(db);
            Logger.Log(true, "Loaded Meta Data...", EventLogEntryType.Information, false, true);
            _testEnv = db.LoadTestEnvironment();
            Logger.Log(true, "Loaded Test Environment...", EventLogEntryType.Information, false, true);
            LoadRTSAttributes(db);
            Logger.Log(true, "Loaded RTS Attributes Data...", EventLogEntryType.Information, false, true);

            int?longDbCommandTimeout = null;

            if (!String.IsNullOrEmpty(ConfigurationManager.AppSettings["LongDbCommandTimeout"]))
            {
                longDbCommandTimeout = int.Parse(ConfigurationManager.AppSettings["LongDbCommandTimeout"]);
            }
            _configHolder[dbHandle] = new ScoringEngine.TestCollection(
                ConfigurationManager.ConnectionStrings["ITEMBANK"].ConnectionString,
                ConfigurationManager.AppSettings["ScoringEnvironment"],
                ClientName,
                longDbCommandTimeout);

            Logger.Log(true, "Initialized Scoring Engine...", EventLogEntryType.Information, false, true);

            _admins = db.LoadAdministration();

            //do some error checking on the TDSSessionDatabases key in the app.config
            _sessionDatabases = new HashSet <string>(StringComparer.InvariantCultureIgnoreCase);
            //remove all whitespace and newlines from the value in the app settings
            Regex ptrn = new Regex(@"\s*", RegexOptions.Compiled | RegexOptions.CultureInvariant);

            _tdsSessionDatabasesValue = ptrn.Replace(ConfigurationManager.AppSettings["TDSSessionDatabases"] ?? "", "");

            if (string.IsNullOrEmpty(_tdsSessionDatabasesValue))
            {
                Logger.Log(true, "The key TDSSessionDatabases does not appear in the app.config file", EventLogEntryType.Information, false, true);
            }
            else
            {
                string[] dbsArr = _tdsSessionDatabasesValue.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
                foreach (String value in dbsArr)
                {
                    if (!_sessionDatabases.Add(value))
                    {
                        Logger.Log(true, "The TDSSessionDatabases value in the app.config file contains a duplicate entry: " + value, EventLogEntryType.Information, false, true);
                    }
                }
            }
            Logger.Log(true, "Loaded Administration and Server Name...Finished initializing configuration", EventLogEntryType.Information, false, true);
        }