private void AddPages(SiteMapNode parentNode) { SiteMapDataContext dbSiteMap = new SiteMapDataContext(SystemSetting.SageFrameConnectionString); string userName = SystemSetting.AnonymousUsername; if (HttpContext.Current.User != null) { if (Membership.GetUser() != null) { userName = Membership.GetUser().UserName; } } var pages = dbSiteMap.sp_GetSiteMapNodeByParentNodeID(Int32.Parse(parentNode.Key.ToString()), userName, GetPortalID); foreach (var page in pages) { string[] PageRoles = page.PageRoles.Split(','); IList roles = new ArrayList(); for (int i = 0; i < PageRoles.Length; i++) { roles.Add(PageRoles[i]); } SiteMapNode pageNode = new SiteMapNode(this, page.PageID.ToString(), "~/Sagin" + page.Url, page.PageName, page.Description, roles, null, null, null); AddNode(pageNode, parentNode); AddPages(pageNode); } }
public override SiteMapNode BuildSiteMap() { try { lock (this) { if (root != null) { return(root); } base.Clear(); string nodeKey, nodeTitle, nodeUrl, nodeDescription; SiteMapDataContext dbSiteMap = new SiteMapDataContext(SystemSetting.SageFrameConnectionString); string userName = SystemSetting.AnonymousUsername; if (HttpContext.Current.User != null) { if (Membership.GetUser() != null) { userName = Membership.GetUser().UserName; } } IList rootRoles = new ArrayList(); rootRoles.Add("*"); root = new SiteMapNode(this, "root", "~/Sagin/" + CommonHelper.DefaultPage, "Home", "", rootRoles, null, null, null); AddNode(root); var pages = dbSiteMap.sp_GetSiteMapNodeByParentNodeID(0, userName, GetPortalID); foreach (var page in pages) { nodeKey = page.PageID.ToString(); nodeTitle = page.PageName; nodeUrl = "~/Sagin" + page.Url; nodeDescription = page.Description; string[] PageRoles = page.PageRoles.Split(','); IList roles = new ArrayList(); for (int i = 0; i < PageRoles.Length; i++) { roles.Add(PageRoles[i]); } SiteMapNode childNode = FindSiteMapNodeFromKey(nodeKey); if (childNode == null) { childNode = new SiteMapNode(this, nodeKey, nodeUrl, nodeTitle, nodeDescription, roles, null, null, null); AddNode(childNode, root); AddPages(childNode); } } SqlCacheDependency pagesTableDependency = new SqlCacheDependency(SystemSetting.SageFrameDBName, "Pages"); SqlCacheDependency MembershipTableDependency = new SqlCacheDependency(SystemSetting.SageFrameDBName, "aspnet_Membership"); SqlCacheDependency UsersTableDependency = new SqlCacheDependency(SystemSetting.SageFrameDBName, "aspnet_users"); AggregateCacheDependency aggregateDependencies = new AggregateCacheDependency(); aggregateDependencies.Add(pagesTableDependency); aggregateDependencies.Add(MembershipTableDependency); aggregateDependencies.Add(UsersTableDependency); HttpRuntime.Cache.Insert(CacheDependencyKey, DateTime.Now, aggregateDependencies , DateTime.Now , Cache.NoSlidingExpiration , CacheItemPriority.Normal , new CacheItemRemovedCallback(OnSiteMapChanged)); return(root); } } catch { return(root); } }
public override SiteMapNode BuildSiteMap() { try { lock (this) { if (root != null) return root; base.Clear(); string nodeKey, nodeTitle, nodeUrl, nodeDescription; SiteMapDataContext dbSiteMap = new SiteMapDataContext(SystemSetting.SageFrameConnectionString); string userName = SystemSetting.AnonymousUsername; if (HttpContext.Current.User != null) { if (Membership.GetUser() != null) { userName = Membership.GetUser().UserName; } } IList rootRoles = new ArrayList(); rootRoles.Add("*"); root = new SiteMapNode(this, "root", "~/Sagin/" + CommonHelper.DefaultPage, "Home", "", rootRoles, null, null, null); AddNode(root); var pages = dbSiteMap.sp_GetSiteMapNodeByParentNodeID(0, userName, GetPortalID); foreach (var page in pages) { nodeKey = page.PageID.ToString(); nodeTitle = page.PageName; nodeUrl = "~/Sagin" + page.Url; nodeDescription = page.Description; string[] PageRoles = page.PageRoles.Split(','); IList roles = new ArrayList(); for (int i = 0; i < PageRoles.Length; i++) { roles.Add(PageRoles[i]); } SiteMapNode childNode = FindSiteMapNodeFromKey(nodeKey); if (childNode == null) { childNode = new SiteMapNode(this, nodeKey, nodeUrl, nodeTitle, nodeDescription, roles, null, null, null); AddNode(childNode, root); AddPages(childNode); } } SqlCacheDependency pagesTableDependency = new SqlCacheDependency(SystemSetting.SageFrameDBName, "Pages"); SqlCacheDependency MembershipTableDependency = new SqlCacheDependency(SystemSetting.SageFrameDBName, "aspnet_Membership"); SqlCacheDependency UsersTableDependency = new SqlCacheDependency(SystemSetting.SageFrameDBName, "aspnet_users"); AggregateCacheDependency aggregateDependencies = new AggregateCacheDependency(); aggregateDependencies.Add(pagesTableDependency); aggregateDependencies.Add(MembershipTableDependency); aggregateDependencies.Add(UsersTableDependency); HttpRuntime.Cache.Insert(CacheDependencyKey, DateTime.Now, aggregateDependencies , DateTime.Now , Cache.NoSlidingExpiration , CacheItemPriority.Normal , new CacheItemRemovedCallback(OnSiteMapChanged)); return root; } } catch { return root; } }