Esempio n. 1
0
    private void BuildMenu()
    {
        CoreLibrary.SiteMap.Controller smController = new CoreLibrary.SiteMap.Controller();
        User entCurrenUser = (User)Session["currentUser"];
        List<ServicesLibrary.Entities.SiteMap> MenuItemsList = smController.GetMenuByIdRole(entCurrenUser.EntRole.IdRole);

        StringBuilder sbItemMenuLink = new StringBuilder();
        sbItemMenuLink.Append("<table class=\"menuTable\">");
        foreach(ServicesLibrary.Entities.SiteMap mItem in MenuItemsList)
        {

            string controlID = String.Format(" ID =\"itemLink{0} \"", System.Guid.NewGuid().ToString().Replace("-", ""));
            string runatServer = " runat=\"server\" ";
            string classproperty = " class=\"menu_link\" ";
            string hrefURL = String.Format(" href=\"{0}\"", this.ResolveClientUrl(mItem.URL));
            sbItemMenuLink.Append("<tr>");
            sbItemMenuLink.Append("<td >");//class=\"menu_link1\"

            sbItemMenuLink.Append("<a ");
            sbItemMenuLink.Append(controlID);
            sbItemMenuLink.Append(runatServer);
            //sbItemMenuLink.Append(classproperty);
            sbItemMenuLink.Append(hrefURL);
            sbItemMenuLink.Append(">");
            sbItemMenuLink.Append(mItem.Name);
            sbItemMenuLink.Append("</a>");
            sbItemMenuLink.Append("</td>");

            sbItemMenuLink.Append("</tr>");
        }
        sbItemMenuLink.Append("</table>");
        this.Controls.Add(new LiteralControl(sbItemMenuLink.ToString()));
    }
Esempio n. 2
0
    public void BuidlRolesTree()
    {
        CoreLibrary.SiteMap.Controller smController = new CoreLibrary.SiteMap.Controller();
        List<ServicesLibrary.Entities.SiteMap> sitemapList = smController.GetAll().OrderBy(c => c.IdParent).ToList();
        List<SiteMapTree> smtList = new List<SiteMapTree>();

        int ilLevel = 0;
        int? ilParent = 0;
        string slParentKey ="";
        foreach (ServicesLibrary.Entities.SiteMap smItem in sitemapList)
        {
            if (ilParent != smItem.IdParent)
            {
                ilLevel = smtList.Where(c => c.IdSiteMap == smItem.IdParent).FirstOrDefault().Level + 1;
                ilParent = smItem.IdParent.Value;
            }
            slParentKey =String.Format("{0}",smtList.Where(c=>c.IdSiteMap == (ilParent==null?null :ilParent) ).Select(c=> c.OrderKey).FirstOrDefault());

            SiteMapTree smtItem = new SiteMapTree()
            {
                Level = ilLevel,
                IdSiteMap = smItem.IdSiteMap,
                IdParent = smItem.IdParent,
                Description = smItem.Description,
                EntStatus = smItem.EntStatus,
                IsBrowsable = smItem.IsBrowsable,
                Name = smItem.Name,
                RoleCode = smItem.RoleCode,
                URL = smItem.URL,
                OrderKey = String.Format("{0}{1}", slParentKey != "" ? slParentKey + "," : "", ilLevel.ToString())
                //OrderKey = String.Format("{0}", slParentKey != "" ? slParentKey + "," : slParentKey)
            };
            //OrderKey = String.Format("{0}-{1}-{2}",ilLevel,smItem.IdSiteMap,smItem.IdParent)
            smtList.Add(smtItem);
        }
         smtList = smtList.OrderBy(c => c.OrderKey).ToList();

         tvSiteMap.Nodes.Clear();

         BuildTreeView(null, smtList, 0);

         //return smtList;
    }