Exemplo n.º 1
0
        public static MenuItemData ToXmlEntity(this MenuItemModel model)
        {
            if (model == null)
            {
                return(null);
            }

            string parentMenuId = null;

            if (model.ParentMenuId.HasValue)
            {
                parentMenuId = model.ParentMenuId.Value.ToString();
            }

            return(new MenuItemData
            {
                MenuId = model.MenuId.Value.ToString(),
                Name = model.DisplayName,
                Description = model.Description,
                LinkPath = model.LinkPath,
                MenuType = model.Type,
                AuthKey = model.AuthKey,
                ParentMenuId = parentMenuId,
                ApplicationName = model.ApplicationName,
                IsDisplay = model.IsDisplay,
                Status = model.Status,

                LocalizedResList = model.LocalizedResCollection
            });
        }
Exemplo n.º 2
0
        private static ObservableCollection <MenuItemModel> Clone(ObservableCollection <MenuItemModel> list, MenuItemModel parentItem)
        {
            ObservableCollection <MenuItemModel> result = null;

            if (list != null)
            {
                result = new ObservableCollection <MenuItemModel>();

                foreach (MenuItemModel item in list)
                {
                    MenuItemModel model = item.Clone() as MenuItemModel;

                    model.Parent = parentItem;

                    if (item.Children != null)
                    {
                        model.Children = Clone(item.Children, item);
                    }

                    result.Add(model);
                }
            }

            return(result);
        }
Exemplo n.º 3
0
 public void SetFields(MenuItemModel model)
 {
     if (model != null)
     {
         this.MenuId                 = model.MenuId;
         this.DisplayName            = model.DisplayName;
         this.Description            = model.Description;
         this.IconStyle              = model.IconStyle;
         this.LinkPath               = model.LinkPath;
         this.AuthKey                = model.AuthKey;
         this.Type                   = model.Type;
         this.SortIndex              = model.SortIndex;
         this.ParentMenuId           = model.ParentMenuId;
         this.Status                 = model.Status;
         this.IsDisplay              = model.IsDisplay;
         this.LanguageCode           = model.LanguageCode;
         this.ApplicationId          = model.ApplicationId;
         this.ApplicationName        = model.ApplicationName;
         this.InDate                 = model.InDate;
         this.InUser                 = model.InUser;
         this.EditDate               = model.EditDate;
         this.EditUser               = model.EditUser;
         this.LocalizedResCollection = model.LocalizedResCollection;
     }
 }
Exemplo n.º 4
0
        public object Clone()
        {
            MenuItemModel model = new MenuItemModel()
            {
                MenuId                 = this.MenuId,
                DisplayName            = this.DisplayName,
                Description            = this.Description,
                IconStyle              = this.IconStyle,
                LinkPath               = this.LinkPath,
                AuthKey                = this.AuthKey,
                Type                   = this.Type,
                SortIndex              = this.SortIndex,
                ParentMenuId           = this.ParentMenuId,
                Status                 = this.Status,
                IsDisplay              = this.IsDisplay,
                LanguageCode           = this.LanguageCode,
                ApplicationId          = this.ApplicationId,
                m_applicationName      = this.ApplicationName,
                InDate                 = this.InDate,
                InUser                 = this.InUser,
                EditDate               = this.EditDate,
                EditUser               = this.EditUser,
                Parent                 = this.Parent,
                Children               = this.Children,
                LocalizedResCollection = this.LocalizedResCollection
            };

            return(model);
        }
Exemplo n.º 5
0
        public MenuItemModel NewCategory(MenuItemModel parentItem)
        {
            this.m_menuId       = null;
            this.m_type         = "C";
            this.m_isDisplay    = true;
            this.m_status       = "A";
            this.m_sortIndex    = 0;
            this.m_languageCode = "en-US";

            this.m_parentMenuId = null;

            if (parentItem != null)
            {
                this.m_parentMenuId = parentItem.MenuId;
            }
            this.m_applicationId   = (parentItem == null) ? null : parentItem.ApplicationId;
            this.m_applicationName = (parentItem == null) ? null : parentItem.ApplicationName;

            this.Parent = parentItem;

            return(this);
        }
Exemplo n.º 6
0
 public MenuItemModel(MenuItemModel model)
 {
     this.SetFields(model);
 }
Exemplo n.º 7
0
        private static ObservableCollection <MenuItemModel> GenerateMenuTree(ObservableCollection <MenuItemModel> dataItems, MenuItemModel parentItem)
        {
            ObservableCollection <MenuItemModel> matchedItems = new ObservableCollection <MenuItemModel>();

            if (dataItems != null)
            {
                // 1、Find matched items
                foreach (MenuItemModel item in dataItems)
                {
                    if ((parentItem == null && item.ParentMenuId == null) || (parentItem != null && item.ParentMenuId == parentItem.MenuId))
                    {
                        matchedItems.Add(item);
                    }
                }
                // 2、Remove matched items from original collection
                foreach (MenuItemModel item in matchedItems)
                {
                    dataItems.Remove(item);
                }
                // 3、Find children for matched items
                foreach (MenuItemModel item in matchedItems)
                {
                    item.Parent   = parentItem;
                    item.Children = GenerateMenuTree(dataItems, item);
                }
            }

            return(matchedItems);
        }