|
@@ -68,6 +68,7 @@ namespace EVCB_OCPP.WSServer.Message
|
|
static private ILogger logger = NLog.LogManager.GetCurrentClassLogger();
|
|
static private ILogger logger = NLog.LogManager.GetCurrentClassLogger();
|
|
string webConnectionString = ConfigurationManager.ConnectionStrings["WebDBContext"].ConnectionString;
|
|
string webConnectionString = ConfigurationManager.ConnectionStrings["WebDBContext"].ConnectionString;
|
|
private OuterHttpClient httpClient = new OuterHttpClient();
|
|
private OuterHttpClient httpClient = new OuterHttpClient();
|
|
|
|
+ private SMSService smsService = new SMSService();
|
|
async internal Task<MessageResult> ExecuteCoreRequest(Actions action, ClientData session, IRequest request)
|
|
async internal Task<MessageResult> ExecuteCoreRequest(Actions action, ClientData session, IRequest request)
|
|
{
|
|
{
|
|
Stopwatch watch = new Stopwatch();
|
|
Stopwatch watch = new Stopwatch();
|
|
@@ -273,6 +274,28 @@ namespace EVCB_OCPP.WSServer.Message
|
|
|
|
|
|
if (_request.status == Packet.Messages.SubTypes.ChargePointStatus.Faulted)
|
|
if (_request.status == Packet.Messages.SubTypes.ChargePointStatus.Faulted)
|
|
{
|
|
{
|
|
|
|
+ var alarmCond = GlobalConfig.GetAlarmNotification_Cond();
|
|
|
|
+
|
|
|
|
+ if (alarmCond.Contains(_request.vendorErrorCode))
|
|
|
|
+ {
|
|
|
|
+ List<string> sendlist = GlobalConfig.GetSMS_Receivers().Split(',').ToList();
|
|
|
|
+ foreach (var item in sendlist)
|
|
|
|
+ {
|
|
|
|
+ //[台北樂群站告警-012251]
|
|
|
|
+ //DBYC182000D1TCN2147A102A1 - 2
|
|
|
|
+ //時間: 2022 / 08 / 11 15:35:30
|
|
|
|
+ string message = string.Format("[{0}告警-{1}]\r\n{2} -{3}\r\n時間:{4}\r\n", session.StationName, _request.vendorErrorCode, session.ChargeBoxId,
|
|
|
|
+ _request.connectorId, DateTime.UtcNow.AddHours(8).ToString("yyyy/MM/dd HH:mm:ss"));
|
|
|
|
+ string errorMsg = string.Empty;
|
|
|
|
+ smsService.SendMessage(item, message, out errorMsg);
|
|
|
|
+
|
|
|
|
+ if(!string.IsNullOrEmpty(errorMsg))
|
|
|
|
+ {
|
|
|
|
+ logger.Error("Send SMS Error "+ errorMsg);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
var businessService = BusinessServiceFactory.CreateBusinessService(session.CustomerId.ToString());
|
|
var businessService = BusinessServiceFactory.CreateBusinessService(session.CustomerId.ToString());
|
|
var notification = businessService.NotifyFaultStatus(new ErrorDetails()
|
|
var notification = businessService.NotifyFaultStatus(new ErrorDetails()
|
|
{
|
|
{
|
|
@@ -284,6 +307,8 @@ namespace EVCB_OCPP.WSServer.Message
|
|
VendorErrorCode = string.IsNullOrEmpty(_request.vendorErrorCode) ? string.Empty : _request.vendorErrorCode,
|
|
VendorErrorCode = string.IsNullOrEmpty(_request.vendorErrorCode) ? string.Empty : _request.vendorErrorCode,
|
|
|
|
|
|
});
|
|
});
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
var confirm = new StatusNotificationConfirmation() { };
|
|
var confirm = new StatusNotificationConfirmation() { };
|
|
@@ -302,7 +327,7 @@ namespace EVCB_OCPP.WSServer.Message
|
|
case Actions.MeterValues:
|
|
case Actions.MeterValues:
|
|
{
|
|
{
|
|
|
|
|
|
- MeterValuesRequest _request = request as MeterValuesRequest;
|
|
|
|
|
|
+ MeterValuesRequest _request = request as MeterValuesRequest;
|
|
|
|
|
|
if (_request.meterValue.Count > 0)
|
|
if (_request.meterValue.Count > 0)
|
|
{
|
|
{
|
|
@@ -312,11 +337,11 @@ namespace EVCB_OCPP.WSServer.Message
|
|
{
|
|
{
|
|
foreach (var item in _request.meterValue)
|
|
foreach (var item in _request.meterValue)
|
|
{
|
|
{
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+
|
|
foreach (var sampleVaule in item.sampledValue)
|
|
foreach (var sampleVaule in item.sampledValue)
|
|
{
|
|
{
|
|
- decimal value = Convert.ToDecimal(sampleVaule.value);
|
|
|
|
|
|
+ decimal value = Convert.ToDecimal(sampleVaule.value);
|
|
|
|
|
|
string sp = "[dbo].[uspInsertMeterValueRecord] @ChargeBoxId," +
|
|
string sp = "[dbo].[uspInsertMeterValueRecord] @ChargeBoxId," +
|
|
"@ConnectorId,@Value,@CreatedOn,@ContextId,@FormatId,@MeasurandId,@PhaseId,@LocationId,@UnitId,@TransactionId";
|
|
"@ConnectorId,@Value,@CreatedOn,@ContextId,@FormatId,@MeasurandId,@PhaseId,@LocationId,@UnitId,@TransactionId";
|