Esempio n. 1
0
        private void populateMenu()
        {
            //if (((PageBase)this.Page).CurrentUserSession.IsNull()) return;
            if (((PageBase)this.Page).CurrentUserSession.IsNull())
            {
                HttpContext.Current.Response.Redirect("~/Security/Login.aspx?back_url=" + Server.UrlEncode(Request.Url.AbsoluteUri));
            }

            var userCode = ((PageBase)this.Page).CurrentUserSession.UserCode;
            var appCode  = ((PageBase)this.Page).CurrentUserSession.CurrentApplicationID;

            CustomList <LeftMenuItems> allMenu = LeftMenuItems.GetAllLeftMenuItemsByUserCodeAndApplicationID(userCode, appCode);
            string moduleName    = string.Empty;
            var    currentModule = GetCurrentModule(Request.Url, out moduleName);
            var    sb            = new StringBuilder();

            var selectedMenu = allMenu.Where(m => m.MenuType.Contains("Home"));

            foreach (var item in selectedMenu)
            {
                if (allMenu.Where(m => m.ParentID == item.ObjectID).Count() > 0)// && string.IsNullOrWhiteSpace(m.FormName)).Count() > 0)
                {
                    sb.Append("<li>");
                    var href = item.FormName == "" ? "#" : ResolveUrl(item.FormName);
                    sb.Append("<a class=\"multi\" href=\" " + root + href + "\">" + item.DisplayMember + "</a>");
                    sb.Append("<ul>");
                    foreach (var inner in allMenu.FindAll(m => m.ParentID == item.ObjectID && m.MenuType != "Home"))
                    {
                        href = inner.FormName == "" ? "#" : ResolveUrl(inner.FormName);
                        sb.Append("<li><a href=\"" + root + href + "\">" + inner.DisplayMember + "</a></li>");
                    }
                    sb.Append("</ul>");
                    sb.Append("</li><li>|</li>");
                }
                //else
                //{
                //    sb.Append("<li>");
                //    var href = item.FormName == "" ? "#" : ResolveUrl(item.FormName);
                //    sb.Append("<a href=\" " + root + href + "\">" + item.DisplayMember + "</a>");
                //    sb.Append("</li><li>|</li>");
                //}
            }
            var menuText = "<div class=\"menu\"><nav><ul>" + new String((new String(sb.ToString().Reverse().Skip(10).ToArray())).Reverse().ToArray()) + "</ul></nav></div>";

            ltrMenu.Text = menuText;
        }
Esempio n. 2
0
 public CustomList <LeftMenuItems> GetAllLeftMenuItemsByUserCodeAndApplicationID(string UserCode, int ObjectID)
 {
     return(LeftMenuItems.GetAllLeftMenuItemsByUserCodeAndApplicationID(UserCode, ObjectID));
 }