@using Microsoft.AspNetCore.Mvc.Localization @model TransactionListViewModel @inject IViewLocalizer Localizer @{ ViewData["Title"] = @Localizer["Title"]; }
@{ string timespan = (Model.Timespan == 2) ? "?t=2" : ((Model.Timespan == 3) ? "?t=3" : string.Empty); List connectorStatusViewModels = new List(); // Copy CP-Names in dictionary for name resolution and Dictionary chargePointNames = new Dictionary(); if (Model.ChargePoints != null) { foreach (ChargePoint cp in Model.ChargePoints) { chargePointNames.Add(cp.ChargePointId, cp.Name); } } // Count connectors for every charge point (=> naming scheme) Dictionary dictConnectorCount = new Dictionary(); string currentConnectorName = string.Empty; foreach (ConnectorStatus cs in Model.ConnectorStatuses) { if (dictConnectorCount.ContainsKey(cs.ChargePointId)) { // > 1 connector dictConnectorCount[cs.ChargePointId] = dictConnectorCount[cs.ChargePointId] + 1; } else { // first connector dictConnectorCount.Add(cs.ChargePointId, 1); } ConnectorStatusViewModel csvm = new ConnectorStatusViewModel(); csvm.ChargePointId = cs.ChargePointId; csvm.ConnectorId = cs.ConnectorId; string connectorName = cs.ConnectorName; if (string.IsNullOrEmpty(connectorName)) { // Default: use charge point name chargePointNames.TryGetValue(cs.ChargePointId, out connectorName); if (string.IsNullOrEmpty(connectorName)) { // Fallback: use charge point ID connectorName = cs.ChargePointId; } connectorName = $"{connectorName}:{cs.ConnectorId}"; } csvm.ConnectorName = connectorName; connectorStatusViewModels.Add(csvm); if (cs.ChargePointId == Model.CurrentChargePointId && cs.ConnectorId == Model.CurrentConnectorId) { currentConnectorName = connectorName; } } }
@Localizer["ChargePointLabel"]
@Localizer["TimeSpanLabel"]

@if (Model != null) { @if (Model.Transactions != null) { foreach (Transaction t in Model.Transactions) { string startTag = t.StartTagId; string stopTag = t.StopTagId; if (!string.IsNullOrEmpty(t.StartTagId) && Model.ChargeTags != null && Model.ChargeTags.ContainsKey(t.StartTagId)) { startTag = Model.ChargeTags[t.StartTagId]?.TagName; } if (!string.IsNullOrEmpty(t.StopTagId) && Model.ChargeTags != null && Model.ChargeTags.ContainsKey(t.StopTagId)) { stopTag = Model.ChargeTags[t.StopTagId]?.TagName; } } }
@Localizer["Connector"] @Localizer["StartTime"] @Localizer["StartTag"] @Localizer["StartMeter"] @Localizer["StopTime"] @Localizer["StopTag"] @Localizer["StopMeter"] @Localizer["ChargeSum"]
@currentConnectorName @string.Format("{0} {1}", t.StartTime.ToLocalTime().ToShortDateString(), t.StartTime.ToLocalTime().ToShortTimeString()) @startTag @string.Format("{0:0.0##}", t.MeterStart) @((t.StopTime != null) ? string.Format("{0} {1}", t.StopTime.Value.ToLocalTime().ToShortDateString(), t.StopTime.Value.ToLocalTime().ToShortTimeString()) : string.Empty) @stopTag @((t.MeterStop != null) ? string.Format("{0:0.0##}", t.MeterStop) : string.Empty) @((t.MeterStop != null) ? string.Format("{0:0.0##}", (t.MeterStop - t.MeterStart)) : string.Empty)
}