Пример #1
0
        /// <summary>
        /// Return a JSON representation for the given enumeration of charging stations.
        /// </summary>
        /// <param name="ChargingStations">An enumeration of charging stations.</param>
        /// <param name="Skip">The optional number of charging stations to skip.</param>
        /// <param name="Take">The optional number of charging stations to return.</param>
        /// <param name="Embedded">Whether this data is embedded into another data structure, e.g. into a charging pool.</param>
        public static JArray ToJSON(this IEnumerable <ChargingStation> ChargingStations,
                                    UInt64?Skip      = null,
                                    UInt64?Take      = null,
                                    Boolean Embedded = false,
                                    InfoStatus ExpandRoamingNetworkId          = InfoStatus.ShowIdOnly,
                                    InfoStatus ExpandChargingStationOperatorId = InfoStatus.ShowIdOnly,
                                    InfoStatus ExpandChargingPoolId            = InfoStatus.ShowIdOnly,
                                    InfoStatus ExpandEVSEIds      = InfoStatus.Expand,
                                    InfoStatus ExpandBrandIds     = InfoStatus.ShowIdOnly,
                                    InfoStatus ExpandDataLicenses = InfoStatus.ShowIdOnly)


        => ChargingStations != null && ChargingStations.Any()

                   ? new JArray(ChargingStations.
                                Where(station => station != null).
                                OrderBy(station => station.Id).
                                SkipTakeFilter(Skip, Take).
                                SafeSelect(station => station.ToJSON(Embedded,
                                                                     ExpandRoamingNetworkId,
                                                                     ExpandChargingStationOperatorId,
                                                                     ExpandChargingPoolId,
                                                                     ExpandEVSEIds,
                                                                     ExpandBrandIds,
                                                                     ExpandDataLicenses)))

                   : null;
Пример #2
0
        /// <summary>
        /// Return a JSON representation for the given enumeration of dashboards.
        /// </summary>
        /// <param name="Dashboard">An enumeration of dashboards.</param>
        /// <param name="Skip">The optional number of dashboards to skip.</param>
        /// <param name="Take">The optional number of dashboards to return.</param>
        /// <param name="Embedded">Whether this data is embedded into another data structure.</param>
        public static JArray ToJSON(this IEnumerable <Dashboard> Dashboard,
                                    UInt64?Skip           = null,
                                    UInt64?Take           = null,
                                    Boolean Embedded      = false,
                                    InfoStatus ExpandTags = InfoStatus.ShowIdOnly,
                                    DashboardToJSONDelegate DashboardToJSON = null,
                                    Boolean IncludeCryptoHash = true)


        => Dashboard?.Any() != true

                   ? new JArray()

                   : new JArray(Dashboard.
                                Where(dashboard => dashboard != null).
                                OrderByDescending(dashboard => dashboard.CreationDate).
                                SkipTakeFilter(Skip, Take).
                                SafeSelect(dashboard => DashboardToJSON != null
                                                                     ? DashboardToJSON(dashboard,
                                                                                       Embedded,
                                                                                       ExpandTags,
                                                                                       IncludeCryptoHash)

                                                                     : dashboard.ToJSON(Embedded,
                                                                                        ExpandTags,
                                                                                        IncludeCryptoHash)));
Пример #3
0
        /// <summary>
        /// Return a JSON representation for the given enumeration of roaming networks.
        /// </summary>
        /// <param name="RoamingNetworks">An enumeration of roaming networks.</param>
        /// <param name="Skip">The optional number of roaming networks to skip.</param>
        /// <param name="Take">The optional number of roaming networks to return.</param>
        /// <param name="Embedded">Whether this data is embedded into another data structure.</param>
        public static JArray ToJSON(this IEnumerable <IRoamingNetwork> RoamingNetworks,
                                    UInt64?Skip      = null,
                                    UInt64?Take      = null,
                                    Boolean Embedded = false,
                                    InfoStatus ExpandChargingStationOperatorIds = InfoStatus.ShowIdOnly,
                                    InfoStatus ExpandRoamingNetworkIds          = InfoStatus.ShowIdOnly,
                                    InfoStatus ExpandChargingStationIds         = InfoStatus.ShowIdOnly,
                                    InfoStatus ExpandEVSEIds      = InfoStatus.ShowIdOnly,
                                    InfoStatus ExpandBrandIds     = InfoStatus.ShowIdOnly,
                                    InfoStatus ExpandDataLicenses = InfoStatus.ShowIdOnly,

                                    InfoStatus ExpandEMobilityProviderId = InfoStatus.ShowIdOnly)


        => RoamingNetworks == null || !RoamingNetworks.Any()

                   ? new JArray()

                   : new JArray(RoamingNetworks.
                                Where(roamingnetwork => roamingnetwork != null).
                                OrderBy(roamingnetwork => roamingnetwork.Id).
                                SkipTakeFilter(Skip, Take).
                                SafeSelect(roamingnetwork => roamingnetwork.ToJSON(Embedded,
                                                                                   ExpandChargingStationOperatorIds,
                                                                                   ExpandRoamingNetworkIds,
                                                                                   ExpandChargingStationIds,
                                                                                   ExpandEVSEIds,
                                                                                   ExpandBrandIds,
                                                                                   ExpandDataLicenses,
                                                                                   ExpandEMobilityProviderId)));
Пример #4
0
        /// <summary>
        /// Return a JSON representation for the given enumeration of charging pools.
        /// </summary>
        /// <param name="ChargingPools">An enumeration of charging pools.</param>
        /// <param name="Skip">The optional number of charging pools to skip.</param>
        /// <param name="Take">The optional number of charging pools to return.</param>
        /// <param name="Embedded">Whether this data is embedded into another data structure, e.g. into a charging station operator.</param>
        public static JArray ToJSON(this IEnumerable <ChargingPool> ChargingPools,
                                    UInt64?Skip      = null,
                                    UInt64?Take      = null,
                                    Boolean Embedded = false,
                                    InfoStatus ExpandRoamingNetworkId          = InfoStatus.ShowIdOnly,
                                    InfoStatus ExpandChargingStationOperatorId = InfoStatus.ShowIdOnly,
                                    InfoStatus ExpandChargingStationIds        = InfoStatus.Expand,
                                    InfoStatus ExpandEVSEIds      = InfoStatus.Hidden,
                                    InfoStatus ExpandBrandIds     = InfoStatus.ShowIdOnly,
                                    InfoStatus ExpandDataLicenses = InfoStatus.ShowIdOnly)


        => ChargingPools == null || !ChargingPools.Any()

                   ? new JArray()

                   : new JArray(ChargingPools.
                                Where(pool => pool != null).
                                OrderBy(pool => pool.Id).
                                SkipTakeFilter(Skip, Take).
                                SafeSelect(pool => pool.ToJSON(Embedded,
                                                               ExpandRoamingNetworkId,
                                                               ExpandChargingStationOperatorId,
                                                               ExpandChargingStationIds,
                                                               ExpandEVSEIds,
                                                               ExpandBrandIds,
                                                               ExpandDataLicenses)));
