Exemplo n.º 1
0
        public virtual List <IEventConsumer> ResolveEventConsumers(IServiceProvider serviceProvider)
        {
            var applicationType = GetConsoleApplicationType();

            string template;
            var    eventConsumers  = new List <IEventConsumer>();
            var    templateManager = serviceProvider.GetRequiredService <TemplateManager>();
            var    logger          = serviceProvider.GetRequiredService <ITelemetryLogger>();

            if (applicationType == _normalizationAppType)
            {
                template = Configuration.GetSection("Template:DeviceContent").Value;
                var collector = ResolveEventCollector(serviceProvider);
                var options   = new NormalizationServiceOptions();
                Configuration.GetSection(NormalizationServiceOptions.Settings).Bind(options);
                IOptions <NormalizationServiceOptions> normalizationServiceOptions = Options.Create(options);
                var deviceDataNormalization = new Normalize.Processor(template, templateManager, collector, logger, normalizationServiceOptions);
                eventConsumers.Add(deviceDataNormalization);
            }
            else if (applicationType == _measurementToFhirAppType)
            {
                template = Configuration.GetSection("Template:FhirMapping").Value;
                var importService = serviceProvider.GetRequiredService <MeasurementFhirImportService>();
                var measurementCollectionToFhir = new MeasurementCollectionToFhir.Processor(template, templateManager, importService, logger);
                eventConsumers.Add(measurementCollectionToFhir);
            }
            else
            {
                throw new Exception($"Unable to determine template from application type {applicationType}");
            }

            return(eventConsumers);
        }
Exemplo n.º 2
0
        public static List <IEventConsumer> GetEventConsumers(IConfiguration config, string inputEventHub, ServiceProvider sp, BlobContainerClientFactory blobClientFactory, ITelemetryLogger logger)
        {
            var eventConsumers = new List <IEventConsumer>();

            var templateManager = GetMappingTemplateManager(config, blobClientFactory);

            if (inputEventHub == "devicedata")
            {
                var template = config.GetSection("Template:DeviceContent").Value;
                var deviceDataNormalization = new Normalize.Processor(template, templateManager, config, sp.GetRequiredService <IOptions <EventHubMeasurementCollectorOptions> >(), logger);
                eventConsumers.Add(deviceDataNormalization);
            }

            else if (inputEventHub == "normalizeddata")
            {
                var template = config.GetSection("Template:FhirMapping").Value;
                var measurementImportService  = ResolveMeasurementService(sp);
                var measurementToFhirConsumer = new MeasurementCollectionToFhir.Processor(template, templateManager, measurementImportService, logger);
                eventConsumers.Add(measurementToFhirConsumer);
            }

            if (config.GetSection("Console:Debug")?.Value == "true")
            {
                eventConsumers.Add(new EventPrinter());
            }

            return(eventConsumers);
        }
Exemplo n.º 3
0
        public static List <IEventConsumer> GetEventConsumers(IConfiguration config, string inputEventHub, ServiceProvider sp, ITelemetryLogger logger)
        {
            var eventConsumers  = new List <IEventConsumer>();
            var templateOptions = new TemplateOptions();

            config.GetSection(TemplateOptions.Settings).Bind(templateOptions);

            EnsureArg.IsNotNull(templateOptions);
            EnsureArg.IsNotNull(templateOptions.BlobContainerName);
            EnsureArg.IsNotNull(templateOptions.BlobStorageConnectionString);

            var storageManager = new StorageManager(
                templateOptions.BlobStorageConnectionString,
                templateOptions.BlobContainerName);

            var templateManager = new TemplateManager(storageManager);

            if (inputEventHub == "devicedata")
            {
                var template = config.GetSection("Template:DeviceContent").Value;
                var deviceDataNormalization = new Normalize.Processor(template, templateManager, config, sp.GetRequiredService <IOptions <EventHubMeasurementCollectorOptions> >(), logger);
                eventConsumers.Add(deviceDataNormalization);
            }

            else if (inputEventHub == "normalizeddata")
            {
                var template = config.GetSection("Template:FhirMapping").Value;
                var measurementImportService  = ResolveMeasurementService(sp);
                var measurementToFhirConsumer = new MeasurementCollectionToFhir.Processor(template, templateManager, measurementImportService, logger);
                eventConsumers.Add(measurementToFhirConsumer);
            }

            if (config.GetSection("Console:Debug")?.Value == "true")
            {
                eventConsumers.Add(new EventPrinter());
            }

            return(eventConsumers);
        }