public override IEnumerable<DynamicNode> GetDynamicNodeCollection(ISiteMapNode node)
        {
            var categories = _unitOfWork.CategoryRepository.Get().ToList();// categoryBuilder.Build();

            foreach (var category in categories.Where(i=>i.ParentCategory==null))
            {
                var dynamicNode = new DynamicNode();
                dynamicNode.Title = category.Name;
                dynamicNode.Key = category.Id.ToString();
                dynamicNode.RouteValues.Add("id",category.Id);

                var category1 = category;
                foreach (var childCategory in categories.Where(c=>c.ParentCategory==category1))
                {
                    var childDynamicNode = new DynamicNode();
                    childDynamicNode.Title = childCategory.Name;
                    childDynamicNode.ParentKey = category.Id.ToString();
                    childDynamicNode.Key = childCategory.Id.ToString();
                    childDynamicNode.RouteValues.Add("id",childCategory.Id);
/*                    foreach (var productItem in productItems.Where(i=>i.CategoryId==childCategory.Id))
                    {
                        var productDynamicNode = new DynamicNode();
                        productDynamicNode.Title = productItem.Name;
                        productDynamicNode.ParentKey = childCategory.Id;
                        productDynamicNode.Key = productItem.Id;
                        productDynamicNode.RouteValues.Add("id", productItem.Id);

                        yield return productDynamicNode;
                    }*/
                    yield return childDynamicNode;
                }

                yield return dynamicNode;
            }
        }
 public override IEnumerable<DynamicNode> GetDynamicNodeCollection(ISiteMapNode nodes)
 {
     var returnValue = new List<DynamicNode>();
     
     // 向BLL層取得選單
     foreach (var item in PermissionService.GetMenu())
     {
         DynamicNode node = new DynamicNode();
         // 選單名稱
         node.Title = item.Name; 
         // 有無父類別,沒有的話則傳空字串
         node.ParentKey = item.ParentID == 0 ? "" : item.ParentID.ToString();
         // 唯一值
         node.Key = item.MenuID.ToString();
         // MVC的View
         node.Action = item.Action;
         // MVC的Controller
         node.Controller = item.Controller;
         // 選單所分配的腳色,逗號分隔
         node.Roles = item.Roles.Split(',').Where(c => !string.IsNullOrEmpty(c)).ToList();
         // 
         node.RouteValues.Add("id", item.MenuID);
         returnValue.Add(node);
     }
     // Return
     return returnValue;
 }
 // Determine canonical (primary) category for the product
 // for the canonical tag. We set the Key of the "master"
 // source of the content and the CanonicalKey for all of the copies.
 private void SetCanonicalKey(DynamicNode dnode, bool isCanonical)
 {
     string canonicalKey = "Canonical|" + dnode.Title;
     if (isCanonical)
         dnode.Key = canonicalKey;
     else
         dnode.CanonicalKey = canonicalKey;
 }
        /// <summary>
        /// Gets the dynamic node collection.
        /// </summary>
        /// <param name="node">The current node.</param>
        /// <returns>
        /// A dynamic node collection represented as a <see cref="IEnumerable&lt;MvcSiteMapProvider.Extensibility.DynamicNode&gt;"/> instance 
        /// </returns>
        public override IEnumerable<DynamicNode> GetDynamicNodeCollection(ISiteMapNode node)
        {
            // Create a node for each genre
            foreach (var genre in storeDB.Genres)
            {
                DynamicNode dynamicNode = new DynamicNode("Genre_" + genre.Name, genre.Name);
                dynamicNode.RouteValues.Add("genre", genre.Name);

                yield return dynamicNode; 
            }
        }
        public override IEnumerable<DynamicNode> GetDynamicNodeCollection(ISiteMapNode node)
        {
            var Departments = DepartmentGetter.GetDepartments();

            foreach (Department dep in Departments)
            {
                DynamicNode dynamicNode = new DynamicNode { Title = dep.Name };
                dynamicNode.RouteValues.Add("acronym", dep.Acronym);
                yield return dynamicNode;
            }
        }
        public override IEnumerable<DynamicNode> GetDynamicNodeCollection(ISiteMapNode node)
        {
            //string parent = "";
            //if (node.Attributes.ContainsKey("parentNode"))
            //{
            //    parent = node.Attributes["parentNode"].ToString();
            //}
            //List<ProductModel> products = DataServices.GetActiveProductBySubType(parent, node.Key);

            //var returnValue = new List<DynamicNode>();
            //foreach (ProductModel p in products)
            //{
            //    DynamicNode dnode = new DynamicNode();
            //    dnode.Title = p.ProductName;
            //    dnode.Action = "Details";
            //    dnode.Controller = "Products";
            //    dnode.RouteValues.Add("id", p.ProductId);

            //    returnValue.Add(dnode);
            //}
            //return returnValue;

            // For demonstration purposes, we are considering the canonical URL to be
            // the one under the BridalRings category.
            bool isCanonical = node.Attributes.ContainsKey("category") && "BridalRings".Equals(node.Attributes["category"]);

            DynamicNode dnode1 = new DynamicNode();
            dnode1.Title = "Product 1";
            dnode1.Action = "Details";
            dnode1.Controller = "Products";
            dnode1.RouteValues.Add("id", 1);
            SetCanonicalKey(dnode1, isCanonical);

            yield return dnode1;

            DynamicNode dnode2 = new DynamicNode();
            dnode2.Title = "Product 2";
            dnode2.Action = "Details";
            dnode2.Controller = "Products";
            dnode2.RouteValues.Add("id", 2);
            SetCanonicalKey(dnode2, isCanonical);

            yield return dnode2;

            DynamicNode dnode3 = new DynamicNode();
            dnode3.Title = "Product 3";
            dnode3.Action = "Details";
            dnode3.Controller = "Products";
            dnode3.RouteValues.Add("id", 3);
            SetCanonicalKey(dnode3, isCanonical);

            yield return dnode3;
        }
 public override IEnumerable<DynamicNode> GetDynamicNodeCollection(ISiteMapNode node_)
 {
     using (var db = new Models.ApplicationDbContext())
     {
         var nodes = new List<DynamicNode>();
         var items = db.tForumLists.ToList();
         foreach (var item in items)
         {
             var node = new DynamicNode {Key = "ForumList_" + item.Id.ToString()};
             // ключ должен быть уникальным для каждой ноды
             node.RouteValues.Add("id", item.Id);
             node.Action = "Index";
             node.Controller = "ForumThemes";
             node.Title = item.tForumList_name;
             nodes.Add(node);
             if (item.tForumThemes == null) continue;
             var c = new DynamicNode
             {
                 Key = "CreateForumThemes_" + item.Id.ToString(),
                 ParentKey = node.Key,
                 Action = "Create",
                 Controller = "ForumThemes",
                 Title = "Создать новую тему"
             };
             c.RouteValues.Add("id", item.Id);
             nodes.Add(c);
             foreach (var item2 in item.tForumThemes)
             {
                 var node2 = new DynamicNode
                 {
                     Key = "ForumMessages_" + item2.Id.ToString(),
                     ParentKey = node.Key
                 };
                 node2.RouteValues.Add("id", item2.Id);
                 node2.RouteValues.Add("id_list", item2.tForumList.Id);
                 node2.Action = "Index";
                 node2.Controller = "ForumMessages";
                 if (item2.tForumThemes_name.Length > 30)
                 {
                     node2.Title = item2.tForumThemes_name.Substring(0,30)+"...";
                 }
                 else
                 {
                     node2.Title = item2.tForumThemes_name;
                 }
                 nodes.Add(node2);
             }
         }
         db.Dispose();
         return nodes;
     }
 }
        public override IEnumerable<DynamicNode> GetDynamicNodeCollection(ISiteMapNode node)
        {
            var response = _storeService.GetAllGenres();

            foreach (var genre in response.Genres)
            {
                var dynamicNode = new DynamicNode("Genre_" + genre.Name, genre.Name);

                dynamicNode.RouteValues.Add("genre", genre.Name);

                yield return dynamicNode;
            }
        }
 public override IEnumerable<DynamicNode> GetDynamicNodeCollection(ISiteMapNode node)
 {
     var reurnValue = new List<DynamicNode>();
     foreach (var a in db.Albums)
     {
         DynamicNode n = new DynamicNode();
         n.Title = a.AlbumTitle;
         n.Key = "Album_" + a.AlbumID;
         n.ParentKey = "Genre_" + a.GenreID;
         n.RouteValues.Add("id", a.AlbumID);
         reurnValue.Add(n);
     }
     return reurnValue;
 }
        public override IEnumerable<DynamicNode> GetDynamicNodeCollection(ISiteMapNode node)
        {
            var ul = Data.UsersList();
                foreach (var u in ul)
                {
                    DynamicNode dynamicNode = new DynamicNode();
                    dynamicNode.Title = u.Name;
                    dynamicNode.ParentKey = "User";

                    dynamicNode.PreservedRouteParameters.Add("id");

                    yield return dynamicNode;
                }
        }
        public override IEnumerable<DynamicNode> GetDynamicNodeCollection(ISiteMapNode node)
        {
            var rl = Data.RewardsList();
                foreach (var r in rl)
                {
                    DynamicNode dynamicNode = new DynamicNode();
                    dynamicNode.Title = r.Title;
                    dynamicNode.ParentKey = "Reward";

                    dynamicNode.PreservedRouteParameters.Add("id");

                    yield return dynamicNode;
                }
        }
        public override IEnumerable<DynamicNode> GetDynamicNodeCollection(ISiteMapNode node)
        {
            var productItems = _unitOfWork.ProductRepository.Get().ToList();// productBuilder.Build();
            foreach (var productItem in productItems)
            {
                var dynamicNode = new DynamicNode();
                dynamicNode.Title = productItem.Name;
                dynamicNode.Key = productItem.Id.ToString();
                dynamicNode.ParentKey = productItem.CategoryId.ToString();
                dynamicNode.RouteValues.Add("id",productItem.Id);

                yield return dynamicNode;
            }
        }
        public IEnumerable<DynamicNode> GetDynamicNodeCollection()
        {
            List<DynamicNode> returnList = new List<DynamicNode>();

            foreach (Photo item in context.Photos)
            {
                DynamicNode newNode = new DynamicNode();
                newNode.Title = item.Title;
                newNode.ParentKey = "AllPhotos";
                newNode.RouteValues.Add("id", item.PhotoID);
                returnList.Add(newNode);
            }

            return returnList;
        }
        public override IEnumerable<DynamicNode> GetDynamicNodeCollection(ISiteMapNode node)
        {
            var result = new List<DynamicNode>();

            using (var db = new CRUDExample())
            {

                var products = db.Product;
                foreach (var product in products)
                {
                    var productKey = "Product_" + product.Id.ToString();

                    // Create the "Details" node for the product
                    var productNode = new DynamicNode(productKey, "Products", product.Name, product.Name, "Product", "Details");

                    // Set the "id" route value so the match will work.
                    productNode.RouteValues.Add("id", product.Id);

                    // Set our visibility. This will override what we have configured on the DynamicProducts node. We need to
                    // do this to ensure our products are visible in the /sitemap.xml path.
                    productNode.Attributes["visibility"] = "SiteMapPathHelper,XmlSiteMapResult,!*";

                    // Add the node to the result
                    result.Add(productNode);

                    // Create the "Edit" node for the product
                    var productEditNode = new DynamicNode("ProductEdit_" + product.Id.ToString(), productKey, "Edit", "Edit", "Product", "Edit");

                    // Set the "id" route value of the edit node
                    productEditNode.RouteValues.Add("id", product.Id);

                    // Add the node to the result
                    result.Add(productEditNode);

                    // Create the "Delete" node for the product
                    var productDeleteNode = new DynamicNode("ProductDelete_" + product.Id.ToString(), productKey, "Delete", "Delete", "Product", "Delete");

                    // Set the "id" route value of the delete node
                    productDeleteNode.RouteValues.Add("id", product.Id);

                    // Add the node to the result
                    result.Add(productDeleteNode);
                }
            }

            return result;
        }
        public override IEnumerable<DynamicNode> GetDynamicNodeCollection(ISiteMapNode node)
        {
            var response = _albumService.GetAllAlbums();

            foreach (var album in response.Albums)
            {
                var dynamicNode = new DynamicNode
                {
                    Title = album.Title,
                    ParentKey = "Genre_" + album.Genre.Name
                };

                dynamicNode.RouteValues.Add("id", album.Id);

                yield return dynamicNode;
            }
        }
        public override IEnumerable<DynamicNode> GetDynamicNodeCollection(ISiteMapNode node)
        {
            var returnValue = new List<DynamicNode>();

            try
            {
                //using (var uow = new MyDBContext())
                using (var menuService = new SmMenuService<SysMenu>())
                {
                    // 取出所有Menu項
                    var menus = menuService.GetAll().ToList();


                    foreach (var menu in menus)
                    {
                        
                        DynamicNode dynamicNode = new DynamicNode()
                        {
                            Title = menu.Name,
                            ParentKey = menu.ParentId.HasValue ? menu.ParentId.Value.ToString() : "",
                            Key = menu.SysMenuId.ToString(),
                            Action = menu.Action,
                            Controller = menu.Controller,
                            Area = menu.Area,
                            Url = menu.Url,
                            //Roles = roles
                        };

                        if (!string.IsNullOrWhiteSpace(menu.RouteValues))
                        {
                            dynamicNode.RouteValues = menu.RouteValues.Split(',').Select(value => value.Split('='))
                                                .ToDictionary(pair => pair[0], pair => (object)pair[1]);

                        }
                        returnValue.Add(dynamicNode);
                    }
                }

                return returnValue;
            }
            catch (Exception ex)
            {
                return null;
            }
        }
        /// <summary>
        /// Gets the dynamic node collection.
        /// </summary>
        /// <param name="node">The current node.</param>
        /// <returns>
        /// A dynamic node collection represented.
        /// </returns>
        public override IEnumerable<DynamicNode> GetDynamicNodeCollection(ISiteMapNode node)
        {
            // Create a node for each album
            foreach (var album in storeDB.Albums.Include("Genre"))
            {
                DynamicNode dynamicNode = new DynamicNode();
                dynamicNode.Title = album.Title;
                dynamicNode.ParentKey = "Genre_" + album.Genre.Name;
                dynamicNode.RouteValues.Add("id", album.AlbumId);

                if (album.Title.Contains("Hit") || album.Title.Contains("Best"))
                {
                    dynamicNode.Attributes.Add("bling", "<span style=\"color: Red;\">hot!</span>");
                }

                yield return dynamicNode; 
            }
        }
        public override IEnumerable<DynamicNode> GetDynamicNodeCollection(ISiteMapNode node)
        {
            using (var ef = new ECoupounEntities())
            {
                // Create a node for each sites 
                foreach (var obj in ef.Categories)
                {
                    DynamicNode dynamicNode;

                    dynamicNode = new DynamicNode();
                    dynamicNode.Title = obj.MappingName;
                    dynamicNode.ParentKey = "CulturePages";
                    dynamicNode.RouteValues.Add("parentCategory", obj.MappingName);
                    dynamicNode.RouteValues.Add("categoryName", obj.MappingName);
                    yield return dynamicNode;
                }
            }
        }
