1 | using FarmatikoData;
|
---|
2 | using FarmatikoServices.FarmatikoServiceInterfaces;
|
---|
3 | using Microsoft.AspNetCore.Mvc;
|
---|
4 | using Microsoft.Extensions.DependencyInjection;
|
---|
5 | using Microsoft.Extensions.Logging;
|
---|
6 | using Quartz;
|
---|
7 | using System;
|
---|
8 | using System.Collections.Generic;
|
---|
9 | using System.Text;
|
---|
10 | using System.Threading.Tasks;
|
---|
11 |
|
---|
12 | namespace FarmatikoServices.Services
|
---|
13 | {
|
---|
14 | [DisallowConcurrentExecution]
|
---|
15 | public class UpdateDataJob : IJob
|
---|
16 | {
|
---|
17 | private readonly ILogger<UpdateDataJob> _logger;
|
---|
18 | private readonly IProcessJSONService _JSONservice;
|
---|
19 | private readonly IServiceScopeFactory _provider;
|
---|
20 | public UpdateDataJob(ILogger<UpdateDataJob> logger, IProcessJSONService JSONservice, IServiceScopeFactory provider)
|
---|
21 | {
|
---|
22 | _logger = logger;
|
---|
23 | _JSONservice = JSONservice;
|
---|
24 | _provider = provider;
|
---|
25 | }
|
---|
26 |
|
---|
27 | public async Task Execute(IJobExecutionContext context)
|
---|
28 | {
|
---|
29 | _logger.LogInformation("UpdateData Job started");
|
---|
30 | using (var scope = _provider.CreateScope())
|
---|
31 | {
|
---|
32 | // Resolve the Scoped service
|
---|
33 | var service = scope.ServiceProvider.GetRequiredService<FarmatikoDataContext>();
|
---|
34 | _logger.LogInformation("UpdateData Job started");
|
---|
35 | _JSONservice.DownloadPharmaciesExcel();
|
---|
36 | _JSONservice.GetProcessedHealthcareWorkersFromJSON();
|
---|
37 | _JSONservice.GetProcessedHealthFacilitiesFromJSON();
|
---|
38 | _JSONservice.GetProcessedMedicinesFromJSON();
|
---|
39 |
|
---|
40 | }
|
---|
41 |
|
---|
42 | await Task.CompletedTask;
|
---|
43 | }
|
---|
44 | }
|
---|
45 | }
|
---|