/// <summary>
        /// Return a XML representation of this object.
        /// </summary>
        /// <param name="CustomGetServiceAuthorisationResponseSerializer">A delegate to serialize custom Heartbeat response XML elements.</param>
        /// <param name="CustomMeterReportSerializer">A delegate to serialize custom MeterReport XML elements.</param>
        public XElement ToXML(CustomXMLSerializerDelegate <GetServiceAuthorisationResponse> CustomGetServiceAuthorisationResponseSerializer = null,
                              CustomXMLSerializerDelegate <MeterReport> CustomMeterReportSerializer = null)
        {
            var XML = new XElement(eMIPNS.Authorisation + "eMIP_FromIOP_GetServiceAuthorisationResponse",

                                   new XElement("transactionId", TransactionId.ToString()),
                                   new XElement("authorisationValue", AuthorisationValue.AsNumber()),
                                   new XElement("partnerServiceSessionId", PartnerServiceSessionId.ToString()),
                                   new XElement("intermediateCDRRequested", IntermediateCDRRequested ? "1" : "0"),

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

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

                                   new XElement("parameter", Parameter),

                                   new XElement("requestStatus", RequestStatus.ToString())

                                   );


            return(CustomGetServiceAuthorisationResponseSerializer != null
                       ? CustomGetServiceAuthorisationResponseSerializer(this, XML)
                       : XML);
        }
Esempio n. 2
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>
            /// Compares two GetServiceAuthorisation responses for equality.
            /// </summary>
            /// <param name="GetServiceAuthorisationResponse">A GetServiceAuthorisation response to compare with.</param>
            /// <returns>True if both match; False otherwise.</returns>
            public override Boolean Equals(GetServiceAuthorisationResponse GetServiceAuthorisationResponse)
            {
                if (GetServiceAuthorisationResponse is null)
                {
                    return(false);
                }

                return(TransactionId.Equals(GetServiceAuthorisationResponse.TransactionId) &&
                       AuthorisationValue.Equals(GetServiceAuthorisationResponse.AuthorisationValue) &&
                       PartnerServiceSessionId.Equals(GetServiceAuthorisationResponse.PartnerServiceSessionId) &&
                       IntermediateCDRRequested.Equals(GetServiceAuthorisationResponse.IntermediateCDRRequested) &&
                       RequestStatus.Equals(GetServiceAuthorisationResponse.RequestStatus) &&

                       ((!UserContractIdAlias.HasValue && !GetServiceAuthorisationResponse.UserContractIdAlias.HasValue) ||
                        (UserContractIdAlias.HasValue && GetServiceAuthorisationResponse.UserContractIdAlias.HasValue && UserContractIdAlias.Value.Equals(GetServiceAuthorisationResponse.UserContractIdAlias.Value))));

                // ToDo: Compare MeterLimitLists!
            }
        /// <summary>
        /// Return the HashCode of this object.
        /// </summary>
        /// <returns>The HashCode of this object.</returns>
        public override Int32 GetHashCode()
        {
            unchecked
            {
                return(TransactionId.GetHashCode() * 17 ^
                       AuthorisationValue.GetHashCode() * 13 ^
                       PartnerServiceSessionId.GetHashCode() * 11 ^
                       IntermediateCDRRequested.GetHashCode() * 7 ^
                       RequestStatus.GetHashCode() * 5 ^

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

                       // ToDo: Add MeterLimits.GetHashCode()!

                       (Parameter.IsNotNullOrEmpty()
                            ? Parameter.GetHashCode()
                            : 0));
            }
        }
