using BizCom; using SiteCore; using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Text; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using Utils; public partial class MainPage : BasePage { DataView dv = null; DataView sDv = null; DataTable resources = null; protected void Page_Load(object sender, EventArgs e) { if (!CheckRights()) return; resources = WebUser.GetPermission(Session["xyUserID"]); if (resources == null || resources.Rows.Count < 1) { ShowError("您的账户暂时还没有分配权限,无法使用系统!"); return; } //litTitle.Text = ""; StringBuilder userStr = new StringBuilder(); userStr.AppendFormat("账号:{0}", Session["xyUserName"]); //if (CurrentUser.User.PreLoginTime != null) //{ // userStr.AppendFormat("上次登录:{0}", Convert.ToDateTime(CurrentUser.User.PreLoginTime).ToString("yy年M月d日 HH:mm")); //} //else //{ // userStr.Append("上一次登录时间:无"); //} //userStr.AppendFormat("登录IP:{0}",CurrentUser.User.LoginIP); litUser.Text = userStr.ToString(); if(Session["xyUserName"].ToString()== "zc_admin") { litTitle.Text = "家具资产管理维保云平台"; } else { litTitle.Text = "后台管理平台"; } //litTitle.Text = SiteName; //this.Title = litTitle.Text + "砼生产管理系统"; dv = new DataView(resources); sDv = new DataView(resources); StringBuilder str = new StringBuilder(); getTreeMenu("0", 0, ref str); litScript.Text = ""; //litMenu.Text = str.ToString(); } int j = 0; private void getTreeMenu(string pId, int idx, ref StringBuilder str) { dv.RowFilter = "ParentID=" + pId + " and isoperate=0"; foreach (DataRowView drv in dv) { //if (drv["Tag"].ToString() == "index") //{ // getIndexMenu(drv["ID"]); // continue; //} sDv.RowFilter = "ParentID=" + drv["ID"] + " and isoperate=0";//判断有没有子节点 if (sDv.Count > 0) { if (j == 0) j++; else str.Append(","); if (pId == "0") { str.Append("{").AppendFormat("\"id\":\"{0}\",\"text\":\"{1}\",iconCls: \"icon-{2}\"", drv["ID"], drv["Name"], drv["Icon"]).Append("}"); } else { str.Append("{").AppendFormat("\"id\":\"{0}\",\"text\":\"{1}\",\"pid\":\"{2}\",iconCls: \"icon-{3}\",\"iconPosition\": \"top\"", drv["ID"], drv["Name"], pId, drv["Icon"]).Append("}"); } getTreeMenu(drv["ID"].ToString(), idx + 1, ref str); } else { if (idx > 1) { if (j == 0) j++; else str.Append(","); str.Append("{"); str.AppendFormat("\"id\":\"{0}\",\"text\":\"{1}\",\"pid\":\"{2}\",\"url\":\"{3}\"", drv["ID"], drv["Name"], pId, drv["Url"]).Append("}"); } else { if (j == 0) j++; else str.Append(","); str.Append("{"); str.AppendFormat("\"id\":\"{0}\",\"text\":\"{1}\",\"pid\":\"{2}\",\"url\":\"{3}\",iconCls: \"icon-{4}\",\"iconPosition\": \"top\"", drv["ID"], drv["Name"], pId, drv["Url"], (drv["Icon"].ToString() == "" ? drv["Tag"] : drv["Icon"]), drv["Icon"]).Append("}"); } //else //{ // str.Append(",{").AppendFormat("\"text\":\"
\",\"pid\":\"{1}\"", drv["ID"], pId).Append("}"); //} } } } //private void getIndexMenu(object pId) //{ // StringBuilder str = new StringBuilder(); // DataView indexDv = new DataView(resources); // indexDv.RowFilter = "ParentID=" + pId + " and isoperate=0"; // foreach (DataRowView drv in indexDv) // { // string tag = drv["Tag"].ToString(); // str.AppendFormat("{0}", drv["Name"], tag.Replace("view", "")); // } // if (str.Length > 0) // litIndexMenu.Text = str.ToString(); //} }