1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- using EVCB_OCPP.TaskScheduler.Helper;
- using EVCB_OCPP.TaskScheduler.Services;
- using Microsoft.Extensions.DependencyInjection;
- using Microsoft.Extensions.Logging;
- using Quartz;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace EVCB_OCPP.TaskScheduler.Jobs
- {
- [DisallowConcurrentExecution]
- public class StopTransacionReportJob : IJob
- {
- private readonly ICustomersService customersService;
- private readonly ILogger logger;
- public StopTransacionReportJob(ICustomersService customersService, ILogger<StopTransacionReportJob> logger)
- {
- this.customersService = customersService;
- this.logger = logger;
- }
- public async Task Execute(IJobExecutionContext context)
- {
- using var timer = TimerHelper.Start(this.ToString(), logger);
- List<Task> tList = new List<Task>();
- var cList = customersService.GetNotifyStopTransactionCustomers();
- foreach (var customerId in cList)
- {
- ICustomerService s = await customersService.GetCustomerService(customerId);
- tList.Add(DoMainTask(s));
- }
- await Task.WhenAll(tList.ToArray());
- logger.LogInformation("{0} complete", this.ToString());
- }
- private Task DoMainTask(ICustomerService _service)
- {
- return _service.ReportStopTransaction();
- }
- }
- }
|