public void OnPipelineStarted(object sender, PipelineStartedArgs args)
 {
     TaskWatcher.AddTask(Task.Run(() =>
     {
         _createdFolderStructures.Enqueue(args.PermStorageFolderStructure);
         SynchronizeDataFlows();
     }));
 }
 public async Task <PermStorageFolderStructure> CreateFolderStructure()
 {
     return(await Task.Run(async() =>
     {
         var structure = await _folderCreator.CreateFolderStructureForProjectionsAsync();
         TaskWatcher.AddTask(_folderCreator.CreateFoldersAsync(structure));
         return structure;
     }));
 }
Esempio n. 3
0
        public Task StartNewFileMonitorInNewFolderAsync(string path, string folderName)
        {
            return(Task.Run(async() =>
            {
                var folderStructure = await _projectionFolderCreator.CreateFolderStructure();

                var newFileMonitor = await Task.Run(() => _monitorFactory.CreateFileMonitor());
                var processor = StartPipeline(newFileMonitor, folderStructure);

                TaskWatcher.AddTask(Task.Run(() => PipelineStarted?.Invoke(this, new PipelineStartedArgs(folderStructure, processor))));

                Logger.Info(CultureInfo.CurrentCulture, "Starts file monitoring at path: {0}", path);
                TaskWatcher.AddTask(newFileMonitor.StartMonitoringAsync(path));
            }));
        }
Esempio n. 4
0
 public Task CreateFoldersAsync(PermStorageFolderStructure structure)
 {
     if (structure == null)
     {
         throw new ArgumentNullException(nameof(structure));
     }
     return(Task.Run(async() =>
     {
         Logger.Info("Creates target folders.");
         await _fileUtil.CreateFolderAsync(structure.BasePath);
         TaskWatcher.AddTask(_fileUtil.CreateFolderAsync(structure.XimPath));
         TaskWatcher.AddTask(_fileUtil.CreateFolderAsync(structure.MhaPath));
         TaskWatcher.AddTask(_fileUtil.CreateFolderAsync(structure.CtPath));
     }));
 }
Esempio n. 5
0
        private IReconstructionProcessor StartPipeline(IFileMonitor fileMonitor, PermStorageFolderStructure folderStructure)
        {
            BlockingCollection <TempProjectionInfo> queue1 = new BlockingCollection <TempProjectionInfo>();
            BlockingCollection <PermProjectionInfo> queue2 = new BlockingCollection <PermProjectionInfo>();

            var eventHandler = _projectionPipelineFactory.CreateFileMonitorListener(folderStructure, queue1);

            fileMonitor.Created  += eventHandler.OnNewFileDetected;
            fileMonitor.Finished += eventHandler.OnMonitorFinished;

            var copier = _projectionPipelineFactory.CreateProjectionCopier(queue1, queue2, folderStructure);

            TaskWatcher.AddTask(copier.StartCopyingFiles());

            var reconstructionProcessor = _projectionPipelineFactory.CreateReconstructionProcessor(queue2, folderStructure);

            TaskWatcher.AddTask(reconstructionProcessor.StartConsumingProjections());
            return(reconstructionProcessor);
        }
 private void PerformReconstruction(List <PermProjectionInfo> infos)
 {
     TaskWatcher.AddTask(Task.Run(() =>
     {
         lock (_lock)
         {
             try
             {
                 _rtkWrapper.PerformReconstruction(infos[0].FilePath, infos[1].FilePath,
                                                   infos[2].FilePath, _targetPath);
             }
             catch (Exception e)
             {
                 Logger.Fatal(e);
                 throw;
             }
         }
     }));
 }
Esempio n. 7
0
        public Task Execute(Application app, string patientId, string id, List <ICorrectedCTScanRetrievedCallback> callbacks)
        {
            return(Task.Run(async() =>
            {
                var patient = await GetPatient(app, patientId);
                var planSetup = GetPlanSetup(patient);
                var ctId = Guid.NewGuid().ToString();
                var cmdFilePath = CreateCmdFilePath(ctId);

                await _dicomMoveScriptGenerator.GenerateDicomMoveScript(patient, planSetup, cmdFilePath);

                await ExecuteCmdFile(cmdFilePath);
                var ctInfo = await CreateCtScanInfoFromFiles(ctId);

                CTAnonymizer.AnonymizeCT(ctInfo);

                foreach (var callback in callbacks)
                {
                    TaskWatcher.AddTask(Task.Run(() => callback.OnCorrectedCTScanRetrieved(ctInfo, id)));
                }
            }));
        }
Esempio n. 8
0
 private void HandleNewFolder(object sender, SearchDirectoryArgs args)
 {
     Logger.Info(CultureInfo.CurrentCulture, "New folder detected: {0}", args.FileName);
     TaskWatcher.AddTask(_subfolderController.StartNewFileMonitorInNewFolderAsync(args.Path, args.FileName));
 }
Esempio n. 9
0
 public void OnNewFileDetected(object sender, SearchDirectoryArgs args)
 {
     Logger.Info(CultureInfo.CurrentCulture, "New file detected: {0}", args.FileName);
     TaskWatcher.AddTask(_projectionEventHandler.HandleNewFile(args.Path));
 }