|
@@ -1,6 +1,5 @@
|
|
|
using Dapper;
|
|
|
using EVCB_OCPP.Domain;
|
|
|
-using EVCB_OCPP.Domain.Models.Database;
|
|
|
using EVCB_OCPP.Packet.Features;
|
|
|
using EVCB_OCPP.Packet.Messages;
|
|
|
using EVCB_OCPP.Packet.Messages.Core;
|
|
@@ -20,6 +19,7 @@ using System.Diagnostics;
|
|
|
using System.Globalization;
|
|
|
using SuperSocket.SocketBase;
|
|
|
using Microsoft.AspNetCore.Http;
|
|
|
+using EVCB_OCPP.Domain.Models.MainDb;
|
|
|
|
|
|
namespace EVCB_OCPP.WSServer.Message;
|
|
|
|
|
@@ -187,7 +187,7 @@ internal partial class ProfileHandler
|
|
|
|
|
|
logger.LogDebug("{0}\r\n{1}\r\n{2}", jo["txId"].Value<int>(), jo["dataString"].Value<string>(), jo["publicKey"].Value<string>());
|
|
|
|
|
|
- await mainDbService.AddOCMF(new OCMF()
|
|
|
+ await mainDbService.AddOCMF(new Ocmf()
|
|
|
{
|
|
|
TransactionId = jo["txId"].Value<int>(),
|
|
|
DataString = jo["dataString"].Value<string>(),
|
|
@@ -229,7 +229,7 @@ internal partial class ProfileHandler
|
|
|
_machine.ChargePointSerialNumber = string.IsNullOrEmpty(_request.chargePointSerialNumber) ? string.Empty : _request.chargePointSerialNumber;
|
|
|
_machine.ChargePointModel = string.IsNullOrEmpty(_request.chargePointModel) ? string.Empty : _request.chargePointModel;
|
|
|
_machine.ChargePointVendor = string.IsNullOrEmpty(_request.chargePointVendor) ? string.Empty : _request.chargePointVendor;
|
|
|
- _machine.FW_CurrentVersion = string.IsNullOrEmpty(_request.firmwareVersion) ? string.Empty : _request.firmwareVersion;
|
|
|
+ _machine.FwCurrentVersion = string.IsNullOrEmpty(_request.firmwareVersion) ? string.Empty : _request.firmwareVersion;
|
|
|
//_machine.Iccid = string.IsNullOrEmpty(_request.iccid) ? string.Empty : _request.iccid;
|
|
|
_machine.Iccid = DateTime.UtcNow.ToString("yy-MM-dd HH:mm");
|
|
|
_machine.Imsi = string.IsNullOrEmpty(_request.imsi) ? string.Empty : _request.imsi;
|
|
@@ -383,7 +383,7 @@ internal partial class ProfileHandler
|
|
|
|
|
|
using (var maindb = await maindbContextFactory.CreateDbContextAsync())
|
|
|
{
|
|
|
- meterStart = await maindb.TransactionRecord
|
|
|
+ meterStart = await maindb.TransactionRecords
|
|
|
.Where(x => x.Id == _request.transactionId.Value).Select(x => x.MeterStart)
|
|
|
.FirstOrDefaultAsync();
|
|
|
}
|
|
@@ -956,14 +956,14 @@ internal partial class ProfileHandler
|
|
|
DataTransferRequest _request = _confirm.GetRequest() as DataTransferRequest;
|
|
|
using (var db = await maindbContextFactory.CreateDbContextAsync())
|
|
|
{
|
|
|
- var operation = await db.MachineOperateRecord.Where(x => x.SerialNo == requestId &&
|
|
|
+ var operation = await db.MachineOperateRecords.Where(x => x.SerialNo == requestId &&
|
|
|
x.ChargeBoxId == session.ChargeBoxId && x.Status == 0).FirstOrDefaultAsync();
|
|
|
if (operation != null)
|
|
|
{
|
|
|
operation.FinishedOn = DateTime.UtcNow;
|
|
|
operation.Status = 1;//電樁有回覆
|
|
|
- operation.EVSE_Status = (int)_confirm.status;
|
|
|
- operation.EVSE_Value = string.IsNullOrEmpty(_confirm.data) ? "" : _confirm.data;
|
|
|
+ operation.EvseStatus = (int)_confirm.status;
|
|
|
+ operation.EvseValue = string.IsNullOrEmpty(_confirm.data) ? "" : _confirm.data;
|
|
|
await db.SaveChangesAsync();
|
|
|
}
|
|
|
|
|
@@ -974,7 +974,7 @@ internal partial class ProfileHandler
|
|
|
{
|
|
|
db.ChangeTracker.AutoDetectChangesEnabled = false;
|
|
|
//db.Configuration.ValidateOnSaveEnabled = false;
|
|
|
- db.Machine.Attach(machine);
|
|
|
+ db.Machines.Attach(machine);
|
|
|
machine.BoardVersions = _confirm.data;
|
|
|
db.Entry(machine).Property(x => x.BoardVersions).IsModified = true;
|
|
|
await db.SaveChangesAsync();
|
|
@@ -991,7 +991,7 @@ internal partial class ProfileHandler
|
|
|
List<ChargingBill> bill = new List<ChargingBill>();
|
|
|
List<ChargingPrice> chargingPrices = new List<ChargingPrice>();
|
|
|
var txEnergy = JsonConvert.DeserializeObject<TransactionEnergy>(_confirm.data);
|
|
|
- var feedto = await db.TransactionRecord.Where(x => x.Id == txEnergy.TxId).Select(x => new { Id = x.Id, ConnectorId = x.ConnectorId, Fee = x.Fee, StopTime = x.StopTime, StartTime = x.StartTime }).FirstOrDefaultAsync();
|
|
|
+ var feedto = await db.TransactionRecords.Where(x => x.Id == txEnergy.TxId).Select(x => new { Id = x.Id, ConnectorId = x.ConnectorId, Fee = x.Fee, StopTime = x.StopTime, StartTime = x.StartTime }).FirstOrDefaultAsync();
|
|
|
decimal chargedEnergy = 0m;
|
|
|
if (feedto == null || string.IsNullOrEmpty(feedto.Fee)) return result;
|
|
|
string currency = feedto.Fee.Substring(feedto.Fee.Length - 3);
|
|
@@ -1086,7 +1086,7 @@ internal partial class ProfileHandler
|
|
|
decimal accountBalance = 0;
|
|
|
decimal.TryParse(feedto.Fee.Split('+')[1], out accountBalance);
|
|
|
|
|
|
- var tx = await db.TransactionRecord.Where(x => x.Id == txEnergy.TxId).FirstOrDefaultAsync();
|
|
|
+ var tx = await db.TransactionRecords.Where(x => x.Id == txEnergy.TxId).FirstOrDefaultAsync();
|
|
|
if (tx == null)
|
|
|
{
|
|
|
logger.LogTrace("Tx is empty");
|
|
@@ -1205,7 +1205,7 @@ internal partial class ProfileHandler
|
|
|
tx.BillingDone = true;
|
|
|
db.ChangeTracker.AutoDetectChangesEnabled = false;
|
|
|
//db.Configuration.ValidateOnSaveEnabled = false;
|
|
|
- db.TransactionRecord.Attach(tx);
|
|
|
+ db.TransactionRecords.Attach(tx);
|
|
|
db.Entry(tx).Property(x => x.Cost).IsModified = true;
|
|
|
db.Entry(tx).Property(x => x.Receipt).IsModified = true;
|
|
|
db.Entry(tx).Property(x => x.BillingDone).IsModified = true;
|
|
@@ -1361,14 +1361,14 @@ internal partial class ProfileHandler
|
|
|
|
|
|
using (var db = await maindbContextFactory.CreateDbContextAsync())
|
|
|
{
|
|
|
- var operation = await db.MachineOperateRecord.Where(x => x.SerialNo == requestId &&
|
|
|
+ var operation = await db.MachineOperateRecords.Where(x => x.SerialNo == requestId &&
|
|
|
x.ChargeBoxId == session.ChargeBoxId && x.Status == 0).FirstOrDefaultAsync();
|
|
|
if (operation != null)
|
|
|
{
|
|
|
operation.FinishedOn = DateTime.UtcNow;
|
|
|
operation.Status = 1;//電樁有回覆
|
|
|
- operation.EVSE_Status = (int)_confirm.status;
|
|
|
- operation.EVSE_Value = _confirm.status.ToString();
|
|
|
+ operation.EvseStatus = (int)_confirm.status;
|
|
|
+ operation.EvseValue = _confirm.status.ToString();
|
|
|
await db.SaveChangesAsync();
|
|
|
}
|
|
|
|
|
@@ -1382,14 +1382,14 @@ internal partial class ProfileHandler
|
|
|
|
|
|
using (var db = await maindbContextFactory.CreateDbContextAsync())
|
|
|
{
|
|
|
- var operation = await db.MachineOperateRecord.Where(x => x.SerialNo == requestId &&
|
|
|
+ var operation = await db.MachineOperateRecords.Where(x => x.SerialNo == requestId &&
|
|
|
x.ChargeBoxId == session.ChargeBoxId && x.Status == 0).FirstOrDefaultAsync();
|
|
|
if (operation != null)
|
|
|
{
|
|
|
operation.FinishedOn = DateTime.UtcNow;
|
|
|
operation.Status = 1;//電樁有回覆
|
|
|
- operation.EVSE_Status = (int)_confirm.status;
|
|
|
- operation.EVSE_Value = _confirm.status.ToString();
|
|
|
+ operation.EvseStatus = (int)_confirm.status;
|
|
|
+ operation.EvseValue = _confirm.status.ToString();
|
|
|
await db.SaveChangesAsync();
|
|
|
}
|
|
|
|
|
@@ -1403,14 +1403,14 @@ internal partial class ProfileHandler
|
|
|
|
|
|
using (var db = await maindbContextFactory.CreateDbContextAsync())
|
|
|
{
|
|
|
- var operation = await db.MachineOperateRecord.Where(x => x.SerialNo == requestId &&
|
|
|
+ var operation = await db.MachineOperateRecords.Where(x => x.SerialNo == requestId &&
|
|
|
x.ChargeBoxId == session.ChargeBoxId && x.Status == 0).FirstOrDefaultAsync();
|
|
|
if (operation != null)
|
|
|
{
|
|
|
operation.FinishedOn = DateTime.UtcNow;
|
|
|
operation.Status = 1;//電樁有回覆
|
|
|
- operation.EVSE_Status = (int)_confirm.status;
|
|
|
- operation.EVSE_Value = _confirm.status.ToString();
|
|
|
+ operation.EvseStatus = (int)_confirm.status;
|
|
|
+ operation.EvseValue = _confirm.status.ToString();
|
|
|
await db.SaveChangesAsync();
|
|
|
}
|
|
|
|
|
@@ -1424,14 +1424,14 @@ internal partial class ProfileHandler
|
|
|
|
|
|
using (var db = await maindbContextFactory.CreateDbContextAsync())
|
|
|
{
|
|
|
- var operation = await db.MachineOperateRecord.Where(x => x.SerialNo == requestId &&
|
|
|
+ var operation = await db.MachineOperateRecords.Where(x => x.SerialNo == requestId &&
|
|
|
x.ChargeBoxId == session.ChargeBoxId && x.Status == 0).FirstOrDefaultAsync();
|
|
|
if (operation != null)
|
|
|
{
|
|
|
operation.FinishedOn = DateTime.UtcNow;
|
|
|
operation.Status = 1;//電樁有回覆
|
|
|
- operation.EVSE_Status = (int)_confirm.status;
|
|
|
- operation.EVSE_Value = _confirm.status.ToString();
|
|
|
+ operation.EvseStatus = (int)_confirm.status;
|
|
|
+ operation.EvseValue = _confirm.status.ToString();
|
|
|
await db.SaveChangesAsync();
|
|
|
}
|
|
|
|
|
@@ -1445,14 +1445,14 @@ internal partial class ProfileHandler
|
|
|
|
|
|
using (var db = await maindbContextFactory.CreateDbContextAsync())
|
|
|
{
|
|
|
- var operation = await db.MachineOperateRecord.Where(x => x.SerialNo == requestId &&
|
|
|
+ var operation = await db.MachineOperateRecords.Where(x => x.SerialNo == requestId &&
|
|
|
x.ChargeBoxId == session.ChargeBoxId && x.Status == 0).FirstOrDefaultAsync();
|
|
|
if (operation != null)
|
|
|
{
|
|
|
operation.FinishedOn = DateTime.UtcNow;
|
|
|
operation.Status = 1;//電樁有回覆
|
|
|
- operation.EVSE_Status = (int)_confirm.status;
|
|
|
- operation.EVSE_Value = _confirm.status.ToString();
|
|
|
+ operation.EvseStatus = (int)_confirm.status;
|
|
|
+ operation.EvseValue = _confirm.status.ToString();
|
|
|
await db.SaveChangesAsync();
|
|
|
}
|
|
|
|
|
@@ -1466,15 +1466,15 @@ internal partial class ProfileHandler
|
|
|
|
|
|
using (var db = await maindbContextFactory.CreateDbContextAsync())
|
|
|
{
|
|
|
- var operation = await db.MachineOperateRecord.Where(x => x.SerialNo == requestId &&
|
|
|
+ var operation = await db.MachineOperateRecords.Where(x => x.SerialNo == requestId &&
|
|
|
x.ChargeBoxId == session.ChargeBoxId && x.Status == 0).FirstOrDefaultAsync();
|
|
|
|
|
|
if (operation != null)
|
|
|
{
|
|
|
operation.FinishedOn = DateTime.UtcNow;
|
|
|
operation.Status = 1;//電樁有回覆
|
|
|
- operation.EVSE_Status = (int)_confirm.status;
|
|
|
- operation.EVSE_Value = _confirm.status.ToString();
|
|
|
+ operation.EvseStatus = (int)_confirm.status;
|
|
|
+ operation.EvseValue = _confirm.status.ToString();
|
|
|
|
|
|
}
|
|
|
|
|
@@ -1581,15 +1581,15 @@ internal partial class ProfileHandler
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- var operation = await db.MachineOperateRecord.Where(x => x.SerialNo == requestId &&
|
|
|
+ var operation = await db.MachineOperateRecords.Where(x => x.SerialNo == requestId &&
|
|
|
x.ChargeBoxId == session.ChargeBoxId && x.Status == 0).FirstOrDefaultAsync();
|
|
|
|
|
|
if (operation != null)
|
|
|
{
|
|
|
operation.FinishedOn = DateTime.UtcNow;
|
|
|
operation.Status = 1;//電樁有回覆
|
|
|
- operation.EVSE_Status = 1;
|
|
|
- operation.EVSE_Value = JsonConvert.SerializeObject(_confirm.configurationKey, Formatting.None);
|
|
|
+ operation.EvseStatus = 1;
|
|
|
+ operation.EvseValue = JsonConvert.SerializeObject(_confirm.configurationKey, Formatting.None);
|
|
|
|
|
|
}
|
|
|
|
|
@@ -1611,14 +1611,14 @@ internal partial class ProfileHandler
|
|
|
|
|
|
using (var db = await maindbContextFactory.CreateDbContextAsync())
|
|
|
{
|
|
|
- var operation = await db.MachineOperateRecord.Where(x => x.SerialNo == requestId &&
|
|
|
+ var operation = await db.MachineOperateRecords.Where(x => x.SerialNo == requestId &&
|
|
|
x.ChargeBoxId == session.ChargeBoxId && x.Status == 0).FirstOrDefaultAsync();
|
|
|
if (operation != null)
|
|
|
{
|
|
|
operation.FinishedOn = DateTime.UtcNow;
|
|
|
operation.Status = 1;//電樁有回覆
|
|
|
- operation.EVSE_Status = (int)_confirm.status;
|
|
|
- operation.EVSE_Value = _confirm.status.ToString();
|
|
|
+ operation.EvseStatus = (int)_confirm.status;
|
|
|
+ operation.EvseValue = _confirm.status.ToString();
|
|
|
await db.SaveChangesAsync();
|
|
|
}
|
|
|
|
|
@@ -1666,14 +1666,14 @@ internal partial class ProfileHandler
|
|
|
|
|
|
using (var db = await maindbContextFactory.CreateDbContextAsync())
|
|
|
{
|
|
|
- var operation = await db.MachineOperateRecord.Where(x => x.SerialNo == requestId &&
|
|
|
+ var operation = await db.MachineOperateRecords.Where(x => x.SerialNo == requestId &&
|
|
|
x.ChargeBoxId == session.ChargeBoxId && x.Status == 0).FirstOrDefaultAsync();
|
|
|
if (operation != null)
|
|
|
{
|
|
|
operation.FinishedOn = DateTime.UtcNow;
|
|
|
operation.Status = 1;//電樁有回覆
|
|
|
- operation.EVSE_Status = (int)255;//錯誤
|
|
|
- operation.EVSE_Value = errorMsg;
|
|
|
+ operation.EvseStatus = (int)255;//錯誤
|
|
|
+ operation.EvseValue = errorMsg;
|
|
|
await db.SaveChangesAsync();
|
|
|
}
|
|
|
|