Example #1
0
        private FilterElementCollection GetFilters()
        {
            FilterElementCollection coll = new FilterElementCollection();

            if (!String.IsNullOrEmpty(ClassName))
            {
                if (ObjectId == null)
                {
                    throw new ArgumentNullException("QueryString:ObjectId");
                }

                //Profile level
                if (String.Compare(ClassName, CustomizationProfileEntity.ClassName, true) == 0)
                {
                    // ProfileId is null OR ProfileId = value
                    OrBlockFilterElement orBlock = new OrBlockFilterElement();
                    orBlock.ChildElements.Add(FilterElement.IsNullElement(CustomPageEntity.FieldProfileId));
                    orBlock.ChildElements.Add(FilterElement.EqualElement(CustomPageEntity.FieldProfileId, ObjectId));

                    coll.Add(orBlock);
                    coll.Add(FilterElement.IsNullElement(CustomPageEntity.FieldUserId));
                }

                //User level
                if (String.Compare(ClassName, "Principal", true) == 0)
                {
                    int profileId = ProfileManager.GetProfileIdByUser();

                    // ProfileId is null AND UserId is null
                    AndBlockFilterElement andBlock1 = new AndBlockFilterElement();
                    andBlock1.ChildElements.Add(FilterElement.IsNullElement(CustomPageEntity.FieldProfileId));
                    andBlock1.ChildElements.Add(FilterElement.IsNullElement(CustomPageEntity.FieldUserId));

                    // ProfileId = value AND UserId is null
                    AndBlockFilterElement andBlock2 = new AndBlockFilterElement();
                    andBlock2.ChildElements.Add(FilterElement.EqualElement(CustomPageEntity.FieldProfileId, profileId));
                    andBlock2.ChildElements.Add(FilterElement.IsNullElement(CustomPageEntity.FieldUserId));

                    // ProfileId is null AND UserId = value
                    AndBlockFilterElement andBlock3 = new AndBlockFilterElement();
                    andBlock3.ChildElements.Add(FilterElement.IsNullElement(CustomPageEntity.FieldProfileId));
                    andBlock3.ChildElements.Add(FilterElement.EqualElement(CustomPageEntity.FieldUserId, ObjectId));

                    OrBlockFilterElement orBlock = new OrBlockFilterElement();
                    orBlock.ChildElements.Add(andBlock1);
                    orBlock.ChildElements.Add(andBlock2);
                    orBlock.ChildElements.Add(andBlock3);

                    coll.Add(orBlock);
                }
            }
            else
            {
                //Site level
                coll.Add(FilterElement.IsNullElement(CustomPageEntity.FieldProfileId));
                coll.Add(FilterElement.IsNullElement(CustomPageEntity.FieldUserId));
            }
            return(coll);
        }
Example #2
0
        private FilterElementCollection GetFilters()
        {
            FilterElementCollection coll = new FilterElementCollection();
            if (!String.IsNullOrEmpty(ClassName))
            {
                if (ObjectId == null)
                    throw new ArgumentNullException("QueryString:ObjectId");

                //Profile level
                if (String.Compare(ClassName, CustomizationProfileEntity.ClassName, true) == 0)
                {
                    // ProfileId is null OR ProfileId = value
                    OrBlockFilterElement orBlock = new OrBlockFilterElement();
                    orBlock.ChildElements.Add(FilterElement.IsNullElement(CustomPageEntity.FieldProfileId));
                    orBlock.ChildElements.Add(FilterElement.EqualElement(CustomPageEntity.FieldProfileId, ObjectId));

                    coll.Add(orBlock);
                    coll.Add(FilterElement.IsNullElement(CustomPageEntity.FieldUserId));
                }

                //User level
                if (String.Compare(ClassName, "Principal", true) == 0)
                {
                    int profileId = ProfileManager.GetProfileIdByUser();

                    // ProfileId is null AND UserId is null
                    AndBlockFilterElement andBlock1 = new AndBlockFilterElement();
                    andBlock1.ChildElements.Add(FilterElement.IsNullElement(CustomPageEntity.FieldProfileId));
                    andBlock1.ChildElements.Add(FilterElement.IsNullElement(CustomPageEntity.FieldUserId));

                    // ProfileId = value AND UserId is null
                    AndBlockFilterElement andBlock2 = new AndBlockFilterElement();
                    andBlock2.ChildElements.Add(FilterElement.EqualElement(CustomPageEntity.FieldProfileId, profileId));
                    andBlock2.ChildElements.Add(FilterElement.IsNullElement(CustomPageEntity.FieldUserId));

                    // ProfileId is null AND UserId = value
                    AndBlockFilterElement andBlock3 = new AndBlockFilterElement();
                    andBlock3.ChildElements.Add(FilterElement.IsNullElement(CustomPageEntity.FieldProfileId));
                    andBlock3.ChildElements.Add(FilterElement.EqualElement(CustomPageEntity.FieldUserId, ObjectId));

                    OrBlockFilterElement orBlock = new OrBlockFilterElement();
                    orBlock.ChildElements.Add(andBlock1);
                    orBlock.ChildElements.Add(andBlock2);
                    orBlock.ChildElements.Add(andBlock3);

                    coll.Add(orBlock);
                }
            }
            else
            {
                //Site level
                coll.Add(FilterElement.IsNullElement(CustomPageEntity.FieldProfileId));
                coll.Add(FilterElement.IsNullElement(CustomPageEntity.FieldUserId));

            }
            return coll;
        }
