コード例 #1
0
        public IsIdentifiableHost(
            [NotNull] GlobalOptions globals,
            [NotNull] IsIdentifiableServiceOptions serviceOpts
            )
            : base(globals)
        {
            _consumerOptions = globals.IsIdentifiableOptions;

            string classifierTypename = globals.IsIdentifiableOptions.ClassifierType;
            string dataDirectory      = globals.IsIdentifiableOptions.DataDirectory;

            if (string.IsNullOrWhiteSpace(classifierTypename))
            {
                throw new ArgumentException("No IClassifier has been set in options.  Enter a value for ClassifierType", nameof(globals));
            }
            if (string.IsNullOrWhiteSpace(dataDirectory))
            {
                throw new ArgumentException("A DataDirectory must be set", nameof(globals));
            }

            var objectFactory = new MicroserviceObjectFactory();
            var classifier    = objectFactory.CreateInstance <IClassifier>(classifierTypename, typeof(IClassifier).Assembly, new DirectoryInfo(dataDirectory), serviceOpts);

            if (classifier == null)
            {
                throw new TypeLoadException($"Could not find IClassifier Type { classifierTypename }");
            }

            _producerModel = RabbitMqAdapter.SetupProducer(globals.IsIdentifiableOptions.IsIdentifiableProducerOptions, isBatch: false);

            Consumer = new IsIdentifiableQueueConsumer(_producerModel, globals.FileSystemOptions.FileSystemRoot, globals.FileSystemOptions.ExtractRoot, classifier);
        }
コード例 #2
0
        /// <summary>
        /// Starts up service and begins listening with the <see cref="Consumer"/>
        /// </summary>
        public override void Start()
        {
            FansiImplementations.Load();

            IRDMPPlatformRepositoryServiceLocator repositoryLocator = Globals.RDMPOptions.GetRepositoryProvider();

            var startup = new Startup(new EnvironmentInfo("netcoreapp2.2"), repositoryLocator);

            var toMemory = new ToMemoryCheckNotifier();

            startup.DoStartup(toMemory);

            foreach (CheckEventArgs args in toMemory.Messages.Where(m => m.Result == CheckResult.Fail))
            {
                Logger.Log(LogLevel.Warn, args.Ex, args.Message);
            }

            _fileMessageProducer = RabbitMqAdapter.SetupProducer(Globals.CohortExtractorOptions.ExtractFilesProducerOptions, isBatch: true);
            IProducerModel fileMessageInfoProducer = RabbitMqAdapter.SetupProducer(Globals.CohortExtractorOptions.ExtractFilesInfoProducerOptions, isBatch: false);

            InitializeExtractionSources(repositoryLocator);

            Consumer = new ExtractionRequestQueueConsumer(Globals.CohortExtractorOptions, _fulfiller, _auditor, _pathResolver, _fileMessageProducer, fileMessageInfoProducer);

            RabbitMqAdapter.StartConsumer(_consumerOptions, Consumer, isSolo: false);
        }
コード例 #3
0
        public override void Start()
        {
            Logger.Info("Starting dead letter consumer");

            Guid consumerId = RabbitMqAdapter.StartConsumer(Globals.DeadLetterReprocessorOptions.DeadLetterConsumerOptions, _deadLetterQueueConsumer, true);

            do
            {
                Thread.Sleep(1000);
            } while (_deadLetterQueueConsumer.MessagesInQueue());


            Logger.Info("DLQ empty, stopping consumer");
            RabbitMqAdapter.StopConsumer(consumerId, Smi.Common.RabbitMqAdapter.DefaultOperationTimeout);

            if (_cliOptions.StoreOnly)
            {
                Logger.Debug("StoreOnly specified, stopping");
                Stop("DLQ empty");
            }
            else
            {
                Logger.Info("Republishing messages");
                _deadLetterRepublisher.RepublishMessages(_cliOptions.ReprocessFromQueue, _cliOptions.FlushMessages);

                Logger.Info("Total messages republished: " + _deadLetterRepublisher.TotalRepublished);
                Stop("Reprocess completed");
            }
        }
