コード例 #1
0
        public ADataStore(IRoamingNetwork RoamingNetwork,
                          Func <RoamingNetwork_Id, String> LogFileNameCreator,
                          Boolean DisableLogfiles = false,
                          IEnumerable <RoamingNetworkInfo> RoamingNetworkInfos = null,
                          Boolean DisableNetworkSync = false,
                          DNSClient DNSClient        = null)
        {
            this.InternalData = new Dictionary <TId, TData>();

            this.RoamingNetwork = RoamingNetwork ?? throw new ArgumentNullException(nameof(RoamingNetwork), "The given roaming network must not be null or empty!");

            if (LogFileNameCreator == null)
            {
                throw new ArgumentNullException(nameof(LogFileNameCreator), "The given LogFileNameCreator delegate must not be null or empty!");
            }

            this.LogfileName = LogFileNameCreator(RoamingNetwork.Id);

            this.DisableLogfiles = DisableLogfiles;

            this._RoamingNetworkInfos = RoamingNetworkInfos != null
                                               ? new List <RoamingNetworkInfo>(RoamingNetworkInfos)
                                               : new List <RoamingNetworkInfo>();

            this.DisableNetworkSync = DisableNetworkSync;

            this.DNSClient = DNSClient ?? new DNSClient(SearchForIPv4DNSServers: true,
                                                        SearchForIPv6DNSServers: false);
        }
コード例 #2
0
        /// <summary>
        /// A roaming network exception within the given roaming network.
        /// </summary>
        /// <param name="RoamingNetwork">The roaming network.</param>
        /// <param name="Message">An exception message.</param>
        public RoamingNetworkException(IRoamingNetwork RoamingNetwork,
                                       String Message)

            : base(Message)

        {
        }
コード例 #3
0
        /// <summary>
        /// An charging station operator exception within the given roaming network.
        /// </summary>
        /// <param name="RoamingNetwork">The roaming network.</param>
        /// <param name="Message">An exception message.</param>
        public ChargingStationOperatorException(IRoamingNetwork RoamingNetwork,
                                                String Message)

            : base(RoamingNetwork,
                   Message)

        {
        }
コード例 #4
0
        /// <summary>
        /// An e-mobility provider exception within the given roaming network.
        /// </summary>
        /// <param name="RoamingNetwork">The roaming network.</param>
        /// <param name="Message">An exception message.</param>
        public eMobilityProviderException(IRoamingNetwork RoamingNetwork,
                                          String Message)

            : base(RoamingNetwork,
                   Message)

        {
        }
コード例 #5
0
        /// <summary>
        /// A roaming network exception within the given roaming network.
        /// </summary>
        /// <param name="RoamingNetwork">The roaming network.</param>
        /// <param name="Message">An exception message.</param>
        /// <param name="InnerException">An inner exception.</param>
        public RoamingNetworkException(IRoamingNetwork RoamingNetwork,
                                       String Message,
                                       Exception InnerException)

            : base(Message, InnerException)

        {
        }
コード例 #6
0
        /// <summary>
        /// Create a new abstract crypto entity.
        /// </summary>
        /// <param name="Ids">The unique entity identifications.</param>
        /// <param name="RoamingNetwork">A WWCP roaming network.</param>
        protected ABaseEMobilityEntity(IEnumerable <TId> Ids,
                                       IRoamingNetwork RoamingNetwork,
                                       String EllipticCurve = "P-256",
                                       ECPrivateKeyParameters PrivateKey           = null,
                                       PublicKeyCertificates PublicKeyCertificates = null)

            : base(Ids,
                   RoamingNetwork,
                   EllipticCurve,
                   PrivateKey,
                   PublicKeyCertificates)

        {
        }
コード例 #7
0
        /// <summary>
        /// Create a new abstract crypto entity.
        /// </summary>
        /// <param name="Id">The unique entity identification.</param>
        protected ACryptoEMobilityEntity(TId Id,
                                         IRoamingNetwork RoamingNetwork,
                                         String EllipticCurve = "P-256",
                                         ECPrivateKeyParameters PrivateKey           = null,
                                         PublicKeyCertificates PublicKeyCertificates = null)

            : base(Id)

        {
            this.RoamingNetwork = RoamingNetwork;
            this.EllipticCurve  = EllipticCurve ?? "P-256";
            this.ECP            = ECNamedCurveTable.GetByName(this.EllipticCurve);
            this.ECSpec         = new ECDomainParameters(ECP.Curve, ECP.G, ECP.N, ECP.H, ECP.GetSeed());
            this.C                     = (FpCurve)ECSpec.Curve;
            this.PrivateKey            = PrivateKey;
            this.PublicKeyCertificates = PublicKeyCertificates;
        }