Пример #5
0
        public JObject ToJSON(Boolean Embedded                  = false,
                              InfoStatus ExpandMembers          = InfoStatus.ShowIdOnly,
                              InfoStatus ExpandParents          = InfoStatus.ShowIdOnly,
                              InfoStatus ExpandSubOrganizations = InfoStatus.ShowIdOnly,
                              InfoStatus ExpandTags             = InfoStatus.ShowIdOnly,
                              Boolean IncludeCryptoHash         = true)
        {
            var org = base.ToJSON(Embedded,
                                  ExpandMembers,
                                  ExpandParents,
                                  ExpandSubOrganizations,
                                  ExpandTags,
                                  IncludeCryptoHash);

            org["@context"] = JSONLDContext.ToString();

            org.Add("youAreMember", YouAreMember);
            org.Add("youCanAddMembers", YouCanAddMembers);
            org.Add("youCanCreateChildOrganizations", YouCanCreateChildOrganizations);
            //org.Add("admins",                          JSONArray.Create(Admins. SafeSelect(user => user.ToJSON())));

            //if (YouAreMember)
            //    org.Add("members",                     JSONArray.Create(Members.SafeSelect(user => user.ToJSON())));

            //org.Add("_childs",                         new JArray(Childs.OrderBy(child => child.Id).Select(child => child.ToJSON())));

            return(org);
        }
Пример #6
0
        /// <summary>
        /// Return a JSON representation for the given enumeration of news banners.
        /// </summary>
        /// <param name="NewsBanner">An enumeration of news banners.</param>
        /// <param name="Skip">The optional number of news banners to skip.</param>
        /// <param name="Take">The optional number of news banners to return.</param>
        /// <param name="Embedded">Whether this data is embedded into another data structure.</param>
        public static JArray ToJSON(this IEnumerable <NewsBanner> NewsBanner,
                                    UInt64?Skip               = null,
                                    UInt64?Take               = null,
                                    Boolean Embedded          = false,
                                    InfoStatus ExpandTags     = InfoStatus.ShowIdOnly,
                                    InfoStatus ExpandAuthorId = InfoStatus.ShowIdOnly,
                                    NewsBannerToJSONDelegate NewsBannerToJSON = null,
                                    Boolean IncludeCryptoHash = true)


        => NewsBanner?.Any() != true

                   ? new JArray()

                   : new JArray(NewsBanner.
                                Where(dataSet => dataSet != null).
                                //OrderByDescending(dataSet => dataSet.PublicationDate).
                                SkipTakeFilter(Skip, Take).
                                SafeSelect(newsBanner => NewsBannerToJSON != null
                                                                     ? NewsBannerToJSON(newsBanner,
                                                                                        Embedded,
                                                                                        ExpandTags,
                                                                                        ExpandAuthorId,
                                                                                        IncludeCryptoHash)

                                                                     : newsBanner.ToJSON(Embedded,
                                                                                         ExpandTags,
                                                                                         ExpandAuthorId,
                                                                                         IncludeCryptoHash)));
Пример #7
0
        /// <summary>
        /// Return a JSON representation of this object.
        /// </summary>
        /// <param name="Embedded">Whether this data is embedded into another data structure.</param>
        /// <param name="IncludeCryptoHash">Include the crypto hash value of this object.</param>
        public JObject ToJSON(Boolean Embedded          = false,
                              InfoStatus ExpandTags     = InfoStatus.ShowIdOnly,
                              InfoStatus ExpandAuthorId = InfoStatus.ShowIdOnly,
                              Boolean IncludeCryptoHash = false)

        => JSONObject.Create(

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

            !Embedded
                       ? new JProperty("@context", JSONLDContext.ToString())
                       : null,

            new JProperty("headline", Headline.ToJSON()),
            new JProperty("text", Text.ToJSON()),

            new JProperty("author", JSONObject.Create(
                              new JProperty("@id", Author.Id.ToString()),
                              new JProperty("name", Author.Name)
                              )),

            new JProperty("publicationDate", PublicationDate.ToIso8601()),

            Tags.Any()
                       ? new JProperty("tags", Tags.SafeSelect(tag => tag.ToJSON(ExpandTags)))
                       : null,

            Signatures.Any()
                       ? new JProperty("signatures", new JArray(Signatures.SafeSelect(signature => signature.ToJSON(Embedded: true))))
                       : null

            );
Пример #8
0
        /// <summary>
        /// Return a JSON representation of this object.
        /// </summary>
        /// <param name="Embedded">Whether this data is embedded into another data structure.</param>
        /// <param name="IncludeCryptoHash">Include the crypto hash value of this object.</param>
        public JObject ToJSON(Boolean Embedded          = false,
                              InfoStatus ExpandTags     = InfoStatus.ShowIdOnly,
                              Boolean IncludeCryptoHash = false)

        => JSONObject.Create(

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

            !Embedded
                       ? new JProperty("@context", JSONLDContext.ToString())
                       : null,

            Text.IsNeitherNullNorEmpty()
                       ? new JProperty("text", Text.ToJSON())
                       : null,

            new JProperty("publicationDate", PublicationDate.ToIso8601()),

            GeoLocation.HasValue
                       ? new JProperty("geoLocation", GeoLocation.ToJSON())
                       : null,

            Tags.Any()
                       ? new JProperty("tags", Tags.SafeSelect(tag => tag.ToJSON(ExpandTags)))
                       : null,

            PrivacyLevel.ToJSON(),

            Signatures.Any()
                       ? new JProperty("signatures", new JArray(Signatures.SafeSelect(signature => signature.ToJSON(Embedded: true))))
                       : null

            );
Пример #9
0
        /// <summary>
        /// Return a JSON representation for the given enumeration of blog postings.
        /// </summary>
        /// <param name="BlogPostings">An enumeration of blog postings.</param>
        /// <param name="Skip">The optional number of blog postings to skip.</param>
        /// <param name="Take">The optional number of blog postings to return.</param>
        /// <param name="Embedded">Whether this data is embedded into another data structure.</param>
        public static JArray ToJSON(this IEnumerable <BlogPosting> BlogPostings,
                                    UInt64?Skip           = null,
                                    UInt64?Take           = null,
                                    Boolean Embedded      = false,
                                    InfoStatus ExpandTags = InfoStatus.ShowIdOnly,
                                    BlogPostingToJSONDelegate BlogPostingToJSON = null,
                                    Boolean IncludeCryptoHash = true)


        => BlogPostings?.Any() != true

                   ? new JArray()

                   : new JArray(BlogPostings.
                                Where(dataSet => dataSet != null).
                                OrderBy(dataSet => dataSet.Id).
                                SkipTakeFilter(Skip, Take).
                                SafeSelect(BlogPosting => BlogPostingToJSON != null
                                                                    ? BlogPostingToJSON(BlogPosting,
                                                                                        Embedded,
                                                                                        ExpandTags,
                                                                                        IncludeCryptoHash)

                                                                    : BlogPosting.ToJSON(Embedded,
                                                                                         ExpandTags,
                                                                                         IncludeCryptoHash)));
