Beispiel #1
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);
        }
Beispiel #2
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));
        }
Beispiel #3
0
        public MapperSource([NotNull] GlobalOptions globalOptions, TriggerUpdatesFromMapperOptions cliOptions)
        {
            _cliOptions    = cliOptions;
            _globalOptions = globalOptions;

            FansiImplementations.Load();

            try
            {
                var objectFactory = new MicroserviceObjectFactory();
                _swapper = objectFactory.CreateInstance <ISwapIdentifiers>(globalOptions.IdentifierMapperOptions.SwapperType, typeof(ISwapIdentifiers).Assembly);
            }
            catch (System.Exception ex)
            {
                throw new System.Exception($"Could not create IdentifierMapper Swapper with SwapperType:{globalOptions.IdentifierMapperOptions?.SwapperType ?? "Null"}", ex);
            }

            if (_swapper == null)
            {
                throw new ArgumentException("No SwapperType has been specified in GlobalOptions.IdentifierMapperOptions");
            }
        }
Beispiel #4
0
        public void ApplyToContext(TestExecutionContext context)
        {
            FansiImplementations.Load();

            var connectionStrings = GetRelationalDatabaseConnectionStrings();
            var server            = connectionStrings.GetServer(_type);

            if (server.Exists())
            {
                return;
            }

            string msg = $"Could not connect to {_type} at '{server.Name}' with the provided connection options";

            if (FailIfUnavailable)
            {
                Assert.Fail(msg);
            }
            else
            {
                Assert.Ignore(msg);
            }
        }
Beispiel #5
0
 public DicomRelationalMapperHost(GlobalOptions globals)
     : base(globals)
 {
     FansiImplementations.Load();
 }
Beispiel #6
0
 public void OneTimeSetUp()
 {
     FansiImplementations.Load();
 }
Beispiel #7
0
        private static int OnParse(GlobalOptions globals, IsIdentifiableReviewerOptions opts)
        {
            FansiImplementations.Load();

            Deserializer  d = new Deserializer();
            List <Target> targets;

            try
            {
                var file = new FileInfo(opts.TargetsFile);

                if (!file.Exists)
                {
                    Console.Write($"Could not find '{file.FullName}'");
                    return(1);
                }

                var contents = File.ReadAllText(file.FullName);

                if (string.IsNullOrWhiteSpace(contents))
                {
                    Console.Write($"Targets file is empty '{file.FullName}'");
                    return(2);
                }

                targets = d.Deserialize <List <Target> >(contents);

                if (!targets.Any())
                {
                    Console.Write($"Targets file did not contain any valid targets '{file.FullName}'");
                    return(3);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine($"Error deserializing '{opts.TargetsFile}'");
                Console.WriteLine(e.Message);
                return(4);
            }

            if (opts.OnlyRules)
            {
                Console.WriteLine("Skipping Connection Tests");
            }
            else
            {
                Console.WriteLine("Running Connection Tests");

                try
                {
                    foreach (Target t in targets)
                    {
                        Console.WriteLine(t.Discover().Exists()
                            ? $"Successfully connected to {t.Name}"
                            : $"Failed to connect to {t.Name}");
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine("Error Validating Targets");
                    Console.WriteLine(e.ToString());
                    return(10);
                }
            }

            //for updater try to match the ProblemValue words
            var updater = new RowUpdater(new FileInfo(opts.RedList))
            {
                RulesOnly    = opts.OnlyRules,
                RulesFactory = new MatchProblemValuesPatternFactory()
            };

            //for Ignorer match the whole string
            var ignorer = new IgnoreRuleGenerator(new FileInfo(opts.IgnoreList));

            try
            {
                if (!string.IsNullOrWhiteSpace(opts.UnattendedOutputPath))
                {
                    //run unattended
                    if (targets.Count != 1)
                    {
                        throw new Exception("Unattended requires a single entry in Targets");
                    }

                    var unattended = new UnattendedReviewer(opts, targets.Single(), ignorer, updater);
                    return(unattended.Run());
                }
                else
                {
                    Console.WriteLine("Press any key to launch GUI");
                    Console.ReadKey();

                    //run interactive
                    Application.Init();
                    var mainWindow = new MainWindow(opts, ignorer, updater);
                    Application.Top.Add(mainWindow);
                    Application.Run();
                    return(0);
                }
            }
            catch (Exception e)
            {
                Console.Write(e.Message);

                int tries = 5;
                while (Application.Top != null && tries-- > 0)
                {
                    try
                    {
                        Application.RequestStop();
                    }
                    catch (Exception)
                    {
                        Console.WriteLine("Failed to terminate GUI on crash");
                    }
                }

                return(99);
            }
        }
Beispiel #8
0
 public UpdateValuesHost([NotNull] GlobalOptions globals, IRabbitMqAdapter rabbitMqAdapter = null, bool threaded = false) : base(globals, rabbitMqAdapter, threaded)
 {
     FansiImplementations.Load();
 }