{"id":298174,"date":"2020-02-04T09:00:38","date_gmt":"2020-02-04T09:00:38","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=298174"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=298174","title":{"rendered":"Quartz \u0432 ASP.NET Core"},"content":{"rendered":"\n<div class=\"post__text post__text-html\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/486678\/\">\n<h3>\u0412\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u0435<\/h3>\n<p>  \u0417\u043d\u0430\u044e, \u0447\u0442\u043e \u043d\u0430 \u044d\u0442\u0443 \u0442\u0435\u043c\u0443 \u0435\u0441\u0442\u044c \u043e\u0447\u0435\u043d\u044c \u043c\u043d\u043e\u0433\u043e \u0441\u0442\u0430\u0442\u0435\u0439 \u0438 \u0441\u0432\u043e\u0435\u0433\u043e \u0440\u043e\u0434\u0430 \u0442\u0443\u0442\u043e\u0440\u0438\u043e\u0430\u043b\u043e\u0432, \u044f \u0443\u0436\u0435 \u0438 \u043d\u0435 \u0433\u043e\u0432\u043e\u0440\u044e \u043e\u0431 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438, \u043d\u043e \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u043d\u0430\u0434 \u0441\u0432\u043e\u0438\u043c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u043c \u044f \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0441\u044f \u0441 \u043e\u0447\u0435\u043d\u044c \u0437\u0430\u043d\u044f\u0442\u043d\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043e\u0439, \u043e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043c\u0430\u043b\u043e \u0433\u0434\u0435 \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u0441\u044f. \u0420\u0435\u0447\u044c \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u043f\u043e\u0439\u0434\u0435\u0442 \u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f Dependency Injection \u0438 Quartz \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u043d\u0430 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0435 ASP.NET Core.<\/p>\n<p>  \u041d\u0430\u0447\u0430\u043b\u043e\u0441\u044c \u0432\u0441\u0451 \u0441 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u044f \u043d\u0435 \u0434\u0443\u043c\u0430\u043b, \u0447\u0442\u043e \u043c\u043e\u0433\u0443\u0442 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u0443\u0442\u044c \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0438 \u0441\u043a\u0430\u0436\u0443 \u0441\u0440\u0430\u0437\u0443, \u0447\u0442\u043e \u043f\u0440\u043e\u0431\u043e\u0432\u0430\u043b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u044b: \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u043b \u0432\u0441\u0435 \u043a\u043b\u0430\u0441\u0441\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u043a\u043b\u044e\u0447\u0430\u043b \u0432 \u0441\u0435\u0431\u044f Quartz \u0432 services \u0438 \u044e\u0437\u0430\u0442\u044c \u0438\u0445 \u0447\u0435\u0440\u0435\u0437 DI \u2014 \u043c\u0438\u043c\u043e (\u043d\u043e \u043d\u0435 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e, \u043a\u0430\u043a \u043f\u043e\u0442\u043e\u043c \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c), \u043f\u0440\u043e\u0431\u043e\u0432\u0430\u043b \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c HostedService \u2014 \u0442\u043e\u0436\u0435 \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u043e (\u0432 \u043a\u043e\u043d\u0446\u0435 \u043f\u0440\u0438\u043a\u0440\u0435\u043f\u043b\u044e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0445\u043e\u0440\u043e\u0448\u0438\u0445 \u0441\u0441\u044b\u043b\u043e\u043a \u043d\u0430 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u0441\u0442\u0430\u0442\u044c\u0438 \u043e \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 Quartz) \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435. \u042f \u0443\u0436\u0435 \u0434\u0443\u043c\u0430\u043b, \u0447\u0442\u043e \u0443 \u043c\u0435\u043d\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0441 \u0442\u0440\u0438\u0433\u0433\u0435\u0440\u043e\u043c \u2014 \u0442\u043e\u0436\u0435 \u043d\u0435\u0442. \u0412 \u044d\u0442\u043e\u0439 \u043a\u043e\u0440\u043e\u0442\u043a\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u043f\u043e\u043f\u044b\u0442\u0430\u044e\u0441\u044c \u043f\u043e\u043c\u043e\u0447\u044c \u0442\u0435\u043c, \u0443 \u043a\u043e\u0433\u043e, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0431\u044b\u043b\u0430 \u0442\u0430\u043a\u0430\u044f \u0436\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0438 \u043d\u0430\u0434\u0435\u044e\u0441\u044c \u043c\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u0438\u043c \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0439 \u0440\u0430\u0431\u043e\u0442\u0435. \u041f\u043e\u0434 \u043a\u043e\u043d\u0435\u0446 \u0432\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u044f \u0445\u043e\u0447\u0443 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c, \u0447\u0442\u043e \u0431\u0443\u0434\u0443 \u0432\u0435\u0441\u044c\u043c\u0430 \u043f\u0440\u0438\u0437\u043d\u0430\u0442\u0435\u043b\u0435\u043d \u0435\u0441\u043b\u0438 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445 \u0442\u0435, \u043a\u0442\u043e \u0445\u043e\u0440\u043e\u0448\u043e \u0437\u043d\u0430\u043a\u043e\u043c \u0441 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0435\u0439, \u0434\u0430\u0434\u0443\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u043e\u0432\u0435\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043c\u043e\u0433\u0443\u0442 \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c \u0442\u043e, \u0447\u0442\u043e \u044f \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0438\u043b.<br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h3>Quartz<\/h3>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u0440\u043e\u0435\u043a\u0442 (\u0438\u043b\u0438 \u0432\u043e\u0437\u044c\u043c\u0451\u043c \u0433\u043e\u0442\u043e\u0432\u044b\u0439 \u2014 \u043d\u0435\u0432\u0430\u0436\u043d\u043e) \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0432 \u043d\u0435\u0433\u043e \u0434\u0432\u0435 \u043f\u0430\u043f\u043a\u0438 \u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043a\u043b\u0430\u0441\u0441\u043e\u0432:<\/p>\n<p>  <b>Quartz<\/b><br \/>  <i>&#8212;DataJob.cs<\/i><br \/>  <i>&#8212;DataScheduler.cs<\/i><br \/>  <i>&#8212;JobFactory.cs<\/i><br \/>  <b>Workers<\/b><br \/>  <i>&#8212;EmailSender<\/i><br \/>  <i>&#8212;IEmailSender<\/i><\/p>\n<p>  \u0412 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0435 IEmailSender, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0441\u043b\u0443\u0436\u0438\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u043c, \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043e\u0434\u0438\u043d \u043c\u0435\u0442\u043e\u0434 \u0434\u043b\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u043f\u0438\u0441\u0435\u043c \u043d\u0430 \u043f\u043e\u0447\u0442\u0443:<\/p>\n<pre><code class=\"cs\">public interface IEmailSender     {         Task SendEmailAsync(string email, string subject, string message);     } <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043e\u043f\u0438\u0448\u0435\u043c \u043a\u043b\u0430\u0441\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441:<\/p>\n<pre><code class=\"cs\">public class EmailSender : IEmailSender     {                  public Task SendEmailAsync(string email, string subject, string message) \t\t{ \t\t\tvar from = &quot;****@gmail.com&quot;; \t\t\tvar pass = &quot;****&quot;;             SmtpClient client = new SmtpClient(&quot;smtp.gmail.com&quot;, 587); \t\t\tclient.DeliveryMethod = SmtpDeliveryMethod.Network; \t\t\tclient.UseDefaultCredentials = false; \t\t\tclient.Credentials = new System.Net.NetworkCredential(from, pass); \t\t\tclient.EnableSsl = true; \t\t\tvar mail = new MailMessage(from, email); \t\t\tmail.Subject = subject; \t\t\tmail.Body = message; \t\t\tmail.IsBodyHtml = true; \t\t\treturn client.SendMailAsync(mail); \t\t}     } <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043e\u043f\u0438\u0448\u0435\u043c \u043a\u043b\u0430\u0441\u0441\u044b DataJob.cs, DataScheduler.cs, JobFactory.cs. \u041a\u043b\u0430\u0441\u0441 DataJob \u0431\u0443\u0434\u0435\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 IJob.<\/p>\n<pre><code class=\"cs\"> public class DataJob : IJob     {         private readonly IServiceScopeFactory serviceScopeFactory;          public DataJob(IServiceScopeFactory serviceScopeFactory)         {             this.serviceScopeFactory = serviceScopeFactory;         }          public async Task Execute(IJobExecutionContext context)         {             using (var scope = serviceScopeFactory.CreateScope())             {                 var emailsender = scope.ServiceProvider.GetService&lt;IEmailSender&gt;();                                   await emailsender.SendEmailAsync(&quot;example@gmail.com&quot;,&quot;example&quot;,&quot;hello&quot;)             }         }     } <\/code><\/pre>\n<p>  \u041a\u0430\u043a \u0432\u0438\u0434\u0438\u043c \u0443 \u043d\u0430\u0441 \u043f\u043e\u043b\u0435 \u0442\u0438\u043f\u0430 IServiceScopeFactory, \u043e\u0442\u0434\u0434\u0430 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0434\u043e\u0441\u0442\u0430\u0432\u0430\u0442\u044c \u0441\u0435\u0440\u0432\u0438\u0441\u044b \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0438\u0437 Startup. \u0418\u043c\u0435\u043d\u043d\u043e \u044d\u0442\u043e\u0442 \u043f\u043e\u0434\u0445\u043e\u0434 \u043f\u043e\u043c\u043e\u0433 \u0440\u0435\u0448\u0438\u0442\u044c \u043c\u043d\u0435 \u043c\u043e\u044e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443, \u0438\u0434\u0451\u043c \u0434\u0430\u043b\u0435\u0435 \u0438 \u043e\u043f\u0438\u0448\u0435\u043c \u043a\u043b\u0430\u0441 DataScheduler \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0431\u0443\u0434\u0435\u043c \u0432 Sheduler \u0441\u0430\u043c\u043e\u0433\u043e \u043a\u0432\u0430\u0440\u0446\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c job \u0438 trigger:<\/p>\n<pre><code class=\"cs\">public static class DataScheduler     {                  public static async void Start(IServiceProvider serviceProvider)         {             IScheduler scheduler = await StdSchedulerFactory.GetDefaultScheduler();             scheduler.JobFactory = serviceProvider.GetService&lt;JobFactory&gt;();             await scheduler.Start();              IJobDetail jobDetail = JobBuilder.Create&lt;DataJob&gt;().Build();             ITrigger trigger = TriggerBuilder.Create()                 .WithIdentity(&quot;MailingTrigger&quot;, &quot;default&quot;)                 .StartNow()                 .WithSimpleSchedule(x =&gt; x                 .WithIntervalInMinutes(1)                 .RepeatForever())                 .Build();              await scheduler.ScheduleJob(jobDetail, trigger);         } <\/code><\/pre>\n<p>  \u0418 \u0442\u0435\u043f\u0435\u0440\u044c \u043a\u043b\u0430\u0441 JobFactory, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 IJobFactory:<\/p>\n<pre><code class=\"cs\"> public class JobFactory : IJobFactory     {         protected readonly IServiceScopeFactory serviceScopeFactory;                   public JobFactory(IServiceScopeFactory serviceScopeFactory)         {             this.serviceScopeFactory = serviceScopeFactory;         }          public IJob NewJob(TriggerFiredBundle bundle, IScheduler scheduler)         {             using (var scope = serviceScopeFactory.CreateScope())             {                 var job = scope.ServiceProvider.GetService(bundle.JobDetail.JobType) as IJob;                 return job;             }                      }          public void ReturnJob(IJob job)         {            \/\/Do something if need         }     } <\/code><\/pre>\n<p>  \u041a\u0430\u043a \u0432\u0438\u0434\u0438\u043c, \u044f, \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438, \u0432\u0441\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u044e \u0441\u0440\u0430\u0437\u0443 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0438\u0437 serviceScopeFactory. \u0412\u0441\u0451 \u043f\u043e\u0447\u0442\u0438 \u0433\u043e\u0442\u043e\u0432\u043e, \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u043a\u043b\u0430\u0441\u0441 Program: <\/p>\n<pre><code class=\"cs\">public class Program     {         public static void Main(string[] args)         {             var host = BuildWebHost(args);             using (var scope = host.Services.CreateScope())             {                 var serviceProvider = scope.ServiceProvider;                 try                 {                     DataScheduler.Start(serviceProvider);                 }                 catch (Exception)                 {                     throw;                 }             }             host.Run();         }          public static IWebHost BuildWebHost(string[] args) =&gt;            WebHost.CreateDefaultBuilder(args)                .UseStartup&lt;Startup&gt;()                .Build();     } <\/code><\/pre>\n<p>  \u0418 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432 Startup \u0432 \u043c\u0435\u0442\u043e\u0434 ConfigureServices \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<pre><code class=\"cs\">   services.AddTransient&lt;JobFactory&gt;();    services.AddScoped&lt;DataJob&gt;();    services.AddScoped&lt;IEmailSender,EmailSender&gt;(); <\/code><\/pre>\n<p>  \u0413\u043e\u0442\u043e\u0432\u043e. \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0437\u0430\u0434\u0430\u0447\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u043a\u0430\u0436\u0434\u0443\u044e \u043c\u0438\u043d\u0443\u0442\u0443. \u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c \u0432 DataScheduler.Start (\u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0430\u0445, \u0447\u0430\u0441\u0430\u0445 \u0438\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c CRON). \u0414\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u043d\u043e\u0432\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u043f\u0440\u0438 \u0442\u0430\u043a\u043e\u043c \u043f\u043e\u0434\u0445\u043e\u0434\u0435 \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c IJob \u0438 \u043f\u0440\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443 DataScheduler. \u0422\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0438 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 Scheduler \u043a\u043b\u0430\u0441 \u0434\u043b\u044f \u043d\u043e\u0432\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438. <\/p>\n<p>  \u0411\u0443\u0434\u0443 \u043e\u0447\u0435\u043d\u044c \u0440\u0430\u0434, \u0435\u0441\u043b\u0438 \u0441\u043c\u043e\u0433 \u043a\u043e\u043c\u0443-\u0442\u043e \u043f\u043e\u043c\u043e\u0447\u044c, \u0430 \u0432\u043e\u0442 \u043f\u0430\u0440\u0443 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0445 \u0441\u0442\u0430\u0442\u0435\u0439 \u043e Quartz \u0438 \u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438:<\/p>\n<p>  <a href=\"https:\/\/andrewlock.net\/creating-a-quartz-net-hosted-service-with-asp-net-core\/\">Creating a Quartz.NET hosted service with ASP.NET Core<\/a><br \/>  <a href=\"https:\/\/andrewlock.net\/using-scoped-services-inside-a-quartz-net-hosted-service-with-asp-net-core\/\">Using scoped services inside a Quartz.NET hosted service with ASP.NET Core<\/a><br \/>  <cut><\/cut><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/486678\/\"> https:\/\/habr.com\/ru\/post\/486678\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/486678\/\">\n<h3>\u0412\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u0435<\/h3>\n<p>  \u0417\u043d\u0430\u044e, \u0447\u0442\u043e \u043d\u0430 \u044d\u0442\u0443 \u0442\u0435\u043c\u0443 \u0435\u0441\u0442\u044c \u043e\u0447\u0435\u043d\u044c \u043c\u043d\u043e\u0433\u043e \u0441\u0442\u0430\u0442\u0435\u0439 \u0438 \u0441\u0432\u043e\u0435\u0433\u043e \u0440\u043e\u0434\u0430 \u0442\u0443\u0442\u043e\u0440\u0438\u043e\u0430\u043b\u043e\u0432, \u044f \u0443\u0436\u0435 \u0438 \u043d\u0435 \u0433\u043e\u0432\u043e\u0440\u044e \u043e\u0431 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438, \u043d\u043e \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u043d\u0430\u0434 \u0441\u0432\u043e\u0438\u043c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u043c \u044f \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0441\u044f \u0441 \u043e\u0447\u0435\u043d\u044c \u0437\u0430\u043d\u044f\u0442\u043d\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043e\u0439, \u043e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043c\u0430\u043b\u043e \u0433\u0434\u0435 \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u0441\u044f. \u0420\u0435\u0447\u044c \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u043f\u043e\u0439\u0434\u0435\u0442 \u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f Dependency Injection \u0438 Quartz \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u043d\u0430 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0435 ASP.NET Core.<\/p>\n<p>  \u041d\u0430\u0447\u0430\u043b\u043e\u0441\u044c \u0432\u0441\u0451 \u0441 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u044f \u043d\u0435 \u0434\u0443\u043c\u0430\u043b, \u0447\u0442\u043e \u043c\u043e\u0433\u0443\u0442 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u0443\u0442\u044c \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0438 \u0441\u043a\u0430\u0436\u0443 \u0441\u0440\u0430\u0437\u0443, \u0447\u0442\u043e \u043f\u0440\u043e\u0431\u043e\u0432\u0430\u043b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u044b: \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u043b \u0432\u0441\u0435 \u043a\u043b\u0430\u0441\u0441\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u043a\u043b\u044e\u0447\u0430\u043b \u0432 \u0441\u0435\u0431\u044f Quartz \u0432 services \u0438 \u044e\u0437\u0430\u0442\u044c \u0438\u0445 \u0447\u0435\u0440\u0435\u0437 DI \u2014 \u043c\u0438\u043c\u043e (\u043d\u043e \u043d\u0435 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e, \u043a\u0430\u043a \u043f\u043e\u0442\u043e\u043c \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c), \u043f\u0440\u043e\u0431\u043e\u0432\u0430\u043b \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c HostedService \u2014 \u0442\u043e\u0436\u0435 \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u043e (\u0432 \u043a\u043e\u043d\u0446\u0435 \u043f\u0440\u0438\u043a\u0440\u0435\u043f\u043b\u044e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0445\u043e\u0440\u043e\u0448\u0438\u0445 \u0441\u0441\u044b\u043b\u043e\u043a \u043d\u0430 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u0441\u0442\u0430\u0442\u044c\u0438 \u043e \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 Quartz) \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435. \u042f \u0443\u0436\u0435 \u0434\u0443\u043c\u0430\u043b, \u0447\u0442\u043e \u0443 \u043c\u0435\u043d\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0441 \u0442\u0440\u0438\u0433\u0433\u0435\u0440\u043e\u043c \u2014 \u0442\u043e\u0436\u0435 \u043d\u0435\u0442. \u0412 \u044d\u0442\u043e\u0439 \u043a\u043e\u0440\u043e\u0442\u043a\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u043f\u043e\u043f\u044b\u0442\u0430\u044e\u0441\u044c \u043f\u043e\u043c\u043e\u0447\u044c \u0442\u0435\u043c, \u0443 \u043a\u043e\u0433\u043e, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0431\u044b\u043b\u0430 \u0442\u0430\u043a\u0430\u044f \u0436\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0438 \u043d\u0430\u0434\u0435\u044e\u0441\u044c \u043c\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u0438\u043c \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0439 \u0440\u0430\u0431\u043e\u0442\u0435. \u041f\u043e\u0434 \u043a\u043e\u043d\u0435\u0446 \u0432\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u044f \u0445\u043e\u0447\u0443 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c, \u0447\u0442\u043e \u0431\u0443\u0434\u0443 \u0432\u0435\u0441\u044c\u043c\u0430 \u043f\u0440\u0438\u0437\u043d\u0430\u0442\u0435\u043b\u0435\u043d \u0435\u0441\u043b\u0438 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445 \u0442\u0435, \u043a\u0442\u043e \u0445\u043e\u0440\u043e\u0448\u043e \u0437\u043d\u0430\u043a\u043e\u043c \u0441 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0435\u0439, \u0434\u0430\u0434\u0443\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u043e\u0432\u0435\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043c\u043e\u0433\u0443\u0442 \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c \u0442\u043e, \u0447\u0442\u043e \u044f \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0438\u043b.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-298174","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/298174","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=298174"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/298174\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=298174"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=298174"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=298174"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}