12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- 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<ServerMessageService> logger)
- {
- this.mainDbService = mainDbService;
- this.logger = logger;
- }
- private readonly IMainDbService mainDbService;
- private readonly ILogger<ServerMessageService> logger;
- internal Task<string> SendGetEVSEConfigureRequest(string chargeBoxId, List<string> configKeys = default , string serialNo = "")
- {
- if (string.IsNullOrEmpty(chargeBoxId)) return null;
- List<string> toPassConfig = configKeys == default ? new List<string>() : configKeys;
- return mainDbService.AddServerMessage(
- ChargeBoxId: chargeBoxId,
- OutAction: Actions.GetConfiguration.ToString(),
- OutRequest: new GetConfigurationRequest() { key = toPassConfig },
- SerialNo: serialNo
- );
- }
- internal Task<string> 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<string> 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
- }
- );
- }
- }
|