コード例 #8
0
        public ChargeDetailRecordsStore(IRoamingNetwork RoamingNetwork,
                                        Func <RoamingNetwork_Id, String> LogFileNameCreator = null,
                                        Boolean DisableLogfiles = false,
                                        IEnumerable <RoamingNetworkInfo> RoamingNetworkInfos = null,
                                        Boolean DisableNetworkSync = false)

            : base(RoamingNetwork,
                   LogFileNameCreator ?? (roamingNetworkId => String.Concat("ChargeDetailRecords", Path.DirectorySeparatorChar, "ChargeDetailRecords-",
                                                                            roamingNetworkId, "-",
                                                                            Environment.MachineName, "_",
                                                                            DateTime.UtcNow.Year, "-", DateTime.UtcNow.Month.ToString("D2"),
                                                                            ".log")),
                   DisableLogfiles,
                   RoamingNetworkInfos,
                   DisableNetworkSync)

        {
        }
コード例 #9
0
ファイル: RoamingNetwork.cs プロジェクト: rsegovia/WWCP_Core
        /// <summary>
        /// Return a JSON representation of the given roaming network.
        /// </summary>
        /// <param name="RoamingNetwork">A roaming network.</param>
        /// <param name="Embedded">Whether this data is embedded into another data structure.</param>
        public static JObject ToJSON(this IRoamingNetwork RoamingNetwork,
                                     Boolean Embedded = false,
                                     InfoStatus ExpandChargingStationOperatorIds = InfoStatus.ShowIdOnly,
                                     InfoStatus ExpandChargingPoolIds            = InfoStatus.ShowIdOnly,
                                     InfoStatus ExpandChargingStationIds         = InfoStatus.ShowIdOnly,
                                     InfoStatus ExpandEVSEIds      = InfoStatus.ShowIdOnly,
                                     InfoStatus ExpandBrandIds     = InfoStatus.ShowIdOnly,
                                     InfoStatus ExpandDataLicenses = InfoStatus.ShowIdOnly,

                                     InfoStatus ExpandEMobilityProviderId = InfoStatus.ShowIdOnly)


        => RoamingNetwork == null
                   ? null

                   : JSONObject.Create(

            new JProperty("@id", RoamingNetwork.Id.ToString()),

            Embedded
                             ? null
                             : new JProperty("@context", "https://open.charging.cloud/contexts/wwcp+json/RoamingNetwork"),

            new JProperty("name", RoamingNetwork.Name.ToJSON()),

            RoamingNetwork.Description.IsNeitherNullNorEmpty()
                             ? RoamingNetwork.Description.ToJSON("description")
                             : null,

            RoamingNetwork.DataSource.IsNeitherNullNorEmpty()
                             ? RoamingNetwork.DataSource.ToJSON("dataSource")
                             : null,

            RoamingNetwork.DataLicenses.Any()
                             ? ExpandDataLicenses.Switch(
                () => new JProperty("dataLicenseIds", new JArray(RoamingNetwork.DataLicenses.SafeSelect(license => license.Id.ToString()))),
                () => new JProperty("dataLicenses", RoamingNetwork.DataLicenses.ToJSON()))
                             : null,

            RoamingNetwork.ChargingStationOperators.Any()
                             ? ExpandChargingStationOperatorIds.Switch(

                () => new JProperty("chargingStationOperatorIds", new JArray(RoamingNetwork.ChargingStationOperatorIds.
                                                                             OrderBy(id => id).
                                                                             Select(id => id.ToString()))),

                () => new JProperty("chargingStationOperators", new JArray(RoamingNetwork.ChargingStationOperators.
                                                                           OrderBy(cso => cso).
                                                                           ToJSON(Embedded: true,
                                                                                  ExpandRoamingNetworkId:           InfoStatus.Hidden,
                                                                                  ExpandChargingPoolIds:            InfoStatus.Hidden,
                                                                                  ExpandChargingStationIds:         InfoStatus.Hidden,
                                                                                  ExpandEVSEIds:                    InfoStatus.Hidden,
                                                                                  ExpandBrandIds:                   InfoStatus.Hidden,
                                                                                  ExpandDataLicenses:               InfoStatus.Hidden))))
                             : null,

            !RoamingNetwork.ChargingStationOperators.Any() || ExpandChargingStationOperatorIds == InfoStatus.Expand
                             ? null
                             : ExpandChargingPoolIds.Switch(
                () => new JProperty("chargingPoolIds", new JArray(RoamingNetwork.ChargingPoolIds().
                                                                  OrderBy(id => id).
                                                                  Select(id => id.ToString()))),

                () => new JProperty("chargingPools", new JArray(RoamingNetwork.ChargingPools.
                                                                OrderBy(pool => pool).
                                                                ToJSON(Embedded: true,
                                                                       ExpandRoamingNetworkId:           InfoStatus.Hidden,
                                                                       ExpandChargingStationOperatorId:  InfoStatus.Hidden,
                                                                       ExpandChargingStationIds:         InfoStatus.Hidden,
                                                                       ExpandEVSEIds:                    InfoStatus.Hidden,
                                                                       ExpandBrandIds:                   InfoStatus.Hidden,
                                                                       ExpandDataLicenses:               InfoStatus.Hidden)))),

            !RoamingNetwork.ChargingStationOperators.Any() || (ExpandChargingPoolIds == InfoStatus.Expand || ExpandChargingStationOperatorIds == InfoStatus.Expand)
                             ? null
                             : ExpandChargingStationIds.Switch(
                () => new JProperty("chargingStationIds", new JArray(RoamingNetwork.ChargingStationIds().
                                                                     OrderBy(id => id).
                                                                     Select(id => id.ToString()))),

                () => new JProperty("chargingStations", new JArray(RoamingNetwork.ChargingStations.
                                                                   OrderBy(station => station).
                                                                   ToJSON(Embedded: true,
                                                                          ExpandRoamingNetworkId:           InfoStatus.Hidden,
                                                                          ExpandChargingStationOperatorId:  InfoStatus.Hidden,
                                                                          ExpandChargingPoolId:             InfoStatus.Hidden,
                                                                          ExpandEVSEIds:                    InfoStatus.Hidden,
                                                                          ExpandBrandIds:                   InfoStatus.Hidden,
                                                                          ExpandDataLicenses:               InfoStatus.Hidden)))),

            !RoamingNetwork.ChargingStationOperators.Any() || (ExpandChargingStationIds == InfoStatus.Expand || ExpandChargingPoolIds == InfoStatus.Expand || ExpandChargingStationOperatorIds == InfoStatus.Expand)
                             ? null
                             : ExpandEVSEIds.Switch(
                () => new JProperty("EVSEIds", new JArray(RoamingNetwork.EVSEIds().
                                                          OrderBy(id => id).
                                                          Select(id => id.ToString()))),

                () => new JProperty("EVSEs", new JArray(RoamingNetwork.EVSEs.
                                                        OrderBy(evse => evse).
                                                        ToJSON(Embedded: true,
                                                               ExpandRoamingNetworkId:           InfoStatus.Hidden,
                                                               ExpandChargingStationOperatorId:  InfoStatus.Hidden,
                                                               ExpandChargingPoolId:             InfoStatus.Hidden,
                                                               ExpandChargingStationId:          InfoStatus.Hidden,
                                                               ExpandBrandIds:                   InfoStatus.Hidden,
                                                               ExpandDataLicenses:               InfoStatus.Hidden)))),


            RoamingNetwork.eMobilityProviders.Any()
                             ? ExpandEMobilityProviderId.Switch(
                () => new JProperty("eMobilityProviderIds", new JArray(RoamingNetwork.ChargingStationOperatorIds.
                                                                       OrderBy(id => id).
                                                                       Select(id => id.ToString()))),

                () => new JProperty("eMobilityProviders", new JArray(RoamingNetwork.eMobilityProviders.
                                                                     OrderBy(emp => emp).
                                                                     ToJSON(Embedded: true,
                                                                            ExpandRoamingNetworkId:           InfoStatus.Hidden,
                                                                            ExpandBrandIds:                   InfoStatus.Hidden,
                                                                            ExpandDataLicenses:               InfoStatus.Hidden))))
                             : null

            );