コード例 #4
0
        public void SendHeader()
        {
            var o = new GlobalOptionsFactory().Load();

            var consumerOptions = new ConsumerOptions();

            consumerOptions.QueueName        = "TEST.HeaderPreservationTest_Read1";
            consumerOptions.AutoAck          = false;
            consumerOptions.QoSPrefetchCount = 1;

            TestConsumer consumer;

            using (var tester = new MicroserviceTester(o.RabbitOptions, consumerOptions))
            {
                var header = new MessageHeader();
                header.MessageGuid = Guid.Parse("5afce68f-c270-4bf3-b327-756f6038bb76");
                header.Parents     = new[] { Guid.Parse("12345678-c270-4bf3-b327-756f6038bb76"), Guid.Parse("87654321-c270-4bf3-b327-756f6038bb76") };

                tester.SendMessage(consumerOptions, header, new TestMessage()
                {
                    Message = "hi"
                });

                consumer = new TestConsumer();
                var a = new RabbitMqAdapter(o.RabbitOptions.CreateConnectionFactory(), "TestHost");
                a.StartConsumer(consumerOptions, consumer);

                TestTimelineAwaiter awaiter = new TestTimelineAwaiter();
                awaiter.Await(() => consumer.Failed || consumer.Passed, "timed out", 5000);
                a.Shutdown(RabbitMqAdapter.DefaultOperationTimeout);
            }

            Assert.IsTrue(consumer.Passed);
        }
コード例 #5
0
        public override void Start()
        {
            IRDMPPlatformRepositoryServiceLocator repositoryLocator = Globals.RDMPOptions.GetRepositoryProvider();

            Consumer = new UpdateValuesQueueConsumer(Globals.UpdateValuesOptions, repositoryLocator.CatalogueRepository);

            RabbitMqAdapter.StartConsumer(Globals.UpdateValuesOptions, Consumer, isSolo: false);
        }
コード例 #6
0
        public DeadLetterReprocessorHost(GlobalOptions globals, DeadLetterReprocessorCliOptions cliOptions)
            : base(globals)
        {
            var deadLetterStore = new MongoDeadLetterStore(globals.MongoDatabases.DeadLetterStoreOptions, Globals.RabbitOptions.RabbitMqVirtualHost);

            _deadLetterQueueConsumer = new DeadLetterQueueConsumer(deadLetterStore, globals.DeadLetterReprocessorOptions);
            _deadLetterRepublisher   = new DeadLetterRepublisher(deadLetterStore, RabbitMqAdapter.GetModel("DeadLetterRepublisher"));

            _cliOptions = cliOptions;
        }
コード例 #7
0
        public void SetUpSuite()
        {
            TestLogger.Setup();
            GlobalOptions = new GlobalOptionsFactory().Load();

            var testConnectionFactory = new ConnectionFactory
            {
                HostName    = GlobalOptions.RabbitOptions.RabbitMqHostName,
                Port        = GlobalOptions.RabbitOptions.RabbitMqHostPort,
                VirtualHost = GlobalOptions.RabbitOptions.RabbitMqVirtualHost,
                UserName    = GlobalOptions.RabbitOptions.RabbitMqUserName,
                Password    = GlobalOptions.RabbitOptions.RabbitMqPassword
            };

            _testConnection = testConnectionFactory.CreateConnection("TestConnection");

            TestModel = _testConnection.CreateModel();
            TestModel.ConfirmSelect();

            IBasicProperties props = TestModel.CreateBasicProperties();

            props.ContentEncoding = "UTF-8";
            props.ContentType     = "application/json";
            props.Persistent      = true;

            TestModel.ExchangeDeclare(TestDlExchangeName, "topic", true);
            TestModel.QueueDeclare(TestDlQueueName, true, false, false);
            TestModel.QueueBind(TestDlQueueName, TestDlExchangeName, RabbitMqAdapter.RabbitMqRoutingKey_MatchAnything);

            var queueProps = new Dictionary <string, object>
            {
                { "x-dead-letter-exchange", TestDlExchangeName }
            };

            TestModel.ExchangeDeclare(RejectExchangeName, "direct", true);
            TestModel.QueueDeclare(RejectQueueName, true, false, false, queueProps);
            TestModel.QueueBind(RejectQueueName, RejectExchangeName, TestRoutingKey);

            TestModel.ExchangeDeclare(GlobalOptions.RabbitOptions.RabbitMqControlExchangeName, "topic", true);
            TestModel.ExchangeDeclare(GlobalOptions.RabbitOptions.FatalLoggingExchange, "direct", true);

            TestProducer = new ProducerModel(RejectExchangeName, TestModel, props);

            _messageRejectorOptions = new ConsumerOptions
            {
                QueueName        = RejectQueueName,
                QoSPrefetchCount = 1,
                AutoAck          = false
            };

            PurgeQueues();

            _testAdapter = new RabbitMqAdapter(GlobalOptions.RabbitOptions.CreateConnectionFactory(), "TestHost");
        }
