private bool ImportFile(DoWorkEventArgs e, ImportContext importContext, bool addToReimportQueueOnFailure = true) { var filePath = importContext.GetCurrentFile(); try { _fileWatcher.WaitForFileReady(filePath); } catch (FileStatusException fse) { if (fse.Message.Contains(FileStatusException.DOES_NOT_EXIST)) { _logger.LogError("{0} does not exist.", GetFilePathForLog(filePath)); } else { _logger.LogException(fse, "Error getting status of file {0}.", GetFilePathForLog(filePath)); } // Put the file in the re-import queue if (addToReimportQueueOnFailure) { AddToReimportQueue(filePath); } return(false); } if (_worker.CancellationPending) { e.Result = CANCELLED; return(false); } _panoramaUploadError = false; var docImported = ProcessOneFile(importContext); if (!docImported) { if (addToReimportQueueOnFailure) { AddToReimportQueue(filePath); } } return(docImported); }
private void WaitForNetworkPath(DateTime startTime) { var available = Directory.Exists(_driveInfo.Path); if (available) { if (_fileWatcherError != null) { // There may have been a network interruption before call to CheckDrive() RestartFileWatcher(); } return; } if (_fileWatcherError == null) { // Path is unavailable. Disable raising events _fileWatcher.EnableRaisingEvents = false; } _configRunner.ChangeStatus(ConfigRunner.RunnerStatus.Disconnected); while (true) { _logger.LogError("Watched folder is not available: {0}. Waiting...", _driveInfo.Path); // keep trying every 1 minute for a hour or until the network share is available again. Thread.Sleep(TimeSpan.FromMinutes(1)); available = Directory.Exists(_driveInfo.Path); if (!available) { if (startTime.AddHours(1) < DateTime.Now) { throw new FileWatcherException(string.Format("Watched folder has been unavailable for > 1 hour for configuration \"{1}\". {0}", _driveInfo, _configName)); } } else { _logger.Log("Watched folder is available: {0}.", _driveInfo.Path); if (_configRunner.IsDisconnected()) { _configRunner.ChangeStatus(ConfigRunner.RunnerStatus.Running); } RestartFileWatcher(); break; } } }
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 void LogError(string message, params object[] args) { _logger.LogError(message, args); }