Esempio n. 1
0
        /// <summary>
        /// Return a JSON representation of this object.
        /// </summary>
        /// <param name="CustomChargingStartNotificationRequestSerializer">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 <ChargingStartNotificationRequest> CustomChargingStartNotificationRequestSerializer = 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()),

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

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

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

                MeterValueStart.HasValue
                               ? new JProperty("MeterValueStart", String.Format("{0:0.###}", MeterValueStart.Value).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(CustomChargingStartNotificationRequestSerializer != null
                       ? CustomChargingStartNotificationRequestSerializer(this, JSON)
                       : JSON);
        }
Esempio n. 2
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);
        }