using EVCB_OCPP.Packet.Features; using EVCB_OCPP.Packet.Messages.Core; using Microsoft.Extensions.Logging; using static System.Runtime.InteropServices.JavaScript.JSType; using System.ServiceModel.Channels; using EVCB_OCPP.WSServer.Service.DbService; using Azure; using EVCB_OCPP.WSServer.Message; namespace EVCB_OCPP.WSServer.Service; public class ServerMessageService { public ServerMessageService( IMainDbService mainDbService , ILogger logger) { this.mainDbService = mainDbService; this.logger = logger; } private readonly IMainDbService mainDbService; private readonly ILogger logger; internal Task SendGetEVSEConfigureRequest(string chargeBoxId, List configKeys = default , string serialNo = "") { if (string.IsNullOrEmpty(chargeBoxId)) return null; List toPassConfig = configKeys == default ? new List() : configKeys; return mainDbService.AddServerMessage( ChargeBoxId: chargeBoxId, OutAction: Actions.GetConfiguration.ToString(), OutRequest: new GetConfigurationRequest() { key = toPassConfig }, SerialNo: serialNo ); } internal Task SendChangeConfigurationRequest(string chargeBoxId, string key, string value, string serialNo = "") { return mainDbService.AddServerMessage( ChargeBoxId: chargeBoxId, OutAction: Actions.ChangeConfiguration.ToString(), OutRequest: new ChangeConfigurationRequest() { key = key, value = value }, SerialNo: serialNo ); } internal Task SendDataTransferRequest(string chargeBoxId, string messageId, string vendorId, string data) { return mainDbService.AddServerMessage( ChargeBoxId: chargeBoxId, OutAction: Actions.DataTransfer.ToString(), OutRequest: new DataTransferRequest() { messageId = messageId, vendorId = vendorId, data = data } ); } }