Пример #10
0
        /// <summary>
        /// Return a JSON representation for the given enumeration of EVSEs.
        /// </summary>
        /// <param name="EVSEs">An enumeration of EVSEs.</param>
        /// <param name="Skip">The optional number of EVSEs to skip.</param>
        /// <param name="Take">The optional number of EVSEs to return.</param>
        /// <param name="Embedded">Whether this data is embedded into another data structure, e.g. into a charging station.</param>
        public static JArray ToJSON(this IEnumerable <EVSE> EVSEs,
                                    UInt64?Skip      = null,
                                    UInt64?Take      = null,
                                    Boolean Embedded = false,
                                    InfoStatus ExpandRoamingNetworkId          = InfoStatus.ShowIdOnly,
                                    InfoStatus ExpandChargingStationOperatorId = InfoStatus.ShowIdOnly,
                                    InfoStatus ExpandChargingPoolId            = InfoStatus.ShowIdOnly,
                                    InfoStatus ExpandChargingStationId         = InfoStatus.ShowIdOnly,
                                    InfoStatus ExpandBrandIds     = InfoStatus.ShowIdOnly,
                                    InfoStatus ExpandDataLicenses = InfoStatus.ShowIdOnly)


        => EVSEs == null || !EVSEs.Any()

                   ? null

                   : new JArray(EVSEs.
                                Where(evse => evse != null).
                                OrderBy(evse => evse.Id).
                                SkipTakeFilter(Skip, Take).
                                SafeSelect(evse => evse.ToJSON(Embedded,
                                                               ExpandRoamingNetworkId,
                                                               ExpandChargingStationOperatorId,
                                                               ExpandChargingPoolId,
                                                               ExpandChargingStationId,
                                                               ExpandBrandIds,
                                                               ExpandDataLicenses)));
Пример #11
0
        /// <summary>
        /// Return a JSON representation for the given enumeration of FAQs.
        /// </summary>
        /// <param name="FAQ">An enumeration of FAQs.</param>
        /// <param name="Skip">The optional number of FAQs to skip.</param>
        /// <param name="Take">The optional number of FAQs to return.</param>
        /// <param name="Embedded">Whether this data is embedded into another data structure.</param>
        public static JArray ToJSON(this IEnumerable <FAQ> FAQ,
                                    UInt64?Skip                 = null,
                                    UInt64?Take                 = null,
                                    Boolean Embedded            = false,
                                    InfoStatus ExpandTags       = InfoStatus.ShowIdOnly,
                                    InfoStatus ExpandAuthorId   = InfoStatus.ShowIdOnly,
                                    FAQToJSONDelegate FAQToJSON = null,
                                    Boolean IncludeCryptoHash   = true)


        => FAQ?.Any() != true

                   ? new JArray()

                   : new JArray(FAQ.
                                Where(dataSet => dataSet != null).
                                //OrderByDescending(dataSet => dataSet.PublicationDate).
                                SkipTakeFilter(Skip, Take).
                                SafeSelect(faq => FAQToJSON != null
                                                                     ? FAQToJSON(faq,
                                                                                 Embedded,
                                                                                 ExpandTags,
                                                                                 ExpandAuthorId,
                                                                                 IncludeCryptoHash)

                                                                     : faq.ToJSON(Embedded,
                                                                                  ExpandTags,
                                                                                  ExpandAuthorId,
                                                                                  IncludeCryptoHash)));
Пример #12
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="item"></param>
 /// <param name="infoStatus"></param>
 /// <param name="objectId"></param>
 /// <param name="revisionDate"></param>
 public CustomObject(T item, InfoStatus infoStatus = InfoStatus.New, long?objectId = null, DateTime?revisionDate = null)
 {
     _item        = item;
     _status      = infoStatus;
     ObjectId     = objectId;
     RevisionDate = revisionDate;
 }
Пример #13
0
        /// <summary>
        /// Return a JSON representation of this object.
        /// </summary>
        /// <param name="Embedded">Whether this data is embedded into another data structure.</param>
        /// <param name="IncludeCryptoHash">Include the crypto hash value of this object.</param>
        public JObject ToJSON(Boolean Embedded          = false,
                              InfoStatus ExpandTags     = InfoStatus.ShowIdOnly,
                              Boolean IncludeCryptoHash = false)

        => JSONObject.Create(

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

            !Embedded
                       ? new JProperty("@context", JSONLDContext.ToString())
                       : null,

            Name.IsNeitherNullNorEmpty()
                       ? new JProperty("name", Name.ToJSON())
                       : null,

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

            new JProperty("creationDate", CreationDate.ToIso8601()),

            Tags.Any()
                       ? new JProperty("tags", Tags.SafeSelect(tag => tag.ToJSON(ExpandTags)))
                       : null,

            new JProperty("isDisabled", IsDisabled)

            );
Пример #14
0
        public JToken ToJSON(InfoStatus ExpandTags = InfoStatus.ShowIdOnly)

        => ExpandTags.Switch(this,

                             info => new JObject(new JProperty("tag", info.Tag.ToJSON(true, ExpandDescription: InfoStatus.Expanded)),
                                                 new JProperty("relevance", info.Value)),

                             info => new JArray(info.Tag.Id.ToString(),
                                                info.Value));
Пример #15
0
        ///// <summary>
        ///// Return a JSON representation of this object.
        ///// </summary>
        ///// <param name="Embedded">Whether this data is embedded into another data structure.</param>
        ///// <param name="IncludeCryptoHash">Include the crypto hash value of this object.</param>
        //public JObject ToJSON(Boolean Embedded           = false,
        //                      Boolean IncludeCryptoHash  = false)

        //    => ToJSON(Embedded:           false,
        //              IncludeSignatures:  InfoStatus.Hidden,
        //              IncludeCryptoHash:  true);



        /// <summary>
        /// Return a JSON representation of this object.
        /// </summary>
        /// <param name="Embedded">Whether this data is embedded into another data structure, e.g. into a AttachedFile.</param>
        /// <param name="IncludeCryptoHash">Whether to include the cryptograhical hash value of this object.</param>
        public JObject ToJSON(Boolean Embedded             = false,
                              InfoStatus IncludeSignatures = InfoStatus.Hidden,
                              Boolean IncludeCryptoHash    = true,
                              CustomJObjectSerializerDelegate <AttachedFile> CustomAttachedFileSerializer = null)
        {
            var JSON = JSONObject.Create(

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

                Embedded
                               ? null
                               : new JProperty("@context", DefaultJSONLDContext.ToString()),

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

                Icon.HasValue
                               ? new JProperty("icon", Icon.ToString())
                               : null,

                ContentType != null
                               ? new JProperty("contentType", ContentType.ToString())
                               : null,

                Created.HasValue
                               ? new JProperty("created", Created.Value.ToIso8601())
                               : null,

                LastModified.HasValue
                               ? new JProperty("lastModified", LastModified.Value.ToIso8601())
                               : null,

                Size.HasValue
                               ? new JProperty("size", Size.Value)
                               : null,

                Locations.SafeAny()
                               ? new JProperty("locations", new JArray(Locations.SafeSelect(location => location.ToString())))
                               : null

                //IncludeCryptoHash
                //    ? new JProperty("cryptoHash", CurrentCryptoHash)
                //    : null


                );

            return(CustomAttachedFileSerializer != null
                       ? CustomAttachedFileSerializer(this, JSON)
                       : JSON);
        }
