CheckExecutionCmdJob.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. using EVCB_OCPP.TaskScheduler.Services;
  2. using Quartz;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. namespace EVCB_OCPP.TaskScheduler.Jobs
  9. {
  10. [DisallowConcurrentExecution]
  11. public class CheckExecutionCmdJob : IJob
  12. {
  13. private NLog.ILogger logger = NLog.LogManager.GetCurrentClassLogger();
  14. public CheckExecutionCmdJob()
  15. {
  16. }
  17. public async Task Execute(IJobExecutionContext context)
  18. {
  19. await Console.Out.WriteLineAsync(this.ToString() + " :Starting........");
  20. List<Task> tList = new List<Task>();
  21. ICustomerService cs = new CommonCustomerService();
  22. var cList = cs.GetCallPartnerCustomers();
  23. foreach (var customerId in cList)
  24. {
  25. ICustomerService s = CustomerBackendFactory.Create(customerId);
  26. tList.Add(Task.Run(() => DoMainTask(customerId)));
  27. }
  28. Task.WaitAll(tList.ToArray());
  29. await Console.Out.WriteLineAsync(this.ToString() + " :Finished........");
  30. }
  31. private void DoMainTask(Guid customerId)
  32. {
  33. ICustomerService _service = CustomerBackendFactory.Create(customerId);
  34. _service.MonitorRemoteCommand().Wait();
  35. }
  36. }
  37. }