示例#1
0
        public JObject ToJSON()

        => JSONObject.Create(

            new JProperty("@id", Id.ToString()),
            new JProperty("timestamp", Timestamp.ToIso8601()),
            new JProperty("startTime", StartTime.ToIso8601()),
            new JProperty("duration", Duration.TotalMinutes),
            new JProperty("endTime", EndTime.ToIso8601()),

            new JProperty("consumedReservationTime", ConsumedReservationTime.TotalMinutes),
            new JProperty("reservationLevel", ReservationLevel.ToString()),

            ProviderId.HasValue
                       ? new JProperty("providerId", ProviderId.ToString())
                       : null,

            StartAuthentication != null
                       ? new JProperty("authentication", EndTime.ToIso8601())
                       : null,

            RoamingNetworkId.HasValue
                       ? new JProperty("roamingNetworkId", RoamingNetworkId.ToString())
                       : null,

            ChargingPoolId.HasValue
                       ? new JProperty("chargingPoolId", ChargingPoolId.ToString())
                       : null,

            ChargingStationId.HasValue
                       ? new JProperty("chargingStationId", ChargingStationId.ToString())
                       : null,

            EVSEId.HasValue
                       ? new JProperty("EVSEId", EVSEId.ToString())
                       : null,

            ChargingProduct != null
                       ? new JProperty("chargingProduct", ChargingProduct.ToJSON())
                       : null,

            ChargingSession != null
                       ? new JProperty("chargingSessionId", ChargingSession.Id.ToString())
                       : null

            );
