コード例 #1
0
        private List <MDMSVC.DC_SiteMap> GetData()
        {
            try
            {
                Controller.AccomodationSVC AccSvc = new Controller.AccomodationSVC();
                if (String.IsNullOrWhiteSpace(System.Web.HttpContext.Current.User.Identity.Name))
                {
                    Response.Redirect("/Account/Login", true);
                }

                Label LoggedInUser = (Label)LoginViewForSiteMap.FindControl("lblLoggedInUser");
                LoggedInUser.Text = System.Web.HttpContext.Current.User.Identity.Name;
                List <MDMSVC.DC_SiteMap> objSiteMap = AccSvc.GetSiteMapByUserRole(System.Web.HttpContext.Current.User.Identity.Name);
                objSiteMap = (from s in objSiteMap where s.ID != 1 orderby s.ID select s).ToList();
                return(objSiteMap);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #2
0
 private void PopulateMenu(List <MDMSVC.DC_SiteMap> objSiteMap)
 {
     try
     {
         Menu SiteMenu = (Menu)LoginViewForSiteMap.FindControl("SiteMenu");
         if (objSiteMap != null && objSiteMap.Count > 0)
         {
             int iCounter = 1;
             foreach (var row in objSiteMap)
             {
                 string currentPage = Path.GetFileName(Request.Url.AbsolutePath);
                 if (iCounter == 1)
                 {
                     SiteMenu.Items.Add(CreateSiteMapNode(row, currentPage));
                 }
                 else
                 {
                     var parentMenu = SiteMenu.FindItem(Convert.ToString(row.ParentID));// GetParentMenu((from x in objSiteMap where x.ID == row.ParentID select x).FirstOrDefault());
                     if (parentMenu != null)
                     {
                         parentMenu.ChildItems.Add(CreateSiteMapNode(row, currentPage));
                     }
                     else
                     {
                         SiteMenu.Items.Add(CreateSiteMapNode(row, currentPage));
                     }
                 }
                 iCounter++;
             }
         }
     }
     catch
     {
         throw;
     }
 }