Exemple #19
0
        public override IEnumerable<DynamicNode> GetDynamicNodeCollection(ISiteMapNode nodes)
        {
            var returnValue = new List<DynamicNode>();

            using (EPSContext context =new EPSContext())
            {
                var LoginUserID = HttpContext.Current.Session["UserID"].ToString();
                int UserRole = Convert.ToInt32(HttpContext.Current.Session["UserRole"].ToString());
                var query = from rm in context.ROLEFUNCMAPPINGS
                            where rm.RId == UserRole
                            join f in context.FUNCS on rm.FId equals f.FId into memu
                            from x in memu.DefaultIfEmpty()
                            select new
                            {
                                PId = x.PId,
                                FId = x.FId,
                                FuncName=x.FuncName,
                                Controller=x.Controller,
                                Action=x.Action,
                                Url= x.Url,
                                ShowOrder=x.ShowOrder
                            };
                var SysMenus = query.OrderBy(c=>c.ShowOrder).ToList();

                foreach (var menu in SysMenus)
                {
                    DynamicNode Node = new DynamicNode()
                    {
                        Title = menu.FuncName,
                        ParentKey= menu.PId > 0 ? menu.PId.ToString():"",
                        Key=menu.FId.ToString(),
                        Controller=menu.Controller,
                        Action=menu.Action,
                        Url=menu.Url
                    };

                    returnValue.Add(Node);
                }
            }

            return returnValue;
        }
        public override IEnumerable<DynamicNode> GetDynamicNodeCollection(ISiteMapNode node)
        {
            // Build value
            var returnValue = new List<DynamicNode>();

            // Create a node for each Category
            foreach (var item in _albumService.GetAll())
            {
                DynamicNode dynamicNode = new DynamicNode();
                dynamicNode.Title = item.Title;
                dynamicNode.RouteValues.Add("id", item.ID);
                dynamicNode.RouteValues.Add("slug", item.Slug);
                dynamicNode.PreservedRouteParameters = new List<string> { item.Slug };
                dynamicNode.Description = item.Description;
                dynamicNode.ParentKey = "Album";
                returnValue.Add(dynamicNode);
            }

            // Return
            return returnValue;
        }
        public IEnumerable<DynamicNode> GetDynamicNodeCollection(ISiteMapNode node)
        {
            var usuarioLogado = ((AppPrincipal)HttpContext.Current.User);
            var permissoes =
                _contexto.Usuarios.Include(u => u.Perfil)
                    .Include(u => u.Perfil.Permissoes)
                    .First(u => u.Id == usuarioLogado.Id).Perfil.Permissoes;

            var nodeList = new List<DynamicNode>();
            foreach (var permissao in permissoes)
            {
                var dNode = new DynamicNode
                {
                    Key = permissao.Id.ToString(CultureInfo.InvariantCulture),
                    ParentKey = permissao.ParenteId.ToString(CultureInfo.InvariantCulture),
                    Title = permissao.Nome,
                    Description = permissao.Descricao,
                    Url = permissao.Url,
                    Action = permissao.Action,
                    Controller = permissao.Controller,
                    Order = permissao.Ordem
                };

                //Quando for CRUD
                if (permissao.VisivelNoMenu == false)
                {
                    var cList = new List<string>();
                    cList.Add("id");
                    dNode.PreservedRouteParameters = cList;
                }

                dNode.Attributes.Add("icone", permissao.Icone);
                dNode.Attributes.Add("visibility", permissao.VisivelNoMenu ? "" : "!MenuHelper");

                nodeList.Add(dNode);
            }

            return nodeList;
        }
 public override IEnumerable<DynamicNode> GetDynamicNodeCollection(ISiteMapNode node)
 {
     using (var db = new ApplicationDbContext())
     {
         foreach (var post in db.BlogPosts.Include("Category").ToList())
         {
             DynamicNode dynamicNode = new DynamicNode();
             dynamicNode.Title = post.Title;
             //dynamicNode.ParentKey = "Category_" + post.Category.Name;
             dynamicNode.Action = "Details";
             dynamicNode.Controller = "BlogPosts";
             dynamicNode.RouteValues.Add("id", post.CategoryId);
             dynamicNode.RouteValues.Add("postId", post.GenerateSlug());
             //dynamicNode.RouteValues.Add("CategoryName", post.Category.Name.Replace(" ", "-"));
             //dynamicNode.RouteValues.Add("Title", post.Title.Replace(" ","-"));
             dynamicNode.LastModifiedDate = post.LastModifiedDate;
             dynamicNode.Description = post.Title;
             dynamicNode.ChangeFrequency = ChangeFrequency.Weekly;
             dynamicNode.UpdatePriority = UpdatePriority.Normal;
             yield return dynamicNode;
         }
     }
 }
        public IEnumerable<DynamicNode> GetDynamicNodeCollection(ISiteMapNode node)
        {
            var usuarioLogado = ((AppPrincipal)HttpContext.Current.User);
            var permissoes = _context.Usuarios.Include(u => u.Perfil)
                .Include(u => u.Perfil.Permissoes)
                .First(u => u.Id == usuarioLogado.Id).Perfil.Permissoes;

            var nodeList = new List<DynamicNode>();
            foreach (var permissao in permissoes)
            {
                var dNode = new DynamicNode
                {
                    Key = permissao.Id.ToString(),
                    ParentKey = permissao.ParenteId.ToString(),
                    Title = permissao.Nome,
                    Description = permissao.Descricao,
                    Url = permissao.Url,
                    Action = permissao.Acao,
                    Controller = permissao.Controle,
                    Order = permissao.Ordem
                };

                //Quando for CRUD
                if (permissao.EhCRUD)
                {
                    var cList = permissao.Atributos.Split(';');
                    dNode.PreservedRouteParameters = cList;
                }

                dNode.Attributes.Add("icon", permissao.ClasseIcone);
                dNode.Attributes.Add("visibility", permissao.MostrarNoMenu ? string.Empty : "!MenuHelper");

                nodeList.Add(dNode);
            }

            return nodeList;
        }
        public override IEnumerable<DynamicNode> GetDynamicNodeCollection(ISiteMapNode node)
        {
            var catalog = CatalogHelper.CatalogClient.GetCatalog(StoreHelper.CustomerSession.CatalogId);
            var nodes = new List<DynamicNode>();
            int order = 0;
            var categories = catalog.CategoryBases.OfType<Category>().Where(x => x.IsActive).ToList();
            foreach (var category in categories.OrderByDescending(x => x.Priority).ThenBy(x => x.Name))
            {

                var pNode = new DynamicNode
                {
                    Action = "Display",
                    Title = category.DisplayName(),
                    Key = category.CategoryId,
                    Order = order++,
                    ParentKey = category.ParentCategoryId,
                    RouteValues = new Dictionary<string, object> { { Constants.Category, category.CategoryId } },
                    PreservedRouteParameters = new[] { Constants.Language, Constants.Store },
                     
                };

                //Add category translations for each language in store
                var store = StoreHelper.StoreClient.GetCurrentStore();
                foreach (var lang in store.Languages)
                {
                    var culture = CultureInfo.CreateSpecificCulture(lang.LanguageCode);
                    pNode.Attributes.Add(string.Format(TitleAttributeFormat, culture.Name),
                        category.DisplayName(culture.Name));
                }

                nodes.Add(pNode);

                #region This is needed only for demo purposes
                if (category.Code.Equals("audio-mp3", StringComparison.OrdinalIgnoreCase))
                {
                    pNode.Attributes.Add("Template", "MegaMenu");
                    nodes.Add(new DynamicNode
                    {
                        Action = "Display",
                        Title = "Audio & MP3".Localize(),
                        Key = category.CategoryId + "AUDIO",
                        ParentKey = category.CategoryId,
                        ImageUrl = "~/Content/themes/default/images/menu/mobiles.png",
                        RouteValues = new Dictionary<string, object> { { Constants.Category, category.CategoryId } },
                    });

                    nodes.Add(new DynamicNode
                    {
                        Action = "Display",
                        Title = "Samsung".Localize(),
                        ParentKey = category.CategoryId + "AUDIO",
                        RouteValues = new Dictionary<string, object> { { Constants.Category, category.CategoryId }, { "f_Brand", "samsung" } },
                    });
                    nodes.Add(new DynamicNode
                    {
                        Action = "Display",
                        Title = "Sony".Localize(),
                        ParentKey = category.CategoryId + "AUDIO",
                        RouteValues = new Dictionary<string, object> { { Constants.Category, category.CategoryId }, { "f_Brand", "sony" } },
                    });
                    nodes.Add(new DynamicNode
                    {
                        Action = "Display",
                        Title = "Apple".Localize(),
                        ParentKey = category.CategoryId + "AUDIO",
                        RouteValues = new Dictionary<string, object> { { Constants.Category, category.CategoryId }, { "f_Brand", "apple" } },
                    });

                    var computersCat = categories.FirstOrDefault(
                        c => c.Code.Equals("computers-tablets", StringComparison.OrdinalIgnoreCase));

                    if (computersCat != null)
                    {

                        nodes.Add(new DynamicNode
                        {
                            Action = "Display",
                            Title = "Computers & Tablets".Localize(),
                            Key = category.CategoryId + "COMPUTERS",
                            ParentKey = category.CategoryId,
                            ImageUrl = "~/Content/themes/default/images/menu/computers.png",
                            RouteValues = new Dictionary<string, object> { { Constants.Category, computersCat.CategoryId} },
                        });

                        nodes.Add(new DynamicNode
                        {
                            Action = "Display",
                            Title = "Samsung".Localize(),
                            ParentKey = category.CategoryId + "COMPUTERS",
                            RouteValues =
                                new Dictionary<string, object>
                                {
                                    {Constants.Category, computersCat.CategoryId},
                                    {"f_Brand", "samsung"}
                                },
                        });

                        nodes.Add(new DynamicNode
                        {
                            Action = "Display",
                            Title = "Sony".Localize(),
                            ParentKey = category.CategoryId + "COMPUTERS",
                            RouteValues =
                                new Dictionary<string, object>
                                {
                                    {Constants.Category, computersCat.CategoryId},
                                    {"f_Brand", "sony"}
                                },
                        });

                        nodes.Add(new DynamicNode
                        {
                            Action = "Display",
                            Title = "Apple".Localize(),
                            ParentKey = category.CategoryId + "COMPUTERS",
                            RouteValues =
                                new Dictionary<string, object>
                                {
                                    {Constants.Category, computersCat.CategoryId},
                                    {"f_Brand", "apple"}
                                },
                        });
                    }

                    var camCat = categories.FirstOrDefault(
                        c => c.Code.Equals("cameras", StringComparison.OrdinalIgnoreCase));

                    if (camCat != null)
                    {

                        nodes.Add(new DynamicNode
                        {
                            Action = "Display",
                            Title = "Cameras".Localize(),
                            Key = category.CategoryId + "CAMERAS",
                            ParentKey = category.CategoryId,
                            ImageUrl = "~/Content/themes/default/images/menu/Cameras.png",
                            RouteValues = new Dictionary<string, object> { { Constants.Category, camCat.CategoryId} },
                        });

                        nodes.Add(new DynamicNode
                        {
                            Action = "Display",
                            Title = "Samsung".Localize(),
                            ParentKey = category.CategoryId + "CAMERAS",
                            RouteValues =
                                new Dictionary<string, object> { { Constants.Category, camCat.CategoryId }, { "f_Brand", "samsung" } },
                        });
                        nodes.Add(new DynamicNode
                        {
                            Action = "Display",
                            Title = "Sony".Localize(),
                            ParentKey = category.CategoryId + "CAMERAS",
                            RouteValues =
                                new Dictionary<string, object> { { Constants.Category, camCat.CategoryId }, { "f_Brand", "sony" } },
                        });
                    }

                     var tvCat = categories.FirstOrDefault(
                        c => c.Code.Equals("tv-video", StringComparison.OrdinalIgnoreCase));

                    if (tvCat != null)
                    {

                        nodes.Add(new DynamicNode
                        {
                            Action = "Display",
                            Title = "TV & Video".Localize(),
                            Key = category.CategoryId + "TVVIDEO",
                            ParentKey = category.CategoryId,
                            ImageUrl = "~/Content/themes/default/images/menu/accessories.png",
                            RouteValues = new Dictionary<string, object> { { Constants.Category, tvCat.CategoryId} },
                        });

                        nodes.Add(new DynamicNode
                        {
                            Action = "Display",
                            Title = "Samsung".Localize(),
                            ParentKey = category.CategoryId + "TVVIDEO",
                            RouteValues =
                                new Dictionary<string, object>
                                {
                                    {Constants.Category, tvCat.CategoryId},
                                    {"f_Brand", "samsung"}
                                },
                        });
                        nodes.Add(new DynamicNode
                        {
                            Action = "Display",
                            Title = "Sony".Localize(),
                            ParentKey = category.CategoryId + "TVVIDEO",
                            RouteValues =
                                new Dictionary<string, object> { { Constants.Category, tvCat.CategoryId }, { "f_Brand", "sony" } },
                        });
                    }
                }
                #endregion
            }

            return nodes;

        }
        public override IEnumerable<DynamicNode> GetDynamicNodeCollection(ISiteMapNode nodes)
        {
            var is_tablet = (new WebInfo()).isTablet();

            //var returnValue = new List<DynamicNode>();

            LogicCenter log = new LogicCenter(CommWebSetup.DB0_CodeString);
            C44A0_ChangYuEntities db = LogicCenter.getDB0;

            try
            {
                LogicCenter.SetDB0EntityString(CommSetup.CommWebSetup.DB0_CodeString);
                IList<DynamicNode> colle_node = new List<DynamicNode>();
                //if (!is_tablet)
                //{
                    #region PC Menu
                    var items = db.Menu.Where(x => x.is_use == true && x.is_only_tablet == false).ToList();
                    var folder_items = items.Where(x => x.is_folder == true).OrderBy(x => x.sort);

                    foreach (var item in folder_items)
                    {
                        DynamicNode folder_node = new DynamicNode();

                        folder_node.Title = item.menu_name;
                        folder_node.Key = item.menu_id.ToString();
                        //dynamicNode.RouteValues.Add("genreId", item.menu_id); //製作連結參數
                        folder_node.Area = item.area;
                        folder_node.Attributes.Add("IconClass", item.icon_class);
                        folder_node.Clickable = false;

                        folder_node.Roles.Add("Admins");

                        var get_roles = item.AspNetRoles.Select(x => x.Name);

                        foreach (var role_name in get_roles) {
                            folder_node.Roles.Add(role_name);
                        }

                        colle_node.Add(folder_node);
                        var sub_items = items.Where(x => x.parent_menu_id == item.menu_id).OrderBy(x => x.sort);
                        foreach (var sub_item in sub_items)
                        {
                            DynamicNode subNode = new DynamicNode();

                            subNode.Title = sub_item.menu_name;
                            subNode.ParentKey = folder_node.Key;
                            //dynamicNode.RouteValues.Add("genreId", item.menu_id); //製作連結參數
                            if (!string.IsNullOrEmpty(sub_item.area))
                            {
                                subNode.Area = sub_item.area;
                            }
                            subNode.Controller = sub_item.controller;
                            subNode.Action = sub_item.action;
                            subNode.Clickable = true;
                            subNode.Roles.Add("Admins");

                            var get_sub_roles = sub_item.AspNetRoles.Select(x => x.Name);

                            foreach (var role_name in get_sub_roles)
                            {
                                subNode.Roles.Add(role_name);
                            }

                            colle_node.Add(subNode);
                        }
                    }
                    #endregion
                //}
                //else
                //{
                //    #region Tablet
                //    var items = db.Menu
                //        .Where(x => x.is_use == true && x.is_on_tablet == true)
                //        .ToList();

                //    foreach (var item in items)
                //    {
                //        DynamicNode item_node = new DynamicNode();

                //        item_node.Title = item.menu_name;
                //        item_node.Key = item.menu_id.ToString();
                //        //dynamicNode.RouteValues.Add("genreId", item.menu_id); //製作連結參數
                //        item_node.Area = item.area;
                //        item_node.Controller = item.controller;
                //        item_node.Action = item.action;
                //        //item_node.Attributes.Add("IconClass", item.icon_class);
                //        item_node.Clickable = true;
                //        //yield return item_node;
                //        colle_node.Add(item_node);
                //    }
                //    #endregion
                //}
                return colle_node;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return null;
            }
            finally
            {
                db.Dispose();
            }
        }
        public override IEnumerable<DynamicNode> GetDynamicNodeCollection(ISiteMapNode node)
        {
            // Build value
            var returnValue = new List<DynamicNode>();

            // Create a node for each Category
            foreach (var tag in _tagServices.GetByTaxonomy(TNVTH.Web.Utilities.Constants.TAXONOMY_CATEGORY))
            {
                DynamicNode dynamicNode = new DynamicNode();
                dynamicNode.Key = "NewsCate" + tag.ID;
                dynamicNode.Title = tag.Title;
                dynamicNode.RouteValues.Add("id", tag.ID);
                dynamicNode.RouteValues.Add("slug", tag.Slug);
                dynamicNode.PreservedRouteParameters = new List<string> { tag.Slug };
                dynamicNode.Description = tag.Description;
                dynamicNode.Attributes.Add("keywords", tag.Slug);
                dynamicNode.Attributes.Add("type", "website");

                if (tag.ParentID != null)
                {
                    //Add parent key
                    T_Tag Cate = _tagServices.GetByID((int)tag.ParentID);
                    if (Cate != null)
                    {
                        dynamicNode.ParentKey = "NewsCate" + Cate.ID;
                    }
                }

                returnValue.Add(dynamicNode);
            }

            // Return
            return returnValue;
        }
        public override IEnumerable<DynamicNode> GetDynamicNodeCollection(ISiteMapNode node)
        {
            // Build value
            var returnValue = new List<DynamicNode>();

            // Create a node for each Arrticle
            foreach (var article in _newServices.GetAll())
            {
                T_News_TagServices newsTagServies = new T_News_TagServices();
                IEnumerable<T_Tag> TagList = newsTagServies.GetTagByNewsID(article.ID, TNVTH.Web.Utilities.Constants.TAXONOMY_TAG);
                string TagString = "";
                foreach (var tag in TagList)
                {
                    TagString += tag.Title;
                    TagString += ", ";
                }

                DynamicNode dynamicNode = new DynamicNode();
                dynamicNode.Title = article.Title;
                dynamicNode.RouteValues.Add("id", article.ID);
                dynamicNode.RouteValues.Add("slug", article.Slug);
                dynamicNode.PreservedRouteParameters = new List<string> { article.Slug };
                string Description = Utilities.Common.GetDescription(article.ContentNews, 50);
                dynamicNode.Description = (Description== null)? article.Title: Description;
                dynamicNode.Attributes.Add("keywords", TagString);
                dynamicNode.Attributes.Add("og:image", "http://" + HttpContext.Current.Request.Url.Host + article.AvataImageUrl);
                dynamicNode.Attributes.Add("type", "article");
                dynamicNode.Attributes.Add("author", article.Author);
                T_Tag NewsCate = _newServices.GetCateByNewsID(article.ID);
                if (NewsCate != null)
                {
                    dynamicNode.ParentKey = "NewsCate" + NewsCate.ID;
                }
                returnValue.Add(dynamicNode);
            }

            // Return
            return returnValue;
        }