PushEVSEStatus(this ICPOClient     CPOClient,
                           EVSEStatusRecord    EVSEStatusRecord,
                           Operator_Id         OperatorId,
                           String              OperatorName,
                           ActionTypes         Action              = ActionTypes.Update,

                           DateTime?           Timestamp           = null,
                           CancellationToken?  CancellationToken   = null,
                           EventTracking_Id    EventTrackingId     = null,
                           TimeSpan?           RequestTimeout      = null)


                => CPOClient.PushEVSEStatus(
                       new PushEVSEStatusRequest(
                           new OperatorEVSEStatus(
                               new EVSEStatusRecord[] { EVSEStatusRecord },
                               OperatorId,
                               OperatorName
                           ),
                           Action,

                           Timestamp,
                           CancellationToken,
                           EventTrackingId,
                           RequestTimeout ?? CPOClient.RequestTimeout));
Exemplo n.º 2
0
        /// <summary>
        /// Try to parse the given XML representation of an OICP EVSEStatusById request.
        /// </summary>
        /// <param name="Request">A EVSEStatusById request.</param>
        /// <param name="EVSEStatusByIdXML">The XML to parse.</param>
        /// <param name="EVSEStatusById">The parsed EVSEStatusById request.</param>
        /// <param name="CustomEVSEStatusByIdParser">A delegate to parse custom EVSEStatusById respones.</param>
        /// <param name="CustomEVSEStatusRecordParser">A delegate to parse custom EVSEStatusRecord XML elements.</param>
        /// <param name="CustomStatusCodeParser">A delegate to parse custom StatusCode XML elements.</param>
        /// <param name="OnException">An optional delegate called whenever an exception occured.</param>
        public static Boolean TryParse(PullEVSEStatusByIdRequest Request,
                                       XElement EVSEStatusByIdXML,
                                       out EVSEStatusById EVSEStatusById,
                                       CustomXMLParserDelegate <EVSEStatusById> CustomEVSEStatusByIdParser     = null,
                                       CustomXMLParserDelegate <EVSEStatusRecord> CustomEVSEStatusRecordParser = null,
                                       CustomXMLParserDelegate <StatusCode> CustomStatusCodeParser             = null,
                                       OnExceptionDelegate OnException = null)
        {
            try
            {
                if (EVSEStatusByIdXML.Name != OICPNS.EVSEStatus + "eRoamingEvseStatusById")
                {
                    EVSEStatusById = null;
                    return(false);
                }

                var _EVSEStatusRecordsXML = EVSEStatusByIdXML.Element(OICPNS.EVSEStatus + "EvseStatusRecords");

                EVSEStatusById = new EVSEStatusById(

                    Request,

                    _EVSEStatusRecordsXML != null
                                         ? _EVSEStatusRecordsXML.MapElementsOrFail(OICPNS.EVSEStatus + "EvseStatusRecord",
                                                                                   (s, e) => EVSEStatusRecord.Parse(s, CustomEVSEStatusRecordParser, e),
                                                                                   OnException)
                                         : null,

                    EVSEStatusByIdXML.MapElement(OICPNS.EVSEStatus + "StatusCode",
                                                 (xml, e) => OICPv2_2.StatusCode.Parse(xml,
                                                                                       CustomStatusCodeParser,
                                                                                       e),
                                                 OnException));


                if (CustomEVSEStatusByIdParser != null)
                {
                    EVSEStatusById = CustomEVSEStatusByIdParser(EVSEStatusByIdXML,
                                                                EVSEStatusById);
                }

                return(true);
            }
            catch (Exception e)
            {
                OnException?.Invoke(DateTime.UtcNow, EVSEStatusByIdXML, e);

                EVSEStatusById = null;
                return(false);
            }
        }