コード例 #8
0
        /// <summary>
        /// Start processing messages
        /// </summary>
        public override void Start()
        {
            Logger.Info("Starting consumers");

            foreach (IMongoDbPopulatorMessageConsumer consumer in Consumers)
            {
                RabbitMqAdapter.StartConsumer(consumer.ConsumerOptions, consumer, isSolo: false);
            }

            Logger.Info("Consumers successfully started");
        }
コード例 #9
0
        public MicroserviceTester(RabbitOptions rabbitOptions, params ConsumerOptions[] peopleYouWantToSendMessagesTo)
        {
            CleanUpAfterTest = true;

            _adapter = new RabbitMqAdapter(rabbitOptions.CreateConnectionFactory(), "TestHost");

            Factory = new ConnectionFactory
            {
                HostName    = rabbitOptions.RabbitMqHostName,
                Port        = rabbitOptions.RabbitMqHostPort,
                VirtualHost = rabbitOptions.RabbitMqVirtualHost,
                UserName    = rabbitOptions.RabbitMqUserName,
                Password    = rabbitOptions.RabbitMqPassword
            };

            using (var con = Factory.CreateConnection())
                using (var model = con.CreateModel())
                {
                    //get rid of old exchanges
                    model.ExchangeDelete(rabbitOptions.RabbitMqControlExchangeName);
                    //create a new one
                    model.ExchangeDeclare(rabbitOptions.RabbitMqControlExchangeName, ExchangeType.Topic, true);

                    //setup a sender chanel for each of the consumers you want to test sending messages to
                    foreach (ConsumerOptions consumer in peopleYouWantToSendMessagesTo)
                    {
                        if (!consumer.QueueName.Contains("TEST."))
                        {
                            consumer.QueueName = consumer.QueueName.Insert(0, "TEST.");
                        }

                        var exchangeName = consumer.QueueName.Replace("Queue", "Exchange");

                        //terminate any old queues / exchanges
                        model.ExchangeDelete(exchangeName);
                        model.QueueDelete(consumer.QueueName);
                        _declaredExchanges.Add(exchangeName);

                        //Create a binding between the exchange and the queue
                        model.ExchangeDeclare(exchangeName, ExchangeType.Direct, true); //durable seems to be needed because RabbitMQAdapter wants it?
                        model.QueueDeclare(consumer.QueueName, true, false, false);     //shared with other users
                        model.QueueBind(consumer.QueueName, exchangeName, "");
                        _declaredQueues.Add(consumer.QueueName);

                        //Create a producer which can send to the
                        var producerOptions = new ProducerOptions
                        {
                            ExchangeName = exchangeName
                        };

                        _sendToConsumers.Add(consumer, _adapter.SetupProducer(producerOptions, true));
                    }
                }
        }
コード例 #10
0
        public override void Start()
        {
            Logger.Debug("Starting host");

            _jobWatcher.Start();

            // TODO(rkm 2020-03-02) Once this is transactional, we can have one "master" service which actually does the job checking
            RabbitMqAdapter.StartConsumer(Globals.CohortPackagerOptions.ExtractRequestInfoOptions, _requestInfoMessageConsumer, isSolo: true);
            RabbitMqAdapter.StartConsumer(Globals.CohortPackagerOptions.FileCollectionInfoOptions, _fileCollectionMessageConsumer, isSolo: true);
            RabbitMqAdapter.StartConsumer(Globals.CohortPackagerOptions.NoVerifyStatusOptions, _anonFailedMessageConsumer, isSolo: true);
            RabbitMqAdapter.StartConsumer(Globals.CohortPackagerOptions.VerificationStatusOptions, _anonVerificationMessageConsumer, isSolo: true);
        }