Esempio n. 5
0
        public void Add(WWCPCPOAdapter CPOAdapter)
        {
            _CPOAdapters.Add(CPOAdapter);

            #region OnGetServiceAuthorisationRequest/-Response

            CPOAdapter.CPOClient.OnGetServiceAuthorisationRequest += async(LogTimestamp,
                                                                           RequestTimestamp,
                                                                           Sender,
                                                                           SenderId,
                                                                           EventTrackingId,
                                                                           PartnerId,
                                                                           OperatorId,
                                                                           EVSEId,
                                                                           UserId,
                                                                           ServiceId,
                                                                           TransactionId,
                                                                           PartnerServiceSessionId,
                                                                           RequestTimeout) => await DebugLog.SubmitEvent("GetServiceAuthorisationRequest",
                                                                                                                         JSONObject.Create(
                                                                                                                             new JProperty("timestamp", RequestTimestamp.ToIso8601()),
                                                                                                                             new JProperty("eventTrackingId", EventTrackingId.ToString()),
                                                                                                                             //new JProperty("roamingNetworkId",               RoamingNetworkId.    ToString()),
                                                                                                                             //EMPRoamingProviderId.HasValue
                                                                                                                             //    ? new JProperty("EMPRoamingProviderId",  EMPRoamingProviderId.ToString())
                                                                                                                             //    : null,
                                                                                                                             //CSORoamingProviderId.HasValue
                                                                                                                             //    ? new JProperty("CSORoamingProviderId",  CSORoamingProviderId.ToString())
                                                                                                                             //    : null,
                                                                                                                             new JProperty("partnerId", PartnerId.ToString()),
                                                                                                                             new JProperty("operatorId", OperatorId.ToString()),
                                                                                                                             new JProperty("EVSEId", EVSEId.ToString()),
                                                                                                                             new JProperty("userId", UserId.ToString()),
                                                                                                                             new JProperty("serviceId", ServiceId.ToString()),
                                                                                                                             TransactionId.HasValue
                                                                                                                                   ? new JProperty("transactionId", TransactionId.ToString())
                                                                                                                                   : null,
                                                                                                                             PartnerServiceSessionId.HasValue
                                                                                                                                   ? new JProperty("partnerServiceSessionId", PartnerServiceSessionId.ToString())
                                                                                                                                   : null,
                                                                                                                             new JProperty("requestTimeout", Math.Round(RequestTimeout.TotalSeconds, 0))
                                                                                                                             ));

            CPOAdapter.CPOClient.OnGetServiceAuthorisationResponse += async(LogTimestamp,
                                                                            RequestTimestamp,
                                                                            Sender,
                                                                            SenderId,
                                                                            EventTrackingId,
                                                                            PartnerId,
                                                                            OperatorId,
                                                                            EVSEId,
                                                                            UserId,
                                                                            ServiceId,
                                                                            TransactionId,
                                                                            PartnerServiceSessionId,
                                                                            RequestTimeout,
                                                                            Result,
                                                                            Runtime) => await DebugLog.SubmitEvent("GetServiceAuthorisationResponse",
                                                                                                                   JSONObject.Create(
                                                                                                                       new JProperty("timestamp", RequestTimestamp.ToIso8601()),
                                                                                                                       new JProperty("eventTrackingId", EventTrackingId.ToString()),
                                                                                                                       //new JProperty("roamingNetworkId",            RoamingNetwork.Id.   ToString()),
                                                                                                                       //EMPRoamingProviderId.HasValue
                                                                                                                       //    ? new JProperty("EMPRoamingProviderId",  EMPRoamingProviderId.ToString())
                                                                                                                       //    : null,
                                                                                                                       //CSORoamingProviderId.HasValue
                                                                                                                       //    ? new JProperty("CSORoamingProviderId",  CSORoamingProviderId.ToString())
                                                                                                                       //    : null,
                                                                                                                       new JProperty("partnerId", PartnerId.ToString()),
                                                                                                                       new JProperty("operatorId", OperatorId.ToString()),
                                                                                                                       new JProperty("EVSEId", EVSEId.ToString()),
                                                                                                                       new JProperty("userId", UserId.ToString()),
                                                                                                                       new JProperty("serviceId", ServiceId.ToString()),
                                                                                                                       TransactionId.HasValue
                                                                                                                            ? new JProperty("transactionId", TransactionId.ToString())
                                                                                                                            : null,
                                                                                                                       PartnerServiceSessionId.HasValue
                                                                                                                            ? new JProperty("partnerServiceSessionId", PartnerServiceSessionId.ToString())
                                                                                                                            : null,
                                                                                                                       new JProperty("requestTimeout", Math.Round(RequestTimeout.TotalSeconds, 0)),
                                                                                                                       new JProperty("result", Result.ToJSON()),
                                                                                                                       new JProperty("runtime", Math.Round(Runtime.TotalMilliseconds, 0))

                                                                                                                       ));

            #endregion
        }