Example #3
0
        /// <summary>
        /// Gets the custom page.
        /// </summary>
        /// <param name="uid">The page uid.</param>
        /// <param name="profileId">The profile id.</param>
        /// <param name="userId">The user id.</param>
        /// <returns></returns>
        public static CustomPageEntity GetCustomPage(Guid uid, int? profileId, int? userId)
        {
            FilterElementCollection filters = new FilterElementCollection();
            filters.Add(FilterElement.EqualElement(CustomPageEntity.FieldUid, uid));

            if (userId.HasValue)	// User layer
            {
                if (!profileId.HasValue)
                    profileId = ProfileManager.GetProfileIdByUser(userId.Value);

                // ProfileId is null AND UserId is null
                AndBlockFilterElement andBlock1 = new AndBlockFilterElement();
                andBlock1.ChildElements.Add(FilterElement.IsNullElement(CustomPageEntity.FieldProfileId));
                andBlock1.ChildElements.Add(FilterElement.IsNullElement(CustomPageEntity.FieldUserId));

                // ProfileId = value AND UserId is null
                AndBlockFilterElement andBlock2 = new AndBlockFilterElement();
                andBlock2.ChildElements.Add(FilterElement.EqualElement(CustomPageEntity.FieldProfileId, profileId.Value));
                andBlock2.ChildElements.Add(FilterElement.IsNullElement(CustomPageEntity.FieldUserId));

                // ProfileId is null AND UserId = value
                AndBlockFilterElement andBlock3 = new AndBlockFilterElement();
                andBlock3.ChildElements.Add(FilterElement.IsNullElement(CustomPageEntity.FieldProfileId));
                andBlock3.ChildElements.Add(FilterElement.EqualElement(CustomPageEntity.FieldUserId, userId.Value));

                OrBlockFilterElement orBlock = new OrBlockFilterElement();
                orBlock.ChildElements.Add(andBlock1);
                orBlock.ChildElements.Add(andBlock2);
                orBlock.ChildElements.Add(andBlock3);

                filters.Add(orBlock);
            }
            else if (profileId.HasValue)	// Profile layer
            {
                filters.Add(FilterElement.IsNullElement(CustomPageEntity.FieldUserId));

                OrBlockFilterElement orBlock = new OrBlockFilterElement();
                orBlock.ChildElements.Add(FilterElement.EqualElement(CustomPageEntity.FieldProfileId, profileId.Value));
                orBlock.ChildElements.Add(FilterElement.IsNullElement(CustomPageEntity.FieldProfileId));
                filters.Add(orBlock);
            }
            else // Site layer
            {
                filters.Add(FilterElement.IsNullElement(CustomPageEntity.FieldProfileId));
                filters.Add(FilterElement.IsNullElement(CustomPageEntity.FieldUserId));
            }

            EntityObject[] pages = BusinessManager.List(CustomPageEntity.ClassName, filters.ToArray());

            CustomPageEntity retval = null;
            if (pages.Length > 0)
                retval = (CustomPageEntity)pages[0];

            return retval;
        }
Example #4
0
        private static FilterElement[] ConstructFilterByEntity(EntityObject entity)
        {
            AndBlockFilterElement retVal = new AndBlockFilterElement();

            foreach (string propName in CalendarEventResourceEntity.ComparedProperties)
            {
                EntityObjectProperty property = entity.Properties[propName];
                if (property != null && property.Value != null)
                {
                    retVal.ChildElements.Add(new FilterElement(propName, FilterElementType.Equal, property.Value));
                }
            }
            return(new FilterElement[] { retVal });
        }
