|
@@ -15,21 +15,22 @@ namespace EVCB_OCPP.TaskScheduler.Services
|
|
|
{
|
|
|
public class CommonCustomerService : ICustomerService
|
|
|
{
|
|
|
- private ILogger logger;
|
|
|
+ private readonly ILogger logger;
|
|
|
+ private readonly DatabaseService _dbService;// = new DatabaseService();
|
|
|
+ private readonly OuterHttpClient httpClient;//= new OuterHttpClient();
|
|
|
private Guid customerId = Guid.Empty;
|
|
|
private string customerName = string.Empty;
|
|
|
private string _partnerAPIRoot = string.Empty;
|
|
|
private string _saltkey = string.Empty;
|
|
|
private CancellationToken _ct;
|
|
|
- private DatabaseService _dbService;// = new DatabaseService();
|
|
|
private ParallelOptions po = new ParallelOptions();
|
|
|
- private OuterHttpClient httpClient;//= new OuterHttpClient();
|
|
|
private int ChargeRecordCallCounter = 0;
|
|
|
|
|
|
- public CommonCustomerService(IServiceProvider serviceProvider) {
|
|
|
- this.logger = serviceProvider.GetService<ILogger<CommonCustomerService>>();
|
|
|
- this._dbService = serviceProvider.GetService<DatabaseService>();
|
|
|
- this.httpClient = serviceProvider.GetService<OuterHttpClient>();
|
|
|
+ public CommonCustomerService(DatabaseService databaseService,ILoggerProvider loggerProvider)
|
|
|
+ {
|
|
|
+ this._dbService = databaseService;
|
|
|
+ this.logger = loggerProvider.CreateLogger(nameof(CommonCustomerService));
|
|
|
+ this.httpClient = new OuterHttpClient(loggerProvider.CreateLogger(nameof(OuterHttpClient)));
|
|
|
}
|
|
|
|
|
|
public async Task SetCustomerId(Guid customerId)
|
|
@@ -43,22 +44,11 @@ namespace EVCB_OCPP.TaskScheduler.Services
|
|
|
_partnerAPIRoot = connectionInfo.ApiUrl;
|
|
|
}
|
|
|
|
|
|
- public List<Guid> GetCallPartnerCustomers()
|
|
|
- {
|
|
|
- return _dbService.GetCallParterAPICustomers();
|
|
|
- }
|
|
|
-
|
|
|
- public List<Guid> GetNotifyStopTransactionCustomers()
|
|
|
- {
|
|
|
- return _dbService.GetNotifyStopTransactionCustomers();
|
|
|
- }
|
|
|
-
|
|
|
async public Task ReportStartTransaction()
|
|
|
{
|
|
|
var items = await _dbService.GetNeedReportSession(customerId, true, 1000);
|
|
|
|
|
|
- Stopwatch watch = new Stopwatch();
|
|
|
- watch.Start();
|
|
|
+ Stopwatch watch = Stopwatch.StartNew();
|
|
|
|
|
|
List<Task> groupTasks = new List<Task>();
|
|
|
int skipCount = 0;
|
|
@@ -133,7 +123,7 @@ namespace EVCB_OCPP.TaskScheduler.Services
|
|
|
{
|
|
|
sendBack.Add(r.Id, new TransactionResponse()
|
|
|
{
|
|
|
- StartTransactionReportedOn = DateTime.Now,
|
|
|
+ StartTransactionReportedOn = DateTime.UtcNow,
|
|
|
ErrorMsg = response.Success ? null :
|
|
|
(response.Exception == null ? response.Response : response.Exception.ToString())
|
|
|
});
|
|
@@ -264,7 +254,7 @@ namespace EVCB_OCPP.TaskScheduler.Services
|
|
|
{
|
|
|
sendBack.Add(r.Id, new TransactionResponse()
|
|
|
{
|
|
|
- StopTransactionReportedOn = DateTime.Now,
|
|
|
+ StopTransactionReportedOn = DateTime.UtcNow,
|
|
|
ErrorMsg = response.Success ? null :
|
|
|
(response.Exception == null ? response.Response : response.Exception.ToString())
|
|
|
});
|
|
@@ -394,7 +384,7 @@ namespace EVCB_OCPP.TaskScheduler.Services
|
|
|
{
|
|
|
sendBack.Add(r.Id, new BasicResponse()
|
|
|
{
|
|
|
- ReportedOn = DateTime.Now,
|
|
|
+ ReportedOn = DateTime.UtcNow,
|
|
|
ErrorMsg = response.Success ? null :
|
|
|
(response.Exception == null ? response.Response : response.Exception.ToString())
|
|
|
});
|