public static float?GetNumberFloatPropertyValueSemCms(SemanticPropertyModel pProperty) { if (pProperty != null && pProperty.PropertyValues.Count > 0 && !string.IsNullOrEmpty(pProperty.PropertyValues[0].Value)) { return(float.Parse(pProperty.PropertyValues[0].Value.Replace('.', ','))); } return(0); }
public static int?GetNumberIntPropertyValueSemCms(SemanticPropertyModel pProperty) { if (pProperty != null && pProperty.PropertyValues.Count > 0 && !string.IsNullOrEmpty(pProperty.PropertyValues[0].Value)) { return(int.Parse(pProperty.PropertyValues[0].Value)); } return(0); }
public static string GetPropertyValueSemCms(SemanticPropertyModel pProperty) { if (pProperty != null && pProperty.PropertyValues.Count > 0) { return(pProperty.PropertyValues[0].Value); } return(""); }
public static bool GetBooleanPropertyValueSemCms(SemanticPropertyModel pProperty) { bool resultado = false; if (pProperty != null && pProperty.PropertyValues.Count > 0 && !string.IsNullOrEmpty(pProperty.PropertyValues[0].Value)) { if (!bool.TryParse(pProperty.PropertyValues[0].Value, out resultado)) { resultado = !NoEnIdiomas.Contains(pProperty.PropertyValues[0].Value); } } return(resultado); }
public static DateTime?GetDateValuePropertySemCms(SemanticPropertyModel pProperty) { string stringDate = GetPropertyValueSemCms(pProperty); if (!string.IsNullOrEmpty(stringDate)) { int year = 0; int month = 0; int day = 0; if (stringDate.Contains('/')) { day = int.Parse(stringDate.Split('/')[0]); month = int.Parse(stringDate.Split('/')[1]); year = int.Parse(stringDate.Split('/')[2]); } else { year = int.Parse(stringDate.Substring(0, 4)); month = int.Parse(stringDate.Substring(4, 2)); day = int.Parse(stringDate.Substring(6, 2)); } if (stringDate.Length == 14) { if (month == 0 || day == 0) { return(new DateTime(year)); } else { int hour = int.Parse(stringDate.Substring(8, 2)); int minute = int.Parse(stringDate.Substring(10, 2)); int second = int.Parse(stringDate.Substring(12, 2)); return(new DateTime(year, month, day, hour, minute, second)); } } else { return(new DateTime(year, month, day)); } } return(null); }
public Movie(SemanticResourceModel pSemCmsModel, LanguageEnum idiomaUsuario) : base() { this.mGNOSSID = pSemCmsModel.RootEntities[0].Entity.Uri; this.Schema_author = new List <Person>(); SemanticPropertyModel propSchema_author = pSemCmsModel.GetPropertyByPath("http://schema.org/author"); if (propSchema_author != null && propSchema_author.PropertyValues.Count > 0) { foreach (SemanticPropertyModel.PropertyValue propValue in propSchema_author.PropertyValues) { if (propValue.RelatedEntity != null) { Person schema_author = new Person(propValue.RelatedEntity, idiomaUsuario); this.Schema_author.Add(schema_author); } } } this.Schema_rating = new List <Rating>(); SemanticPropertyModel propSchema_rating = pSemCmsModel.GetPropertyByPath("http://schema.org/rating"); if (propSchema_rating != null && propSchema_rating.PropertyValues.Count > 0) { foreach (SemanticPropertyModel.PropertyValue propValue in propSchema_rating.PropertyValues) { if (propValue.RelatedEntity != null) { Rating schema_rating = new Rating(propValue.RelatedEntity, idiomaUsuario); this.Schema_rating.Add(schema_rating); } } } this.Schema_director = new List <Person>(); SemanticPropertyModel propSchema_director = pSemCmsModel.GetPropertyByPath("http://schema.org/director"); if (propSchema_director != null && propSchema_director.PropertyValues.Count > 0) { foreach (SemanticPropertyModel.PropertyValue propValue in propSchema_director.PropertyValues) { if (propValue.RelatedEntity != null) { Person schema_director = new Person(propValue.RelatedEntity, idiomaUsuario); this.Schema_director.Add(schema_director); } } } this.Schema_actor = new List <Person>(); SemanticPropertyModel propSchema_actor = pSemCmsModel.GetPropertyByPath("http://schema.org/actor"); if (propSchema_actor != null && propSchema_actor.PropertyValues.Count > 0) { foreach (SemanticPropertyModel.PropertyValue propValue in propSchema_actor.PropertyValues) { if (propValue.RelatedEntity != null) { Person schema_actor = new Person(propValue.RelatedEntity, idiomaUsuario); this.Schema_actor.Add(schema_actor); } } } SemanticPropertyModel propSchema_genre = pSemCmsModel.GetPropertyByPath("http://schema.org/genre"); this.Schema_genre = new List <string>(); if (propSchema_genre != null && propSchema_genre.PropertyValues.Count > 0) { foreach (SemanticPropertyModel.PropertyValue propValue in propSchema_genre.PropertyValues) { this.Schema_genre.Add(propValue.Value); } } SemanticPropertyModel propSchema_url = pSemCmsModel.GetPropertyByPath("http://schema.org/url"); this.Schema_url = new List <string>(); if (propSchema_url != null && propSchema_url.PropertyValues.Count > 0) { foreach (SemanticPropertyModel.PropertyValue propValue in propSchema_url.PropertyValues) { this.Schema_url.Add(propValue.Value); } } SemanticPropertyModel propSchema_aggregateRating = pSemCmsModel.GetPropertyByPath("http://schema.org/aggregateRating"); this.Schema_aggregateRating = new List <string>(); if (propSchema_aggregateRating != null && propSchema_aggregateRating.PropertyValues.Count > 0) { foreach (SemanticPropertyModel.PropertyValue propValue in propSchema_aggregateRating.PropertyValues) { this.Schema_aggregateRating.Add(propValue.Value); } } SemanticPropertyModel propSchema_productionCompany = pSemCmsModel.GetPropertyByPath("http://schema.org/productionCompany"); this.Schema_productionCompany = new List <string>(); if (propSchema_productionCompany != null && propSchema_productionCompany.PropertyValues.Count > 0) { foreach (SemanticPropertyModel.PropertyValue propValue in propSchema_productionCompany.PropertyValues) { this.Schema_productionCompany.Add(propValue.Value); } } this.Schema_recordedAt = new List <int>(); SemanticPropertyModel propSchema_recordedAt = pSemCmsModel.GetPropertyByPath("http://schema.org/recordedAt"); if (propSchema_recordedAt != null && propSchema_recordedAt.PropertyValues.Count > 0) { foreach (SemanticPropertyModel.PropertyValue propValue in propSchema_recordedAt.PropertyValues) { this.Schema_recordedAt.Add(GetNumberIntPropertyMultipleValueSemCms(propValue).Value); } } SemanticPropertyModel propSchema_countryOfOrigin = pSemCmsModel.GetPropertyByPath("http://schema.org/countryOfOrigin"); this.Schema_countryOfOrigin = new List <string>(); if (propSchema_countryOfOrigin != null && propSchema_countryOfOrigin.PropertyValues.Count > 0) { foreach (SemanticPropertyModel.PropertyValue propValue in propSchema_countryOfOrigin.PropertyValues) { this.Schema_countryOfOrigin.Add(propValue.Value); } } this.Schema_duration = new List <int>(); SemanticPropertyModel propSchema_duration = pSemCmsModel.GetPropertyByPath("http://schema.org/duration"); if (propSchema_duration != null && propSchema_duration.PropertyValues.Count > 0) { foreach (SemanticPropertyModel.PropertyValue propValue in propSchema_duration.PropertyValues) { this.Schema_duration.Add(GetNumberIntPropertyMultipleValueSemCms(propValue).Value); } } SemanticPropertyModel propSchema_inLanguage = pSemCmsModel.GetPropertyByPath("http://schema.org/inLanguage"); this.Schema_inLanguage = new List <string>(); if (propSchema_inLanguage != null && propSchema_inLanguage.PropertyValues.Count > 0) { foreach (SemanticPropertyModel.PropertyValue propValue in propSchema_inLanguage.PropertyValues) { this.Schema_inLanguage.Add(propValue.Value); } } SemanticPropertyModel propSchema_award = pSemCmsModel.GetPropertyByPath("http://schema.org/award"); this.Schema_award = new List <string>(); if (propSchema_award != null && propSchema_award.PropertyValues.Count > 0) { foreach (SemanticPropertyModel.PropertyValue propValue in propSchema_award.PropertyValues) { this.Schema_award.Add(propValue.Value); } } this.Schema_description = GetPropertyValueSemCms(pSemCmsModel.GetPropertyByPath("http://schema.org/description")); this.Schema_image = GetPropertyValueSemCms(pSemCmsModel.GetPropertyByPath("http://schema.org/image")); this.Schema_name = GetPropertyValueSemCms(pSemCmsModel.GetPropertyByPath("http://schema.org/name")); this.Schema_datePublished = GetDateValuePropertySemCms(pSemCmsModel.GetPropertyByPath("http://schema.org/datePublished")).Value; this.Schema_contentRating = GetPropertyValueSemCms(pSemCmsModel.GetPropertyByPath("http://schema.org/contentRating")); }