Example #1
0
        CreateeMIPv0_7_4_CSORoamingProvider(this RoamingNetwork RoamingNetwork,
                                            EMPRoamingProvider_Id Id,
                                            I18NString Name,
                                            I18NString Description,
                                            CPORoaming CPORoaming,

                                            eMIPv0_7_4.Partner_Id PartnerId,
                                            ChargingStationOperator DefaultOperator,

                                            WWCPChargeDetailRecord2ChargeDetailRecordDelegate WWCPChargeDetailRecord2eMIPChargeDetailRecord = null,

                                            IncludeEVSEIdDelegate IncludeEVSEIds = null,
                                            IncludeEVSEDelegate IncludeEVSEs     = null,
                                            IncludeChargingStationIdDelegate IncludeChargingStationIds = null,
                                            IncludeChargingStationDelegate IncludeChargingStations     = null,
                                            IncludeChargingPoolIdDelegate IncludeChargingPoolIds       = null,
                                            IncludeChargingPoolDelegate IncludeChargingPools           = null,
                                            ChargeDetailRecordFilterDelegate ChargeDetailRecordFilter  = null,
                                            CustomOperatorIdMapperDelegate CustomOperatorIdMapper      = null,
                                            CustomEVSEIdMapperDelegate CustomEVSEIdMapper = null,

                                            TimeSpan?SendHeartbeatsEvery = null,
                                            TimeSpan?ServiceCheckEvery   = null,
                                            TimeSpan?StatusCheckEvery    = null,
                                            TimeSpan?CDRCheckEvery       = null,

                                            Boolean DisableSendHeartbeats          = false,
                                            Boolean DisablePushData                = false,
                                            Boolean DisablePushStatus              = false,
                                            Boolean DisableAuthentication          = false,
                                            Boolean DisableSendChargeDetailRecords = false,

                                            Action <eMIPv0_7_4.CPO.WWCPCPOAdapter> eMIPConfigurator = null,
                                            Action <IEMPRoamingProvider> Configurator = null,

                                            String EllipticCurve = "P-256",
                                            ECPrivateKeyParameters PrivateKey           = null,
                                            PublicKeyCertificates PublicKeyCertificates = null,

                                            CounterValues?CPOClientSendHeartbeatCounter = null,
                                            CounterValues?CPOClientSetChargingPoolAvailabilityStatusCounter      = null,
                                            CounterValues?CPOClientSetChargingStationAvailabilityStatusCounter   = null,
                                            CounterValues?CPOClientSetEVSEAvailabilityStatusCounter              = null,
                                            CounterValues?CPOClientSetChargingConnectorAvailabilityStatusCounter = null,
                                            CounterValues?CPOClientSetEVSEBusyStatusCounter       = null,
                                            CounterValues?CPOClientSetEVSESyntheticStatusCounter  = null,
                                            CounterValues?CPOClientGetServiceAuthorisationCounter = null,
                                            CounterValues?CPOClientSetSessionEventReportCounter   = null,
                                            CounterValues?CPOClientSetChargeDetailRecordCounter   = null)

        {
            #region Initial checks

            if (RoamingNetwork == null)
            {
                throw new ArgumentNullException(nameof(RoamingNetwork), "The given roaming network must not be null!");
            }

            if (Id == null)
            {
                throw new ArgumentNullException(nameof(Id), "The given unique roaming provider identification must not be null!");
            }

            if (Name.IsNullOrEmpty())
            {
                throw new ArgumentNullException(nameof(Name), "The given roaming provider name must not be null or empty!");
            }

            if (CPORoaming is null)
            {
                throw new ArgumentNullException(nameof(CPORoaming), "The given CPO roaming must not be null!");
            }

            #endregion

            var NewRoamingProvider = new WWCPCPOAdapter(Id,
                                                        Name,
                                                        Description,
                                                        RoamingNetwork,
                                                        CPORoaming,

                                                        PartnerId,
                                                        DefaultOperator,

                                                        IncludeEVSEIds,
                                                        IncludeEVSEs,
                                                        IncludeChargingStationIds,
                                                        IncludeChargingStations,
                                                        IncludeChargingPoolIds,
                                                        IncludeChargingPools,
                                                        ChargeDetailRecordFilter,
                                                        CustomOperatorIdMapper,
                                                        CustomEVSEIdMapper,

                                                        //EVSE2EVSEDataRecord,
                                                        //EVSEStatusUpdate2EVSEStatusRecord,
                                                        WWCPChargeDetailRecord2eMIPChargeDetailRecord,

                                                        SendHeartbeatsEvery,
                                                        ServiceCheckEvery,
                                                        StatusCheckEvery,
                                                        CDRCheckEvery,

                                                        DisableSendHeartbeats,
                                                        DisablePushData,
                                                        DisablePushStatus,
                                                        DisableAuthentication,
                                                        DisableSendChargeDetailRecords,

                                                        EllipticCurve,
                                                        PrivateKey,
                                                        PublicKeyCertificates);

            eMIPConfigurator?.Invoke(NewRoamingProvider);

            return(RoamingNetwork.
                   CreateNewRoamingProvider(NewRoamingProvider,
                                            Configurator) as WWCPCPOAdapter);
        }
        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
        }