Exemplo n.º 1
0
        private static int OnParse(GlobalOptions globals, DicomReprocessorCliOptions opts)
        {
            var bootstrapper = new MicroserviceHostBootstrapper(() => new DicomReprocessorHost(globals, opts));
            int ret          = bootstrapper.Main();

            return(ret);
        }
Exemplo n.º 2
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));
        }
Exemplo n.º 3
0
        public MongoDbReader(MongoDbOptions mongoOptions, DicomReprocessorCliOptions reprocessorOptions, string appId)
        {
            _logger = LogManager.GetLogger(GetType().Name);

            MongoClient mongoClient = MongoClientHelpers.GetMongoClient(mongoOptions, appId);

            if (string.IsNullOrWhiteSpace(reprocessorOptions.SourceCollection))
            {
                throw new ArgumentException("SourceCollection");
            }

            _collection    = mongoClient.GetDatabase(mongoOptions.DatabaseName).GetCollection <BsonDocument>(reprocessorOptions.SourceCollection);
            _collNamespace = mongoOptions.DatabaseName + "." + reprocessorOptions.SourceCollection;

            // if specified, batch size must be gt 1:
            // https://docs.mongodb.com/manual/reference/method/cursor.batchSize/
            if (reprocessorOptions.MongoDbBatchSize > 1)
            {
                _findOptionsBase.BatchSize = reprocessorOptions.MongoDbBatchSize;
            }

            _autoRun = reprocessorOptions.AutoRun;
        }