コード例 #11
0
        public IdentifierMapperHost(GlobalOptions options, ISwapIdentifiers swapper = null)
            : base(options)
        {
            _consumerOptions = options.IdentifierMapperOptions;

            FansiImplementations.Load();

            if (swapper == null)
            {
                Logger.Info("Not passed a swapper, creating one of type " + options.IdentifierMapperOptions.SwapperType);
                _swapper = ObjectFactory.CreateInstance <ISwapIdentifiers>(options.IdentifierMapperOptions.SwapperType, typeof(ISwapIdentifiers).Assembly);
            }
            else
            {
                _swapper = swapper;
            }

            // If we want to use a Redis server to cache answers then wrap the mapper in a Redis caching swapper
            if (!string.IsNullOrWhiteSpace(options.IdentifierMapperOptions.RedisConnectionString))
            {
                try
                {
                    _swapper = new RedisSwapper(options.IdentifierMapperOptions.RedisConnectionString, _swapper);
                }
                catch (RedisConnectionException e)
                {
                    // NOTE(rkm 2020-03-30) Log & throw! I hate this, but if we don't log here using NLog, then the exception will bubble-up
                    //                      and only be printed to STDERR instead of to the log file and may be lost
                    Logger.Error(e, "Could not connect to Redis");
                    throw;
                }
            }

            _swapper.Setup(_consumerOptions);
            Logger.Info($"Swapper of type {_swapper.GetType()} created");

            // Batching now handled implicitly as backlog demands
            _producerModel = RabbitMqAdapter.SetupProducer(options.IdentifierMapperOptions.AnonImagesProducerOptions, isBatch: true);

            Consumer = new IdentifierMapperQueueConsumer(_producerModel, _swapper)
            {
                AllowRegexMatching = options.IdentifierMapperOptions.AllowRegexMatching
            };

            // Add our event handler for control messages
            AddControlHandler(new IdentifierMapperControlMessageHandler(_swapper));
        }
コード例 #12
0
        public void RabbitAvailable()
        {
            var options       = new GlobalOptionsFactory().Load();
            var rabbitOptions = options.RabbitOptions;

            Console.WriteLine("Checking the following configuration:" + Environment.NewLine + rabbitOptions);
            try
            {
                var adapter = new RabbitMqAdapter(rabbitOptions.CreateConnectionFactory(), "TestHost");
            }
            catch (Exception)
            {
                Assert.Fail("Could not access Rabbit MQ Server");
            }

            Assert.Pass();
        }
コード例 #13
0
        public DicomTagReaderHost(GlobalOptions options)
            : base(options)
        {
            if (!Directory.Exists(options.FileSystemOptions.FileSystemRoot))
            {
                throw new ArgumentException("Cannot find the FileSystemRoot specified in the given MicroservicesOptions (" + options.FileSystemOptions.FileSystemRoot + ")");
            }

            Logger.Debug("Creating DicomTagReaderHost with FileSystemRoot: " + options.FileSystemOptions.FileSystemRoot);
            Logger.Debug("NackIfAnyFileErrors option set to " + options.DicomTagReaderOptions.NackIfAnyFileErrors);

            IProducerModel seriesProducerModel;
            IProducerModel imageProducerModel;

            try
            {
                Logger.Debug("Creating seriesProducerModel with ExchangeName: " + options.DicomTagReaderOptions.SeriesProducerOptions.ExchangeName);
                seriesProducerModel = RabbitMqAdapter.SetupProducer(options.DicomTagReaderOptions.SeriesProducerOptions, true);

                Logger.Debug("Creating imageProducerModel with ExchangeName: " + options.DicomTagReaderOptions.ImageProducerOptions.ExchangeName);
                imageProducerModel = RabbitMqAdapter.SetupProducer(options.DicomTagReaderOptions.ImageProducerOptions, true);
            }
            catch (Exception e)
            {
                throw new ApplicationException("Couldn't create series producer model on startup", e);
            }

            Logger.Debug("Creating AccessionDirectoryMessageConsumer");

            switch (options.DicomTagReaderOptions.TagProcessorMode)
            {
            case TagProcessorMode.Serial:
                _tagReader = new SerialTagReader(options.DicomTagReaderOptions, options.FileSystemOptions, seriesProducerModel, imageProducerModel, new FileSystem());
                break;

            case TagProcessorMode.Parallel:
                _tagReader = new ParallelTagReader(options.DicomTagReaderOptions, options.FileSystemOptions, seriesProducerModel, imageProducerModel, new FileSystem());
                break;

            default:
                throw new ArgumentException($"No case for mode {options.DicomTagReaderOptions.TagProcessorMode}");
            }

            // Setup our consumer
            AccessionDirectoryMessageConsumer = new DicomTagReaderConsumer(_tagReader, options);
        }