示例#2
0
        public JObject ToJSON()

        => JSONObject.Create(

            new JProperty("@id", SessionId.ToString()),
            new JProperty("@context", ""),

            SessionTime.HasValue
                               ? new JProperty("sessionTime", JSONObject.Create(
                                                   new JProperty("start", SessionTime.Value.StartTime.ToIso8601()),
                                                   SessionTime.Value.EndTime.HasValue
                                         ? new JProperty("end", SessionTime.Value.EndTime.Value.ToIso8601())
                                         : null
                                                   ))
                               : null,

            Duration.HasValue
                               ? new JProperty("duration", Duration.Value.TotalSeconds)
                               : null,

            ChargingStationOperatorId.HasValue
                               ? new JProperty("chargingStationOperatorId", ChargingStationOperatorId.ToString())
                               : null,
            ChargingPoolId.HasValue
                               ? new JProperty("chargingPoolId", ChargingPoolId.ToString())
                               : null,
            ChargingStationId.HasValue
                               ? new JProperty("chargingStationId", ChargingStationId.ToString())
                               : null,
            EVSEId.HasValue
                               ? new JProperty("evseId", EVSEId.ToString())
                               : null,


            ChargingProduct != null
                               ? new JProperty("chargingProduct", ChargingProduct.ToJSON())
                               : null

            //new JProperty("meterValue",     MeterValue),
            //new JProperty("meterId",        MeterId.ToString()),

            //new JProperty("userId",         UserId),
            //new JProperty("publicKey",      PublicKey.KeyId),
            //new JProperty("lastSignature",  lastSignature),
            //new JProperty("signature",      Signature)
            );
        /// <summary>
        /// Compares two heartbeat requests for equality.
        /// </summary>
        /// <param name="SetChargingStationAvailabilityStatusRequest">A heartbeat request to compare with.</param>
        /// <returns>True if both match; False otherwise.</returns>
        public override Boolean Equals(SetChargingStationAvailabilityStatusRequest SetChargingStationAvailabilityStatusRequest)
        {
            if ((Object)SetChargingStationAvailabilityStatusRequest == null)
            {
                return(false);
            }

            return(((!TransactionId.HasValue && !SetChargingStationAvailabilityStatusRequest.TransactionId.HasValue) ||
                    (TransactionId.HasValue && SetChargingStationAvailabilityStatusRequest.TransactionId.HasValue && TransactionId.Value.Equals(SetChargingStationAvailabilityStatusRequest.TransactionId.Value))) &&

                   PartnerId.Equals(SetChargingStationAvailabilityStatusRequest.PartnerId) &&
                   OperatorId.Equals(SetChargingStationAvailabilityStatusRequest.OperatorId) &&
                   ChargingStationId.Equals(SetChargingStationAvailabilityStatusRequest.ChargingStationId) &&
                   StatusEventDate.Equals(SetChargingStationAvailabilityStatusRequest.StatusEventDate) &&
                   AvailabilityStatus.Equals(SetChargingStationAvailabilityStatusRequest.AvailabilityStatus) &&

                   ((!AvailabilityStatusUntil.HasValue && !SetChargingStationAvailabilityStatusRequest.AvailabilityStatusUntil.HasValue) ||
                    (AvailabilityStatusUntil.HasValue && SetChargingStationAvailabilityStatusRequest.AvailabilityStatusUntil.HasValue && AvailabilityStatusUntil.Value.Equals(SetChargingStationAvailabilityStatusRequest.AvailabilityStatusUntil.Value))) &&

                   ((!AvailabilityStatusComment.IsNeitherNullNorEmpty() && !SetChargingStationAvailabilityStatusRequest.AvailabilityStatusComment.IsNeitherNullNorEmpty()) ||
                    (AvailabilityStatusComment.IsNeitherNullNorEmpty() && SetChargingStationAvailabilityStatusRequest.AvailabilityStatusComment.IsNeitherNullNorEmpty() && AvailabilityStatusComment.Equals(SetChargingStationAvailabilityStatusRequest.AvailabilityStatusComment))));
        }
        /// <summary>
        /// Return the HashCode of this object.
        /// </summary>
        /// <returns>The HashCode of this object.</returns>
        public override Int32 GetHashCode()
        {
            unchecked
            {
                return((TransactionId.HasValue
                            ? TransactionId.GetHashCode() * 19
                            : 0) ^

                       PartnerId.GetHashCode() * 17 ^
                       OperatorId.GetHashCode() * 13 ^
                       ChargingStationId.GetHashCode() * 11 ^
                       StatusEventDate.GetHashCode() * 7 ^
                       AvailabilityStatus.GetHashCode() * 5 ^

                       (AvailabilityStatusUntil.HasValue
                            ? AvailabilityStatusUntil.GetHashCode() * 3
                            : 0) ^

                       (AvailabilityStatusComment.IsNeitherNullNorEmpty()
                            ? AvailabilityStatusComment.GetHashCode()
                            : 0));
            }
        }
        /// <summary>
        /// Return a XML representation of this object.
        /// </summary>
        /// <param name="CustomSetChargingStationAvailabilityStatusRequestSerializer">A delegate to serialize custom set ChargingStation availability status request XML elements.</param>
        public XElement ToXML(CustomXMLSerializerDelegate <SetChargingStationAvailabilityStatusRequest> CustomSetChargingStationAvailabilityStatusRequestSerializer = null)
        {
            var XML = new XElement(eMIPNS.EVCIDynamic + "eMIP_ToIOP_SetChargingStationAvailabilityStatusRequest",

                                   TransactionId.HasValue
                              ? new XElement(eMIPNS.EVCIDynamic + "transactionId", TransactionId.ToString())
                              : null,

                                   new XElement(eMIPNS.EVCIDynamic + "partnerIdType", PartnerId.Format.ToString()),
                                   new XElement(eMIPNS.EVCIDynamic + "partnerId", PartnerId.ToString()),

                                   new XElement(eMIPNS.EVCIDynamic + "operatorIdType", OperatorId.Format.ToString()),
                                   new XElement(eMIPNS.EVCIDynamic + "operatorId", OperatorId.ToString()),

                                   new XElement(eMIPNS.EVCIDynamic + "ChargingStationIdType", ChargingStationId.Format.ToString()),
                                   new XElement(eMIPNS.EVCIDynamic + "ChargingStationId", ChargingStationId.ToString()),

                                   new XElement(eMIPNS.EVCIDynamic + "statusEventDate", StatusEventDate.ToIso8601(false)),
                                   new XElement(eMIPNS.EVCIDynamic + "availabilityStatus", AvailabilityStatus.AsNumber()),

                                   AvailabilityStatusUntil.HasValue
                              ? new XElement(eMIPNS.EVCIDynamic + "availabilityStatusUntil", AvailabilityStatusUntil.Value.ToIso8601(false))
                              : null,

                                   AvailabilityStatusComment.IsNeitherNullNorEmpty()
                              ? new XElement(eMIPNS.EVCIDynamic + "availabilityStatusComment", AvailabilityStatusComment)
                              : null

                                   );


            return(CustomSetChargingStationAvailabilityStatusRequestSerializer != null
                       ? CustomSetChargingStationAvailabilityStatusRequestSerializer(this, XML)
                       : XML);
        }
