/// <summary>
        /// Return a JSON-representation of this object.
        /// </summary>
        /// <param name="CustomAuthorizeRemoteReservationStartRequestSerializer">A delegate to customize the serialization of AuthorizeRemoteReservationStartRequest responses.</param>
        /// <param name="CustomIdentificationSerializer">A delegate to serialize custom Identification JSON objects.</param>
        public JObject ToJSON(CustomJObjectSerializerDelegate <AuthorizeRemoteReservationStartRequest> CustomAuthorizeRemoteReservationStartRequestSerializer = null,
                              CustomJObjectSerializerDelegate <Identification> CustomIdentificationSerializer = null)
        {
            var JSON = JSONObject.Create(

                new JProperty("ProviderID", ProviderId.ToString()),
                new JProperty("EvseID", EVSEId.ToString()),
                new JProperty("Identification", Identification.ToJSON(CustomIdentificationSerializer)),

                SessionId.HasValue
                               ? new JProperty("SessionID", SessionId.Value.ToString())
                               : null,

                CPOPartnerSessionId.HasValue
                               ? new JProperty("CPOPartnerSessionID", CPOPartnerSessionId.Value.ToString())
                               : null,

                EMPPartnerSessionId.HasValue
                               ? new JProperty("EMPPartnerSessionID", EMPPartnerSessionId.Value.ToString())
                               : null,

                PartnerProductId.HasValue
                               ? new JProperty("PartnerProductID", PartnerProductId.Value.ToString())
                               : null,

                Duration.HasValue
                               ? new JProperty("Duration", (Int32)Duration.Value.TotalMinutes)
                               : null,

                CustomData != null
                               ? new JProperty("CustomData", CustomData)
                               : null

                );

            return(CustomAuthorizeRemoteReservationStartRequestSerializer != null
                       ? CustomAuthorizeRemoteReservationStartRequestSerializer(this, JSON)
                       : JSON);
        }
예제 #2
0
        /// <summary>
        /// Create a new ChargingStartNotification request.
        /// </summary>
        /// <param name="SessionId">The Hubject session identification, that identifies the charging process.</param>
        /// <param name="Identification">The authentication data used to authorize the user or the car.</param>
        /// <param name="EVSEId">The EVSE identification, that identifies the location of the charging process.</param>
        /// <param name="ChargingStart">The timestamp when the charging process started.</param>
        ///
        /// <param name="CPOPartnerSessionId">An optional session identification assinged by the CPO partner.</param>
        /// <param name="EMPPartnerSessionId">An optional session identification assinged by the EMP partner.</param>
        /// <param name="SessionStart">An optional timestamp when the charging session started.</param>
        /// <param name="MeterValueStart">An optional starting value of the energy meter [kWh].</param>
        /// <param name="OperatorId">An optional operator identification of the hub operator.</param>
        /// <param name="PartnerProductId">An optional pricing product name (for identifying a tariff) that must be unique.</param>
        /// <param name="CustomData">Optional customer specific data, e.g. in combination with custom parsers and serializers.</param>
        ///
        /// <param name="Timestamp">The optional timestamp of the request.</param>
        /// <param name="CancellationToken">An optional token to cancel this request.</param>
        /// <param name="EventTrackingId">An optional event tracking identification for correlating this request with other events.</param>
        /// <param name="RequestTimeout">The timeout for this request.</param>
        public ChargingStartNotificationRequest(Session_Id SessionId,
                                                Identification Identification,
                                                EVSE_Id EVSEId,
                                                DateTime ChargingStart,

                                                CPOPartnerSession_Id?CPOPartnerSessionId = null,
                                                EMPPartnerSession_Id?EMPPartnerSessionId = null,
                                                DateTime?SessionStart              = null,
                                                Decimal?MeterValueStart            = null,
                                                Operator_Id?OperatorId             = null,
                                                PartnerProduct_Id?PartnerProductId = null,
                                                JObject CustomData = null,

                                                DateTime?Timestamp = null,
                                                CancellationToken?CancellationToken = null,
                                                EventTracking_Id EventTrackingId    = null,
                                                TimeSpan?RequestTimeout             = null)

            : base(CustomData,
                   Timestamp,
                   CancellationToken,
                   EventTrackingId,
                   RequestTimeout)

        {
            this.Type           = ChargingNotificationTypes.Start;
            this.SessionId      = SessionId;
            this.Identification = Identification;
            this.EVSEId         = EVSEId;
            this.ChargingStart  = ChargingStart;

            this.CPOPartnerSessionId = CPOPartnerSessionId;
            this.EMPPartnerSessionId = EMPPartnerSessionId;
            this.SessionStart        = SessionStart;
            this.MeterValueStart     = MeterValueStart;
            this.OperatorId          = OperatorId;
            this.PartnerProductId    = PartnerProductId;
        }
        /// <summary>
        /// Compares two authorize remote start requests for equality.
        /// </summary>
        /// <param name="AuthorizeRemoteStartRequest">An authorize remote start request to compare with.</param>
        /// <returns>True if both match; False otherwise.</returns>
        public override Boolean Equals(AuthorizeRemoteStartRequest AuthorizeRemoteStartRequest)
        {
            if (AuthorizeRemoteStartRequest is null)
            {
                return(false);
            }

            return(ProviderId.Equals(AuthorizeRemoteStartRequest.ProviderId) &&
                   EVSEId.Equals(AuthorizeRemoteStartRequest.EVSEId) &&
                   Identification.Equals(AuthorizeRemoteStartRequest.Identification) &&

                   ((!SessionId.HasValue && !AuthorizeRemoteStartRequest.SessionId.HasValue) ||
                    (SessionId.HasValue && AuthorizeRemoteStartRequest.SessionId.HasValue && SessionId.Value.Equals(AuthorizeRemoteStartRequest.SessionId.Value))) &&

                   ((!CPOPartnerSessionId.HasValue && !AuthorizeRemoteStartRequest.CPOPartnerSessionId.HasValue) ||
                    (CPOPartnerSessionId.HasValue && AuthorizeRemoteStartRequest.CPOPartnerSessionId.HasValue && CPOPartnerSessionId.Value.Equals(AuthorizeRemoteStartRequest.CPOPartnerSessionId.Value))) &&

                   ((!EMPPartnerSessionId.HasValue && !AuthorizeRemoteStartRequest.EMPPartnerSessionId.HasValue) ||
                    (EMPPartnerSessionId.HasValue && AuthorizeRemoteStartRequest.EMPPartnerSessionId.HasValue && EMPPartnerSessionId.Value.Equals(AuthorizeRemoteStartRequest.EMPPartnerSessionId.Value))) &&

                   ((!PartnerProductId.HasValue && !AuthorizeRemoteStartRequest.PartnerProductId.HasValue) ||
                    (PartnerProductId.HasValue && AuthorizeRemoteStartRequest.PartnerProductId.HasValue && PartnerProductId.Value.Equals(AuthorizeRemoteStartRequest.PartnerProductId.Value))));
        }
