|
@@ -11,13 +11,10 @@ using EVCB_OCPP.Packet.Messages.Reservation;
|
|
|
using EVCB_OCPP.Packet.Messages.Security;
|
|
|
using EVCB_OCPP.Packet.Messages.SmartCharging;
|
|
|
using EVCB_OCPP.WSServer.Helper;
|
|
|
-using EVCB_OCPP.WSServer.Message;
|
|
|
-using Microsoft.AspNetCore.Connections;
|
|
|
using Microsoft.Data.SqlClient;
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
using Microsoft.Extensions.Caching.Memory;
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
-using Microsoft.Extensions.Hosting;
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
using Newtonsoft.Json;
|
|
|
using OCPPPackage.Profiles;
|
|
@@ -41,7 +38,9 @@ public interface IMainDbService
|
|
|
Task<string> AddServerMessage(ServerMessage message);
|
|
|
Task<string> 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);
|
|
@@ -239,7 +238,13 @@ public class MainDbService : IMainDbService
|
|
|
return AddMachineErrorDapper(ConnectorId, CreatedOn, Status, ChargeBoxId, ErrorCodeId, ErrorInfo, PreStatus, VendorErrorCode, VendorId);
|
|
|
}
|
|
|
|
|
|
- public async Task<string> 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 async Task<string> AddServerMessage(string ChargeBoxId, string OutAction, object OutRequest, string CreatedBy, DateTime? CreatedOn = null, string SerialNo = "", string InMessage = "")
|
|
|
{
|
|
|
if (string.IsNullOrEmpty(CreatedBy))
|
|
|
{
|
|
@@ -833,7 +838,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();
|