Beispiel #1
0
        // Updates the Filter property of the FileProcessor with the
        // latest collection of filters from the DataReader table.
        private void UpdateFileProcessorFilter(SystemSettings systemSettings)
        {
            // Do not attempt to load filter patterns if file processor is not defined
            if ((object)m_fileProcessor == null)
            {
                return;
            }

            UserAccount userAccount = new UserAccount();

            userAccount.Name     = systemSettings.XDAUsername;
            userAccount.Password = systemSettings.XDAPassword;

            // Get the list of file extensions to be processed by openXDA
            List <string> filterPatterns = WebAPIHub.GetRecords <DataReader>(systemSettings.XDAAddress, "all", userAccount)
                                           .Select(reader => reader.FilePattern)
                                           .ToList();

            m_fileProcessor.Filter = string.Join(Path.PathSeparator.ToString(), filterPatterns);
        }
Beispiel #2
0
        // Loads system settings from the database.
        private string LoadSystemSettings()
        {
            List <Setting> settingList = WebAPIHub.GetRecords <Setting>(m_xdaAddress, "all", m_xdaUserAccount)
                                         .ToList();

            foreach (IGrouping <string, Setting> grouping in settingList.GroupBy(setting => setting.Name))
            {
                if (grouping.Count() > 1)
                {
                    Log.Warn($"Duplicate record for setting {grouping.Key} detected.");
                }
            }

            // Convert the Setting table to a dictionary
            Dictionary <string, string> settings = settingList
                                                   .DistinctBy(setting => setting.Name)
                                                   .ToDictionary(setting => setting.Name, setting => setting.Value, StringComparer.OrdinalIgnoreCase);

            // Add the configuration files settings if they are not
            // already explicitly specified in the Setting table
            if (!settings.ContainsKey("XDAAddress"))
            {
                settings.Add("XDAAddress", m_xdaAddress);
            }

            if (!settings.ContainsKey("XDAUsername"))
            {
                settings.Add("XDAUsername", m_xdaUserAccount.Name);
            }

            if (!settings.ContainsKey("XDAPassword"))
            {
                settings.Add("XDAPassword", m_xdaUserAccount.Password);
            }

            // Convert dictionary to a connection string and return it
            return(SystemSettings.ToConnectionString(settings));
        }