コード例 #1
0
        /// <summary>
        /// Shows the hidden customization item.
        /// </summary>
        /// <param name="fullId">The full id.</param>
        /// <param name="structureType">Type of the structure.</param>
        /// <param name="profileId">The profile id.</param>
        /// <param name="principalId">The principal id.</param>
        public static void ShowCustomizationItem(string fullId, CustomizationStructureType structureType, PrimaryKeyId?profileId, PrimaryKeyId?principalId)
        {
            CustomizationItemEntity item = GetCustomizationItem(fullId, structureType, ItemCommandType.Remove, profileId, principalId);

            if (item != null)
            {
                BusinessManager.Delete(item);

                ClearCache(profileId, principalId);
            }
        }
コード例 #2
0
        /// <summary>
        /// Gets the customization item arguments.
        /// </summary>
        /// <param name="fullId">The full id.</param>
        /// <param name="structureType">Type of the structure.</param>
        /// <param name="commandType">Type of the command.</param>
        /// <param name="profileId">The profile id.</param>
        /// <param name="principalId">The principal id.</param>
        /// <returns></returns>
        public static Dictionary <string, CustomizationItemArgumentEntity> GetCustomizationItemArguments(string fullId, CustomizationStructureType structureType, ItemCommandType commandType, PrimaryKeyId?profileId, PrimaryKeyId?principalId)
        {
            CustomizationItemEntity item = GetCustomizationItem(fullId, structureType, commandType, profileId, principalId);

            if (item != null && item.PrimaryKeyId.HasValue)
            {
                return(GetCustomizationItemArguments(item.PrimaryKeyId.Value));
            }

            return(null);
        }
コード例 #3
0
        /// <summary>
        /// Hides the customization item.
        /// </summary>
        /// <param name="fullId">The full id.</param>
        /// <param name="structureType">Type of the structure.</param>
        /// <param name="profileId">The profile id.</param>
        /// <param name="principalId">The principal id.</param>
        public static void HideCustomizationItem(string fullId, CustomizationStructureType structureType, PrimaryKeyId?profileId, PrimaryKeyId?principalId)
        {
            CustomizationItemEntity item = GetCustomizationItem(fullId, structureType, ItemCommandType.Remove, profileId, principalId);

            if (item == null)
            {
                CreateCustomizationItem(fullId, structureType, ItemCommandType.Remove, profileId, principalId);

                ClearCache(profileId, principalId);
            }
        }
コード例 #4
0
        /// <summary>
        /// Undoes the modify navigation item.
        /// </summary>
        /// <param name="xmlFullId">The XML full id.</param>
        /// <param name="profileId">The profile id.</param>
        /// <param name="principalId">The principal id.</param>
        public static void UndoModifyNavigationItem(string xmlFullId, PrimaryKeyId?profileId, PrimaryKeyId?principalId)
        {
            CustomizationItemEntity item = GetCustomizationItem(xmlFullId, CustomizationStructureType.NavigationMenu, ItemCommandType.Update, profileId, principalId);

            if (item != null)
            {
                BusinessManager.Delete(item);

                ClearCache(profileId, principalId);
            }
        }
コード例 #5
0
        /// <summary>
        /// Creates the entity object.
        /// </summary>
        /// <param name="metaClassName">Name of the meta class.</param>
        /// <param name="primaryKeyId">The primary key id.</param>
        /// <returns></returns>
        protected override EntityObject CreateEntityObject(string metaClassName, PrimaryKeyId?primaryKeyId)
        {
            if (metaClassName == CustomizationItemEntity.ClassName)
            {
                CustomizationItemEntity retVal = new CustomizationItemEntity();
                retVal.PrimaryKeyId = primaryKeyId;
                return(retVal);
            }

            return(base.CreateEntityObject(metaClassName, primaryKeyId));
        }
