|
@@ -7,7 +7,9 @@ using Newtonsoft.Json.Linq;
|
|
|
using NLog;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
+using System.Configuration;
|
|
|
using System.Linq;
|
|
|
+using System.Net;
|
|
|
using System.Security.Cryptography.X509Certificates;
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
@@ -58,8 +60,68 @@ namespace EVCB_OCPP.WSServer.Service
|
|
|
signMaterial = GetSign(customerId);
|
|
|
}
|
|
|
|
|
|
+ async public Task<IdTokenInfo> Authorize(string chargeBoxId, string idTag, int? connectorId = -1)
|
|
|
+ {
|
|
|
+ await Task.Delay(10);
|
|
|
+ IdTokenInfo info = new IdTokenInfo() { IdTagInfo = new IdTagInfo() { status = AuthorizationStatus.Invalid } };
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+ if (CustomerId.ToUpper() == "009E603C-79CD-4620-A2B8-D9349C0E8AD8")
|
|
|
+ {
|
|
|
+ info.IdTagInfo = new IdTagInfo() { status = AuthorizationStatus.Accepted };
|
|
|
+ return info;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ 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.IdTagInfo.status = (AuthorizationStatus)Enum.Parse(typeof(AuthorizationStatus), jo["message"].ToString());
|
|
|
+ }
|
|
|
+ catch (Exception)
|
|
|
+ {
|
|
|
+ ;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ ;
|
|
|
+ }
|
|
|
+ return info;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
- async public Task<IdTokenInfo> Authorize(string chargeBoxId, string idTag,int? connectorId =-1)
|
|
|
+ async public Task<IdTokenInfo> Authorize_outer(string chargeBoxId, string idTag,int? connectorId =-1)
|
|
|
{
|
|
|
await Task.Delay(10);
|
|
|
IdTokenInfo result = new IdTokenInfo() { IdTagInfo = new IdTagInfo() { status = AuthorizationStatus.Invalid } };
|