using EVCB_OCPP.TaskScheduler.Services; 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 NLog.ILogger logger = NLog.LogManager.GetCurrentClassLogger(); public StopTransacionReportJob() { } public async Task Execute(IJobExecutionContext context) { await Console.Out.WriteLineAsync(this.ToString() + " :Starting........"); List<Task> tList = new List<Task>(); ICustomerService cs = new CommonCustomerService(); var cList = cs.GetCallPartnerCustomers(); foreach (var customerId in cList) { ICustomerService s = CustomerBackendFactory.Create(customerId); tList.Add(Task.Run(() => DoMainTask(customerId))); } Task.WaitAll(tList.ToArray()); await Console.Out.WriteLineAsync(this.ToString() + " :Finished........"); } private void DoMainTask(Guid customerId) { ICustomerService _service = CustomerBackendFactory.Create(customerId); _service.ReportStopTransaction().Wait(); } } }