Ignore:
Timestamp:
02/14/21 17:54:35 (18 months ago)
Author:
Dimitar Slezenkovski <dslezenkovski@…>
Branches:
master
Children:
472dd7e
Parents:
6e6f04b
Message:

Add cron job for updating data, with Quartz.NET

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Farmatiko/Startup.cs

    r6e6f04b rf554983  
    1818using FarmatikoServices.Infrastructure;
    1919using System;
     20using Quartz;
     21using Quartz.Impl;
     22using Quartz.Spi;
     23using FarmatikoServices.Services.JobDTO;
     24
    2025namespace Farmatiko
    2126{
     
    2328    {
    2429        readonly string MyAllowSpecificOrigins = "_myAllowSpecificOrigins";
    25 
    2630        public Startup(IConfiguration configuration)
    2731        {
     
    5357            services.AddEntityFrameworkNpgsql().AddDbContext<FarmatikoDataContext>(opt => opt.UseNpgsql(connectionString));
    5458
     59
     60
    5561            services.AddScoped<IPHRepo, PHRepo>();
    5662            services.AddScoped<IRepository, Repository>();
    5763            services.AddScoped<IAdminRepo, AdminRepo>();
     64            services.AddTransient<IUpdateDataRepo, UpdateDataRepo>();
    5865
    59             services.AddScoped<IPHService, PHService>();
     66            services.AddTransient<IPHService, PHService>();
    6067            services.AddTransient<IAdminService, AdminService>();
    6168            services.AddTransient<IService, Service>();
     
    6471
    6572            services.AddTransient<ILogger, Logger<ProcessJSONService>>();
    66 
    67             // services.AddTransient<ISystemService, SystemService>();
    6873
    6974
     
    116121                o.MemoryBufferThreshold = int.MaxValue;
    117122            });*/
     123
     124            services.AddSingleton<IJobFactory, SingletonUpdateDataJobFactory>();
     125            services.AddSingleton<ISchedulerFactory, StdSchedulerFactory>();
     126
     127            services.AddTransient<UpdateDataJob>();
     128            services.AddSingleton(new JobSchedule(
     129            jobType: typeof(UpdateDataJob),
     130            cronExpression: "0/30 * * * * ?"));
     131
     132
     133            // "0 0 12 */7 * ?"
     134
     135
     136            services.AddHostedService<UpdateDataHostedService>();
    118137
    119138        }
Note: See TracChangeset for help on using the changeset viewer.