123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- using EVCB_OCPP.Packet.Messages.SubTypes;
- using EVCB_OCPP.WSServer.Dto;
- using Newtonsoft.Json.Linq;
- using System;
- using System.Collections.Generic;
- using System.Configuration;
- using System.Net;
- using System.Threading.Tasks;
- namespace EVCB_OCPP.WSServer.Service
- {
- public class LocalBusinessService : IBusinessService
- {
- string customerId = string.Empty;
- public LocalBusinessService(string customerId)
- {
- this.customerId = customerId;
- }
- async public Task<IdTagInfo> Authorize(string chargeBoxId, string idTag)
- {
- await Task.Delay(10);
- IdTagInfo info = new IdTagInfo() { status = AuthorizationStatus.Invalid };
- try
- {
- OuterHttpClient _client = new OuterHttpClient();
- string url = ConfigurationManager.AppSettings["LocalAuthAPI"];
- HttpClientService service = new HttpClientService();
- Dictionary<string, string> postData = new Dictionary<string, string>()
- {
- { "ChargeBoxId", chargeBoxId },
- { "IdTag", idTag },
- };
- var _innerresult = await service.PostFormDataAsync(url, postData, null);
- if (_innerresult.StatusCode == HttpStatusCode.OK)
- {
- JObject jo = JObject.Parse(_innerresult.Response);
- if (jo["code"].ToString() == "1")
- {
- try
- {
- info.status = (AuthorizationStatus)Enum.Parse(typeof(AuthorizationStatus), jo["message"].ToString());
- }
- catch (Exception)
- {
- ;
- }
- }
- }
- }
- catch (Exception ex)
- {
- ;
- }
- return info;
- }
- async public Task NotifyFaultStatus(ErrorDetails details)
- {
- await Task.Delay(10);
- }
- }
- }
|