public static PushRoamingNetworkAdminStatusResult Flatten(IId AuthId, ISendAdminStatus ISendAdminStatus, IEnumerable <PushRoamingNetworkAdminStatusResult> PushRoamingNetworkAdminStatusResults, TimeSpan Runtime) { #region Initial checks if (PushRoamingNetworkAdminStatusResults == null || !PushRoamingNetworkAdminStatusResults.Any()) { return(new PushRoamingNetworkAdminStatusResult(AuthId, ISendAdminStatus, PushRoamingNetworkAdminStatusResultTypes.Error, "!", new RoamingNetworkAdminStatusUpdate[0], new Warning[0], Runtime)); } #endregion var All = PushRoamingNetworkAdminStatusResults.ToArray(); var ResultOverview = All.GroupBy(_ => _.Result). ToDictionary(_ => _.Key, _ => new List <PushRoamingNetworkAdminStatusResult>(_)); var Descriptions = All.Where(_ => _ != null). SafeSelect(_ => _.Description). AggregateWith(Environment.NewLine); var RejectedRoamingNetworkAdminStatusUpdates = All.Where(_ => _ != null). SelectMany(_ => _.RejectedRoamingNetworkAdminStatusUpdates); var Warnings = All.Where(_ => _ != null). SelectMany(_ => _.Warnings); foreach (var result in ResultOverview) { if (ResultOverview[result.Key].Count == All.Length) { return(new PushRoamingNetworkAdminStatusResult(All[0].AuthId, ISendAdminStatus, result.Key, Descriptions, RejectedRoamingNetworkAdminStatusUpdates, Warnings, Runtime)); } } return(new PushRoamingNetworkAdminStatusResult(All[0].AuthId, ISendAdminStatus, PushRoamingNetworkAdminStatusResultTypes.Partial, Descriptions, RejectedRoamingNetworkAdminStatusUpdates, Warnings, Runtime)); }
public static PushRoamingNetworkAdminStatusResult LockTimeout(IId AuthId, ISendAdminStatus ISendAdminStatus, String Description = null, IEnumerable <Warning> Warnings = null, TimeSpan?Runtime = null) => new PushRoamingNetworkAdminStatusResult(AuthId, ISendAdminStatus, PushRoamingNetworkAdminStatusResultTypes.LockTimeout, Description, new RoamingNetworkAdminStatusUpdate[0], Warnings, Runtime);
NoOperation(IId AuthId, ISendAdminStatus ISendAdminStatus, String Description = null, IEnumerable <Warning> Warnings = null, TimeSpan?Runtime = null) => new PushChargingStationAdminStatusResult(AuthId, ISendAdminStatus, PushChargingStationAdminStatusResultTypes.NoOperation, Description, new ChargingStationAdminStatusUpdate[0], Warnings, Runtime);
Enqueued(IId AuthId, ISendAdminStatus ISendAdminStatus, String Description = null, IEnumerable <Warning> Warnings = null, TimeSpan?Runtime = null) => new PushEVSEAdminStatusResult(AuthId, ISendAdminStatus, PushEVSEAdminStatusResultTypes.Enqueued, Description, new EVSEAdminStatusUpdate[0], Warnings, Runtime);
Error(IId AuthId, ISendAdminStatus ISendAdminStatus, IEnumerable <RoamingNetworkAdminStatusUpdate> RejectedRoamingNetworks = null, String Description = null, IEnumerable <Warning> Warnings = null, TimeSpan?Runtime = null) => new PushRoamingNetworkAdminStatusResult(AuthId, ISendAdminStatus, PushRoamingNetworkAdminStatusResultTypes.Error, Description, RejectedRoamingNetworks, Warnings, Runtime);
AdminDown(IId AuthId, ISendAdminStatus ISendAdminStatus, IEnumerable <ChargingPoolAdminStatusUpdate> RejectedRoamingNetworkAdminStatusUpdates, String Description = null, IEnumerable <Warning> Warnings = null, TimeSpan?Runtime = null) => new PushRoamingNetworkAdminStatusResult(AuthId, ISendAdminStatus, PushRoamingNetworkAdminStatusResultTypes.AdminDown, Description, new RoamingNetworkAdminStatusUpdate[0], Warnings, Runtime);
Error(IId AuthId, ISendAdminStatus ISendAdminStatus, IEnumerable <ChargingStationAdminStatusUpdate> RejectedChargingStations = null, String Description = null, IEnumerable <Warning> Warnings = null, TimeSpan?Runtime = null) => new PushChargingStationAdminStatusResult(AuthId, ISendAdminStatus, PushChargingStationAdminStatusResultTypes.Error, Description, RejectedChargingStations, Warnings, Runtime);
OutOfService(IId AuthId, ISendAdminStatus ISendAdminStatus, IEnumerable <ChargingPoolAdminStatusUpdate> RejectedChargingStationAdminStatusUpdates, String Description = null, IEnumerable <Warning> Warnings = null, TimeSpan?Runtime = null) => new PushChargingStationAdminStatusResult(AuthId, ISendAdminStatus, PushChargingStationAdminStatusResultTypes.OutOfService, Description, new ChargingStationAdminStatusUpdate[0], Warnings, Runtime);
AdminDown(IId AuthId, ISendAdminStatus ISendAdminStatus, IEnumerable <EVSEAdminStatusUpdate> RejectedEVSEAdminStatusUpdates, String Description = null, IEnumerable <Warning> Warnings = null, TimeSpan?Runtime = null) => new PushEVSEAdminStatusResult(AuthId, ISendAdminStatus, PushEVSEAdminStatusResultTypes.AdminDown, Description, RejectedEVSEAdminStatusUpdates, Warnings, Runtime);
/// <summary> /// Create a new PushRoamingNetworkAdminStatus result. /// </summary> /// <param name="AuthId">The unqiue identification of the authenticator.</param> /// <param name="ISendAdminStatus">An object implementing ISendAdminStatus.</param> /// <param name="Result">The result of the operation.</param> /// <param name="Description">An optional description of the result code.</param> /// <param name="RejectedRoamingNetworkAdminStatusUpdates">An enumeration of rejected RoamingNetwork status updates.</param> /// <param name="Warnings">Warnings or additional information.</param> /// <param name="Runtime">The runtime of the request.</param> internal PushRoamingNetworkAdminStatusResult(IId AuthId, ISendAdminStatus ISendAdminStatus, PushRoamingNetworkAdminStatusResultTypes Result, String Description = null, IEnumerable <RoamingNetworkAdminStatusUpdate> RejectedRoamingNetworkAdminStatusUpdates = null, IEnumerable <Warning> Warnings = null, TimeSpan?Runtime = null) : this(AuthId, Result, Description, RejectedRoamingNetworkAdminStatusUpdates, Warnings, Runtime) { this.ISendAdminStatus = ISendAdminStatus; }
UpdateStatus(ISendAdminStatus Sender, IEnumerable <EVSEAdminStatusUpdate> AdminStatusUpdates, DateTime?Timestamp, CancellationToken?CancellationToken, EventTracking_Id EventTrackingId, TimeSpan?RequestTimeout) { #region Initial checks if (AdminStatusUpdates == null || !AdminStatusUpdates.Any()) { return(PushEVSEAdminStatusResult.NoOperation(Id, Sender)); } if (DisablePushStatus) { return(PushEVSEAdminStatusResult.AdminDown(Id, Sender, AdminStatusUpdates)); } #endregion #region Send OnEnqueueSendCDRRequest event //try //{ // OnEnqueueSendCDRRequest?.Invoke(StartTime, // Timestamp.Value, // this, // EventTrackingId, // RoamingNetwork.Id, // ChargeDetailRecord, // RequestTimeout); //} //catch (Exception e) //{ // e.Log(nameof(WWCPCPOAdapter) + "." + nameof(OnSendCDRRequest)); //} #endregion await DataAndStatusLock.WaitAsync().ConfigureAwait(false); try { var FilteredUpdates = AdminStatusUpdates.Where(adminstatusupdate => _IncludeEVSEs(adminstatusupdate.EVSE) && _IncludeEVSEIds(adminstatusupdate.EVSE.Id)). ToArray(); if (FilteredUpdates.Length > 0) { foreach (var Update in FilteredUpdates) { // Delay the status update until the EVSE data had been uploaded! if (!DisablePushData && EVSEsToAddQueue.Any(evse => evse == Update.EVSE)) { EVSEAdminStatusChangesDelayedQueue.Add(Update); } else { EVSEAdminStatusChangesFastQueue.Add(Update); } } FlushEVSEFastStatusTimer.Change(FlushEVSEFastStatusEvery, TimeSpan.FromMilliseconds(-1)); return(PushEVSEAdminStatusResult.Enqueued(Id, Sender)); } return(PushEVSEAdminStatusResult.NoOperation(Id, Sender)); } finally { DataAndStatusLock.Release(); } }