コード例 #1
0
ファイル: JobBase.cs プロジェクト: saeedmaghdam/DashService
        public JobBase(ILogger logger, ConfigurationRoot config)
        {
            _logger = logger;

            var jobOptions = config.Get <JobOptions>();

            Name        = jobOptions.JobHeader?.Name ?? "Name not defined";
            Description = jobOptions.JobHeader?.Description ?? "Description not defined";
        }
コード例 #2
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            var config = ConfigurationRoot.Get <Configuration>();

            services.AddTransient <Configuration>((p) => config);

            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);

            // In production, the Angular files will be served from this directory
            services.AddSpaStaticFiles(configuration =>
            {
                configuration.RootPath = "ClientApp/dist/ClientApp";
            });

            services.AddAuthentication(AzureADDefaults.BearerAuthenticationScheme)
            .AddAzureADBearer(options => Configuration.Bind("AzureAd", options));
            services.AddCors(options =>
            {
                options.AddPolicy("AllowAllOrigins",
                                  builder =>
                {
                    builder.AllowAnyMethod().AllowAnyHeader().AllowAnyOrigin();
                });
            });

            services.AddTransient <IUserRepository, UserRepository>();
            services.AddTransient <IAddressRepository, AddressRepository>();
            services.AddTransient <IFeederRepository, FeederRepository>();
            services.AddTransient <ITransformerRepository, TransformerRepository>();

            services.AddTransient <ISendMessage, SendMessage>();
            services.AddTransient <IHttpClientWrapper, HttpclientWrapper>();

            services.AddTransient <Data.Repository.Interfaces.IUserRepository, Data.Repository.Implementations.UserRepository>();
            services.AddTransient <Data.Repository.Interfaces.IAddressRepository, Data.Repository.Implementations.AddressRepository>();
            services.AddTransient <Data.Repository.Interfaces.IFeederRepository, Data.Repository.Implementations.FeederRepository>();
            services.AddTransient <Data.Repository.Interfaces.ITransformerRepository, Data.Repository.Implementations.TransformerRepository>();
            services.AddTransient <Data.Repository.Interfaces.ISendMessage, Data.Repository.Implementations.SendMessage>();
        }
コード例 #3
0
        public Task StartAsync(CancellationToken cancellationToken)
        {
            do
            {
                if (cancellationToken.IsCancellationRequested)
                {
                    break;
                }

                //_logger.LogInformation(new EventId(0, "Service1"), "*************************************");
                _logger.LogInformation(new EventId(0, "Service1"), $"##################{_config.Get<JobOptions>()?.Done}###################");

                Task.Delay(3000, cancellationToken).Wait(cancellationToken);
            }while (true);

            return(Task.CompletedTask);
        }