Пример #16
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="wvObject"></param>
        /// <param name="infoStatus"></param>
        public CustomObject(Hyland.Unity.WorkView.Object wvObject, InfoStatus infoStatus = InfoStatus.Ignore)
        {
            if (wvObject == null)
            {
                throw new ArgumentNullException(nameof(wvObject));
            }

            _item = WorkViewObjectConvert.DeserializeWorkViewObject <T>(wvObject);

            ObjectId     = wvObject.ID;
            RevisionDate = wvObject.RevisionDate;
            _status      = infoStatus;
        }
Пример #17
0
        public JToken ToJSON(InfoStatus ExpandTags = InfoStatus.ShowIdOnly)

        => ExpandTags.Switch(this,

                             info => new JObject(new JProperty("tag1", info.Tag1.ToJSON(true, ExpandDescription: InfoStatus.Expanded)),
                                                 new JProperty("label", info.Label.ToString()),
                                                 new JProperty("value", info.Value),
                                                 new JProperty("tag2", info.Tag2.ToJSON(true, ExpandDescription: InfoStatus.Expanded))),

                             info => new JArray(info.Tag1.Id.ToString(),
                                                info.Label.ToString(),
                                                info.Value,
                                                info.Tag2.Id.ToString()));
Пример #18
0
        /// <summary>
        /// Return a JSON representation of this object.
        /// </summary>
        /// <param name="Embedded">Whether this data is embedded into another data structure, e.g. into a defibrillator.</param>
        public JObject ToJSON(Boolean Embedded             = false,
                              InfoStatus ExpandDescription = InfoStatus.Hidden)

        => JSONObject.Create(

            Id.ToJSON("@id"),

            Embedded
                       ? null
                       : new JProperty("@context", JSONLDContext.ToString()),

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

            );
Пример #19
0
        /// <summary>
        /// Return a JSON representation of this object.
        /// </summary>
        public JObject ToJSON(InfoStatus ExpandUserIds         = InfoStatus.ShowIdOnly,
                              InfoStatus ExpandOrganizationIds = InfoStatus.ShowIdOnly)

        => JSONObject.Create(

            _ServiceTickets.SafeAny()
                       ? new JProperty("serviceTicketIds", new JArray(_ServiceTickets.SafeSelect(serviceTicket => serviceTicket.Id.ToString())))
                       : null,

            _Users.SafeAny()
                       ? new JProperty("userIds", new JArray(_Users.SafeSelect(user => user.Id.ToString())))
                       : null,

            _Organizations.SafeAny()
                       ? new JProperty("organizationIds", new JArray(_Organizations.SafeSelect(organization => organization.Id.ToString())))
                       : null

            );
Пример #20
0
        public JObject ToJSON(Boolean Embedded = false,
                              InfoStatus ExpandChargingPoolIds    = InfoStatus.Hidden,
                              InfoStatus ExpandChargingStationIds = InfoStatus.Hidden,
                              InfoStatus ExpandEVSEIds            = InfoStatus.Hidden,
                              InfoStatus ExpandDataLicenses       = InfoStatus.ShowIdOnly)

        => JSONObject.Create(

            new JProperty("Id", Id.ToString()),
            new JProperty("Name", Name.ToJSON()),

            LogoURI.IsNotNullOrEmpty()
                       ? new JProperty("LogoURI", LogoURI)
                       : null,

            Homepage.IsNotNullOrEmpty()
                       ? new JProperty("Homepage", Homepage)
                       : null

            );
Пример #21
0
        /// <summary>
        /// Return a JSON representation for the given enumeration of e-mobility providers.
        /// </summary>
        /// <param name="eMobilityProviders">An enumeration of e-mobility providers.</param>
        /// <param name="Skip">The optional number of e-mobility providers to skip.</param>
        /// <param name="Take">The optional number of e-mobility providers to return.</param>
        public static JArray ToJSON(this IEnumerable <eMobilityProvider> eMobilityProviders,
                                    UInt64?Skip      = null,
                                    UInt64?Take      = null,
                                    Boolean Embedded = false,
                                    InfoStatus ExpandRoamingNetworkId = InfoStatus.ShowIdOnly,
                                    InfoStatus ExpandBrandIds         = InfoStatus.ShowIdOnly,
                                    InfoStatus ExpandDataLicenses     = InfoStatus.ShowIdOnly)


        => eMobilityProviders == null

                   ? new JArray()

                   : new JArray(eMobilityProviders.
                                Where(emp => emp != null).
                                OrderBy(emp => emp.Id).
                                SkipTakeFilter(Skip, Take).
                                SafeSelect(emp => emp.ToJSON(Embedded,
                                                             ExpandRoamingNetworkId,
                                                             ExpandBrandIds,
                                                             ExpandDataLicenses)));
Пример #22
0
        /// <summary>
        /// Return a JSON representation of this object.
        /// </summary>
        /// <param name="Embedded">Whether this data is embedded into another data structure, e.g. into a OrganizationGroup.</param>
        /// <param name="IncludeCryptoHash">Whether to include the cryptograhical hash value of this object.</param>
        public virtual JObject ToJSON(Boolean Embedded = false,
                                      InfoStatus ExpandOrganizations           = InfoStatus.ShowIdOnly,
                                      InfoStatus ExpandParentGroup             = InfoStatus.ShowIdOnly,
                                      InfoStatus ExpandSubgroups               = InfoStatus.ShowIdOnly,
                                      InfoStatus ExpandAttachedFiles           = InfoStatus.ShowIdOnly,
                                      InfoStatus IncludeAttachedFileSignatures = InfoStatus.ShowIdOnly,
                                      Boolean IncludeCryptoHash = true)
        {
            var JSON = JSONObject.Create(

                Members.SafeAny() && ExpandOrganizations != InfoStatus.Hidden
                               ? ExpandSubgroups.Switch(
                    () => new JProperty("memberIds", new JArray(Members.SafeSelect(organization => organization.Id.ToString()))),
                    () => new JProperty("members", new JArray(Members.SafeSelect(organization => organization.ToJSON(Embedded: true,
                                                                                                                     //ExpandParentGroup:  InfoStatus.Hidden,
                                                                                                                     //ExpandSubgroups:    InfoStatus.Expand,
                                                                                                                     IncludeCryptoHash:  IncludeCryptoHash)))))
                               : null,

                ParentGroup != null && ExpandParentGroup != InfoStatus.Hidden
                               ? ExpandParentGroup.Switch(
                    () => new JProperty("parentGroupId", ParentGroup.Id.ToString()),
                    () => new JProperty("parentGroup", ParentGroup.ToJSON()))
                               : null,

                Subgroups.SafeAny() && ExpandSubgroups != InfoStatus.Hidden
                               ? ExpandSubgroups.Switch(
                    () => new JProperty("subgroupsIds", new JArray(Subgroups.SafeSelect(subgroup => subgroup.Id.ToString()))),
                    () => new JProperty("subgroups", new JArray(Subgroups.SafeSelect(subgroup => subgroup.ToJSON(Embedded:           true,
                                                                                                                 ExpandParentGroup:  InfoStatus.Hidden,
                                                                                                                 ExpandSubgroups:    InfoStatus.Expanded,
                                                                                                                 IncludeCryptoHash:  IncludeCryptoHash)))))
                               : null

                );

            return(JSON);
        }
