示例#1
0
        /// <summary>
        /// Return a XML representation of this object.
        /// </summary>
        /// <param name="CustomSetServiceAuthorisationRequestSerializer">A delegate to serialize custom set EVSE busy status request XML elements.</param>
        /// <param name="CustomMeterReportSerializer">A delegate to serialize custom MeterReport XML elements.</param>
        public XElement ToXML(CustomXMLSerializerDelegate <SetServiceAuthorisationRequest> CustomSetServiceAuthorisationRequestSerializer = null,
                              CustomXMLSerializerDelegate <MeterReport> CustomMeterReportSerializer = null)
        {
            var XML = new XElement(eMIPNS.Authorisation + "eMIP_ToIOP_SetServiceAuthorisationRequest",

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

                                   new XElement("partnerIdType", PartnerId.Format.AsText()),
                                   new XElement("partnerId", PartnerId.ToString()),

                                   new XElement("operatorIdType", OperatorId.Format.AsText()),
                                   new XElement("operatorId", OperatorId.ToString()),

                                   new XElement("EVSEIdType", EVSEId.Format.AsText()),
                                   new XElement("EVSEId", EVSEId.ToString()),

                                   new XElement("userIdType", UserId.Format.AsText()),
                                   new XElement("userId", UserId.ToString()),

                                   new XElement("requestedServiceId", RequestedServiceId.ToString()),
                                   new XElement("authorisationValue", AuthorisationValue.ToString()),
                                   new XElement("intermediateCDRRequested", IntermediateCDRRequested ? "1" : "0"),

                                   PartnerServiceSessionId.HasValue
                              ? new XElement("serviceSessionId", PartnerServiceSessionId.ToString())
                              : null,

                                   UserContractIdAlias.HasValue
                              ? new XElement("userContractIdAlias", UserContractIdAlias.ToString())
                              : null,

                                   MeterLimits.SafeAny()
                              ? new XElement("meterLimitList", MeterLimits.Select(meterreport => meterreport.ToXML(CustomMeterReportSerializer: CustomMeterReportSerializer)))
                              : null,

                                   Parameter.IsNotNullOrEmpty()
                              ? new XElement("parameter", Parameter)
                              : null,

                                   BookingId.HasValue
                              ? new XElement("bookingId", BookingId.ToString())
                              : null,

                                   SalePartnerBookingId.HasValue
                              ? new XElement("salePartnerBookingId", SalePartnerBookingId.ToString())
                              : null

                                   );


            return(CustomSetServiceAuthorisationRequestSerializer != null
                       ? CustomSetServiceAuthorisationRequestSerializer(this, XML)
                       : XML);
        }
        /// <summary>
        /// Return a XML representation of this EVSE data record.
        /// </summary>
        /// <param name="XName">The XML name to use.</param>
        /// <param name="CustomChargeDetailRecordSerializer">A delegate to serialize custom ChargeDetailRecord XML elements.</param>
        /// <param name="CustomMeterReportSerializer">A delegate to serialize custom MeterReport XML elements.</param>
        public XElement ToXML(XName XName = null,
                              CustomXMLSerializerDelegate <ChargeDetailRecord> CustomChargeDetailRecordSerializer = null,
                              CustomXMLSerializerDelegate <MeterReport> CustomMeterReportSerializer = null)
        {
            var XML = new XElement(XName ?? "chargeDetailRecord",

                                   new XElement("CDRNature", CDRNature.AsText()),
                                   new XElement("serviceSessionId", ServiceSessionId.ToString()),

                                   ExecPartnerSessionId.HasValue
                              ? new XElement("execPartnerSessionId", ExecPartnerSessionId.Value.ToString())
                              : null,

                                   ExecPartnerOperatorId.HasValue
                              ? new XElement("execPartnerOperatorIdType", ExecPartnerOperatorId.Value.Format.AsText())
                              : null,

                                   ExecPartnerOperatorId.HasValue
                              ? new XElement("execPartnerOperatorId", ExecPartnerOperatorId.Value.ToString())
                              : null,


                                   SalesPartnerSessionId.HasValue
                              ? new XElement("execPartnerSessionId", ExecPartnerSessionId.Value.ToString())
                              : null,

                                   SalesPartnerOperatorId.HasValue
                              ? new XElement("execPartnerOperatorIdType", ExecPartnerOperatorId.Value.Format.AsText())
                              : null,

                                   SalesPartnerOperatorId.HasValue
                              ? new XElement("execPartnerOperatorId", ExecPartnerOperatorId.Value.ToString())
                              : null,


                                   new XElement("requestedServiceId", RequestedServiceId.ToString()),

                                   new XElement("EVSEIdType", EVSEId.Format.AsText()),
                                   new XElement("EVSEId", EVSEId.ToString()),

                                   new XElement("userContractIdAlias", UserContractIdAlias.ToString()),

                                   new XElement("userIdType", UserId.Format.AsText()),
                                   new XElement("userId", UserId.ToString()),

                                   PartnerProductId.HasValue
                              ? new XElement("partnerProductId", PartnerProductId.Value.ToString())
                              : null,

                                   new XElement("startTime", StartTime.ToIso8601(false)),
                                   new XElement("endTime", EndTime.ToIso8601(false)),

                                   new XElement("meterReportList",
                                                MeterReports.Any()
                                  ? MeterReports.Select(meterreport => meterreport.ToXML(CustomMeterReportSerializer: CustomMeterReportSerializer))
                                  : null
                                                )

                                   );

            return(CustomChargeDetailRecordSerializer != null
                       ? CustomChargeDetailRecordSerializer(this, XML)
                       : XML);
        }