Ejemplo n.º 1
0
        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("Cound not get path to the Skyline report file");
                return(false);
            }
            var skyrFile   = Path.Combine(exeDir, "FileAcquisitionTime.skyr");
            var reportFile = Path.Combine(SkylineFileDir, "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}""",
                    SkylineFilePath, skyrFile, "AcquisitionTimes", reportFile);

            var procInfo = new ProcessInfo(AutoQCForm.SkylineRunnerPath, AutoQCForm.SKYLINE_RUNNER, args, args);

            if (!processControl.RunProcess(procInfo))
            {
                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
            {
                LastAcquiredFileDate = GetLastAcquiredFileDate(reportFile, logger);
                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.LogError("Exception reading file {0}. Exception details are: ", reportFile);
                logger.LogException(e);
                return(false);
            }
            return(true);
        }
        private void TryReimportOldFiles(DoWorkEventArgs e, bool forceImport)
        {
            var reimportQueue = _fileWatcher.GetFilesToReimport();
            var failed        = new List <RawFile>();

            while (reimportQueue.Count > 0)
            {
                var file = reimportQueue.Dequeue();
                if (forceImport || file.TryReimport())
                {
                    var importContext = new ImportContext(file.FilePath)
                    {
                        TotalImportCount = _totalImportCount
                    };
                    _logger.Log("Attempting to re-import file {0}.", file.FilePath);
                    if (!ImportFile(e, importContext, false))
                    {
                        _logger.Log("Adding file to re-import queue: {0}", file.FilePath);
                        file.LastImportTime = DateTime.Now;
                        failed.Add(file);
                    }
                }
                else
                {
                    failed.Add(file); // We are going to try to re-import later
                }
            }

            foreach (var file in failed)
            {
                _fileWatcher.AddToReimportQueue(file);
            }
        }
Ejemplo n.º 3
0
        private void TryReimportOldFiles(DoWorkEventArgs e, bool forceImport)
        {
            var reimportQueue = _fileWatcher.GetFilesToReimport();
            var failed        = new List <RawFile>();

            while (reimportQueue.Count > 0)
            {
                var file = reimportQueue.Dequeue();
                if (forceImport || file.TryReimport())
                {
                    var importContext = new ImportContext(file.FilePath)
                    {
                        TotalImportCount = _totalImportCount
                    };
                    _logger.Log("Attempting to re-import {0}.", file.FilePath);
                    if (!ImportFile(e, importContext, false))
                    {
                        if (forceImport)
                        {
                            // forceImport is true when we attempt to import failed files after successfully importing a newer file.
                            // If the file still fails to import we will not add it back to the re-import queue.
                            _logger.Log("{0} failed to import successfully. Skipping...", file.FilePath);
                        }
                        else
                        {
                            if (_fileWatcher.RawDataExists(file.FilePath))
                            {
                                _logger.Log("Adding {0} to re-import queue.", file.FilePath);
                                file.LastImportTime = DateTime.Now;
                                failed.Add(file);
                            }
                            else
                            {
                                _logger.Log("{0} no longer exists. Skipping...", file.FilePath);
                            }
                        }
                    }
                }
                else
                {
                    failed.Add(file); // We are going to try to re-import later
                }
            }

            foreach (var file in failed)
            {
                if (_fileWatcher.RawDataExists(file.FilePath))
                {
                    _fileWatcher.AddToReimportQueue(file);
                }
            }
        }
Ejemplo n.º 4
0
        public void Restart(DateTime timeDisconnected)
        {
            if (_cancelled)
            {
                _logger.Log("FileSystemWatcher cancelled. ");
                return;
            }

            _logger.Log("Reconnected. Re-initializing FileSystemWatcher...");

            var filter = _fileWatcher.Filter;
            var path   = _fileWatcher.Path;

            _fileWatcher.Dispose();
            _fileWatcher        = null;
            _fileWatcher        = InitFileSystemWatcher();
            _fileWatcher.Filter = filter;
            _fileWatcher.Path   = path;

            _logger.Log("Looking for raw data added to directory while the folder was unavailable.");

            var files = GetExistingFiles();

            _folderAvailable = true;

            _fileWatcher.EnableRaisingEvents = true;

            foreach (var file in files)
            {
                var fileInfo = new FileInfo(file);

                if (fileInfo.CreationTime <= timeDisconnected)
                {
                    continue;
                }

                _logger.Log("Adding {0}.", fileInfo.Name);
                _dataFiles.Enqueue(file);
            }
        }