Пример #23
0
        /// <summary>
        /// Return a JSON representation for the given enumeration of brands.
        /// </summary>
        /// <param name="Brands">An enumeration of brands.</param>
        /// <param name="Skip">The optional number of charging station operators to skip.</param>
        /// <param name="Take">The optional number of charging station operators to return.</param>
        /// <param name="Embedded">Whether this data is embedded into another data structure.</param>
        public static JArray ToJSON(this IEnumerable <Brand> Brands,
                                    UInt64?Skip      = null,
                                    UInt64?Take      = null,
                                    Boolean Embedded = false,
                                    InfoStatus ExpandChargingPoolIds    = InfoStatus.Hidden,
                                    InfoStatus ExpandChargingStationIds = InfoStatus.Hidden,
                                    InfoStatus ExpandEVSEIds            = InfoStatus.Hidden,
                                    InfoStatus ExpandDataLicenses       = InfoStatus.ShowIdOnly)


        => Brands == null || !Brands.Any()

                   ? new JArray()

                   : new JArray(Brands.
                                Where(brand => brand != null).
                                OrderBy(brand => brand.Id).
                                SkipTakeFilter(Skip, Take).
                                SafeSelect(brand => brand.ToJSON(Embedded,
                                                                 ExpandChargingPoolIds,
                                                                 ExpandChargingStationIds,
                                                                 ExpandEVSEIds,
                                                                 ExpandDataLicenses)));
Пример #24
0
        /// <summary>
        /// Return a JSON representation of this object.
        /// </summary>
        /// <param name="Embedded">Whether this data is embedded into another data structure.</param>
        /// <param name="IncludeCryptoHash">Include the crypto hash value of this object.</param>
        public JObject ToJSON(Boolean Embedded          = false,
                              InfoStatus ExpandTags     = InfoStatus.ShowIdOnly,
                              InfoStatus ExpandAuthorId = InfoStatus.ShowIdOnly,
                              Boolean IncludeCryptoHash = false)

        => JSONObject.Create(

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

            !Embedded
                       ? new JProperty("@context", JSONLDContext.ToString())
                       : null,

            new JProperty("text", Text.ToJSON()),

            new JProperty("startTimestamp", StartTimestamp.ToIso8601()),
            new JProperty("endTimestamp", EndTimestamp.ToIso8601()),
            new JProperty("author", JSONObject.Create(
                              new JProperty("@id", Author.Id.ToString()),
                              new JProperty("name", Author.Name)
                              ))

            );
Пример #25
0
        /// <summary>
        /// Return a JSON representation for the given enumeration of organization groups.
        /// </summary>
        /// <param name="OrganizationGroups">An enumeration of organization groups.</param>
        /// <param name="Skip">The optional number of organization groups to skip.</param>
        /// <param name="Take">The optional number of organization groups to return.</param>
        /// <param name="Embedded">Whether this data is embedded into another data structure, e.g. into a organization group.</param>
        public static JArray ToJSON(this IEnumerable <OrganizationGroup> OrganizationGroups,
                                    UInt64?Skip      = null,
                                    UInt64?Take      = null,
                                    Boolean Embedded = false,
                                    InfoStatus ExpandOrganizations           = InfoStatus.ShowIdOnly,
                                    InfoStatus ExpandParentGroup             = InfoStatus.ShowIdOnly,
                                    InfoStatus ExpandSubgroups               = InfoStatus.ShowIdOnly,
                                    InfoStatus ExpandAttachedFiles           = InfoStatus.ShowIdOnly,
                                    InfoStatus IncludeAttachedFileSignatures = InfoStatus.ShowIdOnly,
                                    OrganizationGroupToJSONDelegate OrganizationGroupToJSON = null,
                                    Boolean IncludeCryptoHash = true)


        => OrganizationGroups?.Any() != true

                   ? new JArray()

                   : new JArray(OrganizationGroups.
                                OrderBy(organizationGroup => organizationGroup.Id).
                                SkipTakeFilter(Skip, Take).
                                SafeSelect(organizationGroup => OrganizationGroupToJSON != null
                                                                            ? OrganizationGroupToJSON(organizationGroup,
                                                                                                      Embedded,
                                                                                                      ExpandOrganizations,
                                                                                                      ExpandParentGroup,
                                                                                                      ExpandSubgroups,
                                                                                                      ExpandAttachedFiles,
                                                                                                      IncludeAttachedFileSignatures,
                                                                                                      IncludeCryptoHash)

                                                                            : organizationGroup.ToJSON(Embedded,
                                                                                                       ExpandOrganizations,
                                                                                                       ExpandParentGroup,
                                                                                                       ExpandSubgroups,
                                                                                                       ExpandAttachedFiles,
                                                                                                       IncludeAttachedFileSignatures,
                                                                                                       IncludeCryptoHash)));
Пример #26
0
        private static InfoStatus ParseInfoResult(string path, XmlDocument xmlDoc)
        {
            if (!xmlDoc.HasChildNodes)
            {
                return(null);
            }

            var entry  = xmlDoc.GetElementsByTagName("entry").Item(0);
            var commit = entry["commit"];
            var repo   = entry["repository"];

            InfoStatus infoStatus = new InfoStatus();

            infoStatus.url                 = entry["url"].InnerText;
            infoStatus.relativeUrl         = entry["relative-url"].InnerText;
            infoStatus.uuid                = repo["uuid"].InnerText;;
            infoStatus.repositoryRoot      = repo["root"].InnerText;;
            infoStatus.author              = commit["author"].InnerText;
            infoStatus.revision            = Int32.Parse(entry.Attributes["revision"].InnerText);
            infoStatus.lastChangedRevision = Int32.Parse(commit.Attributes["revision"].InnerText);
            infoStatus.lastChangedDate     = DateTime.Parse(commit["date"].InnerText, null, DateTimeStyles.RoundtripKind);

            return(infoStatus);
        }
Пример #27
0
        protected JObject ToJSON(String JSONLDContext,
                                 Boolean Embedded = false,
                                 InfoStatus ExpandAttachedFiles                 = InfoStatus.ShowIdOnly,
                                 InfoStatus IncludeAttachedFileSignatures       = InfoStatus.ShowIdOnly,
                                 Func <JObject, JObject> CustomAGroupSerializer = null)
        {
            var JSON = JSONObject.Create(

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

                Embedded
                        ? null
                        : new JProperty("@context", JSONLDContext.ToString()),

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

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

                AttachedFiles.SafeAny() && ExpandAttachedFiles != InfoStatus.Hidden
                        ? ExpandAttachedFiles.Switch(
                    () => new JProperty("attachedFileIds", new JArray(AttachedFiles.SafeSelect(attachedFile => attachedFile.Id.ToString()))),
                    () => new JProperty("attachedFiles", new JArray(AttachedFiles.SafeSelect(attachedFile => attachedFile.ToJSON(Embedded:           true,
                                                                                                                                 IncludeSignatures:  IncludeAttachedFileSignatures,
                                                                                                                                 IncludeCryptoHash:  true)))))
                        : null,

                DataSource?.ToJSON("dataSource")

                );

            return(CustomAGroupSerializer != null
                       ? CustomAGroupSerializer(JSON)
                       : JSON);
        }