예제 #4
0
        /// <summary>
        /// Return a JSON representation of this object.
        /// </summary>
        /// <param name="CustomChargingProgressNotificationRequestSerializer">A delegate to serialize custom time period JSON objects.</param>
        /// <param name="CustomIdentificationSerializer">A delegate to serialize custom Identification JSON elements.</param>
        public JObject ToJSON(CustomJObjectSerializerDelegate <ChargingProgressNotificationRequest> CustomChargingProgressNotificationRequestSerializer = null,
                              CustomJObjectSerializerDelegate <Identification> CustomIdentificationSerializer = null)
        {
            var JSON = JSONObject.Create(
                new JProperty("Type", Type.AsString()),
                new JProperty("SessionID", SessionId.ToString()),
                new JProperty("EvseID", EVSEId.ToString()),
                new JProperty("Identification", Identification.ToJSON(CustomIdentificationSerializer: CustomIdentificationSerializer)),
                new JProperty("ChargingStart", ChargingStart.ToIso8601()),
                new JProperty("EventOcurred", EventOcurred.ToIso8601()),

                CPOPartnerSessionId.HasValue
                               ? new JProperty("CPOPartnerSessionID", CPOPartnerSessionId.Value.ToString())
                               : null,

                EMPPartnerSessionId.HasValue
                               ? new JProperty("EMPPartnerSessionID", EMPPartnerSessionId.Value.ToString())
                               : null,

                ChargingDuration.HasValue
                               ? new JProperty("ChargingDuration", Convert.ToUInt64(ChargingDuration.Value.TotalMilliseconds))
                               : null,

                SessionStart.HasValue
                               ? new JProperty("SessionStart", SessionStart.Value.ToIso8601())
                               : null,

                ConsumedEnergyProgress.HasValue
                               ? new JProperty("ConsumedEnergyProgress", String.Format("{0:0.###}", ConsumedEnergyProgress.Value).Replace(",", "."))
                               : null,

                MeterValueStart.HasValue
                               ? new JProperty("MeterValueStart", String.Format("{0:0.###}", MeterValueStart.Value).Replace(",", "."))
                               : null,

                MeterValuesInBetween.SafeAny()
                               ? new JProperty("MeterValueInBetween",
                                               new JObject( // OICP is crazy!
                                                   new JProperty("meterValues", new JArray(MeterValuesInBetween.
                                                                                           Select(meterValue => String.Format("{0:0.###}", meterValue).Replace(",", ".")))
                                                                 )
                                                   )
                                               )
                               : null,

                OperatorId.HasValue
                               ? new JProperty("OperatorID", OperatorId.Value.ToString())
                               : null,

                PartnerProductId.HasValue
                               ? new JProperty("PartnerProductID", PartnerProductId.Value.ToString())
                               : null,

                CustomData != null
                               ? new JProperty("CustomData", CustomData)
                               : null

                );

            return(CustomChargingProgressNotificationRequestSerializer != null
                       ? CustomChargingProgressNotificationRequestSerializer(this, JSON)
                       : JSON);
        }