|
@@ -3,6 +3,7 @@ using EVCB_OCPP.Domain;
|
|
|
using EVCB_OCPP.Domain.ConnectionFactory;
|
|
|
using EVCB_OCPP.Domain.Models.MainDb;
|
|
|
using EVCB_OCPP.WSServer.Helper;
|
|
|
+using Microsoft.AspNetCore.Http.HttpResults;
|
|
|
using Microsoft.Data.SqlClient;
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
using Microsoft.Extensions.Caching.Memory;
|
|
@@ -31,7 +32,9 @@ public interface IMainDbService
|
|
|
Task AddServerMessage(ServerMessage message);
|
|
|
Task AddServerMessage(string ChargeBoxId, string OutAction, object OutRequest, string CreatedBy = "", DateTime? CreatedOn = null, string SerialNo = "", string InMessage = "");
|
|
|
ValueTask AddMachineError(byte ConnectorId, DateTime CreatedOn, int Status, string ChargeBoxId, int ErrorCodeId, string ErrorInfo, int PreStatus, string VendorErrorCode, string VendorId);
|
|
|
- ValueTask<Customer> GetCustomer(string id, CancellationToken token = default);
|
|
|
+ ValueTask FillupFinishedTimetoMachineError(byte ConnectorId, DateTime FinishedOn, string ChargeBoxId, DateTime PreviousErrorOn);
|
|
|
+
|
|
|
+ ValueTask<Customer> GetCustomer(string id, CancellationToken token = default);
|
|
|
ValueTask<Customer> GetCustomer(Guid id, CancellationToken token = default);
|
|
|
Task<Guid> GetCustomerIdByChargeBoxId(string chargeboxId);
|
|
|
Task<int?> TryGetDuplicatedTransactionId(string chargeBoxId, Guid customerId, int connectorId, DateTime timestamp);
|
|
@@ -213,7 +216,12 @@ public class MainDbService : IMainDbService
|
|
|
return AddMachineErrorDapper(ConnectorId, CreatedOn, Status, ChargeBoxId, ErrorCodeId, ErrorInfo, PreStatus, VendorErrorCode, VendorId);
|
|
|
}
|
|
|
|
|
|
- public Task AddServerMessage(string ChargeBoxId, string OutAction, object OutRequest, string CreatedBy, DateTime? CreatedOn = null, string SerialNo = "", string InMessage = "")
|
|
|
+ public ValueTask FillupFinishedTimetoMachineError(byte ConnectorId, DateTime FinishedOn, string ChargeBoxId, DateTime PreviousErrorOn)
|
|
|
+ {
|
|
|
+
|
|
|
+ return AddFinishedTimetoMachineErrorDapper(ConnectorId, FinishedOn, ChargeBoxId, PreviousErrorOn);
|
|
|
+ }
|
|
|
+ public Task AddServerMessage(string ChargeBoxId, string OutAction, object OutRequest, string CreatedBy, DateTime? CreatedOn = null, string SerialNo = "", string InMessage = "")
|
|
|
{
|
|
|
if (string.IsNullOrEmpty(CreatedBy))
|
|
|
{
|
|
@@ -621,7 +629,22 @@ public class MainDbService : IMainDbService
|
|
|
""", parameters);
|
|
|
}
|
|
|
|
|
|
- private async Task BundleUpdateConnectorStatus(IEnumerable<StatusNotificationParam> statusNotifications)
|
|
|
+ private async ValueTask AddFinishedTimetoMachineErrorDapper(byte connectorId, DateTime finishedTime, string chargeBoxId, DateTime previousErrorOn)
|
|
|
+ {
|
|
|
+ var parameters = new DynamicParameters();
|
|
|
+ parameters.Add("@FinishedOn", finishedTime, DbType.DateTime, ParameterDirection.Input,50);
|
|
|
+ parameters.Add("@ConnectorId", connectorId, DbType.Int16, ParameterDirection.Input);
|
|
|
+ parameters.Add("@ChargeBoxId", chargeBoxId, DbType.String, ParameterDirection.Input, 50);
|
|
|
+ parameters.Add("@CreatedOn", previousErrorOn, DbType.DateTime, ParameterDirection.Input, 50);
|
|
|
+
|
|
|
+ using var conn = await sqlConnectionFactory.CreateAsync();
|
|
|
+ await conn.ExecuteAsync("""
|
|
|
+ Update MachineError set FinishedOn=@FinishedOn where
|
|
|
+ ChargeBoxId=@ChargeBoxId and ConnectorId=@ConnectorId and CreatedOn=@CreatedOn
|
|
|
+ """, parameters);
|
|
|
+ }
|
|
|
+
|
|
|
+ private async Task BundleUpdateConnectorStatus(IEnumerable<StatusNotificationParam> statusNotifications)
|
|
|
{
|
|
|
using var db = await contextFactory.CreateDbContextAsync();
|
|
|
using var trans = await db.Database.BeginTransactionAsync();
|