Пример #1
0
 public void Clear()
 {
     if (SMSSemaphore.Wait(TimeSpan.FromSeconds(60)))
     {
         try
         {
             _SMSs.Clear();
         }
         catch (Exception e)
         {
             DebugX.LogException(e);
         }
         finally
         {
             SMSSemaphore.Release();
         }
     }
 }
Пример #2
0
        /// <summary>
        /// Register all URI templates for this SOAP API.
        /// </summary>
        protected void RegisterURITemplates()
        {
            #region ~/ - SetServiceAuthorisation

            // --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
            // curl -v -X POST  -H "Content-Type: application/soap+xml" -H "Accept: application/soap+xml" --data-binary "@Tests/SetServiceAuthorisationRequest001.xml" http://127.0.0.1:3004/RNs/Prod/IO/Gireve
            // --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
            SOAPServer.RegisterSOAPDelegate(HTTPHostname.Any,
                                            URLPrefix + AuthorisationURL,
                                            "SetServiceAuthorisationRequest",
                                            XML => XML.Descendants(eMIPNS.Authorisation + "eMIP_FromIOP_SetServiceAuthorisationRequest").FirstOrDefault(),
                                            async(HTTPRequest, SetServiceAuthorisationXML) => {
                SetServiceAuthorisationResponse Response = null;

                #region Send OnSetServiceAuthorisationSOAPRequest event

                var StartTime = DateTime.UtcNow;

                try
                {
                    if (OnSetServiceAuthorisationSOAPRequest != null)
                    {
                        await Task.WhenAll(OnSetServiceAuthorisationSOAPRequest.GetInvocationList().
                                           Cast <RequestLogHandler>().
                                           Select(e => e(StartTime,
                                                         SOAPServer.HTTPServer,
                                                         HTTPRequest))).
                        ConfigureAwait(false);
                    }
                }
                catch (Exception e)
                {
                    DebugX.LogException(e, nameof(CPOServer) + "." + nameof(OnSetServiceAuthorisationSOAPRequest));
                }

                #endregion


                if (SetServiceAuthorisationRequest.TryParse(SetServiceAuthorisationXML,
                                                            CustomSetServiceAuthorisationRequestParser,
                                                            CustomMeterReportParser,
                                                            out SetServiceAuthorisationRequest _SetServiceAuthorisationRequest,
                                                            OnException,

                                                            HTTPRequest,
                                                            HTTPRequest.Timestamp,
                                                            HTTPRequest.CancellationToken,
                                                            HTTPRequest.EventTrackingId,
                                                            HTTPRequest.Timeout ?? DefaultRequestTimeout))
                {
                    #region Send OnSetServiceAuthorisationRequest event

                    try
                    {
                        if (OnSetServiceAuthorisationRequest != null)
                        {
                            await Task.WhenAll(OnSetServiceAuthorisationRequest.GetInvocationList().
                                               Cast <OnSetServiceAuthorisationRequestDelegate>().
                                               Select(e => e(StartTime,
                                                             _SetServiceAuthorisationRequest.Timestamp.Value,
                                                             this,
                                                             ServiceName,
                                                             _SetServiceAuthorisationRequest.EventTrackingId,
                                                             _SetServiceAuthorisationRequest.PartnerId,
                                                             _SetServiceAuthorisationRequest.OperatorId,
                                                             _SetServiceAuthorisationRequest.TargetOperatorId,
                                                             _SetServiceAuthorisationRequest.EVSEId,
                                                             _SetServiceAuthorisationRequest.UserId,
                                                             _SetServiceAuthorisationRequest.RequestedServiceId,
                                                             _SetServiceAuthorisationRequest.ServiceSessionId,
                                                             _SetServiceAuthorisationRequest.AuthorisationValue,
                                                             _SetServiceAuthorisationRequest.IntermediateCDRRequested,
                                                             _SetServiceAuthorisationRequest.TransactionId,
                                                             _SetServiceAuthorisationRequest.UserContractIdAlias,
                                                             _SetServiceAuthorisationRequest.MeterLimits,
                                                             _SetServiceAuthorisationRequest.Parameter,
                                                             _SetServiceAuthorisationRequest.BookingId,
                                                             _SetServiceAuthorisationRequest.RequestTimeout ?? DefaultRequestTimeout))).
                            ConfigureAwait(false);
                        }
                    }
                    catch (Exception e)
                    {
                        DebugX.LogException(e, nameof(CPOServer) + "." + nameof(OnSetServiceAuthorisationRequest));
                    }

                    #endregion

                    #region Call async subscribers

                    if (OnSetServiceAuthorisation != null)
                    {
                        var results = await Task.WhenAll(OnSetServiceAuthorisation.GetInvocationList().
                                                         Cast <OnSetServiceAuthorisationDelegate>().
                                                         Select(e => e(DateTime.UtcNow,
                                                                       this,
                                                                       _SetServiceAuthorisationRequest))).
                                      ConfigureAwait(false);

                        Response = results.FirstOrDefault();
                    }

                    //"Could not forward the incoming SetServiceAuthorisation request!",
                    if (Response == null)
                    {
                        Response = SetServiceAuthorisationResponse.SystemError(
                            _SetServiceAuthorisationRequest,
                            _SetServiceAuthorisationRequest.TransactionId ?? Transaction_Id.Zero
                            );
                    }

                    #endregion

                    #region Send OnSetServiceAuthorisationResponse event

                    var EndTime = DateTime.UtcNow;

                    try
                    {
                        if (OnSetServiceAuthorisationResponse != null)
                        {
                            await Task.WhenAll(OnSetServiceAuthorisationResponse.GetInvocationList().
                                               Cast <OnSetServiceAuthorisationResponseDelegate>().
                                               Select(e => e(EndTime,
                                                             this,
                                                             ServiceName,
                                                             _SetServiceAuthorisationRequest.EventTrackingId,
                                                             _SetServiceAuthorisationRequest.PartnerId,
                                                             _SetServiceAuthorisationRequest.OperatorId,
                                                             _SetServiceAuthorisationRequest.TargetOperatorId,
                                                             _SetServiceAuthorisationRequest.EVSEId,
                                                             _SetServiceAuthorisationRequest.UserId,
                                                             _SetServiceAuthorisationRequest.RequestedServiceId,
                                                             _SetServiceAuthorisationRequest.ServiceSessionId,
                                                             _SetServiceAuthorisationRequest.AuthorisationValue,
                                                             _SetServiceAuthorisationRequest.IntermediateCDRRequested,
                                                             _SetServiceAuthorisationRequest.TransactionId,
                                                             _SetServiceAuthorisationRequest.UserContractIdAlias,
                                                             _SetServiceAuthorisationRequest.MeterLimits,
                                                             _SetServiceAuthorisationRequest.Parameter,
                                                             _SetServiceAuthorisationRequest.BookingId,
                                                             _SetServiceAuthorisationRequest.RequestTimeout ?? DefaultRequestTimeout,
                                                             Response,
                                                             EndTime - StartTime))).
                            ConfigureAwait(false);
                        }
                    }
                    catch (Exception e)
                    {
                        DebugX.LogException(e, nameof(CPOServer) + "." + nameof(OnSetServiceAuthorisationResponse));
                    }

                    #endregion
                }
Пример #3
0
        /// <summary>
        /// Register all URI templates for this SOAP API.
        /// </summary>
        protected void RegisterURITemplates()
        {
            #region ~/ - GetServiceAuthorisation

            SOAPServer.RegisterSOAPDelegate(HTTPHostname.Any,
                                            URLPrefix + AuthorisationURL,
                                            "GetServiceAuthorisationRequest",
                                            XML => XML.Descendants(eMIPNS.Authorisation + "eMIP_FromIOP_GetServiceAuthorisationRequest").FirstOrDefault(),
                                            async(HTTPRequest, GetServiceAuthorisationXML) => {
                GetServiceAuthorisationResponse Response = null;

                #region Send OnGetServiceAuthorisationSOAPRequest event

                var StartTime = DateTime.UtcNow;

                try
                {
                    if (OnGetServiceAuthorisationSOAPRequest != null)
                    {
                        await Task.WhenAll(OnGetServiceAuthorisationSOAPRequest.GetInvocationList().
                                           Cast <RequestLogHandler>().
                                           Select(e => e(StartTime,
                                                         SOAPServer.HTTPServer,
                                                         HTTPRequest))).
                        ConfigureAwait(false);
                    }
                }
                catch (Exception e)
                {
                    DebugX.LogException(e, nameof(EMPServer) + "." + nameof(OnGetServiceAuthorisationSOAPRequest));
                }

                #endregion


                if (GetServiceAuthorisationRequest.TryParse(GetServiceAuthorisationXML,
                                                            CustomGetServiceAuthorisationRequestParser,
                                                            out GetServiceAuthorisationRequest _GetServiceAuthorisationRequest,
                                                            OnException,

                                                            HTTPRequest,
                                                            HTTPRequest.Timestamp,
                                                            HTTPRequest.CancellationToken,
                                                            HTTPRequest.EventTrackingId,
                                                            HTTPRequest.Timeout ?? DefaultRequestTimeout))
                {
                    #region Send OnGetServiceAuthorisationRequest event

                    try
                    {
                        if (OnGetServiceAuthorisationRequest != null)
                        {
                            await Task.WhenAll(OnGetServiceAuthorisationRequest.GetInvocationList().
                                               Cast <OnGetServiceAuthorisationRequestDelegate>().
                                               Select(e => e(StartTime,
                                                             _GetServiceAuthorisationRequest.Timestamp.Value,
                                                             this,
                                                             ServiceName,
                                                             _GetServiceAuthorisationRequest.EventTrackingId,
                                                             _GetServiceAuthorisationRequest.TransactionId.Value,
                                                             _GetServiceAuthorisationRequest.PartnerId,
                                                             _GetServiceAuthorisationRequest.OperatorId,
                                                             _GetServiceAuthorisationRequest.TargetOperatorId,
                                                             _GetServiceAuthorisationRequest.EVSEId,
                                                             _GetServiceAuthorisationRequest.UserId,
                                                             _GetServiceAuthorisationRequest.RequestedServiceId,
                                                             _GetServiceAuthorisationRequest.ServiceSessionId,
                                                             _GetServiceAuthorisationRequest.BookingId,

                                                             _GetServiceAuthorisationRequest.RequestTimeout ?? DefaultRequestTimeout))).
                            ConfigureAwait(false);
                        }
                    }
                    catch (Exception e)
                    {
                        DebugX.LogException(e, nameof(EMPServer) + "." + nameof(OnGetServiceAuthorisationRequest));
                    }

                    #endregion

                    #region Call async subscribers

                    if (OnGetServiceAuthorisation != null)
                    {
                        var results = await Task.WhenAll(OnGetServiceAuthorisation.GetInvocationList().
                                                         Cast <OnGetServiceAuthorisationDelegate>().
                                                         Select(e => e(DateTime.UtcNow,
                                                                       this,
                                                                       _GetServiceAuthorisationRequest))).
                                      ConfigureAwait(false);

                        Response = results.FirstOrDefault();
                    }

                    //if (Response == null)
                    //    Response = Response<EMP.GetServiceAuthorisationRequest>.SystemError(
                    //                         _GetServiceAuthorisationRequest,
                    //                         "Could not process the incoming GetServiceAuthorisation request!",
                    //                         null,
                    //                         _GetServiceAuthorisationRequest.SessionId,
                    //                         _GetServiceAuthorisationRequest.PartnerSessionId
                    //                     );

                    #endregion

                    #region Send OnGetServiceAuthorisationResponse event

                    var EndTime = DateTime.UtcNow;

                    try
                    {
                        if (OnGetServiceAuthorisationResponse != null)
                        {
                            await Task.WhenAll(OnGetServiceAuthorisationResponse.GetInvocationList().
                                               Cast <OnGetServiceAuthorisationResponseDelegate>().
                                               Select(e => e(EndTime,
                                                             this,
                                                             ServiceName,
                                                             _GetServiceAuthorisationRequest.EventTrackingId,
                                                             _GetServiceAuthorisationRequest.TransactionId.Value,
                                                             _GetServiceAuthorisationRequest.PartnerId,
                                                             _GetServiceAuthorisationRequest.OperatorId,
                                                             _GetServiceAuthorisationRequest.TargetOperatorId,
                                                             _GetServiceAuthorisationRequest.EVSEId,
                                                             _GetServiceAuthorisationRequest.UserId,
                                                             _GetServiceAuthorisationRequest.RequestedServiceId,
                                                             _GetServiceAuthorisationRequest.ServiceSessionId,
                                                             _GetServiceAuthorisationRequest.BookingId,
                                                             _GetServiceAuthorisationRequest.RequestTimeout ?? DefaultRequestTimeout,
                                                             Response,
                                                             EndTime - StartTime))).
                            ConfigureAwait(false);
                        }
                    }
                    catch (Exception e)
                    {
                        DebugX.LogException(e, nameof(EMPServer) + "." + nameof(OnGetServiceAuthorisationResponse));
                    }

                    #endregion
                }

                //else
                //    Response = Response<EMP.GetServiceAuthorisationRequest>.DataError(
                //                          _GetServiceAuthorisationRequest,
                //                          "Could not process the incoming GetServiceAuthorisation request!"
                //                      );


                #region Create SOAPResponse

                var HTTPResponse = new HTTPResponse.Builder(HTTPRequest)
                {
                    HTTPStatusCode = HTTPStatusCode.OK,
                    Server         = SOAPServer.HTTPServer.DefaultServerName,
                    Date           = DateTime.UtcNow,
                    ContentType    = HTTPContentType.XMLTEXT_UTF8,
                    Content        = SOAP.Encapsulation(Response.ToXML(CustomGetServiceAuthorisationResponseSerializer)).ToUTF8Bytes(),
                    Connection     = "close"
                };

                #endregion

                #region Send OnGetServiceAuthorisationSOAPResponse event

                try
                {
                    if (OnGetServiceAuthorisationSOAPResponse != null)
                    {
                        await Task.WhenAll(OnGetServiceAuthorisationSOAPResponse.GetInvocationList().
                                           Cast <AccessLogHandler>().
                                           Select(e => e(HTTPResponse.Timestamp,
                                                         SOAPServer.HTTPServer,
                                                         HTTPRequest,
                                                         HTTPResponse))).
                        ConfigureAwait(false);
                    }
                }
                catch (Exception e)
                {
                    DebugX.LogException(e, nameof(EMPServer) + "." + nameof(OnGetServiceAuthorisationSOAPResponse));
                }

                #endregion

                return(HTTPResponse);
            });

            #endregion

            #region ~/ - SetSessionEventReport

            SOAPServer.RegisterSOAPDelegate(HTTPHostname.Any,
                                            URLPrefix + AuthorisationURL,
                                            "SetSessionEventReportRequest",
                                            XML => XML.Descendants(eMIPNS.Authorisation + "eMIP_FromIOP_SetSessionEventReportRequest").FirstOrDefault(),
                                            async(HTTPRequest, SetSessionEventReportXML) => {
                SetSessionEventReportResponse Response = null;

                #region Send OnSetSessionEventReportSOAPRequest event

                var StartTime = DateTime.UtcNow;

                try
                {
                    if (OnSetSessionEventReportSOAPRequest != null)
                    {
                        await Task.WhenAll(OnSetSessionEventReportSOAPRequest.GetInvocationList().
                                           Cast <RequestLogHandler>().
                                           Select(e => e(StartTime,
                                                         SOAPServer.HTTPServer,
                                                         HTTPRequest))).
                        ConfigureAwait(false);
                    }
                }
                catch (Exception e)
                {
                    DebugX.LogException(e, nameof(EMPServer) + "." + nameof(OnSetSessionEventReportSOAPRequest));
                }

                #endregion


                if (SetSessionEventReportRequest.TryParse(SetSessionEventReportXML,
                                                          out SetSessionEventReportRequest _SetSessionEventReportRequest,
                                                          CustomSetSessionEventReportRequestParser,
                                                          CustomSessionEventParser,
                                                          OnException,

                                                          HTTPRequest,
                                                          HTTPRequest.Timestamp,
                                                          HTTPRequest.CancellationToken,
                                                          HTTPRequest.EventTrackingId,
                                                          HTTPRequest.Timeout ?? DefaultRequestTimeout))
                {
                    #region Send OnSetSessionEventReportRequest event

                    try
                    {
                        if (OnSetSessionEventReportRequest != null)
                        {
                            await Task.WhenAll(OnSetSessionEventReportRequest.GetInvocationList().
                                               Cast <OnSetSessionEventReportRequestDelegate>().
                                               Select(e => e(StartTime,
                                                             _SetSessionEventReportRequest.Timestamp.Value,
                                                             this,
                                                             ServiceName,
                                                             _SetSessionEventReportRequest.EventTrackingId,

                                                             _SetSessionEventReportRequest.PartnerId,
                                                             _SetSessionEventReportRequest.OperatorId,
                                                             _SetSessionEventReportRequest.TargetOperatorId,
                                                             _SetSessionEventReportRequest.ServiceSessionId,
                                                             _SetSessionEventReportRequest.SessionEvent,

                                                             _SetSessionEventReportRequest.TransactionId,
                                                             _SetSessionEventReportRequest.SalePartnerSessionId,

                                                             _SetSessionEventReportRequest.RequestTimeout ?? DefaultRequestTimeout))).
                            ConfigureAwait(false);
                        }
                    }
                    catch (Exception e)
                    {
                        DebugX.LogException(e, nameof(EMPServer) + "." + nameof(OnSetSessionEventReportRequest));
                    }

                    #endregion

                    #region Call async subscribers

                    if (OnSetSessionEventReport != null)
                    {
                        var results = await Task.WhenAll(OnSetSessionEventReport.GetInvocationList().
                                                         Cast <OnSetSessionEventReportDelegate>().
                                                         Select(e => e(DateTime.UtcNow,
                                                                       this,
                                                                       _SetSessionEventReportRequest))).
                                      ConfigureAwait(false);

                        Response = results.FirstOrDefault();
                    }

                    //if (Response == null)
                    //    Response = Response<EMP.SetSessionEventReportRequest>.SystemError(
                    //                         _SetSessionEventReportRequest,
                    //                         "Could not process the incoming SetSessionEventReport request!",
                    //                         null,
                    //                         _SetSessionEventReportRequest.SessionId,
                    //                         _SetSessionEventReportRequest.PartnerSessionId
                    //                     );

                    #endregion

                    #region Send OnSetSessionEventReportResponse event

                    var EndTime = DateTime.UtcNow;

                    try
                    {
                        if (OnSetSessionEventReportResponse != null)
                        {
                            await Task.WhenAll(OnSetSessionEventReportResponse.GetInvocationList().
                                               Cast <OnSetSessionEventReportResponseDelegate>().
                                               Select(e => e(EndTime,
                                                             this,
                                                             ServiceName,
                                                             _SetSessionEventReportRequest.EventTrackingId,

                                                             _SetSessionEventReportRequest.PartnerId,
                                                             _SetSessionEventReportRequest.OperatorId,
                                                             _SetSessionEventReportRequest.TargetOperatorId,
                                                             _SetSessionEventReportRequest.ServiceSessionId,
                                                             _SetSessionEventReportRequest.SessionEvent,

                                                             _SetSessionEventReportRequest.TransactionId,
                                                             _SetSessionEventReportRequest.SalePartnerSessionId,

                                                             _SetSessionEventReportRequest.RequestTimeout ?? DefaultRequestTimeout,
                                                             Response,
                                                             EndTime - StartTime))).
                            ConfigureAwait(false);
                        }
                    }
                    catch (Exception e)
                    {
                        DebugX.LogException(e, nameof(EMPServer) + "." + nameof(OnSetSessionEventReportResponse));
                    }

                    #endregion
                }

                //else
                //    Response = Response<EMP.SetSessionEventReportRequest>.DataError(
                //                          _SetSessionEventReportRequest,
                //                          "Could not process the incoming SetSessionEventReport request!"
                //                      );


                #region Create SOAPResponse

                var HTTPResponse = new HTTPResponse.Builder(HTTPRequest)
                {
                    HTTPStatusCode = HTTPStatusCode.OK,
                    Server         = SOAPServer.HTTPServer.DefaultServerName,
                    Date           = DateTime.UtcNow,
                    ContentType    = HTTPContentType.XMLTEXT_UTF8,
                    Content        = SOAP.Encapsulation(Response.ToXML(CustomSetSessionEventReportResponseSerializer)).ToUTF8Bytes(),
                    Connection     = "close"
                };

                #endregion

                #region Send OnSetSessionEventReportSOAPResponse event

                try
                {
                    if (OnSetSessionEventReportSOAPResponse != null)
                    {
                        await Task.WhenAll(OnSetSessionEventReportSOAPResponse.GetInvocationList().
                                           Cast <AccessLogHandler>().
                                           Select(e => e(HTTPResponse.Timestamp,
                                                         SOAPServer.HTTPServer,
                                                         HTTPRequest,
                                                         HTTPResponse))).
                        ConfigureAwait(false);
                    }
                }
                catch (Exception e)
                {
                    DebugX.LogException(e, nameof(EMPServer) + "." + nameof(OnSetSessionEventReportSOAPResponse));
                }

                #endregion

                return(HTTPResponse);
            });

            #endregion

            #region ~/ - SetChargeDetailRecord

            SOAPServer.RegisterSOAPDelegate(HTTPHostname.Any,
                                            URLPrefix + AuthorisationURL,
                                            "SetChargeDetailRecordRequest",
                                            XML => XML.Descendants(eMIPNS.Authorisation + "eMIP_FromIOP_SetChargeDetailRecordRequest").FirstOrDefault(),
                                            async(HTTPRequest, SetChargeDetailRecordXML) => {
                SetChargeDetailRecordResponse Response = null;

                #region Send OnSetChargeDetailRecordSOAPRequest event

                var StartTime = DateTime.UtcNow;

                try
                {
                    if (OnSetChargeDetailRecordSOAPRequest != null)
                    {
                        await Task.WhenAll(OnSetChargeDetailRecordSOAPRequest.GetInvocationList().
                                           Cast <RequestLogHandler>().
                                           Select(e => e(StartTime,
                                                         SOAPServer.HTTPServer,
                                                         HTTPRequest))).
                        ConfigureAwait(false);
                    }
                }
                catch (Exception e)
                {
                    DebugX.LogException(e, nameof(EMPServer) + "." + nameof(OnSetChargeDetailRecordSOAPRequest));
                }

                #endregion


                if (SetChargeDetailRecordRequest.TryParse(SetChargeDetailRecordXML,
                                                          out SetChargeDetailRecordRequest _SetChargeDetailRecordRequest,
                                                          CustomSetChargeDetailRecordRequestParser,
                                                          CustomChargeDetailRecordParser,
                                                          CustomMeterReportParser,
                                                          OnException,

                                                          HTTPRequest,
                                                          HTTPRequest.Timestamp,
                                                          HTTPRequest.CancellationToken,
                                                          HTTPRequest.EventTrackingId,
                                                          HTTPRequest.Timeout ?? DefaultRequestTimeout))
                {
                    #region Send OnSetChargeDetailRecordRequest event

                    try
                    {
                        if (OnSetChargeDetailRecordRequest != null)
                        {
                            await Task.WhenAll(OnSetChargeDetailRecordRequest.GetInvocationList().
                                               Cast <OnSetChargeDetailRecordRequestDelegate>().
                                               Select(e => e(StartTime,
                                                             _SetChargeDetailRecordRequest.Timestamp.Value,
                                                             this,
                                                             ServiceName,
                                                             _SetChargeDetailRecordRequest.EventTrackingId,

                                                             _SetChargeDetailRecordRequest.PartnerId,
                                                             _SetChargeDetailRecordRequest.OperatorId,
                                                             _SetChargeDetailRecordRequest.ChargeDetailRecord,
                                                             _SetChargeDetailRecordRequest.TransactionId,

                                                             _SetChargeDetailRecordRequest.RequestTimeout ?? DefaultRequestTimeout))).
                            ConfigureAwait(false);
                        }
                    }
                    catch (Exception e)
                    {
                        DebugX.LogException(e, nameof(EMPServer) + "." + nameof(OnSetChargeDetailRecordRequest));
                    }

                    #endregion

                    #region Call async subscribers

                    if (OnSetChargeDetailRecord != null)
                    {
                        var results = await Task.WhenAll(OnSetChargeDetailRecord.GetInvocationList().
                                                         Cast <OnSetChargeDetailRecordDelegate>().
                                                         Select(e => e(DateTime.UtcNow,
                                                                       this,
                                                                       _SetChargeDetailRecordRequest))).
                                      ConfigureAwait(false);

                        Response = results.FirstOrDefault();
                    }

                    //if (Response == null)
                    //    Response = Response<EMP.SetChargeDetailRecordRequest>.SystemError(
                    //                         _SetChargeDetailRecordRequest,
                    //                         "Could not process the incoming SetChargeDetailRecord request!",
                    //                         null,
                    //                         _SetChargeDetailRecordRequest.SessionId,
                    //                         _SetChargeDetailRecordRequest.PartnerSessionId
                    //                     );

                    #endregion

                    #region Send OnSetChargeDetailRecordResponse event

                    var EndTime = DateTime.UtcNow;

                    try
                    {
                        if (OnSetChargeDetailRecordResponse != null)
                        {
                            await Task.WhenAll(OnSetChargeDetailRecordResponse.GetInvocationList().
                                               Cast <OnSetChargeDetailRecordResponseDelegate>().
                                               Select(e => e(EndTime,
                                                             this,
                                                             ServiceName,
                                                             _SetChargeDetailRecordRequest.EventTrackingId,

                                                             _SetChargeDetailRecordRequest.PartnerId,
                                                             _SetChargeDetailRecordRequest.OperatorId,
                                                             _SetChargeDetailRecordRequest.ChargeDetailRecord,
                                                             _SetChargeDetailRecordRequest.TransactionId,

                                                             _SetChargeDetailRecordRequest.RequestTimeout ?? DefaultRequestTimeout,
                                                             Response,
                                                             EndTime - StartTime))).
                            ConfigureAwait(false);
                        }
                    }
                    catch (Exception e)
                    {
                        DebugX.LogException(e, nameof(EMPServer) + "." + nameof(OnSetChargeDetailRecordResponse));
                    }

                    #endregion
                }

                //else
                //    Response = Response<EMP.SetChargeDetailRecordRequest>.DataError(
                //                          _SetChargeDetailRecordRequest,
                //                          "Could not process the incoming SetChargeDetailRecord request!"
                //                      );


                #region Create SOAPResponse

                var HTTPResponse = new HTTPResponse.Builder(HTTPRequest)
                {
                    HTTPStatusCode = HTTPStatusCode.OK,
                    Server         = SOAPServer.HTTPServer.DefaultServerName,
                    Date           = DateTime.UtcNow,
                    ContentType    = HTTPContentType.XMLTEXT_UTF8,
                    Content        = SOAP.Encapsulation(Response.ToXML(CustomSetChargeDetailRecordResponseSerializer)).ToUTF8Bytes(),
                    Connection     = "close"
                };

                #endregion

                #region Send OnSetChargeDetailRecordSOAPResponse event

                try
                {
                    if (OnSetChargeDetailRecordSOAPResponse != null)
                    {
                        await Task.WhenAll(OnSetChargeDetailRecordSOAPResponse.GetInvocationList().
                                           Cast <AccessLogHandler>().
                                           Select(e => e(HTTPResponse.Timestamp,
                                                         SOAPServer.HTTPServer,
                                                         HTTPRequest,
                                                         HTTPResponse))).
                        ConfigureAwait(false);
                    }
                }
                catch (Exception e)
                {
                    DebugX.LogException(e, nameof(EMPServer) + "." + nameof(OnSetChargeDetailRecordSOAPResponse));
                }

                #endregion

                return(HTTPResponse);
            });

            #endregion
        }