コード例 #6
0
        /// <summary>
        /// Modifies the navigation item.
        /// </summary>
        /// <param name="fullId">The full id.</param>
        /// <param name="order">The order.</param>
        /// <param name="text">The text.</param>
        /// <param name="profileId">The profile id.</param>
        /// <param name="principalId">The principal id.</param>
        public static void ModifyNavigationItem(string fullId, int order, string text, PrimaryKeyId?profileId, PrimaryKeyId?principalId)
        {
            CustomizationItemEntity item = GetCustomizationItem(fullId, CustomizationStructureType.NavigationMenu, ItemCommandType.Update, profileId, principalId);

            if (item == null)             // add
            {
                using (TransactionScope transaction = DataContext.Current.BeginTransaction())
                {
                    // Create item
                    item = CreateCustomizationItem(fullId, CustomizationStructureType.NavigationMenu, ItemCommandType.Update, profileId, principalId);

                    // Create arguments
                    CreateCustomizationItemArgument(item.PrimaryKeyId.Value, ItemArgumentText, text);
                    CreateCustomizationItemArgument(item.PrimaryKeyId.Value, ItemArgumentOrder, order.ToString());

                    transaction.Commit();
                }
            }
            else             // update
            {
                PrimaryKeyId itemId = item.PrimaryKeyId.Value;
                Dictionary <string, CustomizationItemArgumentEntity> arguments = GetCustomizationItemArguments(itemId);

                using (TransactionScope transaction = DataContext.Current.BeginTransaction())
                {
                    // Text
                    if (arguments.ContainsKey(ItemArgumentText.ToLowerInvariant()))
                    {
                        UpdateCustomizationItemArgument(arguments[ItemArgumentText.ToLowerInvariant()], text);
                    }
                    else
                    {
                        CreateCustomizationItemArgument(itemId, ItemArgumentText, text);
                    }

                    // Order
                    if (arguments.ContainsKey(ItemArgumentOrder.ToLowerInvariant()))
                    {
                        UpdateCustomizationItemArgument(arguments[ItemArgumentOrder.ToLowerInvariant()], order.ToString());
                    }
                    else
                    {
                        CreateCustomizationItemArgument(itemId, ItemArgumentOrder, order.ToString());
                    }

                    transaction.Commit();
                }
            }

            ClearCache(profileId, principalId);
        }
コード例 #7
0
        /// <summary>
        /// Adds the navigation item.
        /// </summary>
        /// <param name="parentFullId">The parent full id.</param>
        /// <param name="order">The order.</param>
        /// <param name="text">The text.</param>
        /// <param name="url">The URL.</param>
        /// <param name="profileId">The profile id.</param>
        /// <param name="principalId">The principal id.</param>
        public static void AddNavigationItem(string parentFullId, int order, string text, string url, PrimaryKeyId?profileId, PrimaryKeyId?principalId)
        {
            using (TransactionScope transaction = DataContext.Current.BeginTransaction())
            {
                // Create item
                CustomizationItemEntity item = CreateCustomizationItemByParent(parentFullId, CustomizationStructureType.NavigationMenu, ItemCommandType.Add, profileId, principalId);

                CreateCustomizationItemArgument(item.PrimaryKeyId.Value, ItemArgumentText, text);
                CreateCustomizationItemArgument(item.PrimaryKeyId.Value, ItemArgumentOrder, order.ToString());
                CreateCustomizationItemArgument(item.PrimaryKeyId.Value, ItemArgumentCommand, Guid.NewGuid().ToString("D"));
                if (!string.IsNullOrEmpty(url))
                {
                    CreateCustomizationItemArgument(item.PrimaryKeyId.Value, ItemArgumentUrl, url);
                }

                transaction.Commit();
            }

            ClearCache(profileId, principalId);
        }