Ejemplo n.º 5
0
        public void EnsureDrive(string path)
        {
            if (Directory.Exists(path))
            {
                ReadNetworkDriveProperties(path);
                return;
            }

            var timeDisconnected = DateTime.Now.AddMilliseconds(-(AutoQCBackgroundWorker.WAIT_FOR_NEW_FILE));

            _fileSystemWatcher.Pause();
            if (!string.IsNullOrWhiteSpace(_networkDrivePath))
            {
                _logger.Log("Waiting to reconnect to mapped network drive " + path);
                // Attempt to reconnect to a mapped network drive
                var process = Process.Start("net.exe", @"USE " + _networkDriveLetter + " " + _networkDrivePath);
                if (process != null)
                {
                    process.WaitForExit();
                }
            }
            _fileSystemWatcher.Restart(timeDisconnected);
        }
Ejemplo n.º 6
0
        public void PingPanoramaServer()
        {
            var panoramaServerUri = _panoramaSettingsTab.PanoramaServerUri;

            if (_panoramaSettingsTab.IsSelected() && panoramaServerUri != null)
            {
                var panoramaClient = new WebPanoramaClient(panoramaServerUri);
                try
                {
                    var success = panoramaClient.PingPanorama(_panoramaSettingsTab.Settings.PanoramaFolder,
                                                              _panoramaSettingsTab.Settings.PanoramaUserEmail,
                                                              _panoramaSettingsTab.DecryptPassword(_panoramaSettingsTab.Settings.PanoramaPassword
                                                                                                   ));

                    if (success && _status != 1)
                    {
                        _logger.Log("Successfully pinged Panorama server.");
                        _status = 1;
                    }
                    if (!success && _status != 2)
                    {
                        _logger.LogErrorToFile("Error pinging Panorama server.  Please confirm that " + panoramaServerUri +
                                               " is running LabKey Server 16.1 or higher.");
                        _status = 2;
                    }
                }
                catch (Exception ex)
                {
                    if (_status != 2)
                    {
                        _logger.LogError("Error pinging Panorama server " + panoramaServerUri);
                        _logger.LogException(ex);
                        _status = 2;
                    }
                }
            }
        }
 void FileAdded(FileSystemEventArgs e)
 {
     _logger.Log("File {0} added to directory.", e.Name);
     _dataFiles.Enqueue(e.FullPath);
 }
Ejemplo n.º 8
0
        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("Cound not get path to the Skyline report file");
                return false;

            }
            var skyrFile = Path.Combine(exeDir, "FileAcquisitionTime.skyr");
            var reportFile = Path.Combine(SkylineFileDir, "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}""",
                    SkylineFilePath, skyrFile, "AcquisitionTimes", reportFile);

            var procInfo = new ProcessInfo(AutoQCForm.SkylineRunnerPath, AutoQCForm.SKYLINE_RUNNER, args, args);
            if (!processControl.RunProcess(procInfo))
            {
                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
            {
                LastAcquiredFileDate = GetLastAcquiredFileDate(reportFile, logger);
                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.LogError("Exception reading file {0}. Exception details are: ", reportFile);
                logger.LogException(e);
                return false;
            }
            return true;
        }
Ejemplo n.º 9
0
 public void Log(string message, params Object[] args)
 {
     Logger.Log(message, args);
 }
Ejemplo n.º 10
0
 private void Log(string message, params Object[] args)
 {
     _logger.Log(message, args);
 }