コード例 #14
0
        public DicomReprocessorHost(GlobalOptions options, DicomReprocessorCliOptions cliOptions)
            : base(options)
        {
            string key = cliOptions.ReprocessingRoutingKey;

            if (string.IsNullOrWhiteSpace(key))
            {
                throw new ArgumentException("ReprocessingRoutingKey");
            }

            // Set the initial sleep time
            Globals.DicomReprocessorOptions.SleepTime = TimeSpan.FromMilliseconds(cliOptions.SleepTimeMs);

            IProducerModel reprocessingProducerModel = RabbitMqAdapter.SetupProducer(options.DicomReprocessorOptions.ReprocessingProducerOptions, true);

            Logger.Info("Documents will be reprocessed to " +
                        options.DicomReprocessorOptions.ReprocessingProducerOptions.ExchangeName + " on vhost " +
                        options.RabbitOptions.RabbitMqVirtualHost + " with routing key \"" + key + "\"");

            if (!string.IsNullOrWhiteSpace(cliOptions.QueryFile))
            {
                _queryString = File.ReadAllText(cliOptions.QueryFile);
            }

            //TODO Make this into a CreateInstance<> call
            switch (options.DicomReprocessorOptions.ProcessingMode)
            {
            case ProcessingMode.TagPromotion:
                _processor = new TagPromotionProcessor(options.DicomReprocessorOptions, reprocessingProducerModel, key);
                break;

            case ProcessingMode.ImageReprocessing:
                _processor = new DicomFileProcessor(options.DicomReprocessorOptions, reprocessingProducerModel, key);
                break;

            default:
                throw new ArgumentException("ProcessingMode " + options.DicomReprocessorOptions.ProcessingMode + " not supported");
            }

            _mongoReader = new MongoDbReader(options.MongoDatabases.DicomStoreOptions, cliOptions, HostProcessName + "-" + HostProcessID);

            AddControlHandler(new DicomReprocessorControlMessageHandler(Globals.DicomReprocessorOptions));
        }
コード例 #15
0
        public override void Stop(string reason)
        {
            if (_consumerId != Guid.Empty)
            {
                RabbitMqAdapter.StopConsumer(_consumerId, Smi.Common.RabbitMqAdapter.DefaultOperationTimeout);
            }
            try
            {
                // Wait for any unconfirmed messages before calling stop
                _producerModel.WaitForConfirms();
            }
            catch (AlreadyClosedException)
            {
            }

            _swapper?.LogProgress(Logger, LogLevel.Info);

            base.Stop(reason);
        }
