|
@@ -38,7 +38,7 @@ 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 FillupFinishedTimetoMachineError(byte ConnectorId, DateTime FinishedOn, string ChargeBoxId, DateTime PreviousErrorOn);
|
|
|
+ ValueTask FillupFinishedTimetoMachineError(byte ConnectorId, DateTime FinishedOn, string ChargeBoxId);
|
|
|
|
|
|
ValueTask<Customer> GetCustomer(string id, CancellationToken token = default);
|
|
|
ValueTask<Customer> GetCustomer(Guid id, CancellationToken token = default);
|
|
@@ -238,10 +238,10 @@ public class MainDbService : IMainDbService
|
|
|
return AddMachineErrorDapper(ConnectorId, CreatedOn, Status, ChargeBoxId, ErrorCodeId, ErrorInfo, PreStatus, VendorErrorCode, VendorId);
|
|
|
}
|
|
|
|
|
|
- public ValueTask FillupFinishedTimetoMachineError(byte ConnectorId, DateTime FinishedOn, string ChargeBoxId, DateTime PreviousErrorOn)
|
|
|
+ public ValueTask FillupFinishedTimetoMachineError(byte ConnectorId, DateTime FinishedOn, string ChargeBoxId)
|
|
|
{
|
|
|
|
|
|
- return AddFinishedTimetoMachineErrorDapper(ConnectorId, FinishedOn, ChargeBoxId, PreviousErrorOn);
|
|
|
+ return AddFinishedTimetoMachineErrorDapper(ConnectorId, FinishedOn, ChargeBoxId);
|
|
|
}
|
|
|
|
|
|
public async Task<string> AddServerMessage(string ChargeBoxId, string OutAction, object OutRequest, string CreatedBy, DateTime? CreatedOn = null, string SerialNo = "", string InMessage = "")
|
|
@@ -838,19 +838,39 @@ public class MainDbService : IMainDbService
|
|
|
""", parameters);
|
|
|
}
|
|
|
|
|
|
- private async ValueTask AddFinishedTimetoMachineErrorDapper(byte connectorId, DateTime finishedTime, string chargeBoxId, DateTime previousErrorOn)
|
|
|
+ private async ValueTask AddFinishedTimetoMachineErrorDapper(byte connectorId, DateTime finishedTime, string chargeBoxId)
|
|
|
{
|
|
|
- var parameters = new DynamicParameters();
|
|
|
- parameters.Add("@FinishedOn", finishedTime, DbType.DateTime, ParameterDirection.Input,50);
|
|
|
+ var getCommand = """
|
|
|
+ SELECT Id
|
|
|
+ FROM [dbo].[MachineError]
|
|
|
+ where ChargeBoxId=@ChargeBoxId and ConnectorId=@ConnectorId
|
|
|
+ Order by Id desc
|
|
|
+ """;
|
|
|
+
|
|
|
+ var updateCommand = """
|
|
|
+ Update MachineError
|
|
|
+ set FinishedOn=@FinishedOn
|
|
|
+ where Id=@Id
|
|
|
+ """;
|
|
|
+
|
|
|
+ var parameters = new DynamicParameters();
|
|
|
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);
|
|
|
+ //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);
|
|
|
+
|
|
|
+ var recordId = await conn.QueryFirstOrDefaultAsync<int?>(getCommand, parameters);
|
|
|
+ if (recordId is null)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ parameters = new DynamicParameters();
|
|
|
+ parameters.Add("@Id", recordId, DbType.Int32, ParameterDirection.Input);
|
|
|
+ parameters.Add("@FinishedOn", finishedTime, DbType.DateTime, ParameterDirection.Input, 50);
|
|
|
+
|
|
|
+ await conn.ExecuteAsync(updateCommand, parameters);
|
|
|
}
|
|
|
|
|
|
private async Task BundleUpdateConnectorStatus(IEnumerable<StatusNotificationParam> statusNotifications)
|