Example #5
0
        public static ItemMetadataAdaptor FindMetadataItemById(SyncId replicaId, SyncId globalId)
        {
            ItemMetadataAdaptor retVal   = null;
            FilterElement       filterEl = new AndBlockFilterElement();

            filterEl.ChildElements.Add(new FilterElement(SynchronizationMetadataRow.ColumnReplicaId, FilterElementType.Equal,
                                                         replicaId.GetGuidId()));
            filterEl.ChildElements.Add(new FilterElement(SynchronizationMetadataRow.ColumnUniqueId, FilterElementType.Equal,
                                                         globalId.GetSyncGlobalId().UniqueId));
            filterEl.ChildElements.Add(new FilterElement(SynchronizationMetadataRow.ColumnPrefix, FilterElementType.Equal,
                                                         (long)globalId.GetSyncGlobalId().Prefix));

            SynchronizationMetadataRow[] itemRows = SynchronizationMetadataRow.List(filterEl);
            if (itemRows.Length != 0)
            {
                retVal = new ItemMetadataAdaptor(itemRows[0]);
            }

            return(retVal);
        }
Example #6
0
        /// <summary>
        /// Gets the custom page.
        /// </summary>
        /// <param name="uid">The page uid.</param>
        /// <param name="profileId">The profile id.</param>
        /// <param name="userId">The user id.</param>
        /// <returns></returns>
        public static CustomPageEntity GetCustomPage(Guid uid, int?profileId, int?userId)
        {
            FilterElementCollection filters = new FilterElementCollection();

            filters.Add(FilterElement.EqualElement(CustomPageEntity.FieldUid, uid));

            if (userId.HasValue)                // User layer
            {
                if (!profileId.HasValue)
                {
                    profileId = ProfileManager.GetProfileIdByUser(userId.Value);
                }

                // ProfileId is null AND UserId is null
                AndBlockFilterElement andBlock1 = new AndBlockFilterElement();
                andBlock1.ChildElements.Add(FilterElement.IsNullElement(CustomPageEntity.FieldProfileId));
                andBlock1.ChildElements.Add(FilterElement.IsNullElement(CustomPageEntity.FieldUserId));

                // ProfileId = value AND UserId is null
                AndBlockFilterElement andBlock2 = new AndBlockFilterElement();
                andBlock2.ChildElements.Add(FilterElement.EqualElement(CustomPageEntity.FieldProfileId, profileId.Value));
                andBlock2.ChildElements.Add(FilterElement.IsNullElement(CustomPageEntity.FieldUserId));

                // ProfileId is null AND UserId = value
                AndBlockFilterElement andBlock3 = new AndBlockFilterElement();
                andBlock3.ChildElements.Add(FilterElement.IsNullElement(CustomPageEntity.FieldProfileId));
                andBlock3.ChildElements.Add(FilterElement.EqualElement(CustomPageEntity.FieldUserId, userId.Value));

                OrBlockFilterElement orBlock = new OrBlockFilterElement();
                orBlock.ChildElements.Add(andBlock1);
                orBlock.ChildElements.Add(andBlock2);
                orBlock.ChildElements.Add(andBlock3);

                filters.Add(orBlock);
            }
            else if (profileId.HasValue)                // Profile layer
            {
                filters.Add(FilterElement.IsNullElement(CustomPageEntity.FieldUserId));

                OrBlockFilterElement orBlock = new OrBlockFilterElement();
                orBlock.ChildElements.Add(FilterElement.EqualElement(CustomPageEntity.FieldProfileId, profileId.Value));
                orBlock.ChildElements.Add(FilterElement.IsNullElement(CustomPageEntity.FieldProfileId));
                filters.Add(orBlock);
            }
            else             // Site layer
            {
                filters.Add(FilterElement.IsNullElement(CustomPageEntity.FieldProfileId));
                filters.Add(FilterElement.IsNullElement(CustomPageEntity.FieldUserId));
            }

            EntityObject[] pages = BusinessManager.List(CustomPageEntity.ClassName, filters.ToArray());

            CustomPageEntity retval = null;

            if (pages.Length > 0)
            {
                retval = (CustomPageEntity)pages[0];
            }

            return(retval);
        }
 private static FilterElement[] ConstructFilterByEntity(EntityObject entity)
 {
     AndBlockFilterElement retVal = new AndBlockFilterElement();
     foreach (string propName in CalendarEventResourceEntity.ComparedProperties)
     {
         EntityObjectProperty property = entity.Properties[propName];
         if (property != null && property.Value != null)
         {
             retVal.ChildElements.Add(new FilterElement(propName, FilterElementType.Equal, property.Value));
         }
     }
     return new FilterElement[] { retVal };
 }