Inheritance: System.Data.Linq.DataContext
 private string LoadSystemSettings()
 {
     using (SystemInfoDataContext systemInfo = new SystemInfoDataContext(m_dbConnectionString))
     {
         return LoadSystemSettings(systemInfo);
     }
 }
        private string LoadSystemSettings(SystemInfoDataContext systemInfo)
        {
            // Convert the Setting table to a dictionary
            Dictionary<string, string> settings = systemInfo.Settings
                .ToDictionary(setting => setting.Name, setting => setting.Value, StringComparer.OrdinalIgnoreCase);

            // Add the database connection string if there is not
            // already one explicitly specified in the Setting table
            if (!settings.ContainsKey("dbConnectionString"))
                settings.Add("dbConnectionString", m_dbConnectionString);

            // Convert dictionary to a connection string and return it
            return SystemSettings.ToConnectionString(settings);
        }
        /// <summary>
        /// Starts the fault location engine.
        /// </summary>
        public void Start()
        {
            IEnumerable<string> filterPatterns;

            // Get system settings from the database
            ReloadSystemSettings();

            // Get the list of file extensions to be processed by openXDA
            using (SystemInfoDataContext systemInfo = new SystemInfoDataContext(m_dbConnectionString))
            {
                filterPatterns = systemInfo.DataReaders
                    .Select(reader => reader.FilePattern)
                    .Select(extension => string.Format("*.{0}", extension))
                    .ToList();
            }

            // Reload configuration at startup
            ReloadConfiguration();

            // Make sure watch directories exist
            foreach (string path in m_systemSettings.WatchDirectoryList)
                TryCreateDirectory(path);

            // Make sure results directory exists
            TryCreateDirectory(m_systemSettings.ResultsPath);

            if ((object)m_fileWrapperLookup == null)
                m_fileWrapperLookup = new Dictionary<string, FileWrapper>();

            // Create the lookup table used to track which files are being processed
            if ((object)m_activeFiles == null)
                m_activeFiles = new ConcurrentDictionary<string, string>();

            // Create the scheduler used to schedule when to process meter data
            if ((object)m_meterDataScheduler == null)
            {
                m_meterDataScheduler = new LogicalThreadScheduler();
                m_meterDataThreadLookup = new Dictionary<string, LogicalThread>();

                m_meterDataScheduler.UnhandledException += (sender, args) =>
                {
                    string message = $"Unhandled exception occurred while processing meter data: {args.Argument.Message}";
                    Exception ex = new Exception(message, args.Argument);
                    OnProcessException(ex);
                };
            }

            m_meterDataScheduler.MaxThreadCount = m_systemSettings.ProcessingThreadCount;

            // Setup new file processor to monitor the watch directories
            if ((object)m_fileProcessor == null)
            {
                m_fileProcessor = new FileProcessor(FileProcessorID);
                m_fileProcessor.InternalBufferSize = m_systemSettings.FileWatcherBufferSize;
                m_fileProcessor.EnumerationStrategy = m_systemSettings.FileWatcherEnumerationStrategy;
                m_fileProcessor.MaxThreadCount = m_systemSettings.FileWatcherInternalThreadCount;
                m_fileProcessor.MaxFragmentation = m_systemSettings.FileWatcherMaxFragmentation;
                m_fileProcessor.FilterMethod = PrevalidateFile;
                m_fileProcessor.Processing += FileProcessor_Processing;
                m_fileProcessor.Error += FileProcessor_Error;

                UpdateFileProcessorFilter(m_systemSettings);
            }

            foreach (string path in m_systemSettings.WatchDirectoryList)
                m_fileProcessor.AddTrackedDirectory(path);
        }