コード例 #8
0
        /// <summary>
        /// Gets the customization item.
        /// </summary>
        /// <param name="fullId">The full id.</param>
        /// <param name="profileId">The profile id.</param>
        /// <param name="principalId">The principal id.</param>
        /// <returns></returns>
        private static CustomizationItemEntity GetCustomizationItem(string fullId, CustomizationStructureType structureType, ItemCommandType commandType, PrimaryKeyId?profileId, PrimaryKeyId?principalId)
        {
            CustomizationItemEntity result = null;

            FilterElementCollection filters = new FilterElementCollection();

            filters.Add(FilterElement.EqualElement(CustomizationItemEntity.FieldXmlFullId, fullId));
            filters.Add(FilterElement.EqualElement(CustomizationItemEntity.FieldStructureType, (int)structureType));
            filters.Add(FilterElement.EqualElement(CustomizationItemEntity.FieldCommandType, (int)commandType));

            // Filter by profile
            if (profileId.HasValue)
            {
                filters.Add(FilterElement.EqualElement(CustomizationItemEntity.FieldProfileId, profileId.Value));
            }
            else
            {
                filters.Add(FilterElement.IsNullElement(CustomizationItemEntity.FieldProfileId));
            }

            // Filter by principal
            if (principalId.HasValue)
            {
                filters.Add(FilterElement.EqualElement(CustomizationItemEntity.FieldPrincipalId, principalId.Value));
            }
            else
            {
                filters.Add(FilterElement.IsNullElement(CustomizationItemEntity.FieldPrincipalId));
            }

            EntityObject[] items = BusinessManager.List(CustomizationItemEntity.ClassName, filters.ToArray());

            if (items != null && items.Length > 0)
            {
                result = items[0] as CustomizationItemEntity;
            }

            return(result);
        }
コード例 #9
0
        public static void AddNavigationItemForList(string parentFullId, int order, string text, string url, int listId)
        {
            using (TransactionScope transaction = DataContext.Current.BeginTransaction())
            {
                // Create item
                CustomizationItemEntity item   = CreateCustomizationItemByParent(parentFullId, CustomizationStructureType.NavigationMenu, ItemCommandType.Add, null, null);
                PrimaryKeyId            itemId = item.PrimaryKeyId.Value;

                CreateCustomizationItemArgument(itemId, ItemArgumentText, text);
                CreateCustomizationItemArgument(itemId, ItemArgumentOrder, order.ToString());
                CreateCustomizationItemArgument(itemId, ItemArgumentCommand, Guid.NewGuid().ToString("D"));
                CreateCustomizationItemArgument(itemId, ItemArgumentEnableHandler, "Mediachase.Ibn.Web.UI.ListApp.CommandHandlers.CanReadList, Mediachase.UI.Web");
                CreateCustomizationItemArgument(itemId, ItemArgumentParams, listId.ToString());
                if (!string.IsNullOrEmpty(url))
                {
                    CreateCustomizationItemArgument(itemId, ItemArgumentUrl, url);
                }

                transaction.Commit();
            }

            ClearCache(null, null);
        }
コード例 #10
0
        /// <summary>
        /// Creates the navigation item.
        /// </summary>
        /// <param name="structureType">Type of the structure.</param>
        /// <param name="fullId">The full id.</param>
        /// <param name="commandType">Type of the command.</param>
        /// <param name="profileId">The profile id.</param>
        /// <param name="principalId">The principal id.</param>
        /// <returns></returns>
        private static CustomizationItemEntity CreateCustomizationItem(string fullId, CustomizationStructureType structureType, ItemCommandType commandType, PrimaryKeyId?profileId, PrimaryKeyId?principalId)
        {
            CustomizationItemEntity item = BusinessManager.InitializeEntity <CustomizationItemEntity>(CustomizationItemEntity.ClassName);

            if (structureType != CustomizationStructureType.Undefined)
            {
                item.StructureType = (int)structureType;
            }
            item.XmlFullId = fullId;
            if (profileId.HasValue)
            {
                item.Properties["ProfileId"].Value = profileId;
            }
            if (principalId.HasValue)
            {
                item.Properties["PrincipalId"].Value = principalId;
            }

            item.CommandType = (int)commandType;

            item.PrimaryKeyId = BusinessManager.Create(item);

            return(item);
        }