|
@@ -16,7 +16,6 @@ using Microsoft.Extensions.Configuration;
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
using System.Diagnostics;
|
|
|
-using EVCB_OCPP.Domain.Models.Database;
|
|
|
using Azure.Core;
|
|
|
|
|
|
namespace EVCB_OCPP.WEBAPI.Controllers.Version1
|
|
@@ -28,7 +27,10 @@ namespace EVCB_OCPP.WEBAPI.Controllers.Version1
|
|
|
[Route("api/v1/cpo")]
|
|
|
public class CPOController : ControllerBase
|
|
|
{
|
|
|
- public CPOController(IServiceProvider serviceProvider, IConfiguration configuration, ILogger<CPOController> logger)
|
|
|
+ public CPOController(
|
|
|
+ IServiceProvider serviceProvider,
|
|
|
+ IConfiguration configuration,
|
|
|
+ ILogger<CPOController> logger)
|
|
|
{
|
|
|
this.serviceProvider = serviceProvider;
|
|
|
this.logger = logger;
|
|
@@ -83,10 +85,10 @@ namespace EVCB_OCPP.WEBAPI.Controllers.Version1
|
|
|
[FromServices] ChargePointService _CPService,
|
|
|
[FromServices] ChargingStationService _stationService,
|
|
|
int? Limit = -1,
|
|
|
- int StationId = -1,
|
|
|
+ int StationId = -1,
|
|
|
string ChargeBoxId = "",
|
|
|
- DateTime? DateFrom = null,
|
|
|
- DateTime? DateTo = null,
|
|
|
+ DateTime? DateFrom = null,
|
|
|
+ DateTime? DateTo = null,
|
|
|
int? Offset = 0)
|
|
|
{
|
|
|
|
|
@@ -130,12 +132,10 @@ namespace EVCB_OCPP.WEBAPI.Controllers.Version1
|
|
|
|
|
|
}
|
|
|
}
|
|
|
- else
|
|
|
+ else
|
|
|
{
|
|
|
_innerResponse = new { EVSEs = new List<EVSE>() };
|
|
|
_innerResponse.EVSEs.Add(await _CPService.GetEVSEsbyChargeBoxId(_customerId, ChargeBoxId, DateFrom, DateTo));
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
|
|
|
result.Data = JsonConvert.SerializeObject(_innerResponse, EVCBConfiguration.JSONSERIALIZER_FORMAT);
|
|
@@ -1276,7 +1276,7 @@ namespace EVCB_OCPP.WEBAPI.Controllers.Version1
|
|
|
[Route("completedsession")]
|
|
|
[Produces(typeof(CPOOuterResponse))]
|
|
|
[HttpGet]
|
|
|
- public IActionResult CompletedSession(string ChargeBoxId, int SessionId = -1, string IdTag = "", string StartTime = "", string StopTime = "")
|
|
|
+ public async Task<IActionResult> CompletedSession(string ChargeBoxId, int SessionId = -1, string IdTag = "", string StartTime = "", string StopTime = "")
|
|
|
{
|
|
|
var result = new CPOOuterResponse();
|
|
|
//HttpStatusCode statusCode = HttpStatusCode.InternalServerError;
|
|
@@ -1284,9 +1284,9 @@ namespace EVCB_OCPP.WEBAPI.Controllers.Version1
|
|
|
|
|
|
try
|
|
|
{
|
|
|
- string _CustomerId = string.Empty;
|
|
|
+ string _CustomerId = GetCustomerId();
|
|
|
|
|
|
- if (!ContainsChargePoint(ChargeBoxId, out _CustomerId))
|
|
|
+ if (!await ContainsChargePointAsync(ChargeBoxId, _CustomerId))
|
|
|
{
|
|
|
// 沒槍~ 沒得充...
|
|
|
result.StatusMessage = CPO_StatusMessage.ERROR_MSG_CHARGEBOXID_DOESNT_EXIST;
|
|
@@ -1301,7 +1301,7 @@ namespace EVCB_OCPP.WEBAPI.Controllers.Version1
|
|
|
DateTime stopDt = string.IsNullOrEmpty(StopTime) ? new DateTime(1991, 1, 1) : DateTime.Parse(StopTime);
|
|
|
// query meter value
|
|
|
ChargePointService _service = serviceProvider.GetRequiredService<ChargePointService>();
|
|
|
- var _innerData = _service.GetSessionDetail(ChargeBoxId, SessionId, IdTag, startDt, stopDt);
|
|
|
+ var _innerData = await _service.GetSessionDetailAsync(ChargeBoxId, SessionId, IdTag, startDt, stopDt);
|
|
|
|
|
|
if (_innerData == null)
|
|
|
{
|