Пример #28
0
        /// <summary>
        /// Return a JSON representation of the given charging station.
        /// </summary>
        /// <param name="ChargingStation">A charging station.</param>
        /// <param name="Embedded">Whether this data is embedded into another data structure, e.g. into a charging pool.</param>
        public static JObject ToJSON(this ChargingStation ChargingStation,
                                     Boolean Embedded = false,
                                     InfoStatus ExpandRoamingNetworkId          = InfoStatus.ShowIdOnly,
                                     InfoStatus ExpandChargingStationOperatorId = InfoStatus.ShowIdOnly,
                                     InfoStatus ExpandChargingPoolId            = InfoStatus.ShowIdOnly,
                                     InfoStatus ExpandEVSEIds      = InfoStatus.Expand,
                                     InfoStatus ExpandBrandIds     = InfoStatus.ShowIdOnly,
                                     InfoStatus ExpandDataLicenses = InfoStatus.ShowIdOnly)


        => ChargingStation == null

                   ? null

                   : JSONObject.Create(

            ChargingStation.Id.ToJSON("@id"),

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

            ChargingStation.Name.IsNeitherNullNorEmpty()
                             ? ChargingStation.Name.ToJSON("name")
                             : null,

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

            ChargingStation.Brand != null
                             ? ExpandBrandIds.Switch(
                () => new JProperty("brandId", ChargingStation.Brand.Id.ToString()),
                () => new JProperty("brand", ChargingStation.Brand.ToJSON()))
                             : null,

            (!Embedded || ChargingStation.DataSource != ChargingStation.ChargingPool.DataSource)
                             ? ChargingStation.DataSource.ToJSON("dataSource")
                             : null,

            (!Embedded || ChargingStation.DataLicenses != ChargingStation.ChargingPool.DataLicenses)
                             ? ExpandDataLicenses.Switch(
                () => new JProperty("dataLicenseIds", new JArray(ChargingStation.DataLicenses.SafeSelect(license => license.Id.ToString()))),
                () => new JProperty("dataLicenses", ChargingStation.DataLicenses.ToJSON()))
                             : null,

            #region Embedded means it is served as a substructure of e.g. a charging station operator

            Embedded
                             ? null
                             : ExpandRoamingNetworkId.Switch(
                () => new JProperty("roamingNetworkId", ChargingStation.RoamingNetwork.Id.ToString()),
                () => new JProperty("roamingNetwork", ChargingStation.RoamingNetwork.ToJSON(Embedded:                          true,
                                                                                            ExpandChargingStationOperatorIds:  InfoStatus.Hidden,
                                                                                            ExpandChargingPoolIds:             InfoStatus.Hidden,
                                                                                            ExpandChargingStationIds:          InfoStatus.Hidden,
                                                                                            ExpandEVSEIds:                     InfoStatus.Hidden,
                                                                                            ExpandBrandIds:                    InfoStatus.Hidden,
                                                                                            ExpandDataLicenses:                InfoStatus.Hidden))),

            Embedded
                             ? null
                             : ExpandChargingStationOperatorId.Switch(
                () => new JProperty("chargingStationOperatorId", ChargingStation.Operator.Id.ToString()),
                () => new JProperty("chargingStationOperator", ChargingStation.Operator.ToJSON(Embedded:                          true,
                                                                                               ExpandRoamingNetworkId:            InfoStatus.Hidden,
                                                                                               ExpandChargingPoolIds:             InfoStatus.Hidden,
                                                                                               ExpandChargingStationIds:          InfoStatus.Hidden,
                                                                                               ExpandEVSEIds:                     InfoStatus.Hidden,
                                                                                               ExpandBrandIds:                    InfoStatus.Hidden,
                                                                                               ExpandDataLicenses:                InfoStatus.Hidden))),

            Embedded
                             ? null
                             : ExpandChargingPoolId.Switch(
                () => new JProperty("chargingPoolId", ChargingStation.ChargingPool.Id.ToString()),
                () => new JProperty("chargingPool", ChargingStation.ChargingPool.ToJSON(Embedded:                          true,
                                                                                        ExpandRoamingNetworkId:            InfoStatus.Hidden,
                                                                                        ExpandChargingStationOperatorId:   InfoStatus.Hidden,
                                                                                        ExpandChargingStationIds:          InfoStatus.Hidden,
                                                                                        ExpandEVSEIds:                     InfoStatus.Hidden,
                                                                                        ExpandBrandIds:                    InfoStatus.Hidden,
                                                                                        ExpandDataLicenses:                InfoStatus.Hidden))),

            #endregion

            (!Embedded || ChargingStation.GeoLocation != ChargingStation.ChargingPool.GeoLocation)         ? ChargingStation.GeoLocation.Value.ToJSON("geoLocation")         : null,
            (!Embedded || ChargingStation.Address != ChargingStation.ChargingPool.Address)             ? ChargingStation.Address.ToJSON("address")             : null,
            (!Embedded || ChargingStation.AuthenticationModes != ChargingStation.ChargingPool.AuthenticationModes) ? ChargingStation.AuthenticationModes.ToJSON("authenticationModes") : null,
            (!Embedded || ChargingStation.HotlinePhoneNumber != ChargingStation.ChargingPool.HotlinePhoneNumber)  ? ChargingStation.HotlinePhoneNumber.ToJSON("hotlinePhoneNumber")  : null,
            (!Embedded || ChargingStation.OpeningTimes != ChargingStation.ChargingPool.OpeningTimes)        ? ChargingStation.OpeningTimes.ToJSON("openingTimes")        : null,

            ExpandEVSEIds.Switch(
                () => new JProperty("EVSEIds",
                                    ChargingStation.EVSEIds.SafeAny()
                                                     ? new JArray(ChargingStation.EVSEIds.
                                                                  OrderBy(evseid => evseid).
                                                                  Select(evseid => evseid.ToString()))
                                                     : null),

                () => new JProperty("EVSEs",
                                    ChargingStation.EVSEs.SafeAny()
                                                     ? new JArray(ChargingStation.EVSEs.
                                                                  OrderBy(evse => evse.Id).
                                                                  Select(evse => evse.ToJSON(Embedded: true)))
                                                     : null))

            );
