예제 #1
0
 public SingleFileLoadMonitor(MultiFileLoadMonitor loadMonitor, MsDataFileUri dataFile)
 {
     _loadMonitor     = loadMonitor;
     _dataFile        = dataFile;
     _lastCancelCheck = DateTime.UtcNow; // Said to be 117x faster than Now and this is for a delta
     HasUI            = loadMonitor.HasUI;
 }
예제 #2
0
        /// <summary>
        /// Add the given files to the queue of files to load.
        /// </summary>
        public void Load(
            IList <DataFileReplicates> loadList,
            SrmDocument document,
            string documentFilePath,
            ChromatogramCache cacheRecalc,
            MultiFileLoadMonitor loadMonitor,
            Action <IList <FileLoadCompletionAccumulator.Completion> > complete)
        {
            lock (this)
            {
                // Find non-duplicate paths to load.
                var uniqueLoadList = new List <DataFileReplicates>();
                foreach (var loadItem in loadList)
                {
                    // Ignore a file that is already being loaded (or is queued for loading).
                    if (_loadingPaths.ContainsKey(loadItem.DataFile))
                    {
                        continue;
                    }
                    int idIndex = document.Id.GlobalIndex;
                    _loadingPaths.Add(loadItem.DataFile, idIndex);
                    uniqueLoadList.Add(loadItem);
                }

                if (uniqueLoadList.Count == 0)
                {
                    return;
                }

                int threadCount = GetOptimalThreadCount(_threadCountPreferred, uniqueLoadList.Count, _simultaneousFileOptions);
                _worker.RunAsync(threadCount, @"Load file");

                var accumulator = new FileLoadCompletionAccumulator(complete, threadCount, uniqueLoadList.Count);

                // Add new paths to queue.
                foreach (var loadItem in uniqueLoadList)
                {
                    var loadingStatus = new ChromatogramLoadingStatus(loadItem.DataFile, loadItem.ReplicateList);

                    ChangeStatus(s => s.Add(loadingStatus));

                    // Queue work item to load the file.
                    _worker.Add(new LoadInfo
                    {
                        Path             = loadItem.DataFile,
                        PartPath         = loadItem.PartPath,
                        Document         = document,
                        DocumentFilePath = documentFilePath,
                        CacheRecalc      = cacheRecalc,
                        Status           = loadingStatus,
                        LoadMonitor      = new SingleFileLoadMonitor(loadMonitor, loadItem.DataFile),
                        Complete         = accumulator.Complete
                    });
                }
            }
        }
예제 #3
0
        /// <summary>
        /// Add the given file to the queue of files to load.
        /// </summary>
        public void Load(
            IList <DataFileReplicates> loadList,
            SrmDocument document,
            string documentFilePath,
            ChromatogramCache cacheRecalc,
            MultiFileLoadMonitor loadMonitor,
            Action <ChromatogramCache, IProgressStatus> complete)
        {
            // This may be called on multiple background loader threads simultaneously, but QueueWorker can handle it.
            _worker.RunAsync(_threadCount, "Load file"); // Not L10N

            lock (this)
            {
                // Find non-duplicate paths to load.
                var uniqueLoadList = new List <DataFileReplicates>();
                foreach (var loadItem in loadList)
                {
                    // Ignore a file that is already being loaded (or is queued for loading).
                    if (_loadingPaths.ContainsKey(loadItem.DataFile))
                    {
                        continue;
                    }
                    int idIndex = document.Id.GlobalIndex;
                    _loadingPaths.Add(loadItem.DataFile, idIndex);
                    uniqueLoadList.Add(loadItem);
                }

                if (uniqueLoadList.Count == 0)
                {
                    return;
                }

                // Add new paths to queue.
                foreach (var loadItem in uniqueLoadList)
                {
                    var loadingStatus = new ChromatogramLoadingStatus(loadItem.DataFile, loadItem.ReplicateList);

                    ChangeStatus(s => s.Add(loadingStatus));

                    // Queue work item to load the file.
                    _worker.Add(new LoadInfo
                    {
                        Path             = loadItem.DataFile,
                        PartPath         = loadItem.PartPath,
                        Document         = document,
                        DocumentFilePath = documentFilePath,
                        CacheRecalc      = cacheRecalc,
                        Status           = loadingStatus,
                        LoadMonitor      = new SingleFileLoadMonitor(loadMonitor, loadItem.DataFile),
                        Complete         = complete
                    });
                }
            }
        }
예제 #4
0
        public bool CompleteDocument(SrmDocument document, MultiFileLoadMonitor loadMonitor)
        {
            // Refuse completion, if anything is still not final
            var status   = Status;
            var notFinal = status.ProgressList.Where(s => !s.IsFinal).ToArray();

            if (notFinal.Any())
            {
                // Write output in attempt to associate new hangs in nightly tests with the return false below
                Console.WriteLine(TextUtil.LineSeparate("*** Attempt to complete document with non-final status ***",                                                           // Not L10N
                                                        TextUtil.LineSeparate(notFinal.Select(s => string.Format("{0} {1}% - {2}", s.State, s.PercentComplete, s.FilePath))))); // Not L10N
                return(false);
            }

            if (status.ProgressList.Any())
            {
                loadMonitor.UpdateProgress(CompleteStatus());
            }
            ClearDocument(document);
            return(true);
        }
예제 #5
0
 public SingleFileLoadMonitor(MultiFileLoadMonitor loadMonitor, MsDataFileUri dataFile)
 {
     _loadMonitor = loadMonitor;
     _dataFile    = dataFile;
     HasUI        = loadMonitor.HasUI;
 }