|
@@ -33,7 +33,7 @@ namespace EVCB_OCPP.WEBAPI.Controllers.Version1
|
|
|
private HttpClientService service = new HttpClientService();
|
|
|
private readonly IServiceProvider serviceProvider;
|
|
|
|
|
|
- public CPOController(IServiceProvider serviceProvider)
|
|
|
+ public CPOController(IServiceProvider serviceProvider, IConfiguration configuration)
|
|
|
{
|
|
|
this.serviceProvider = serviceProvider;
|
|
|
}
|
|
@@ -72,7 +72,7 @@ namespace EVCB_OCPP.WEBAPI.Controllers.Version1
|
|
|
statusCode = StatusCodes.Status200OK;
|
|
|
}
|
|
|
//return Request.CreateResponse(statusCode, result);
|
|
|
- return StatusCode(statusCode,result);
|
|
|
+ return StatusCode(statusCode, result);
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
@@ -151,12 +151,8 @@ namespace EVCB_OCPP.WEBAPI.Controllers.Version1
|
|
|
//return Request.CreateResponse(statusCode, result);
|
|
|
return StatusCode(statusCode, result);
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
[Route("commands/start_session")]
|
|
|
[Produces(typeof(CPOOuterResponse))]
|
|
|
[HttpPost]
|
|
@@ -190,31 +186,28 @@ namespace EVCB_OCPP.WEBAPI.Controllers.Version1
|
|
|
|| (_CPService.GetNumberofConnectors(request.ChargeBoxId) >= request.ConnectorId && request.ConnectorId > 0))
|
|
|
&& !string.IsNullOrEmpty(request.Token) && request.Token.Length <= 20)
|
|
|
{
|
|
|
-
|
|
|
- InternalHttpClient _client = new InternalHttpClient();
|
|
|
+ InternalHttpClient _client = serviceProvider.GetRequiredService<InternalHttpClient>();
|
|
|
ICustomerService _customer = serviceProvider.GetRequiredService<ICustomerService>();
|
|
|
|
|
|
//trigger to charge
|
|
|
var _request = new Models.WebAPI.StartTransactionRequest()
|
|
|
{
|
|
|
ConnectorId = request.ConnectorId,
|
|
|
- IdTag = request.Token
|
|
|
-
|
|
|
+ IdTag = request.Token
|
|
|
+
|
|
|
};
|
|
|
|
|
|
- string url = Request.GetDisplayUrl();
|
|
|
- string[] parts = url.Split('/');
|
|
|
- string urlformat = "{0}//{1}/api/v1/ocpp16/transaction?ChargeBoxId={3}";
|
|
|
+ string[] parts = Request.GetDisplayUrl().Split('/');
|
|
|
+ string urlformat = "{0}//{1}";
|
|
|
|
|
|
var _innerResult = await _client.Post(
|
|
|
- string.Format(urlformat, parts[0], parts[2], new Uri(url).Port.ToString(), request.ChargeBoxId)
|
|
|
- ,new Dictionary<string, string>()
|
|
|
+ string.Format(urlformat, parts[0], parts[2])
|
|
|
+ , $"/api/v1/ocpp16/transaction?ChargeBoxId={request.ChargeBoxId}"
|
|
|
+ , new Dictionary<string, string>()
|
|
|
{
|
|
|
{ "PartnerId",_CustomerId}
|
|
|
-
|
|
|
}, _request, _customer.GetAPIKey(new Guid(_CustomerId)));
|
|
|
|
|
|
-
|
|
|
_innerData = new { Result = string.IsNullOrEmpty(_innerResult.SerialNo) ? CommandResponseType.Rejected.ToString() : CommandResponseType.Accepted.ToString(), Timeout = 60 };
|
|
|
result = GetErrorDescription(_innerResult);
|
|
|
result.Data = JsonConvert.SerializeObject(_innerData, EVCBConfiguration.JSONSERIALIZER_FORMAT);
|
|
@@ -292,18 +285,23 @@ namespace EVCB_OCPP.WEBAPI.Controllers.Version1
|
|
|
}
|
|
|
|
|
|
|
|
|
- InternalHttpClient _client = new InternalHttpClient();
|
|
|
+ InternalHttpClient _client = serviceProvider.GetRequiredService<InternalHttpClient>();
|
|
|
ICustomerService _customer = serviceProvider.GetRequiredService<ICustomerService>();
|
|
|
|
|
|
string[] parts = Request.GetDisplayUrl().Split('/');
|
|
|
|
|
|
- string urlformat = "{0}//{1}/api/v1/ocpp16/transaction?ChargeBoxId={2}&TransactionId={3}";
|
|
|
+ string urlformat = "{0}//{1}";
|
|
|
|
|
|
- var _innerResult = await _client.Put(string.Format(urlformat, parts[0], parts[2], ChargeBoxId, SessionId), new Dictionary<string, string>()
|
|
|
- {
|
|
|
- { "PartnerId",_CustomerId}
|
|
|
+ var _innerResult = await _client.Put(
|
|
|
+ string.Format(urlformat, parts[0], parts[2] ),
|
|
|
+ $"/api/v1/ocpp16/transaction?ChargeBoxId={ChargeBoxId}&TransactionId={SessionId}",
|
|
|
+ new Dictionary<string, string>()
|
|
|
+ {
|
|
|
+ { "PartnerId",_CustomerId}
|
|
|
|
|
|
- }, null, _customer.GetAPIKey(new Guid(_CustomerId)));
|
|
|
+ },
|
|
|
+ null,
|
|
|
+ _customer.GetAPIKey(new Guid(_CustomerId)));
|
|
|
|
|
|
|
|
|
_innerData = new { Result = string.IsNullOrEmpty(_innerResult.SerialNo) ? CommandResponseType.Rejected.ToString() : CommandResponseType.Accepted.ToString(), Timeout = 60 };
|
|
@@ -378,11 +376,11 @@ namespace EVCB_OCPP.WEBAPI.Controllers.Version1
|
|
|
}
|
|
|
|
|
|
|
|
|
- InternalHttpClient _client = new InternalHttpClient();
|
|
|
+ InternalHttpClient _client = serviceProvider.GetRequiredService<InternalHttpClient>();
|
|
|
ICustomerService _customer = serviceProvider.GetRequiredService<ICustomerService>();
|
|
|
|
|
|
string[] parts = Request.GetDisplayUrl().Split('/');
|
|
|
- string urlformat = "{0}//{1}/api/v1/ocpp16/reservation?ChargeBoxId={2}";
|
|
|
+ string urlformat = "{0}//{1}";
|
|
|
|
|
|
var _innerRequest = new ReserveRequest()
|
|
|
{
|
|
@@ -392,11 +390,16 @@ namespace EVCB_OCPP.WEBAPI.Controllers.Version1
|
|
|
ExpiryDate = request.ExpiryDate.ToString(EVCBConfiguration.UTC_DATETIMEFORMAT)
|
|
|
};
|
|
|
|
|
|
- var _innerResult = await _client.Post(string.Format(urlformat, parts[0], parts[2], request.ChargeBoxId), new Dictionary<string, string>()
|
|
|
+ var _innerResult = await _client.Post(
|
|
|
+ string.Format(urlformat, parts[0], parts[2]),
|
|
|
+ $"/api/v1/ocpp16/reservation?ChargeBoxId={request.ChargeBoxId}",
|
|
|
+ new Dictionary<string, string>()
|
|
|
{
|
|
|
{ "PartnerId",_CustomerId}
|
|
|
|
|
|
- }, _innerRequest, _customer.GetAPIKey(new Guid(_CustomerId)));
|
|
|
+ },
|
|
|
+ _innerRequest,
|
|
|
+ _customer.GetAPIKey(new Guid(_CustomerId)));
|
|
|
|
|
|
|
|
|
_innerData = new { Result = string.IsNullOrEmpty(_innerResult.SerialNo) ? CommandResponseType.Rejected.ToString() : CommandResponseType.Accepted.ToString(), Timeout = 60 };
|
|
@@ -469,19 +472,21 @@ namespace EVCB_OCPP.WEBAPI.Controllers.Version1
|
|
|
}
|
|
|
|
|
|
|
|
|
- InternalHttpClient _client = new InternalHttpClient();
|
|
|
+ InternalHttpClient _client = serviceProvider.GetRequiredService<InternalHttpClient>();
|
|
|
ICustomerService _customer = serviceProvider.GetRequiredService<ICustomerService>();
|
|
|
|
|
|
-
|
|
|
string[] parts = Request.GetDisplayUrl().Split('/');
|
|
|
|
|
|
- string urlformat = "{0}//{1}/api/v1/ocpp16/reservation?ChargeBoxId={2}&ReservationId={3}";
|
|
|
+ string urlformat = "{0}//{1}";
|
|
|
|
|
|
- var _innerResult = await _client.Delete(string.Format(urlformat, parts[0], parts[2], ChargeBoxId, ReservationId), new Dictionary<string, string>()
|
|
|
- {
|
|
|
- { "PartnerId",_CustomerId}
|
|
|
+ var _innerResult = await _client.Delete(
|
|
|
+ string.Format(urlformat, parts[0], parts[2]),
|
|
|
+ $"/api/v1/ocpp16/reservation?ChargeBoxId={ChargeBoxId}&ReservationId={ReservationId}",
|
|
|
+ new Dictionary<string, string>()
|
|
|
+ {
|
|
|
+ { "PartnerId",_CustomerId}
|
|
|
|
|
|
- }, _customer.GetAPIKey(new Guid(_CustomerId)));
|
|
|
+ }, _customer.GetAPIKey(new Guid(_CustomerId)));
|
|
|
|
|
|
|
|
|
_innerData = new { Result = string.IsNullOrEmpty(_innerResult.SerialNo) ? CommandResponseType.Rejected.ToString() : CommandResponseType.Accepted.ToString(), Timeout = 60 };
|
|
@@ -503,7 +508,7 @@ namespace EVCB_OCPP.WEBAPI.Controllers.Version1
|
|
|
result.StatusMessage = CPO_StatusMessage.ERROR_MSG_INNERSERVICE_ERROR;
|
|
|
//statusCode = HttpStatusCode.BadRequest;
|
|
|
statusCode = StatusCodes.Status400BadRequest;
|
|
|
- }
|
|
|
+ }
|
|
|
else
|
|
|
{
|
|
|
result.StatusCode = _innerResult.ErrorCode;
|
|
@@ -553,19 +558,21 @@ namespace EVCB_OCPP.WEBAPI.Controllers.Version1
|
|
|
}
|
|
|
|
|
|
|
|
|
- InternalHttpClient _client = new InternalHttpClient();
|
|
|
+ InternalHttpClient _client = serviceProvider.GetRequiredService<InternalHttpClient>();
|
|
|
ICustomerService _customer = serviceProvider.GetRequiredService<ICustomerService>();
|
|
|
|
|
|
-
|
|
|
string[] parts = Request.GetDisplayUrl().Split('/');
|
|
|
|
|
|
- string urlformat = "{0}//{1}/api/v1/ocpp16/compositeschedule?ChargeBoxId={2}&ConnectorId={3}&Duration={4}&ChargingRateUnit={5}";
|
|
|
+ string urlformat = "{0}//{1}";
|
|
|
|
|
|
- var _innerResult = await _client.Get(string.Format(urlformat, parts[0], parts[2], ChargeBoxId, ConnectorId, Duration, ChargingRateUnit), new Dictionary<string, string>()
|
|
|
- {
|
|
|
- { "PartnerId",_CustomerId}
|
|
|
+ var _innerResult = await _client.Get(
|
|
|
+ string.Format(urlformat, parts[0], parts[2]),
|
|
|
+ $"/api/v1/ocpp16/compositeschedule?ChargeBoxId={ChargeBoxId}&ConnectorId={ConnectorId}&Duration={Duration}&ChargingRateUnit={ChargingRateUnit}",
|
|
|
+ new Dictionary<string, string>()
|
|
|
+ {
|
|
|
+ { "PartnerId",_CustomerId}
|
|
|
|
|
|
- }, _customer.GetAPIKey(new Guid(_CustomerId)));
|
|
|
+ }, _customer.GetAPIKey(new Guid(_CustomerId)));
|
|
|
|
|
|
|
|
|
_innerData = new { Result = string.IsNullOrEmpty(_innerResult.SerialNo) ? CommandResponseType.Rejected.ToString() : CommandResponseType.Accepted.ToString(), Timeout = 60 };
|
|
@@ -638,20 +645,23 @@ namespace EVCB_OCPP.WEBAPI.Controllers.Version1
|
|
|
|
|
|
|
|
|
|
|
|
- InternalHttpClient _client = new InternalHttpClient();
|
|
|
+ InternalHttpClient _client = serviceProvider.GetRequiredService<InternalHttpClient>();
|
|
|
ICustomerService _customer = serviceProvider.GetRequiredService<ICustomerService>();
|
|
|
|
|
|
|
|
|
string[] parts = Request.GetDisplayUrl().Split('/');
|
|
|
|
|
|
- string urlformat = "{0}//{1}/api/v1/ocpp16/chargingprofile?ChargeBoxId={2}";
|
|
|
-
|
|
|
- var _innerResult = await _client.Post(string.Format(urlformat, parts[0], parts[2], ChargeBoxId), new Dictionary<string, string>()
|
|
|
- {
|
|
|
- { "PartnerId",_CustomerId}
|
|
|
-
|
|
|
- }, request, _customer.GetAPIKey(new Guid(_CustomerId)));
|
|
|
+ string urlformat = "{0}//{1}";
|
|
|
|
|
|
+ var _innerResult = await _client.Post(
|
|
|
+ string.Format(urlformat, parts[0], parts[2]),
|
|
|
+ $"/api/v1/ocpp16/chargingprofile?ChargeBoxId={ChargeBoxId}",
|
|
|
+ new Dictionary<string, string>()
|
|
|
+ {
|
|
|
+ { "PartnerId", _CustomerId}
|
|
|
+ },
|
|
|
+ request,
|
|
|
+ _customer.GetAPIKey(new Guid(_CustomerId)));
|
|
|
|
|
|
_innerData = new { Result = string.IsNullOrEmpty(_innerResult.SerialNo) ? CommandResponseType.Rejected.ToString() : CommandResponseType.Accepted.ToString(), Timeout = 60 };
|
|
|
result = GetErrorDescription(_innerResult);
|
|
@@ -737,19 +747,22 @@ namespace EVCB_OCPP.WEBAPI.Controllers.Version1
|
|
|
}
|
|
|
|
|
|
|
|
|
- InternalHttpClient _client = new InternalHttpClient();
|
|
|
+ InternalHttpClient _client = serviceProvider.GetRequiredService<InternalHttpClient>();
|
|
|
ICustomerService _customer = serviceProvider.GetRequiredService<ICustomerService>();
|
|
|
|
|
|
|
|
|
string[] parts = Request.GetDisplayUrl().Split('/');
|
|
|
|
|
|
- string urlformat = "{0}//{1}/api/v1/ocpp16/chargingprofile?ChargeBoxId={2}{3}";
|
|
|
+ string urlformat = "{0}//{1}";
|
|
|
|
|
|
- var _innerResult = await _client.Delete(string.Format(urlformat, parts[0], parts[2], ChargeBoxId, ChargeProfileId == -1 ? "" : "&Id=" + ChargeProfileId), new Dictionary<string, string>()
|
|
|
- {
|
|
|
- { "PartnerId",_CustomerId}
|
|
|
+ var _innerResult = await _client.Delete(
|
|
|
+ string.Format(urlformat, parts[0], parts[2]),
|
|
|
+ string.Format("/api/v1/ocpp16/chargingprofile?ChargeBoxId={2}{3}", ChargeBoxId, ChargeProfileId == -1 ? "" : "&Id=" + ChargeProfileId),
|
|
|
+ new Dictionary<string, string>()
|
|
|
+ {
|
|
|
+ { "PartnerId",_CustomerId}
|
|
|
|
|
|
- }, _customer.GetAPIKey(new Guid(_CustomerId)));
|
|
|
+ }, _customer.GetAPIKey(new Guid(_CustomerId)));
|
|
|
|
|
|
|
|
|
_innerData = new { Result = string.IsNullOrEmpty(_innerResult.SerialNo) ? CommandResponseType.Rejected.ToString() : CommandResponseType.Accepted.ToString(), Timeout = 60 };
|
|
@@ -821,24 +834,24 @@ namespace EVCB_OCPP.WEBAPI.Controllers.Version1
|
|
|
}
|
|
|
|
|
|
|
|
|
- InternalHttpClient _client = new InternalHttpClient();
|
|
|
+ InternalHttpClient _client = serviceProvider.GetRequiredService<InternalHttpClient>();
|
|
|
ICustomerService _customer = serviceProvider.GetRequiredService<ICustomerService>();
|
|
|
|
|
|
|
|
|
|
|
|
string[] parts = Request.GetDisplayUrl().Split('/');
|
|
|
|
|
|
- string urlformat = "{0}//{1}/api/v1/ocpp16/locallist?ChargeBoxId={2}";
|
|
|
-
|
|
|
-
|
|
|
+ string urlformat = "{0}//{1}";
|
|
|
|
|
|
- var _innerResult = await _client.Post(string.Format(urlformat, parts[0], parts[2], ChargeBoxId), new Dictionary<string, string>()
|
|
|
+ var _innerResult = await _client.Post(
|
|
|
+ string.Format(urlformat, parts[0], parts[2]),
|
|
|
+ $"/api/v1/ocpp16/locallist?ChargeBoxId={ChargeBoxId}",
|
|
|
+ new Dictionary<string, string>()
|
|
|
{
|
|
|
{ "PartnerId",_CustomerId}
|
|
|
|
|
|
}, request, _customer.GetAPIKey(new Guid(_CustomerId)));
|
|
|
|
|
|
-
|
|
|
_innerData = new { Result = string.IsNullOrEmpty(_innerResult.SerialNo) ? CommandResponseType.Rejected.ToString() : CommandResponseType.Accepted.ToString(), Timeout = 60 };
|
|
|
result = GetErrorDescription(_innerResult);
|
|
|
result.Data = JsonConvert.SerializeObject(_innerData, EVCBConfiguration.JSONSERIALIZER_FORMAT);
|
|
@@ -911,18 +924,19 @@ namespace EVCB_OCPP.WEBAPI.Controllers.Version1
|
|
|
}
|
|
|
|
|
|
|
|
|
- InternalHttpClient _client = new InternalHttpClient();
|
|
|
+ InternalHttpClient _client = serviceProvider.GetRequiredService<InternalHttpClient>();
|
|
|
ICustomerService _customer = serviceProvider.GetRequiredService<ICustomerService>();
|
|
|
|
|
|
|
|
|
|
|
|
string[] parts = Request.GetDisplayUrl().ToString().Split('/');
|
|
|
|
|
|
- string urlformat = "{0}//{1}/api/v1/ocpp16/locallistversion?ChargeBoxId={2}";
|
|
|
-
|
|
|
-
|
|
|
+ string urlformat = "{0}//{1}";
|
|
|
|
|
|
- var _innerResult = await _client.Get(string.Format(urlformat, parts[0], parts[2], ChargeBoxId), new Dictionary<string, string>()
|
|
|
+ var _innerResult = await _client.Get(
|
|
|
+ string.Format(urlformat, parts[0], parts[2] ),
|
|
|
+ $"/api/v1/ocpp16/locallistversion?ChargeBoxId={ChargeBoxId}",
|
|
|
+ new Dictionary<string, string>()
|
|
|
{
|
|
|
{ "PartnerId",_CustomerId}
|
|
|
|
|
@@ -1001,7 +1015,7 @@ namespace EVCB_OCPP.WEBAPI.Controllers.Version1
|
|
|
}
|
|
|
|
|
|
|
|
|
- InternalHttpClient _client = new InternalHttpClient();
|
|
|
+ InternalHttpClient _client = serviceProvider.GetRequiredService<InternalHttpClient>();
|
|
|
ICustomerService _customer = serviceProvider.GetRequiredService<ICustomerService>();
|
|
|
|
|
|
int? orderNo = (int?)null;
|
|
@@ -1064,15 +1078,16 @@ namespace EVCB_OCPP.WEBAPI.Controllers.Version1
|
|
|
|
|
|
|
|
|
string[] parts = Request.GetDisplayUrl().Split('/');
|
|
|
+ string urlformat = "{0}//{1}";
|
|
|
|
|
|
- string urlformat = "{0}//{1}/api/v1/ocpp16/command?ChargeBoxId={2}{3}&SerialNo={4}";
|
|
|
-
|
|
|
-
|
|
|
- var _innerResult = await _client.Get(string.Format(urlformat, parts[0], parts[2], ChargeBoxId, orderNo.HasValue ? "&OrderNo=" + orderNo.Value : "", SerialNo), new Dictionary<string, string>()
|
|
|
- {
|
|
|
- { "PartnerId",_CustomerId}
|
|
|
+ var _innerResult = await _client.Get(
|
|
|
+ string.Format(urlformat, parts[0], parts[2]),
|
|
|
+ string.Format("/api/v1/ocpp16/command?ChargeBoxId={0}{1}&SerialNo={2}", ChargeBoxId, orderNo.HasValue ? "&OrderNo=" + orderNo.Value : "", SerialNo),
|
|
|
+ new Dictionary<string, string>()
|
|
|
+ {
|
|
|
+ { "PartnerId",_CustomerId}
|
|
|
|
|
|
- }, _customer.GetAPIKey(new Guid(_CustomerId)));
|
|
|
+ }, _customer.GetAPIKey(new Guid(_CustomerId)));
|
|
|
|
|
|
|
|
|
result = GetErrorDescription(_innerResult);
|
|
@@ -1253,7 +1268,7 @@ namespace EVCB_OCPP.WEBAPI.Controllers.Version1
|
|
|
{
|
|
|
|
|
|
|
|
|
- string currencyText = string.IsNullOrEmpty(transactionData.Fee) ? "TWD" : transactionData.Fee.Remove(0, transactionData.Fee.Length - 3);
|
|
|
+ string currencyText = string.IsNullOrEmpty(transactionData.Fee) ? "TWD" : transactionData.Fee.Remove(0, transactionData.Fee.Length - 3);
|
|
|
|
|
|
_innerData.Add(new ActiveSession()
|
|
|
{
|
|
@@ -1378,7 +1393,7 @@ namespace EVCB_OCPP.WEBAPI.Controllers.Version1
|
|
|
try
|
|
|
{
|
|
|
|
|
|
- InternalHttpClient _client = new InternalHttpClient();
|
|
|
+ InternalHttpClient _client = serviceProvider.GetRequiredService<InternalHttpClient>();
|
|
|
ICustomerService _customer = serviceProvider.GetRequiredService<ICustomerService>();
|
|
|
|
|
|
string url = configuration["StatisticsAPI"] + 1;
|
|
@@ -1440,7 +1455,7 @@ namespace EVCB_OCPP.WEBAPI.Controllers.Version1
|
|
|
try
|
|
|
{
|
|
|
|
|
|
- InternalHttpClient _client = new InternalHttpClient();
|
|
|
+ InternalHttpClient _client = serviceProvider.GetRequiredService<InternalHttpClient>();
|
|
|
ICustomerService _customer = serviceProvider.GetRequiredService<ICustomerService>();
|
|
|
|
|
|
string url = configuration["StatisticsAPI"] + 2;
|
|
@@ -1493,7 +1508,7 @@ namespace EVCB_OCPP.WEBAPI.Controllers.Version1
|
|
|
[Route("statistics/time_of_use")]
|
|
|
[Produces(typeof(CPOOuterResponse))]
|
|
|
[HttpPost]
|
|
|
- async public Task<IActionResult> Time_of_Use([FromBody] StatisticsRequest request, [FromServices]IConfiguration configuration)
|
|
|
+ async public Task<IActionResult> Time_of_Use([FromBody] StatisticsRequest request, [FromServices] IConfiguration configuration)
|
|
|
{
|
|
|
var result = new CPOOuterResponse();
|
|
|
//HttpStatusCode statusCode = HttpStatusCode.InternalServerError;
|
|
@@ -1502,7 +1517,7 @@ namespace EVCB_OCPP.WEBAPI.Controllers.Version1
|
|
|
try
|
|
|
{
|
|
|
|
|
|
- InternalHttpClient _client = new InternalHttpClient();
|
|
|
+ InternalHttpClient _client = serviceProvider.GetRequiredService<InternalHttpClient>();
|
|
|
ICustomerService _customer = serviceProvider.GetRequiredService<ICustomerService>();
|
|
|
|
|
|
string url = configuration["StatisticsAPI"] + 3;
|
|
@@ -1555,7 +1570,7 @@ namespace EVCB_OCPP.WEBAPI.Controllers.Version1
|
|
|
[Route("statistics/peak_load")]
|
|
|
[Produces(typeof(CPOOuterResponse))]
|
|
|
[HttpPost]
|
|
|
- async public Task<IActionResult> Peak_Load([FromBody] StatisticsRequest request, [FromServices]IConfiguration configuration)
|
|
|
+ async public Task<IActionResult> Peak_Load([FromBody] StatisticsRequest request, [FromServices] IConfiguration configuration)
|
|
|
{
|
|
|
var result = new CPOOuterResponse();
|
|
|
//HttpStatusCode statusCode = HttpStatusCode.InternalServerError;
|
|
@@ -1564,7 +1579,7 @@ namespace EVCB_OCPP.WEBAPI.Controllers.Version1
|
|
|
try
|
|
|
{
|
|
|
|
|
|
- InternalHttpClient _client = new InternalHttpClient();
|
|
|
+ InternalHttpClient _client = serviceProvider.GetRequiredService<InternalHttpClient>();
|
|
|
ICustomerService _customer = serviceProvider.GetRequiredService<ICustomerService>();
|
|
|
|
|
|
string url = configuration["StatisticsAPI"] + 4;
|
|
@@ -1616,7 +1631,7 @@ namespace EVCB_OCPP.WEBAPI.Controllers.Version1
|
|
|
[Route("statistics/sessions")]
|
|
|
[Produces(typeof(CPOOuterResponse))]
|
|
|
[HttpPost]
|
|
|
- async public Task<IActionResult> Sessions([FromBody] StatisticsRequest request, [FromServices]IConfiguration configuration)
|
|
|
+ async public Task<IActionResult> Sessions([FromBody] StatisticsRequest request, [FromServices] IConfiguration configuration)
|
|
|
{
|
|
|
var result = new CPOOuterResponse();
|
|
|
//HttpStatusCode statusCode = HttpStatusCode.InternalServerError;
|
|
@@ -1625,7 +1640,7 @@ namespace EVCB_OCPP.WEBAPI.Controllers.Version1
|
|
|
try
|
|
|
{
|
|
|
|
|
|
- InternalHttpClient _client = new InternalHttpClient();
|
|
|
+ InternalHttpClient _client = serviceProvider.GetRequiredService<InternalHttpClient>();
|
|
|
ICustomerService _customer = serviceProvider.GetRequiredService<ICustomerService>();
|
|
|
|
|
|
string url = configuration["StatisticsAPI"] + 6;
|
|
@@ -1669,7 +1684,7 @@ namespace EVCB_OCPP.WEBAPI.Controllers.Version1
|
|
|
result.StatusMessage = CPO_StatusMessage.ERROR_MSG_UNEXPECTEDERROR;
|
|
|
result.StatusCode = (int)CPO_StatusCode.UnexpectedError;
|
|
|
//return Request.CreateResponse(statusCode, result);
|
|
|
- return StatusCode(statusCode,result);
|
|
|
+ return StatusCode(statusCode, result);
|
|
|
}
|
|
|
|
|
|
//return Request.CreateResponse(statusCode, result);
|
|
@@ -1679,7 +1694,7 @@ namespace EVCB_OCPP.WEBAPI.Controllers.Version1
|
|
|
[Route("statistics/fault")]
|
|
|
[Produces(typeof(CPOOuterResponse))]
|
|
|
[HttpPost]
|
|
|
- async public Task<IActionResult> Fault([FromBody] StatisticsRequest request, [FromServices]IConfiguration configuration)
|
|
|
+ async public Task<IActionResult> Fault([FromBody] StatisticsRequest request, [FromServices] IConfiguration configuration)
|
|
|
{
|
|
|
var result = new CPOOuterResponse();
|
|
|
//HttpStatusCode statusCode = HttpStatusCode.InternalServerError;
|
|
@@ -1688,7 +1703,7 @@ namespace EVCB_OCPP.WEBAPI.Controllers.Version1
|
|
|
try
|
|
|
{
|
|
|
|
|
|
- InternalHttpClient _client = new InternalHttpClient();
|
|
|
+ InternalHttpClient _client = serviceProvider.GetRequiredService<InternalHttpClient>();
|
|
|
ICustomerService _customer = serviceProvider.GetRequiredService<ICustomerService>();
|
|
|
|
|
|
string url = configuration["StatisticsAPI"] + 5;
|
|
@@ -1736,7 +1751,7 @@ namespace EVCB_OCPP.WEBAPI.Controllers.Version1
|
|
|
|
|
|
//return Request.CreateResponse(statusCode, result);
|
|
|
return StatusCode(statusCode, result);
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
private string GetStatisticChargeBoxIds(List<string> chargeBoxIds)
|
|
|
{
|