Пример #29
0
        private void Form1_KeyPress(object sender, KeyEventArgs e)
        {
            if (iStatus == InfoStatus.Question) {
                answer_label.Width  = 50;
                answer_label.Height = 10;
                //char tmp = cur_info.Answer + 32;
                Keys KeyAns;
                switch(cur_info.Answer){
                    case 'a':
                        KeyAns = Keys.F1;
                        break;
                    case 'b':
                        KeyAns = Keys.F2;
                        break;
                    case 'c':
                        KeyAns = Keys.F3;
                        break;
                    case 'd':
                        KeyAns = Keys.F4;
                        break;
                    default:
                        KeyAns = Keys.E;
                        break;
                }
                if (e.KeyCode == KeyAns) answer_label.Text = ANS_RIGHT;
                else answer_label.Text = ANS_WRONG+ char.ToUpper(cur_info.Answer);
                answer_label.Width = 0;
                answer_label.Height = 0;
                iStatus = InfoStatus.Show;
                return;
            }

            switch (e.KeyCode) {
                case Keys.F1:
                    if (ButtonPbox.Visible == true && iStatus == InfoStatus.Play)
                    {
                        zoomIn();
                        if (cur_info != null)
                        {
                            //message_label.AutoSize = true;
                            message_label.Width = 200;
                            message_label.Height = 200;
                            if (dMode == DisplayMode.Full) {
                                message_label.Width = 380;
                                message_label.Height = 600;
                            }

                            message_label.Text = cur_info.Text;
                            //message_label.AutoSize = true;

                            if (cur_info.Img != null)
                            {
                                //size
                                //pBox_img.Width=cur_info.Img.
                                pBox_img.Image = Image.FromFile(cur_info.Img);
                                pBox_img.Width = pBox_img.Image.Width;
                                pBox_img.Height = pBox_img.Image.Height;

                                //pBox_img.Width = 150;
                                //pBox_img.Height = 150;
                                if (dMode == DisplayMode.Full) {
                                    //pBox_img.Width = FimgSize;
                                    //pBox_img.Height = FimgSize;
                                }

                            }
                            if (cur_info.Type == pType.info) iStatus = InfoStatus.Show;
                            else iStatus = InfoStatus.Question;
                        }
                    }
                    break;
                case Keys.F2:
                    if (menuStrip1.Visible == true && iStatus == InfoStatus.Play)
                    {
                        this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
                        this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;

                        menuStrip1.Visible = false;
                        dMode = DisplayMode.Full;
                        Rectangle ret = Screen.GetWorkingArea(this);

                        /*
                        this.Video_panel.ClientSize = new Size(ret.Width, ret.Height);
                        this.Video_panel.Dock = DockStyle.Fill;
                        */

                        this.Video_panel.BringToFront();
                        setWindow();
                        this.Hide();
                        this.Show();
                        //showSize();
                    }
                    break;
                case Keys.F3:
                    if (menuStrip1.Visible == false && iStatus == InfoStatus.Play)
                    {
                        this.WindowState = System.Windows.Forms.FormWindowState.Normal;
                        this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Sizable;
                        dMode = DisplayMode.Normal;
                        setWindow();
                        menuStrip1.Visible = true;
                        this.Hide();
                        this.Show();
                        //showSize();
                    }
                    break;
                case Keys.F4:
                    if (ButtonPbox.Visible == true && iStatus == InfoStatus.Show)
                    {
                        message_label.Text = "";
                        message_label.Width = 0;
                        message_label.Height = 0;

                        answer_label.Text = "";
                        answer_label.Width = 0;
                        answer_label.Height = 0;

                        pBox_img.Image = null;
                        pBox_img.Width = 0;
                        pBox_img.Height = 0;

                        zoomOut();
                        ButtonPbox.Visible = false;
                        iStatus = InfoStatus.Play;
                        cur_info = null;
                    }
                    break;
                default:
                    break;
            }
        }
Пример #30
0
        void Play(String fileName)
        {
            try
            {
                graphBuilder = (IGraphBuilder)new FilterGraph();
                mediaCtrl = (IMediaControl)graphBuilder;
                mediaEvt = (IMediaEventEx)graphBuilder;
                mediaPos = (IMediaPosition)graphBuilder;
                videoWin = (IVideoWindow)graphBuilder;

                pane.getInfo(InfoQueue, fileName);
                graphBuilder.RenderFile( fileName, null );

                videoWin.put_Owner(Video_panel.Handle);
                //videoWin.put_Owner(this.Handle);
                videoWin.put_WindowStyle(WindowStyle.Child | WindowStyle.ClipChildren);

                setWindow();
                mediaCtrl.Run();

                double total_time;
                mediaPos.get_Duration(out total_time);

                Video_timer.Enabled = true;
                iStatus = InfoStatus.Play;
                message_label.Width = 0;
                message_label.Height = 0;
            }
            catch (Exception)
            {
                MessageBox.Show("Couldn't start");
            }
        }
Пример #31
0
        /// <summary>
        /// Return a JSON representation for the given charging station operator.
        /// </summary>
        /// <param name="ChargingStationOperator">A charging station operator.</param>
        /// <param name="Embedded">Whether this data is embedded into another data structure, e.g. into a roaming network.</param>
        public static JObject ToJSON(this ChargingStationOperator ChargingStationOperator,
                                     Boolean Embedded = false,
                                     InfoStatus ExpandRoamingNetworkId   = InfoStatus.ShowIdOnly,
                                     InfoStatus ExpandChargingPoolIds    = InfoStatus.ShowIdOnly,
                                     InfoStatus ExpandChargingStationIds = InfoStatus.ShowIdOnly,
                                     InfoStatus ExpandEVSEIds            = InfoStatus.ShowIdOnly,
                                     InfoStatus ExpandBrandIds           = InfoStatus.ShowIdOnly,
                                     InfoStatus ExpandDataLicenses       = InfoStatus.ShowIdOnly)


        => ChargingStationOperator == null

                   ? null

                   : JSONObject.Create(

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

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

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

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

            ChargingStationOperator.DataSource.ToJSON("DataSource"),

            ExpandDataLicenses.Switch(
                () => new JProperty("dataLicenseIds", new JArray(ChargingStationOperator.DataLicenses.SafeSelect(license => license.Id.ToString()))),
                () => new JProperty("dataLicenses", ChargingStationOperator.DataLicenses.ToJSON())),

            #region Embedded means it is served as a substructure of e.g. a charging station operator

            Embedded
                             ? null
                             : ExpandRoamingNetworkId.Switch(
                () => new JProperty("roamingNetworkId", ChargingStationOperator.RoamingNetwork.Id.ToString()),
                () => new JProperty("roamingNetwork", ChargingStationOperator.RoamingNetwork.ToJSON(Embedded:                          true,
                                                                                                    ExpandChargingStationOperatorIds:  InfoStatus.Hidden,
                                                                                                    ExpandChargingPoolIds:             InfoStatus.Hidden,
                                                                                                    ExpandChargingStationIds:          InfoStatus.Hidden,
                                                                                                    ExpandEVSEIds:                     InfoStatus.Hidden,
                                                                                                    ExpandBrandIds:                    InfoStatus.Hidden,
                                                                                                    ExpandDataLicenses:                InfoStatus.Hidden))),

            #endregion

            ChargingStationOperator.Address != null
                             ? ChargingStationOperator.Address.ToJSON("address")
                             : null,

            // API
            // MainKeys
            // RobotKeys
            // Endpoints
            // DNS SRV

            ChargingStationOperator.Logo.IsNotNullOrEmpty()
                             ? new JProperty("logos", JSONArray.Create(
                                                 JSONObject.Create(
                                                     new JProperty("uri", ChargingStationOperator.Logo),
                                                     new JProperty("description", I18NString.Empty.ToJSON())
                                                     )
                                                 ))
                             : null,

            ChargingStationOperator.Homepage.IsNotNullOrEmpty()
                             ? new JProperty("homepage", ChargingStationOperator.Homepage)
                             : null,

            ChargingStationOperator.HotlinePhoneNumber.IsNotNullOrEmpty()
                             ? new JProperty("hotline", ChargingStationOperator.HotlinePhoneNumber)
                             : null,


            ChargingStationOperator.ChargingPools.Any()
                             ? ExpandChargingPoolIds.Switch(

                () => new JProperty("chargingPoolIds",
                                    new JArray(ChargingStationOperator.ChargingPoolIds().
                                               OrderBy(poolId => poolId).
                                               Select(poolId => poolId.ToString()))),

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

            ChargingStationOperator.ChargingPools.Any() && ExpandChargingPoolIds == InfoStatus.Expand
                             ? null
                             : ExpandChargingStationIds.Switch(
                () => new JProperty("chargingStationIds",
                                    new JArray(ChargingStationOperator.ChargingStationIds().
                                               OrderBy(stationid => stationid).
                                               Select(stationid => stationid.ToString()))),

                () => new JProperty("chargingStations",
                                    new JArray(ChargingStationOperator.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)))),

            ChargingStationOperator.ChargingPools.Any() && (ExpandChargingPoolIds == InfoStatus.Expand || ExpandChargingStationIds == InfoStatus.Expand)
                             ? null
                             : ExpandEVSEIds.Switch(
                () => new JProperty("EVSEIds",
                                    new JArray(ChargingStationOperator.EVSEIds().
                                               OrderBy(evseId => evseId).
                                               Select(evseId => evseId.ToString()))),

                () => new JProperty("EVSEs",
                                    new JArray(ChargingStationOperator.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)))),


            ChargingStationOperator.Brands.Any()
                             ? ExpandBrandIds.Switch(

                () => new JProperty("brandIds",
                                    new JArray(ChargingStationOperator.BrandIds.
                                               OrderBy(brandId => brandId).
                                               Select(brandId => brandId.ToString()))),

                () => new JProperty("brands",
                                    new JArray(ChargingStationOperator.Brands.
                                               OrderBy(brand => brand).
                                               ToJSON(Embedded:                         true,
                                                      ExpandChargingPoolIds:            InfoStatus.Hidden,
                                                      ExpandChargingStationIds:         InfoStatus.Hidden,
                                                      ExpandEVSEIds:                    InfoStatus.Hidden,
                                                      ExpandDataLicenses:               InfoStatus.ShowIdOnly))))
                             : null

            );
