Ejemplo n.º 1
0
        /// <summary>
        /// Create a new generic eMIP response.
        /// </summary>
        /// <param name="Request">The eMIP request leading to this result.</param>
        /// <param name="TransactionId">A transaction identification.</param>
        /// <param name="RequestStatus">The status of the request.</param>
        /// <param name="ResponseTimestamp">The timestamp of the response creation.</param>
        /// <param name="HTTPResponse">The correlated HTTP response of this eMIP response.</param>
        /// <param name="CustomData">Optional additional customer-specific data.</param>
        protected AResponse(TRequest Request,
                            Transaction_Id TransactionId,
                            RequestStatus RequestStatus,
                            DateTime?ResponseTimestamp = null,
                            HTTPResponse HTTPResponse  = null,
                            IReadOnlyDictionary <String, Object> CustomData = null)

            : base(CustomData)

        {
            this.Request           = Request;
            this.TransactionId     = TransactionId;
            this.RequestStatus     = RequestStatus;
            this.ResponseTimestamp = ResponseTimestamp ?? DateTime.UtcNow;
            this.HTTPResponse      = HTTPResponse;
        }
Ejemplo n.º 2
0
        private void RegisterURITemplates()
        {
            #region / (HTTPRoot)

            HTTPServer.RegisterResourcesFolder(HTTPHostname.Any,
                                               URLPathPrefix,
                                               "org.GraphDefined.WWCP.eMIPv0_7_4.WebAPI.HTTPRoot",
                                               DefaultFilename: "index.html");

            #endregion


            #region GET   ~/ResendAll

            // ========================================================================================
            // curl -v -X SET -H "Accept: application/json" \
            //      http://127.0.0.1:3004/RNs/Prod/IO/Gireve/WebAPI/ResendAll
            // ========================================================================================
            HTTPServer.AddMethodCallback(HTTPHostname.Any,
                                         HTTPMethod.SET,
                                         URLPathPrefix + "/ResendAll",
                                         //HTTPContentType.JSON_UTF8,
                                         //HTTPRequestLogger:  SendAuthStartEVSERequest,
                                         //HTTPResponseLogger: SendAuthStartEVSEResponse,
                                         HTTPDelegate: async Request => {
                var Adapter = _CPOAdapters.FirstOrDefault();
                if (Adapter != null)
                {
                    var AllEVSEs = Adapter.RoamingNetwork.EVSEs.Where(evse => Adapter.IncludeEVSEIds(evse.Id) && Adapter.IncludeEVSEs(evse)).ToArray();

                    foreach (var evse in AllEVSEs)
                    {
                        var evseId = evse.Id.ToEMIP();

                        if (evseId.HasValue)
                        {
                            await Adapter.CPORoaming.SetEVSEAvailabilityStatus(PartnerId:           Adapter.PartnerId,
                                                                               OperatorId:          evse.Id.OperatorId.ToEMIP(CustomOperatorIdMapper),
                                                                               EVSEId:              evseId.Value,
                                                                               StatusEventDate:     evse.AdminStatus.Timestamp,
                                                                               AvailabilityStatus:  evse.AdminStatus.Value.ToEMIP(),
                                                                               TransactionId:       Transaction_Id.Random());

                            await Adapter.CPORoaming.SetEVSEBusyStatus(PartnerId:           Adapter.PartnerId,
                                                                       OperatorId:          evse.Id.OperatorId.ToEMIP(CustomOperatorIdMapper),
                                                                       EVSEId:              evseId.Value,
                                                                       StatusEventDate:     evse.Status.Timestamp,
                                                                       BusyStatus:          evse.Status.Value.ToEMIP(),
                                                                       TransactionId:       Transaction_Id.Random());
                        }
                    }
                }

                return(new HTTPResponse.Builder(Request)
                {
                    HTTPStatusCode = HTTPStatusCode.OK,
                    Connection = "close"
                });
            }, AllowReplacement: URLReplacement.Fail);

            #endregion
        }