コード例 #16
0
        //TODO Should most of this not be in the constructor?
        public override void Start()
        {
            IRDMPPlatformRepositoryServiceLocator repositoryLocator = Globals.RDMPOptions.GetRepositoryProvider();

            Logger.Info("About to run Startup");

            var startup = new Startup(new EnvironmentInfo("netcoreapp2.2"), repositoryLocator);

            startup.DatabaseFound += Startup_DatabaseFound;

            var toMemory = new ToMemoryCheckNotifier();

            startup.DoStartup(toMemory);

            foreach (CheckEventArgs args in toMemory.Messages)
            {
                Logger.Log(args.ToLogLevel(), args.Ex, args.Message);
            }

            Logger.Info("Startup Completed");

            var lmd = repositoryLocator.CatalogueRepository.GetObjectByID <LoadMetadata>(Globals.DicomRelationalMapperOptions.LoadMetadataId);

            Type databaseNamerType = repositoryLocator.CatalogueRepository.MEF.GetType(Globals.DicomRelationalMapperOptions.DatabaseNamerType);

            string liveDatabaseName = lmd.GetDistinctLiveDatabaseServer().GetCurrentDatabase().GetRuntimeName();

            var instance = ObjectFactory.CreateInstance <INameDatabasesAndTablesDuringLoads>(databaseNamerType, liveDatabaseName, Globals.DicomRelationalMapperOptions.Guid);


            Consumer = new DicomRelationalMapperQueueConsumer(repositoryLocator,
                                                              lmd,
                                                              instance,
                                                              Globals.DicomRelationalMapperOptions)
            {
                RunChecks = Globals.DicomRelationalMapperOptions.RunChecks
            };

            RabbitMqAdapter.StartConsumer(Globals.DicomRelationalMapperOptions, Consumer, isSolo: false);
        }
コード例 #17
0
        public FileCopierHost(
            [NotNull] GlobalOptions options,
            [CanBeNull] IFileSystem fileSystem = null
            )
            : base(
                options
                )
        {
            Logger.Debug("Creating FileCopierHost with FileSystemRoot: " + Globals.FileSystemOptions.FileSystemRoot);

            IProducerModel copyStatusProducerModel = RabbitMqAdapter.SetupProducer(Globals.FileCopierOptions.CopyStatusProducerOptions, isBatch: false);

            var fileCopier = new ExtractionFileCopier(
                Globals.FileCopierOptions,
                copyStatusProducerModel,
                Globals.FileSystemOptions.FileSystemRoot,
                Globals.FileSystemOptions.ExtractRoot,
                fileSystem
                );

            _consumer = new FileCopyQueueConsumer(fileCopier);
        }
コード例 #18
0
        public void SetUp()
        {
            _testOptions = new GlobalOptionsFactory().Load();

            _testProducerOptions = new ProducerOptions
            {
                ExchangeName = "TEST.TestExchange"
            };

            _testConsumerOptions = new ConsumerOptions
            {
                QueueName        = "TEST.TestQueue",
                QoSPrefetchCount = 1,
                AutoAck          = false
            };

            _mockConsumer = Mock.Of <Consumer <IMessage> >();

            _testAdapter = new RabbitMqAdapter(_testOptions.RabbitOptions.CreateConnectionFactory(), "RabbitMqAdapterTests");

            _tester = new MicroserviceTester(_testOptions.RabbitOptions, _testConsumerOptions);
        }
コード例 #19
0
 public TriggerUpdatesHost(GlobalOptions options, ITriggerUpdatesSource source, IRabbitMqAdapter rabbitMqAdapter = null)
     : base(options, rabbitMqAdapter)
 {
     this._source = source;
     _producer    = RabbitMqAdapter.SetupProducer(options.TriggerUpdatesOptions, isBatch: false);
 }
コード例 #20
0
 public override void Start()
 {
     // Start the consumer to await callbacks when messages arrive
     RabbitMqAdapter.StartConsumer(Globals.DicomTagReaderOptions, AccessionDirectoryMessageConsumer, isSolo: false);
     Logger.Debug("Consumer started");
 }
コード例 #21
0
 public override void Start()
 {
     RabbitMqAdapter.StartConsumer(Globals.FileCopierOptions, _consumer, isSolo: false);
 }
コード例 #22
0
 public void TestShutdownThrowsOnTimeout()
 {
     _testAdapter.StartConsumer(_testConsumerOptions, _mockConsumer);
     Assert.Throws <ApplicationException>(() => _testAdapter.Shutdown(TimeSpan.Zero));
     _testAdapter = null;
 }