Пример #32
0
        /// <summary>
        /// Return a JSON representation of the given charging tariff.
        /// </summary>
        /// <param name="Embedded">Whether this data is embedded into another data structure, e.g. into a charging station operator.</param>
        public JObject ToJSON(Boolean Embedded = false,
                              InfoStatus ExpandRoamingNetworkId          = InfoStatus.ShowIdOnly,
                              InfoStatus ExpandChargingStationOperatorId = InfoStatus.ShowIdOnly,
                              InfoStatus ExpandChargingPoolId            = InfoStatus.ShowIdOnly,
                              InfoStatus ExpandEVSEIds      = InfoStatus.Expand,
                              InfoStatus ExpandBrandIds     = InfoStatus.ShowIdOnly,
                              InfoStatus ExpandDataLicenses = InfoStatus.ShowIdOnly)


        => JSONObject.Create(

            Id.ToJSON("@id"),

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

            Name.IsNeitherNullNorEmpty()
                             ? Name.ToJSON("name")
                             : null,

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

            Brand != null
                             ? ExpandBrandIds.Switch(
                () => new JProperty("brandId", Brand.Id.ToString()),
                () => new JProperty("brand", Brand.ToJSON()))
                             : null,

            (!Embedded || DataSource != Operator.DataSource)
                             ? DataSource.ToJSON("dataSource")
                             : null,

            //(!Embedded || DataLicenses != Operator.DataLicenses)
            //    ? ExpandDataLicenses.Switch(
            //        () => new JProperty("dataLicenseIds",  new JArray(DataLicenses.SafeSelect(license => license.Id.ToString()))),
            //        () => new JProperty("dataLicenses",    DataLicenses.ToJSON()))
            //    : null,


            new JProperty("currency", Currency.ISOCode),

            TariffURI != null
                             ? new JProperty("URI", TariffURI.ToString())
                             : null,

            TariffElements.Any()
                             ? new JProperty("elements", new JArray(TariffElements.Select(TariffElement => TariffElement.ToJSON())))
                             : null,

            EnergyMix != null
                             ? new JProperty("energy_mix", EnergyMix.ToJSON())
                             : null,



            Operator.ChargingStationGroups.Any(group => group.Tariff == this)
                             ? new JProperty("chargingStations", new JArray(Operator.ChargingStationGroups.
                                                                            Where(group => group.Tariff == this).
                                                                            Select(group => group.AllowedMemberIds.
                                                                                   Select(id => id.ToString()))))
                             : null,

            Operator.EVSEGroups.Any(group => group.Tariff == this)
                             ? new JProperty("EVSEs", new JArray(Operator.EVSEGroups.
                                                                 Where(group => group.Tariff == this).
                                                                 Select(group => group.AllowedMemberIds.
                                                                        Select(id => id.ToString()))))
                             : null



            //                 #region Embedded means it is served as a substructure of e.g. a charging station operator

            //                 Embedded
            //                     ? null
            //                     : ExpandRoamingNetworkId.Switch(
            //                           () => new JProperty("roamingNetworkId",           RoamingNetwork.Id. ToString()),
            //                           () => new JProperty("roamingNetwork",             RoamingNetwork.    ToJSON(Embedded:                          true,
            //                                                                                                                            ExpandChargingStationOperatorIds:  InfoStatus.Hidden,
            //                                                                                                                            ExpandChargingPoolIds:             InfoStatus.Hidden,
            //                                                                                                                            ExpandChargingStationIds:          InfoStatus.Hidden,
            //                                                                                                                            ExpandEVSEIds:                     InfoStatus.Hidden,
            //                                                                                                                            ExpandBrandIds:                    InfoStatus.Hidden,
            //                                                                                                                            ExpandDataLicenses:                InfoStatus.Hidden))),

            //                 Embedded
            //                     ? null
            //                     : ExpandChargingStationOperatorId.Switch(
            //                           () => new JProperty("chargingStationOperatorId",  Operator.Id.       ToString()),
            //                           () => new JProperty("chargingStationOperator",    Operator.          ToJSON(Embedded:                          true,
            //                                                                                                                            ExpandRoamingNetworkId:            InfoStatus.Hidden,
            //                                                                                                                            ExpandChargingPoolIds:             InfoStatus.Hidden,
            //                                                                                                                            ExpandChargingStationIds:          InfoStatus.Hidden,
            //                                                                                                                            ExpandEVSEIds:                     InfoStatus.Hidden,
            //                                                                                                                            ExpandBrandIds:                    InfoStatus.Hidden,
            //                                                                                                                            ExpandDataLicenses:                InfoStatus.Hidden))),

            //                 #endregion

            //                 ExpandEVSEIds.Switch(
            //                     () => new JProperty("EVSEIds",
            //                                         EVSEIds.SafeAny()
            //                                             ? new JArray(EVSEIds.
            //                                                                               OrderBy(evseid => evseid).
            //                                                                               Select (evseid => evseid.ToString()))
            //                                             : null),

            //                     () => new JProperty("EVSEs",
            //                                         EVSEs.SafeAny()
            //                                             ? new JArray(EVSEs.
            //                                                                               OrderBy(evse   => evse.Id).
            //                                                                               Select (evse   => evse.  ToJSON(Embedded: true)))
            //                                             : null))

            );