示例#6
0
        //public ChargingSession AddUserData(String Key, Object Value)
        //{
        //    this._UserDefined
        //}



        public JObject ToJSON(Boolean Embedded = false)

            => JSONObject.Create(

                   Id.ToJSON("@id"),

                   Embedded
                       ? new JProperty("@context",  "https://open.charging.cloud/contexts/wwcp+json/chargingSession")
                       : null,

                   new JProperty("sessionTime",           JSONObject.Create(
                         new JProperty("start",             SessionTime.StartTime.ToIso8601()),
                         SessionTime.EndTime.HasValue
                             ? new JProperty("end",         SessionTime.EndTime.Value.ToIso8601())
                             : null
                     )),

                   new JProperty("duration",                Duration.TotalSeconds),


                   RoamingNetworkId.HasValue
                       ? new JProperty("roamingNetworkId",           RoamingNetworkId.ToString())
                       : null,

                   ChargingStationOperatorId.HasValue
                       ? new JProperty("chargingStationOperatorId",  ChargingStationOperatorId.ToString())
                       : null,

                   ChargingPoolId.HasValue
                       ? new JProperty("chargingPoolId",             ChargingPoolId.           ToString())
                       : null,

                   ChargingStationId.HasValue
                       ? new JProperty("chargingStationId",          ChargingStationId.        ToString())
                       : null,

                   EVSEId.HasValue
                       ? new JProperty("EVSEId",                     EVSEId.                   ToString())
                       : null,

                   ChargingProduct != null
                       ? new JProperty("chargingProduct",            ChargingProduct.          ToJSON())
                       : null,


                   ProviderIdStart != null
                       ? new JProperty("providerIdStart",            ProviderIdStart.ToString())
                       : null,

                   ProviderIdStop != null
                       ? new JProperty("providerIdStop",             ProviderIdStop.ToString())
                       : null,

                   AuthenticationStart.IsDefined()
                       ? new JProperty("authenticationStart",        AuthenticationStart.ToJSON())
                       : null,

                   AuthenticationStop.IsDefined()
                       ? new JProperty("authenticationStop",         AuthenticationStop.ToJSON())
                       : null,




                   Reservation != null

                       ? new JProperty("reservation", new JObject(
                                                          new JProperty("reservationId",  Reservation.Id.ToString()),
                                                          new JProperty("start",          Reservation.StartTime.ToIso8601()),
                                                          new JProperty("duration",       Reservation.Duration.TotalSeconds)
                                                          )
                                                      )

                       : ReservationId != null
                             ? new JProperty("reservationId",            ReservationId.ToString())
                             : null,





                   EnergyMeterId.HasValue
                       ? new JProperty("energyMeterId",              EnergyMeterId.ToString())
                       : null,

                   EnergyMeteringValues.Any()
                       ? new JProperty("energyMeterValues",          new JObject(
                                                                         EnergyMeteringValues.
                                                                         Select(MeterValue => new JProperty(MeterValue.Timestamp.ToIso8601(),
                                                                                                            MeterValue.Value))
                                                                     ))
                       : null

            );