Beispiel #1
0
        public void Stop(ChargingReservation_Id Id,
                         DateTime?Timestamp = null,
                         AAuthentication StopAuthentication = null)
        {
            lock (InternalData)
            {
                if (InternalData.TryGetValue(Id, out ChargingReservationCollection reservationCollection))
                {
                    var reservation = reservationCollection.LastOrDefault();
                    if (reservation != null)
                    {
                        reservation.EndTime = Timestamp ?? DateTime.UtcNow;

                        if (StopAuthentication != null)
                        {
                            reservation.StopAuthentication = StopAuthentication;
                        }

                        LogIt("stop",
                              Id,
                              "reservations",
                              new JArray(reservation.ToJSON()));
                    }
                }
            }
        }
        public bool TryGetValue(object key, out object value)
        {
            if (InternalData.TryGetValue(key, out var entry))
            {
                value = entry.Value;
                return(true);
            }

            value = null;
            return(false);
        }
Beispiel #3
0
        public Boolean TryGetLatest(ChargingReservation_Id Id,
                                    out ChargingReservation LatestReservation)
        {
            if (InternalData.TryGetValue(Id, out ChargingReservationCollection ReservationCollection))
            {
                LatestReservation = ReservationCollection.LastOrDefault();
                return(true);
            }

            LatestReservation = null;
            return(false);
        }
        public void Remove(ChargingSession_Id ChargingSessionId,
                           AAuthentication Authentication)
        {
            lock (InternalData)
            {
                if (InternalData.TryGetValue(ChargingSessionId, out ChargingSession session))
                {
                    InternalData.Remove(session.Id);
                    session.AuthenticationStop = Authentication;

                    LogIt("remove",
                          session.Id,
                          "chargingSession",
                          session.ToJSON());
                }
            }
        }
Beispiel #5
0
        public ChargingReservationsStore UpdateLatest(ChargingReservation_Id Id,
                                                      Action <ChargingReservation> UpdateFunc)
        {
            lock (InternalData)
            {
                if (InternalData.TryGetValue(Id, out ChargingReservationCollection reservationCollection))
                {
                    UpdateFunc(reservationCollection.Last());
                }

                LogIt("update",
                      Id,
                      "reservations",
                      new JArray(reservationCollection.Select(reservation => reservation.ToJSON())));
            }

            return(this);
        }
        public ChargingSessionsStore Update(ChargingSession_Id Id,
                                            Action <ChargingSession> UpdateFunc)
        {
            lock (InternalData)
            {
                if (InternalData.TryGetValue(Id, out ChargingSession chargingSession))
                {
                    UpdateFunc(chargingSession);
                }

                LogIt("update",
                      Id,
                      "chargingSession",
                      chargingSession.ToJSON());
            }

            return(this);
        }
 public bool TryGetEntry(object key, out ICacheEntry entry)
 {
     return(InternalData.TryGetValue(key, out entry));
 }