private async void ViewLog(string configName) { ConfigRunner runner; _configRunners.TryGetValue(configName, out runner); var logger = runner != null?runner.GetLogger() : null; if (_currentAutoQcLogger != null && logger == _currentAutoQcLogger) { return; } foreach (var configRunner in _configRunners.Values) { configRunner.DisableUiLogging(); // Disable logging on all configurations first } textBoxLog.Clear(); // clear any existing log if (runner == null) { MessageBox.Show(string.Format("No configuration found for name \"{0}\"", configName), "", MessageBoxButtons.OK); return; } if (logger == null) { MessageBox.Show("Log for this configuration is not yet initialized.", "", MessageBoxButtons.OK); return; } _currentAutoQcLogger = logger; runner.EnableUiLogging(); var logFile = logger.GetFile(); if (!File.Exists(logFile)) { MessageBox.Show(string.Format("Log file does not exist. {0}.", logFile), "", MessageBoxButtons.OK); return; } try { await Task.Run(() => { // Read the log contents and display in the log tab. logger.DisplayLog(); }); } catch (Exception ex) { ShowErrorDialog("Error Reading Log", ex.Message); } ScrollToLogEnd(); }
public AutoQCFileSystemWatcher(IAutoQcLogger logger, IConfigRunner configRunner) { _fileWatcher = InitFileSystemWatcher(); _logger = logger; _configRunner = configRunner; }
private void CreateLogger() { // Initialize logging to log in the folder with the Skyline document. var skylineFileDir = Config.MainSettings.SkylineFileDir; var logFile = Path.Combine(skylineFileDir, "AutoQC.log"); _logger = new AutoQcLogger(logFile); }
public static bool EnsureDrive(DriveInfo driveInfo, IAutoQcLogger logger, out bool reconnected, string configName) { // Do we need a lock here? Don't want two configurations, on the same mapped (disconnected) drive, // to try to re-map the drive. lock (LOCK) { // Program.LogInfo(string.Format("Checking drive {0} for config {1}", driveInfo, configName)); // TODO - debug if (IsDriveAvailable(driveInfo, configName)) { reconnected = false; return(true); // Drive root already exists. } if (!driveInfo.IsNetworkDrive()) { Program.LogInfo(string.Format("Unable to connect to drive {0}. Config: {1}", driveInfo.DriveLetter, configName)); reconnected = false; return(false); } // TODO: Do we need to unmount first? if (driveInfo.IsNetworkDrive()) { logger.LogProgramError(string.Format( "Lost connection to network drive. Attempting to reconnect to {0}. Config: {1}", driveInfo, configName)); // Attempt to reconnect to a mapped network drive var process = Process.Start("net.exe", @"USE " + driveInfo.DriveLetter + " " + driveInfo.NetworkDrivePath); if (process != null) { process.WaitForExit(); } Program.LogInfo(string.Format("After attempting to reconnect.. {0}. Config: {1}", driveInfo.DriveLetter, configName)); if (IsDriveAvailable(driveInfo, configName)) { reconnected = true; logger.Log( string.Format( "Network drive was temporarily disconnected. Successfully remapped network drive {0}. Config: {1}", driveInfo, configName)); return(true); } } Program.LogInfo(string.Format("Unable to connect to network drive {0}. Config: {1}", driveInfo.DriveLetter, configName)); reconnected = false; return(false); } }
public bool ReadLastAcquiredFileDate(IAutoQcLogger logger, IProcessControl processControl) { logger.Log("Getting the acquisition date on the newest file imported into the Skyline document.", 1, 0); var exeDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); if (exeDir == null) { logger.LogError("Could not get path to the Skyline report file"); return(false); } var skyrFile = Path.Combine(exeDir, "FileAcquisitionTime.skyr"); var reportFile = Path.Combine(GetConfigDir(), "AcquisitionTimes.csv"); // Export a report from the given Skyline file var args = string.Format( @" --in=""{0}"" --report-conflict-resolution=overwrite --report-add=""{1}"" --report-name=""{2}"" --report-file=""{3}""", Config.MainSettings.SkylineFilePath, skyrFile, "AcquisitionTimes", reportFile); var procInfo = new ProcessInfo(MainForm.GetExePath(), args, args); if (processControl.RunProcess(procInfo) == ProcStatus.Error) { logger.LogError("Error getting the last acquired file date from the Skyline document."); return(false); } // Read the exported report to get the last AcquiredTime for imported results in the Skyline doucment. if (!File.Exists(reportFile)) { logger.LogError("Could not find report outout {0}", reportFile); return(false); } try { var lastAcquiredFileDate = GetLastAcquiredFileDate(reportFile, logger); Config.MainSettings.LastAcquiredFileDate = lastAcquiredFileDate; if (!lastAcquiredFileDate.Equals(DateTime.MinValue)) { logger.Log("The most recent acquisition date in the Skyline document is {0}", lastAcquiredFileDate); } else { logger.Log("The Skyline document does not have any imported results."); } } catch (IOException e) { logger.LogException(e, "Error reading file {0}.", reportFile); return(false); } return(true); }
public bool IsIntegrateAllChecked(IAutoQcLogger logger, MainSettings mainSettings) { try { using (var stream = new FileStream(mainSettings.SkylineFilePath, FileMode.Open)) { using (XmlReader reader = XmlReader.Create(stream)) { reader.MoveToContent(); var done = false; while (reader.Read() && !done) { switch (reader.NodeType) { case XmlNodeType.Element: if (reader.Name == "transition_integration") { if (reader.MoveToAttribute("integrate_all")) { bool integrateAll; Boolean.TryParse(reader.Value, out integrateAll); return(integrateAll); } done = true; } break; case XmlNodeType.EndElement: if (reader.Name.Equals("transition_settings")) // We have come too far { done = true; } break; } } } } } catch (Exception e) { logger.LogException(e, "Error reading file {0}.", mainSettings.SkylineFilePath); return(false); } logger.LogError("\"Integrate all\" is not checked for the Skyline document. This setting is under the \"Settings\" menu in Skyline, and should be checked for " + " documents with QC results."); return(false); }
private async void ViewLog(string configName) { ConfigRunner runner; _configRunners.TryGetValue(configName, out runner); var logger = runner != null?runner.GetLogger() : null; if (_currentAutoQcLogger != null && logger == _currentAutoQcLogger) { return; } foreach (var configRunner in _configRunners.Values) { configRunner.DisableUiLogging(); // Disable logging on all configurations first } textBoxLog.Clear(); // clear any existing log if (runner == null) { ShowWarningDialog(string.Empty, string.Format(Resources.MainForm_ViewLog_No_configuration_found_for_name___0__, configName)); return; } if (logger == null) { ShowWarningDialog(string.Empty, Resources.MainForm_ViewLog_Log_for_this_configuration_is_not_yet_initialized_); return; } _currentAutoQcLogger = logger; runner.EnableUiLogging(); try { await Task.Run(() => { // Read the log contents and display in the log tab. logger.DisplayLog(); }); } catch (Exception ex) { ShowErrorWithExceptionDialog(Resources.MainForm_ViewLog_Error_Reading_Log, ex.Message, ex); } ScrollToLogEnd(); }
private static DateTime GetLastAcquiredFileDate(string reportFile, IAutoQcLogger logger) { var lastAcq = new DateTime(); using (var reader = new StreamReader(reportFile)) { string line; // Read the column headers var first = true; while ((line = reader.ReadLine()) != null) { if (first) { first = false; continue; } var values = line.Split(','); if (values.Length == 3) { DateTime acqDate = new DateTime(); try { acqDate = DateTime.Parse(values[1]); // Acquired time, not modified time. } catch (Exception e) { logger.LogException(e, "Error parsing acquired time from Skyline report: {0}", reportFile); } if (acqDate.CompareTo(lastAcq) == 1) { lastAcq = acqDate; } } } } return(lastAcq); }
public ProcessRunner(IAutoQcLogger logger) { _logger = logger; }
public PanoramaPinger(PanoramaSettings panoramaSettings, IAutoQcLogger logger) { _panoramaSettings = panoramaSettings; _logger = logger; }
public MockProcessRunner(IAutoQcLogger logger) : base(logger) { }
public TestProcessControl(IAutoQcLogger logger) { _logger = logger; }
private void CreateLogger() { var logFile = Path.Combine(GetConfigDir(), "AutoQC.log"); _logger = new AutoQcLogger(logFile, GetConfigName()); }
public AutoQCFileSystemWatcher(IAutoQcLogger logger) { _fileWatcher = InitFileSystemWatcher(); _logger = logger; }