public void Init(AutoQcConfig config) { _configName = config.Name; var mainSettings = config.MainSettings; _dataFiles = new ConcurrentQueue <string>(); _retryFiles = new Queue <RawFile>(); _retryFilePaths = new HashSet <string>(); _fileStatusChecker = GetFileStatusChecker(mainSettings); _fileWatcher.EnableRaisingEvents = false; if (mainSettings.IncludeSubfolders) { _fileWatcher.IncludeSubdirectories = true; _includeSubfolders = true; } _fileWatcher.NotifyFilter = NotifyFilters.FileName | NotifyFilters.DirectoryName | NotifyFilters.CreationTime; _instrument = mainSettings.InstrumentType; _dataInDirectories = IsDataInDirectories(_instrument); _fileWatcher.Filter = GetFileFilter(mainSettings.InstrumentType); _fileWatcher.Path = mainSettings.FolderToWatch; _fileFilter = mainSettings.QcFileFilter; _acquisitionTimeSetting = mainSettings.AcquisitionTime; _driveInfo = new DriveInfo(_fileWatcher.Path); }
protected bool Equals(AutoQcConfig other) { return(string.Equals(Name, other.Name) && IsEnabled == other.IsEnabled && Equals(MainSettings, other.MainSettings) && Equals(PanoramaSettings, other.PanoramaSettings)); }
private int RemoveConfiguration(AutoQcConfig config) { Program.LogInfo(string.Format("Removing configuration \"{0}\"", config.Name)); var lvi = listViewConfigs.FindItemWithText(config.Name); var lviIndex = lvi == null ? -1 : lvi.Index; if (lvi != null) { listViewConfigs.Items.Remove(lvi); } comboConfigs.Items.Remove(config.Name); // On the log tab ConfigRunner configRunner; _configRunners.TryGetValue(config.Name, out configRunner); if (configRunner != null) { configRunner.Stop(); } _configRunners.Remove(config.Name); var configList = Settings.Default.ConfigList; configList.Remove(config); Settings.Default.Save(); UpdateLabelVisibility(); return(lviIndex); }
public void AddConfiguration(AutoQcConfig config, int index) { Program.LogInfo(string.Format("Adding configuration \"{0}\"", config.Name)); var lvi = new ListViewItem(config.Name); lvi.Checked = config.IsEnabled; lvi.UseItemStyleForSubItems = false; // So that we can change the color for sub-items. lvi.SubItems.Add(config.User); lvi.SubItems.Add(config.Created.ToShortDateString()); lvi.SubItems.Add(ConfigRunner.RunnerStatus.Stopped.ToString()); if (index == -1) { listViewConfigs.Items.Add(lvi); } else { listViewConfigs.Items.Insert(index, lvi); } comboConfigs.Items.Add(config.Name); // Add a ConfigRunner for this configuration var configRunner = new ConfigRunner(config, this); _configRunners.Add(config.Name, configRunner); var configList = Settings.Default.ConfigList; if (!configList.Contains(config)) { configList.Add(config); Settings.Default.Save(); } UpdateLabelVisibility(); }
public void UpdatePanoramaServerUrl(AutoQcConfig config) { var configList = Settings.Default.ConfigList; if (configList.Contains(config)) { Settings.Default.Save(); } }
public ConfigRunner(AutoQcConfig config, IMainUiControl uiControl) { _runnerStatus = RunnerStatus.Stopped; Config = config; _uiControl = uiControl; CreateLogger(); }
public void UpdateConfiguration(AutoQcConfig oldConfig, AutoQcConfig newConfig) { var index = -1; if (_configRunners.ContainsKey(oldConfig.Name)) { index = RemoveConfiguration(oldConfig); } AddConfiguration(newConfig, index); }
public static AutoQcConfig GetDefault() { var config = new AutoQcConfig { MainSettings = MainSettings.GetDefault(), PanoramaSettings = PanoramaSettings.GetDefault() }; return(config); }
private AutoQcConfig GetConfigFromUi() { AutoQcConfig config = new AutoQcConfig(); config.Name = textConfigName.Text; config.MainSettings = GetMainSettingsFromUI(); config.PanoramaSettings = GetPanoramaSettingsFromUI(); config.User = config.PanoramaSettings.PanoramaUserEmail; return(config); }
private bool IsUniqueConfigName(AutoQcConfig newConfig) { // Make sure that the configuration name is unique var savedConfig = _mainControl.GetConfig(newConfig.Name); if (savedConfig != null && !ReferenceEquals(newConfig, savedConfig)) { return(false); } return(true); }
public void Init(AutoQcConfig config) { _configName = config.Name; var mainSettings = config.MainSettings; _dataFiles = new ConcurrentQueue <string>(); _retryFiles = new Queue <RawFile>(); _fileStatusChecker = GetFileStatusChecker(mainSettings); _fileWatcher.EnableRaisingEvents = false; if (mainSettings.IncludeSubfolders) { _fileWatcher.IncludeSubdirectories = true; _includeSubfolders = true; } _fileWatcher.NotifyFilter = NotifyFilters.FileName | NotifyFilters.DirectoryName | NotifyFilters.CreationTime; _instrument = mainSettings.InstrumentType; _dataInDirectories = IsDataInDirectories(_instrument); _fileWatcher.Filter = GetFileFilter(mainSettings.InstrumentType); _fileWatcher.Path = mainSettings.FolderToWatch; _fileFilter = mainSettings.QcFileFilter; _acquisitionTimeSetting = mainSettings.AcquisitionTime; _driveInfo = new DriveInfo { DriveLetter = NetworkDriveUtil.GetDriveLetter(_fileWatcher.Path) }; if (_driveInfo.DriveLetter == null) { throw new FileWatcherException(string.Format("Unable to get drive letter for path {0}", _fileWatcher.Path)); } try { _driveInfo.NetworkDrivePath = NetworkDriveUtil.ReadNetworkDrivePath(_driveInfo.DriveLetter); } catch (FileWatcherException) { throw; } catch (Exception e) { throw new FileWatcherException(string.Format("Unable to read network drive properties for {0}", _driveInfo.DriveLetter), e); } }
private bool ValidateConfigName(AutoQcConfig newConfig) { if (string.IsNullOrEmpty(_config.Name) || !_config.Name.Equals(newConfig.Name)) { // Make sure that the configuration name is unique. if (!IsUniqueConfigName(newConfig)) { ShowErrorDialog(Resources.AutoQcConfigForm_ValidateConfigName_A_configuration_with_this_name_already_exists_); return(false); } } return(true); }
private bool ValidateConfigName(AutoQcConfig newConfig) { if (string.IsNullOrEmpty(_config.Name) || !_config.Name.Equals(newConfig.Name)) { // Make sure that the configuration name is unique. if (!IsUniqueConfigName(newConfig)) { ShowErrorDialog("A configuration with this name already exists."); return(false); } } return(true); }
private bool ValidateConfig(AutoQcConfig newConfig) { try { newConfig.Validate(); } catch (ArgumentException e) { ShowErrorDialog(e.Message); return(false); } return(true); }
private void ChangeConfigState(AutoQcConfig config) { ConfigRunner configRunner; _configRunners.TryGetValue(config.Name, out configRunner); if (configRunner == null) { return; } if (config.IsEnabled) { Program.LogInfo(string.Format("Starting configuration \"{0}\"", config.Name)); StartConfigRunner(configRunner); } else { Program.LogInfo(string.Format("Stopping configuration \"{0}\"", config.Name)); configRunner.Stop(); } }
public AutoQcConfigForm(AutoQcConfig config, ConfigRunner configRunner, IMainUiControl mainControl) { _mainControl = mainControl; _config = config; InitializeComponent(); // Initialize file filter combobox var filterOptions = new object[] { AllFileFilter.NAME, StartsWithFilter.NAME, EndsWithFilter.NAME, ContainsFilter.NAME, RegexFilter.NAME }; comboBoxFileFilter.Items.AddRange(filterOptions); textConfigName.Text = _config.Name; SetUIMainSettings(_config.MainSettings); SetUIPanoramaSettings(_config.PanoramaSettings); if (configRunner != null && configRunner.IsBusy()) { lblConfigRunning.Show(); btnSaveConfig.Hide(); btnCancelConfig.Hide(); btnOkConfig.Show(); } else { lblConfigRunning.Hide(); btnSaveConfig.Show(); btnCancelConfig.Show(); btnOkConfig.Hide(); } }
public void AddConfiguration(AutoQcConfig config) { AddConfiguration(config, -1); }
public AutoQcConfigForm(IMainUiControl mainControl) : this(AutoQcConfig.GetDefault(), null, mainControl) { }
private void btnImport_Click(object sender, EventArgs e) { var dialog = new OpenFileDialog(); dialog.Filter = "XML Files(*.xml)|*.xml"; if (dialog.ShowDialog(this) != DialogResult.OK) { return; } var filePath = dialog.FileName; List <AutoQcConfig> readConfigs = new List <AutoQcConfig>(); try { using (var stream = new FileStream(filePath, FileMode.Open)) { using (var reader = XmlReader.Create(stream)) { while (reader.IsStartElement()) { if (reader.Name == "autoqc_config") { AutoQcConfig config = AutoQcConfig.Deserialize(reader); readConfigs.Add(config); } reader.Read(); } } } } catch (Exception) { MessageBox.Show(string.Format("Could not import configurations from file {0}", filePath), "Import Configurations Error", MessageBoxButtons.OK); return; } if (readConfigs.Count == 0) { MessageBox.Show(string.Format("Could not import configurations from file {0}", filePath), "Import Configurations", MessageBoxButtons.OK); } var validationErrors = new List <string>(); var duplicateConfigs = new List <string>(); var numAdded = 0; foreach (AutoQcConfig config in readConfigs) { // Make sure that the configuration name is unique if (GetConfig(config.Name) != null) { // If a configuration with the same name already exists, don't add it duplicateConfigs.Add(config.Name); continue; } try { config.Validate(); } catch (Exception ex) { validationErrors.Add(string.Format("\"{0}\" Error: {1}", config.Name, ex.Message)); continue; } config.IsEnabled = false; AddConfiguration(config); numAdded++; } var message = new StringBuilder("Number of configurations imported: "); message.Append(numAdded).Append(Environment.NewLine); if (duplicateConfigs.Count > 0) { message.Append("The following configurations already exist and were not imported:") .Append(Environment.NewLine); foreach (var name in duplicateConfigs) { message.Append("\"").Append(name).Append("\"").Append(Environment.NewLine); } } if (validationErrors.Count > 0) { message.Append("The following configurations could not be validated and were not imported:") .Append(Environment.NewLine); foreach (var error in validationErrors) { message.Append(error).Append(Environment.NewLine); } } MessageBox.Show(message.ToString(), "Import Configurations", MessageBoxButtons.OK); }
private void btnImport_Click(object sender, EventArgs e) { var dialog = new OpenFileDialog(); dialog.Filter = XML_FILES_FILTER; if (dialog.ShowDialog(this) != DialogResult.OK) { return; } var filePath = dialog.FileName; List <AutoQcConfig> readConfigs = new List <AutoQcConfig>(); try { using (var stream = new FileStream(filePath, FileMode.Open)) { using (var reader = XmlReader.Create(stream)) { while (reader.Read()) { if (reader.IsStartElement() && reader.Name.Equals(@"autoqc_config")) { AutoQcConfig config = AutoQcConfig.Deserialize(reader); readConfigs.Add(config); } } } } } catch (Exception ex) { ShowErrorWithExceptionDialog(Resources.MainForm_btnImport_Click_Import_Configurations_Error, string.Format(Resources.MainForm_btnImport_Click_Could_not_import_configurations_from_file__0_, filePath), ex); return; } if (readConfigs.Count == 0) { ShowWarningDialog(Resources.MainForm_btnImport_Click_Import_Configurations, string.Format(Resources.MainForm_btnImport_Click_No_configurations_were_found_in_file__0__, filePath)); return; } var validationErrors = new List <string>(); var duplicateConfigs = new List <string>(); var numAdded = 0; foreach (AutoQcConfig config in readConfigs) { // Make sure that the configuration name is unique if (GetConfig(config.Name) != null) { // If a configuration with the same name already exists, don't add it duplicateConfigs.Add(config.Name); continue; } try { config.Validate(); } catch (Exception ex) { validationErrors.Add(string.Format("\"{0}\" Error: {1}", config.Name, ex.Message)); continue; } config.IsEnabled = false; AddConfiguration(config); numAdded++; } var message = new StringBuilder(Resources.MainForm_btnImport_Click_Number_of_configurations_imported__); message.Append(numAdded).Append(Environment.NewLine); if (duplicateConfigs.Count > 0) { message.Append(Resources.MainForm_btnImport_Click_The_following_configurations_already_exist_and_were_not_imported_) .Append(Environment.NewLine); foreach (var name in duplicateConfigs) { message.Append("\"").Append(name).Append("\"").Append(Environment.NewLine); } } if (validationErrors.Count > 0) { message.Append(Resources.MainForm_btnImport_Click_The_following_configurations_could_not_be_validated_and_were_not_imported_) .Append(Environment.NewLine); foreach (var error in validationErrors) { message.Append(error).Append(Environment.NewLine); } } ShowInfoDialog(Resources.MainForm_btnImport_Click_Import_Configurations, message.ToString()); }