コード例 #23
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="cliOptions">Common microservices options.  Must contain details for an message exchange labelled as "accessionDirectories"</param>
        /// <param name="globals">Configuration settings for the program</param>
        public DicomDirectoryProcessorHost(GlobalOptions globals, DicomDirectoryProcessorCliOptions cliOptions)
            : base(globals)
        {
            _cliOptions = cliOptions;

            if (!cliOptions.DirectoryFormat.ToLower().Equals("list"))
            {
                // TODO(rkm 2020-02-12) I think we want to check this regardless of the mode
                // (bp 2020-02-13) By not doing this check on list means that the list of paths is not required to be in PACS and can be imported from anywhere
                if (!Directory.Exists(globals.FileSystemOptions.FileSystemRoot))
                {
                    throw new ArgumentException("Cannot find the FileSystemRoot specified in the given MicroservicesOptions (" + globals.FileSystemOptions.FileSystemRoot + ")");
                }

                if (!cliOptions.ToProcessDir.Exists)
                {
                    throw new ArgumentException("Could not find directory " + cliOptions.ToProcessDir.FullName);
                }

                if (!cliOptions.ToProcessDir.FullName.StartsWith(globals.FileSystemOptions.FileSystemRoot, true, CultureInfo.CurrentCulture))
                {
                    throw new ArgumentException("Directory parameter (" + cliOptions.ToProcessDir.FullName + ") must be below the FileSystemRoot (" + globals.FileSystemOptions.FileSystemRoot + ")");
                }
            }
            else
            {
                if (!File.Exists(cliOptions.ToProcessDir.FullName))
                {
                    throw new ArgumentException("Could not find accession directory list file (" + cliOptions.ToProcessDir.FullName + ")");
                }

                if (!Path.GetExtension(cliOptions.ToProcessDir.FullName).Equals(".csv"))
                {
                    throw new ArgumentException("When in 'list' mode, path to accession directory file of format .csv expected (" + cliOptions.ToProcessDir.FullName + ")");
                }
            }

            if (cliOptions.DirectoryFormat.ToLower().Equals("pacs"))
            {
                Logger.Info("Creating PACS directory finder");

                _ddf = new PacsDirectoryFinder(globals.FileSystemOptions.FileSystemRoot,
                                               globals.FileSystemOptions.DicomSearchPattern, RabbitMqAdapter.SetupProducer(globals.ProcessDirectoryOptions.AccessionDirectoryProducerOptions, isBatch: false));
            }
            else if (cliOptions.DirectoryFormat.ToLower().Equals("list"))
            {
                Logger.Info("Creating accession directory lister");

                _ddf = new AccessionDirectoryLister(globals.FileSystemOptions.FileSystemRoot,
                                                    globals.FileSystemOptions.DicomSearchPattern, RabbitMqAdapter.SetupProducer(globals.ProcessDirectoryOptions.AccessionDirectoryProducerOptions, isBatch: false));
            }
            else if (cliOptions.DirectoryFormat.ToLower().Equals("default"))
            {
                Logger.Info("Creating basic directory finder");

                _ddf = new BasicDicomDirectoryFinder(globals.FileSystemOptions.FileSystemRoot,
                                                     globals.FileSystemOptions.DicomSearchPattern, RabbitMqAdapter.SetupProducer(globals.ProcessDirectoryOptions.AccessionDirectoryProducerOptions, isBatch: false));
            }
            else if (cliOptions.DirectoryFormat.ToLower().Equals("zips"))
            {
                Logger.Info("Creating zip directory finder");

                _ddf = new ZipDicomDirectoryFinder(globals.FileSystemOptions.FileSystemRoot,
                                                   globals.FileSystemOptions.DicomSearchPattern, RabbitMqAdapter.SetupProducer(globals.ProcessDirectoryOptions.AccessionDirectoryProducerOptions, isBatch: false));
            }
            else
            {
                throw new ArgumentException("Could not match directory format " + cliOptions.DirectoryFormat + " to an directory scan implementation");
            }
        }
コード例 #24
0
 public override void Start()
 {
     _consumerId = RabbitMqAdapter.StartConsumer(_consumerOptions, Consumer, isSolo: false);
 }