コード例 #1
0
        protected virtual bool VerifyEntityTypeCondition(
            [NotNull] string entityPropertyName,
            [NotNull] EntityTypeDefinition entityTypeDefinition,
            [NotNull] EntityProperties entityProperties)
        {
            Assert.ArgumentNotNull(entityPropertyName, "entityPropertyName");
            Assert.ArgumentNotNull(entityTypeDefinition, "entityTypeDefinition");
            Assert.ArgumentNotNull(entityProperties, "entityProperties");

            EntityPropertyValue entityProperty = entityProperties[entityPropertyName];

            if (entityProperty == null)
            {
                return(false);
            }

            string entityPropertyValue = entityProperty.Value;

            if (string.IsNullOrEmpty(entityPropertyValue))
            {
                return(false);
            }

            foreach (string entityTypePropertyValue in entityTypeDefinition.Properties[entityPropertyName])
            {
                if (entityPropertyValue == entityTypePropertyValue)
                {
                    return(true);
                }
            }

            return(false);
        }
コード例 #2
0
        /// <summary>
        /// Builds the string for an array "single-line" property value
        /// </summary>
        /// <param name="arrayValue">EntityProperty of the value of the array</param>
        /// <param name="arrayItemIndex">index of this item in the array</param>
        /// <param name="indentationLevel">current indentation level</param>
        /// <returns>the string for the array "single-line" property value</returns>
        internal static string GetArrayPropertyValueString(EntityPropertyValue arrayValue, int arrayItemIndex, uint indentationLevel)
        {
            StringBuilder arrayPropertyValueString = new StringBuilder();

            arrayPropertyValueString.Append(IndentText("item[", indentationLevel)).Append(arrayItemIndex).Append("] = ");

            if (arrayValue.GetType() == typeof(EntityPropertyStringValue))
            {
                arrayPropertyValueString.Append("\"").Append(((EntityPropertyStringValue)arrayValue).Value).Append("\";");
            }
            else if (arrayValue.GetType() == typeof(EntityPropertyBooleanValue))
            {
                arrayPropertyValueString.Append(((EntityPropertyBooleanValue)arrayValue).Value.ToString().ToLower()).Append(";");
            }
            else if (arrayValue.GetType() == typeof(EntityPropertyDoubleValue))
            {
                arrayPropertyValueString.Append(((EntityPropertyDoubleValue)arrayValue).Value.ToString("R", CultureInfo.InvariantCulture).ToLower()).Append(";");
            }
            else
            {
                arrayPropertyValueString.Append(((EntityPropertyLongValue)arrayValue).Value.ToString(CultureInfo.InvariantCulture).ToLower()).Append(";");
            }

            return(arrayPropertyValueString.ToString());
        }
コード例 #3
0
        // todo: get IsVersioned flag from the EntityPropertyDto
        public async Task SetValueAsync <TId>(IEntity <TId> entity, EntityPropertyDto property, string value, bool createNewVersion)
        {
            var config = entity.GetType().GetEntityConfiguration();

            var prop = _entityPropertyValueRepository.GetAll()
                       .Where(x => x.EntityProperty.Id == property.Id && x.OwnerId == entity.Id.ToString() &&
                              x.OwnerType == config.TypeShortAlias)
                       .OrderByDescending(x => x.CreationTime).FirstOrDefault();

            if (prop?.Value == value)
            {
                return;
            }

            if (createNewVersion || prop == null)
            {
                prop = new EntityPropertyValue()
                {
                    Value = value, EntityProperty = _entityPropertyRepository.Get(property.Id)
                };
                prop.SetOwner(entity);
            }
            else
            {
                prop.Value = value;
            }

            await _entityPropertyValueRepository.InsertOrUpdateAsync(prop);
        }
コード例 #4
0
        protected override List <BaseItem> GetEntities()
        {
            if (this.Entities == null)
            {
                EntityValues itemValuesCollection = new ItemCollectionConnector(this.Context, this.List.WebUrl).GetItems(this.List, this.Options);

                this.Entities = new List <BaseItem>();
                foreach (EntityValues itemValues in itemValuesCollection["Items"])
                {
                    this.Entities.Add(ItemFactory.CreateItemObject(itemValues, this.List, this.Context));
                }

                EntityPropertyValue newNextPagingQuery = itemValuesCollection.Properties["ListItemCollectionPositionNext"];
                this.UpdatePagingQueryCollection(newNextPagingQuery != null ? newNextPagingQuery.Value : null);
            }

            return(this.Entities);
        }
コード例 #5
0
        protected override bool VerifyEntityTypeCondition(
            [NotNull] string entityPropertyName,
            [NotNull] EntityTypeDefinition entityTypeDefinition,
            [NotNull] EntityProperties entityProperties)
        {
            Assert.ArgumentNotNull(entityPropertyName, "entityPropertyName");
            Assert.ArgumentNotNull(entityTypeDefinition, "entityTypeDefinition");
            Assert.ArgumentNotNull(entityProperties, "entityProperties");

            string entityPropertyValue;

            EntityPropertyValue entityProperty = entityProperties["ows_" + entityPropertyName];

            if (entityProperty != null)
            {
                entityPropertyValue = entityProperty.Value;
            }
            else
            {
                if (entityPropertyName != "ContentTypeId")
                {
                    return(false);
                }

                entityPropertyValue = entityProperties.GetMetaInfoProperty(entityPropertyName);
            }

            if (string.IsNullOrEmpty(entityPropertyValue))
            {
                return(false);
            }

            foreach (string entityTypePropertyValue in entityTypeDefinition.Properties[entityPropertyName])
            {
                if (entityPropertyName == "ContentTypeId" ? entityPropertyValue.StartsWith(entityTypePropertyValue) : entityPropertyValue == entityTypePropertyValue)
                {
                    return(true);
                }
            }

            return(false);
        }
コード例 #6
0
        /// <summary>
        /// Initialize class.
        /// </summary>
        protected void Initialize(EntityValues values)
        {
            this.fieldNames = new List <string>();
            foreach (EntityValues fieldValues in values["ViewFields"])
            {
                this.fieldNames.Add(fieldValues.Properties["Name"].Value);
            }

            EntityPropertyValue rowLimit = values.Properties["RowLimit"];

            if (rowLimit != null && !string.IsNullOrEmpty(rowLimit.Value) && int.TryParse(rowLimit.Value, out this.pageSize))
            {
                this.PagingEnabled = true;
            }
            else
            {
                this.PagingEnabled = false;
            }

            this.initialized = true;
        }