コード例 #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()));
                    }
                }
            }
        }
コード例 #2
0
        public bool TryGetValue(object key, out object value)
        {
            if (InternalData.TryGetValue(key, out var entry))
            {
                value = entry.Value;
                return(true);
            }

            value = null;
            return(false);
        }
コード例 #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);
        }
コード例 #4
0
        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());
                }
            }
        }
コード例 #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);
        }
コード例 #6
0
        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);
        }
コード例 #7
0
 public bool TryGetEntry(object key, out ICacheEntry entry)
 {
     return(InternalData.TryGetValue(key, out entry));
 }