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);
        }
Ejemplo n.º 2
0
        public bool IsIntegrateAllChecked(IAutoQCLogger logger)
        {
            try
            {
                using (var stream = new FileStream(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.LogError("Exception reading file {0}. Exception details are: ", SkylineFilePath);
                logger.LogException(e);
                return(false);
            }
            logger.LogError("Skyline documents with QC results should have the\"Integrate all\" setting, under the \"Settings\" menu, checked. Please save the Skyline document with \"Integrate all\" checked and restart AutoQC.");
            return(false);
        }
        private bool ImportFile(DoWorkEventArgs e, ImportContext importContext, bool addToReimportQueueOnFailure = true)
        {
            var filePath = importContext.GetCurrentFile();

            try
            {
                _fileWatcher.WaitForFileReady(filePath);
            }
            catch (FileStatusException fse)
            {
                if (!FileStatusException.DOES_NOT_EXIST.Equals(fse.Message))
                {
                    _logger.LogError("File does not exist: {0}.", filePath);
                }
                else
                {
                    _logger.LogException(fse);
                }
                // Put the file in the re-import queue
                if (addToReimportQueueOnFailure)
                {
                    _logger.Log("Adding file to re-import queue: {0}", filePath);
                    _fileWatcher.AddToReimportQueue(filePath);
                }
                return(false);
            }

            if (_worker.CancellationPending)
            {
                e.Result = CANCELLED;
                return(false);
            }

            if (!ProcessOneFile(importContext))
            {
                if (addToReimportQueueOnFailure)
                {
                    _logger.Log("Adding file to re-import queue: {0}", filePath);
                    _fileWatcher.AddToReimportQueue(filePath);
                }
                return(false);
            }

            return(true);
        }
Ejemplo n.º 4
0
        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[2]);
                        }
                        catch (Exception e)
                        {
                            logger.LogError("Error parsing acquired time from Skyline report: {0}", reportFile);
                            logger.LogException(e);
                        }
                        if (acqDate.CompareTo(lastAcq) == 1)
                        {
                            lastAcq = acqDate;
                        }
                    }
                }
            }

            return(lastAcq);
        }
Ejemplo n.º 5
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;
                    }
                }
            }
        }
Ejemplo n.º 6
0
 void OnFileWatcherError(ErrorEventArgs e)
 {
     _logger.LogError("There was an error watching the folder. {0}", e.GetException().Message);
     _folderAvailable = false;
 }
Ejemplo n.º 7
0
        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[2]);
                        }
                        catch (Exception e)
                        {
                            logger.LogError("Error parsing acquired time from Skyline report: {0}", reportFile);
                            logger.LogException(e);
                        }
                        if (acqDate.CompareTo(lastAcq) == 1)
                        {
                            lastAcq = acqDate;
                        }
                    }
                }
            }

            return lastAcq;
        }
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 bool IsIntegrateAllChecked(IAutoQCLogger logger)
        {
            try
            {
                using (var stream = new FileStream(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.LogError("Exception reading file {0}. Exception details are: ", SkylineFilePath);
                logger.LogException(e);
                return false;
            }
            logger.LogError("Skyline documents with QC results should have the\"Integrate all\" setting, under the \"Settings\" menu, checked. Please save the Skyline document with \"Integrate all\" checked and restart AutoQC.");
            return false;
        }
Ejemplo n.º 10
0
 public void LogError(string message, params Object[] args)
 {
     Logger.LogError(message, args);
 }
Ejemplo n.º 11
0
 private void LogError(string message, params Object[] args)
 {
     _logger.LogError(message, 1, 1, args);
 }