コード例 #1
0
ファイル: Application.cs プロジェクト: skalitin/Armadillo
        public void StartMonitoring()
        {
            try
            {
                var builder = new ConfigurationBuilder()
                              .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
                              .AddUserSecrets("28e6f711-a4c4-4cef-9e37-50ebfee35f91");
                var configuration = builder.Build();

                var dataProviderName = configuration["SubcaseDataProvider"];
                _logger.LogInformation($"Data provider: {dataProviderName}");

                ISubcaseDataProdiver dataProvider = null;
                if (String.Equals("Random", dataProviderName, StringComparison.OrdinalIgnoreCase))
                {
                    _logger.LogInformation("Using random data provider");
                    dataProvider = new RandomDataProvider();
                }
                else if (String.Equals("Report", dataProviderName, StringComparison.OrdinalIgnoreCase))
                {
                    _logger.LogInformation("Using SSRS report data provider");
                    var reportServerClient = _serviceProvider.GetService <IReportServerClient>();
                    dataProvider = new ReportServerDataProvider(_loggerFactory.CreateLogger("ReportServerDataProvider"), reportServerClient);
                }
                else
                {
                    throw new ApplicationException($"Unsupported data provider: {dataProviderName}");
                }

                var endpointUri = configuration["CosmosDB:EndpointUri"];
                var primaryKey  = configuration["CosmosDB:PrimaryKey"];

                _logger.LogInformation("Using database endpoint {0}", endpointUri);
                var documentClient = new DocumentClient(new Uri(endpointUri), primaryKey);

                var uploader = new Uploader(dataProvider, documentClient, _loggerFactory.CreateLogger("Uploader"));

                _timer.Elapsed += (sender, e) =>
                {
                    _logger.LogInformation("Update started...");

                    uploader.UpdateAsync().Wait();
                    _logger.LogInformation("Update completed");
                };

                _timer.AutoReset = true;
                _timer.Enabled   = true;
                _timer.Start();

                _logger.LogInformation($"Periodic update started at every {_timer.Interval/60000} min.");

                // await TestReadSubcasesAsync();
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.ToString());
            }
        }
コード例 #2
0
 public void SetUp()
 {
     _mockReportClient = new Mock <IReportServerClient>();
     _dataProvider     = new ReportServerDataProvider(_logger, _mockReportClient.Object);
 }