|
@@ -19,7 +19,6 @@ using System.Data;
|
|
|
using System.Diagnostics;
|
|
|
using System.Globalization;
|
|
|
using SuperSocket.SocketBase;
|
|
|
-using Microsoft.AspNetCore.Http;
|
|
|
|
|
|
namespace EVCB_OCPP.WSServer.Message;
|
|
|
|
|
@@ -66,6 +65,7 @@ internal partial class ProfileHandler
|
|
|
private readonly ILogger logger;
|
|
|
private readonly BlockingTreePrintService blockingTreePrintService;
|
|
|
private readonly GoogleGetTimePrintService googleGetTimePrintService;
|
|
|
+ private readonly ServerMessageService messageService;
|
|
|
|
|
|
//private readonly string webConnectionString;// = ConfigurationManager.ConnectionStrings[].ConnectionString;
|
|
|
private readonly IDbContextFactory<MainDBContext> maindbContextFactory;
|
|
@@ -88,6 +88,7 @@ internal partial class ProfileHandler
|
|
|
ILogger<ProfileHandler> logger,
|
|
|
BlockingTreePrintService blockingTreePrintService,
|
|
|
GoogleGetTimePrintService googleGetTimePrintService,
|
|
|
+ ServerMessageService messageService,
|
|
|
OuterHttpClient httpClient)
|
|
|
{
|
|
|
//webConnectionString = configuration.GetConnectionString("WebDBContext");
|
|
@@ -95,6 +96,7 @@ internal partial class ProfileHandler
|
|
|
this.logger = logger;
|
|
|
this.blockingTreePrintService = blockingTreePrintService;
|
|
|
this.googleGetTimePrintService = googleGetTimePrintService;
|
|
|
+ this.messageService = messageService;
|
|
|
this.maindbContextFactory = maindbContextFactory;
|
|
|
this.webDbConnectionFactory = webDbConnectionFactory;
|
|
|
this.meterValueDbService = meterValueDbService;
|
|
@@ -455,17 +457,12 @@ internal partial class ProfileHandler
|
|
|
{
|
|
|
if (session.IsBilling)
|
|
|
{
|
|
|
- await mainDbService.AddServerMessage(
|
|
|
- ChargeBoxId: session.ChargeBoxId,
|
|
|
- OutAction: Actions.DataTransfer.ToString(),
|
|
|
- OutRequest:
|
|
|
- new DataTransferRequest()
|
|
|
- {
|
|
|
- messageId = "ID_TxEnergy",
|
|
|
- vendorId = "Phihong Technology",
|
|
|
- data = JsonConvert.SerializeObject(new { txId = _request.transactionId, ConnectorId = _request.connectorId })
|
|
|
- }
|
|
|
- );
|
|
|
+ await messageService.SendDataTransferRequest(
|
|
|
+ session.ChargeBoxId,
|
|
|
+ messageId: "ID_TxEnergy",
|
|
|
+ vendorId: "Phihong Technology",
|
|
|
+ data: JsonConvert.SerializeObject(new { txId = _request.transactionId, ConnectorId = _request.connectorId })
|
|
|
+ );
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
@@ -776,16 +773,11 @@ internal partial class ProfileHandler
|
|
|
|
|
|
if (session.IsBilling)
|
|
|
{
|
|
|
- await mainDbService.AddServerMessage(
|
|
|
- ChargeBoxId: session.ChargeBoxId,
|
|
|
- OutAction: Actions.DataTransfer.ToString(),
|
|
|
- OutRequest:
|
|
|
- new DataTransferRequest()
|
|
|
- {
|
|
|
- messageId = "ID_TxEnergy",
|
|
|
- vendorId = "Phihong Technology",
|
|
|
- data = JsonConvert.SerializeObject(new { txId = _request.transactionId, ConnectorId = transaction.ConnectorId })
|
|
|
- }
|
|
|
+ await messageService.SendDataTransferRequest(
|
|
|
+ session.ChargeBoxId,
|
|
|
+ messageId: "ID_TxEnergy",
|
|
|
+ vendorId: "Phihong Technology",
|
|
|
+ data: JsonConvert.SerializeObject(new { txId = _request.transactionId, ConnectorId = transaction.ConnectorId })
|
|
|
);
|
|
|
}
|
|
|
|
|
@@ -1223,32 +1215,26 @@ internal partial class ProfileHandler
|
|
|
|
|
|
await db.SaveChangesAsync();
|
|
|
|
|
|
- await mainDbService.AddServerMessage(
|
|
|
- ChargeBoxId: session.ChargeBoxId,
|
|
|
- OutAction: Actions.DataTransfer.ToString(),
|
|
|
- OutRequest:
|
|
|
- new DataTransferRequest()
|
|
|
+ await messageService.SendDataTransferRequest(
|
|
|
+ session.ChargeBoxId,
|
|
|
+ messageId: "FinalCost",
|
|
|
+ vendorId: "Phihong Technology",
|
|
|
+ data: JsonConvert.SerializeObject(new
|
|
|
+ {
|
|
|
+ txId = txEnergy.TxId,
|
|
|
+ description = JsonConvert.SerializeObject(new
|
|
|
{
|
|
|
- messageId = "FinalCost",
|
|
|
- vendorId = "Phihong Technology",
|
|
|
- data = JsonConvert.SerializeObject(new
|
|
|
- {
|
|
|
- txId = txEnergy.TxId,
|
|
|
- description = JsonConvert.SerializeObject(new
|
|
|
- {
|
|
|
- chargedEnergy = chargedEnergy,
|
|
|
- chargingFee = chargingCost,
|
|
|
- parkTime = (int)stoptime.Subtract(starttime).TotalSeconds,
|
|
|
- parkingFee = parkingCost,
|
|
|
- currency = currency,
|
|
|
- couponPoint = couponPoint,
|
|
|
- accountBalance = accountBalance - tx.Cost,
|
|
|
- farewellMessage = farewellMessage
|
|
|
- })
|
|
|
- })
|
|
|
-
|
|
|
- }
|
|
|
- );
|
|
|
+ chargedEnergy = chargedEnergy,
|
|
|
+ chargingFee = chargingCost,
|
|
|
+ parkTime = (int)stoptime.Subtract(starttime).TotalSeconds,
|
|
|
+ parkingFee = parkingCost,
|
|
|
+ currency = currency,
|
|
|
+ couponPoint = couponPoint,
|
|
|
+ accountBalance = accountBalance - tx.Cost,
|
|
|
+ farewellMessage = farewellMessage
|
|
|
+ })
|
|
|
+ })
|
|
|
+ );
|
|
|
|
|
|
await meterValueDbService.InsertAsync(
|
|
|
chargeBoxId: session.ChargeBoxId,
|
|
@@ -1291,30 +1277,24 @@ internal partial class ProfileHandler
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- await mainDbService.AddServerMessage(
|
|
|
- ChargeBoxId: session.ChargeBoxId,
|
|
|
- OutAction: Actions.DataTransfer.ToString(),
|
|
|
- OutRequest:
|
|
|
- new DataTransferRequest()
|
|
|
- {
|
|
|
- messageId = "RunningCost",
|
|
|
- vendorId = "Phihong Technology",
|
|
|
- data = JsonConvert.SerializeObject(new
|
|
|
- {
|
|
|
- txId = txEnergy.TxId,
|
|
|
- description = JsonConvert.SerializeObject(new
|
|
|
- {
|
|
|
- chargedEnergy = chargedEnergy,
|
|
|
- chargingFee = chargingCost,
|
|
|
- parkTime = (int)stoptime.Subtract(starttime).TotalSeconds,
|
|
|
- parkingFee = parkingCost,
|
|
|
- currency = currency
|
|
|
- })
|
|
|
-
|
|
|
- })
|
|
|
-
|
|
|
- }
|
|
|
- );
|
|
|
+ await messageService.SendDataTransferRequest(
|
|
|
+ session.ChargeBoxId,
|
|
|
+ messageId: "RunningCost",
|
|
|
+ vendorId: "Phihong Technology",
|
|
|
+ data: JsonConvert.SerializeObject(new
|
|
|
+ {
|
|
|
+ txId = txEnergy.TxId,
|
|
|
+ description = JsonConvert.SerializeObject(new
|
|
|
+ {
|
|
|
+ chargedEnergy = chargedEnergy,
|
|
|
+ chargingFee = chargingCost,
|
|
|
+ parkTime = (int)stoptime.Subtract(starttime).TotalSeconds,
|
|
|
+ parkingFee = parkingCost,
|
|
|
+ currency = currency
|
|
|
+ })
|
|
|
+
|
|
|
+ })
|
|
|
+ );
|
|
|
|
|
|
await meterValueDbService.InsertAsync(
|
|
|
chargeBoxId: session.ChargeBoxId,
|