using System; using System.Collections; using System.Collections.Generic; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Text; using System.IO; using System.Net; using DSWeb.Models; using DSWeb.EntityDA; using DSWeb.Filter; using DSWeb.Authority; using System.Reflection; namespace DSWeb { public partial class _Default : PageBase { private string strUserID; private string strShowName; StringBuilder leftNav = new StringBuilder(); StringBuilder leftTree = new StringBuilder(); StringBuilder tmpLeftTree = new StringBuilder(); //用户权限信息 IList userActionEntities = new List(); protected void Page_Load(object sender, EventArgs e) { if (Session["USERID"] != null) { strUserID = Session["USERID"].ToString(); } if (Session["SHOWNAME"] != null) { strShowName = Session["SHOWNAME"].ToString(); } #region //else //{ // Response.Write(""); // Response.End(); //} //if (strUserID != null) //{ // UserAttributeDA userAttributeDA = new UserAttributeDA(); // IList userAttributeEntities = new List(); // userAttributeEntities = userAttributeDA.GetUserAttributeValue(strUserID); // strRoleName = ""; // if (userAttributeEntities.Count > 0) // { // foreach (UserAttributeEntity userAttributeEntity in userAttributeEntities) // { // if (!userAttributeEntity.Description.Trim().Equals("")) // { // if (!strRoleName.Trim().Equals("")) // { // strRoleName = userAttributeEntity.Description.Trim().Replace("是否", ""); // } // else // { // strRoleName += "、"+userAttributeEntity.Description.Trim().Replace("是否", ""); // } // } // } // } //} #endregion if (strUserID != null) { HttpRequest request = Page.Request; LeftTreeCssFilter myFilter = new LeftTreeCssFilter(request); DoGet(); } else { Response.Redirect("login.aspx"); } } /// /// /// /// /// private List ActionFilter(List moduleEntites) { List ActionFilter = new List(); foreach (ModuleEntity moduleEntity in moduleEntites) { if (moduleEntity.Gid == "0791bbcc-8079-49de-8175-6063b9826ac7") { ActionFilter.Add(moduleEntity); } } return ActionFilter; } public void DoGet() { ModuleDA moduleDA = new ModuleDA(); List moduleEntites = moduleDA.GetParentModule(); #region 获取用户权限 UserDA userDA = new UserDA(); UserEntity userEntity = new UserEntity(); userEntity = userDA.GetUserSignByID(strUserID); object obj = (object)userEntity; AuthorityManage authorityManage = new AuthorityManage(AuthorityManage.AuthorityType.USER, obj); userActionEntities = authorityManage.GetUserAction(); #endregion //遍历用户权限信息对比当前模块信息,只显示模块权限内的主模块信息 int modCount = 0; modCount = moduleEntites.Count; for (int i = 0; i < modCount; i++) { int iCount = 0; foreach (UserActionEntity userActionEntity in userActionEntities) { if (userActionEntity.ActionEntity.ModuleEntity.ParentID.Trim() == "0" && userActionEntity.ActionEntity.ModuleEntity.ModuleType == 0) { //遍历所有顶层模块,所有PARENTID = 0的模块,如果没有属于权限范围内的模块则自动删除 if (userActionEntity.ActionEntity.ModuleEntity.Gid.Trim() == moduleEntites[i].Gid) { iCount++; break; } } } if (iCount == 0) { moduleEntites.Remove(moduleEntites[i]); i = -1; modCount = moduleEntites.Count; } else { continue; } } StringBuilder htmlBuilder = new StringBuilder(); LeftTreeCssFilter cssFilter = new LeftTreeCssFilter(Page.Request); //测试用数据 //string testUserGID = "1BEC90E1-9780-472F-90C2-0C6390C044A4"; //RoleDA roleDA = new RoleDA(); //RoleEntity roleEntity = roleDA.LoadUsingDynamicCode(testUserGID); string strBVersion = cssFilter.Version.Trim(); string strBName = cssFilter.BrowserName.ToLower().Trim(); //显示版本 htmlBuilder.Append(""); htmlBuilder.Append("Manager 版本:" + Assembly.GetExecutingAssembly().GetName().Version.ToString() + ""); //根据不同的浏览器加载不同的css样式 if (strBVersion.Equals("6.0") && strBName.Equals("ie")) { htmlBuilder.Append(""); htmlBuilder.Append(""); } //if (strBName.Equals("firefox")) //{ // htmlBuilder.Append(""); // htmlBuilder.Append(""); //} else { htmlBuilder.Append(""); htmlBuilder.Append(""); } htmlBuilder.Append(""); htmlBuilder.Append(""); htmlBuilder.Append(""); htmlBuilder.Append(""); htmlBuilder.Append(""); htmlBuilder.Append(""); htmlBuilder.Append(""); htmlBuilder.Append(""); //htmlBuilder.Append(""); //htmlBuilder.Append(""); htmlBuilder.Append(""); //htmlBuilder.Append(""); int isOpenAnnounce = 0; isOpenAnnounce = int.Parse(System.Configuration.ConfigurationSettings.AppSettings["isannounce"].ToString());//“1”代表显示“客户登陆”按钮 //消息 string strIntervalCount = System.Configuration.ConfigurationSettings.AppSettings["messageinterval"].ToString() as string; if (strIntervalCount != null) { int iTempCount = int.Parse(strIntervalCount); if (iTempCount < 1000) { strIntervalCount = "1500"; } } //公告 string strIntervalCountAnnounce = System.Configuration.ConfigurationSettings.AppSettings["announceinterval"].ToString() as string; if (strIntervalCountAnnounce != null) { int iTempCount = int.Parse(strIntervalCountAnnounce); if (iTempCount < 1000) { strIntervalCountAnnounce = "2000"; } } htmlBuilder.Append(""); /*htmlBuilder.Append(""); htmlBuilder.Append(""); htmlBuilder.Append(""); htmlBuilder.Append(""); htmlBuilder.Append(""); htmlBuilder.Append(""); htmlBuilder.Append(""); htmlBuilder.Append(""); htmlBuilder.Append(""); htmlBuilder.Append("");*/ //htmlBuilder.Append(""); //2013-04-09 吴工为了解决窗口滚动条的显示问题的修改 if (strBVersion.Equals("9.0") && strBName.Equals("ie")) htmlBuilder.Append("
"); else if (strBVersion.Equals("8.0") && strBName.Equals("ie")) htmlBuilder.Append("
"); else if (strBVersion.Equals("7.0") && strBName.Equals("ie")) htmlBuilder.Append("
"); else htmlBuilder.Append("
"); //END htmlBuilder.Append(""); htmlBuilder.Append(""); htmlBuilder.Append(""); htmlBuilder.Append("
"); htmlBuilder.Append("");// htmlBuilder.Append("");//世腾 htmlBuilder.Append("
"); htmlBuilder.Append(""); htmlBuilder.Append(""); htmlBuilder.Append("
"); htmlBuilder.Append(""); htmlBuilder.Append("
 "); //消息 MessageDA messageDA = new MessageDA(); MessageTotalEntity messageTotalEntity = messageDA.GetMessageTotalByReceiver(strUserID); string strReadTotal = ""; if (messageTotalEntity != null) { strReadTotal = "我的消息(" + messageTotalEntity.ReadTotal + "/" + messageTotalEntity.Total + ")"; } string strAnnounce = ""; if (isOpenAnnounce == 1) { //公告 SysAnnounceDA SysAnnounceDA = new SysAnnounceDA(); strAnnounce = SysAnnounceDA.GetTYPENUM(strUserID, 1); if (strAnnounce.Trim() != "") { strAnnounce = "公告(" + strAnnounce.Trim() + ")"; } } //衍六 字体颜色 #214D8C 世腾 字体颜色 #FFFFFF htmlBuilder.Append("
用户名: " + strShowName + "        "); htmlBuilder.Append("" + strReadTotal + "    "); if (isOpenAnnounce == 1) { htmlBuilder.Append("" + strAnnounce + "    "); } htmlBuilder.Append("下载    "); htmlBuilder.Append("[退出]    
      "); htmlBuilder.Append("
    • "); htmlBuilder.Append("
    "); htmlBuilder.Append("
      "); string strValue = GetTreeView(moduleEntites); htmlBuilder.Append(leftNav.ToString()); htmlBuilder.Append("
    ");//
    htmlBuilder.Append(strValue); // string sCrmPlatform = ""; sCrmPlatform = System.Configuration.ConfigurationSettings.AppSettings["crmplatform"].ToString();//“crmplatform”代表crm系统的登录平台,“crmsale”代表显示“销售平台”按钮 if (sCrmPlatform.Trim() == "") { htmlBuilder.Append(""); } else if (sCrmPlatform.Trim() == "crmsale") { htmlBuilder.Append(""); } // //htmlBuilder.Append("
    "); htmlBuilder.Append(""); Response.Clear(); Response.Write(htmlBuilder.ToString()); } /// /// 获取左侧展开树内容 /// /// 实体类ModuleEntity /// public String GetTreeView(List tempEntities) { //StringBuilder leftNav = new StringBuilder(); StringBuilder leftTree = new StringBuilder(); StringBuilder tmpLeftTree = new StringBuilder(); //树型菜单第一级菜单 StringBuilder leftTreeData = new StringBuilder(); StringBuilder treesJS = new StringBuilder(); foreach (ModuleEntity mdel in tempEntities) { String tmpUrl = mdel.ModuleUrl.Trim() + "?mod=" + mdel.ModuleName; string turl = ""; if (tmpUrl.IndexOf("#")<0) { tmpUrl = "../" + tmpUrl; turl = "CreateTab('" + mdel.ModuleDescription + "','H','" + tmpUrl + "');"; } leftNav.Append("
  • "); leftNav.Append(" "); leftNav.Append(mdel.ModuleDescription); leftNav.Append("
  • "); tmpLeftTree = new StringBuilder();// class=\"TreeMenu\" tmpLeftTree.Append("
    "); tmpLeftTree.Append("
    "); leftTreeData.Append(LeftTreeNodeData(mdel)); leftTree.Append(tmpLeftTree.ToString()); } //treesJS.append(LeftTreeNodeRender(modelsList,appModelsList.get(i),user.getTokenID())); //leftTreeData.Append(LeftTreeNodeData(modelsList, appModelsList.get(i), user.getTokenID())); //leftTreeData.Append(LeftTreeNodeData()); //leftTree.Append(tmpLeftTree.ToString()); return leftTreeData.ToString(); } #region /*public string GetLeftNav(List tempEntities) { StringBuilder navBuilder = new StringBuilder(); if (tempEntities.Count > 0) { foreach (ModuleEntity mdel in tempEntities) { if (mdel.ParentID.Trim().Equals(0)) { navBuilder.Append("
  • "); navBuilder.Append(" "); navBuilder.Append(mdel.ModuleName); navBuilder.Append("
  • "); } else { } } } return navBuilder.ToString(); }*/ #endregion public String ConvertToJS(JSTreeNodeEntity tempJSTreeEntity) { StringBuilder nodeJS = new StringBuilder(); nodeJS.Append("{"); nodeJS.Append("\"id\":\"root" + tempJSTreeEntity.Gid + "\""); nodeJS.Append(","); nodeJS.Append("\"text\":\"" + tempJSTreeEntity.Text + "\""); nodeJS.Append(","); nodeJS.Append("\"value\":\"" + tempJSTreeEntity.Value + "\""); nodeJS.Append(","); nodeJS.Append("\"showcheck\":" + (tempJSTreeEntity.SetShowCheck ? 1 : 0).ToString() + ""); nodeJS.Append(","); nodeJS.Append("\"complete\":1"); nodeJS.Append(","); nodeJS.Append("\"isexpand\":" + (tempJSTreeEntity.IsExpand ? 1 : 0).ToString() + ""); //1"); nodeJS.Append(","); nodeJS.Append("\"checkstate\":" + tempJSTreeEntity.CheckState + ""); nodeJS.Append(","); nodeJS.Append("\"hasChildren\":" + (tempJSTreeEntity.SetHasChild ? 1 : 0).ToString() + ""); nodeJS.Append(","); string classes = tempJSTreeEntity.SetClasses; if (classes != null && !classes.Equals("")) { int ilen = classes.IndexOf('.'); classes = classes.Substring(0, ilen); if (classes.Length > 1) { nodeJS.Append("\"classes\":\"" + classes + "\""); nodeJS.Append(","); } } nodeJS.Append("\"ChildNodes\":\"null\""); nodeJS.Append("}"); return nodeJS.ToString(); } #region /* public String LeftTreeNodeData(ModuleEntity tempEntity) { StringBuilder appTreeData = new StringBuilder(); StringBuilder childerData = new StringBuilder(); ModuleDA moduleDA = new ModuleDA(); List subModule = moduleDA.GetSubModule(tempEntity.Gid); List tempEntities = moduleDA.GetAllSubModules(); appTreeData.Append(""); return appTreeData.ToString(); }*/ #endregion public String LeftTreeNodeData(ModuleEntity tempEntity) { StringBuilder appTreeData = new StringBuilder(); StringBuilder childerData = new StringBuilder(); ModuleDA moduleDA = new ModuleDA(); //List subModule = moduleDA.GetSubModule(tempEntity.Gid); //List tempEntities = moduleDA.GetAllUserBaseSubModules(); List subModule = moduleDA.GetSubModule(tempEntity.Gid); List tempEntities = moduleDA.GetAllSubModules(); if (userActionEntities.Count > 0) { tempEntities = null; tempEntities = new List(); foreach (UserActionEntity userActionEntity in userActionEntities) { if (userActionEntity.ActionEntity.ModuleEntity.ParentID.Trim() != "0") { tempEntities.Add(userActionEntity.ActionEntity.ModuleEntity); } } } appTreeData.Append(""); return appTreeData.ToString(); } /// /// 返回 /// /// /// /// public String GetSubJs(string parentGid, List tempEntities, string tempJSON) { StringBuilder valBuilder = new StringBuilder(); StringBuilder childBuilder = new StringBuilder(); foreach (ModuleEntity mdle in tempEntities) { if (parentGid.Trim().Equals(mdle.ParentID)) { bool isParentNode = IsParent(tempEntities, mdle.Gid); string strTempNode = GetNodeJs(mdle, isParentNode); string strTempValue = ""; if (isParentNode) { strTempValue = GetSubJs(mdle.Gid, tempEntities, strTempNode); childBuilder.Append(strTempValue); } if (strTempValue.Trim().Equals("")) { childBuilder.Append(strTempNode); } } } if (childBuilder.Length > 1) { string strChilds = childBuilder.ToString(); strChilds = strChilds.Substring(0, strChilds.Length - 1);//去除末尾逗号 if (!tempJSON.Equals("")) { tempJSON = tempJSON.Replace("\"null\"", "[" + strChilds + "]"); valBuilder.Append(tempJSON); } else { valBuilder.Append(strChilds); } } return valBuilder.ToString(); } /*public String GetSubJs(string parentGid, List tempEntities) { StringBuilder tempJSON = new StringBuilder(); StringBuilder tempBuilder = new StringBuilder(); foreach (ModuleEntity mdle in tempEntities) { if (parentGid.Trim().Equals(mdle.ParentID)) { tempJSON.Append(GetNodeJs(mdle, true)); tempJSON.Append("-"); tempJSON.Append(GetSubJs(mdle.Gid, tempEntities)); } } return tempJSON.ToString(); }*/ /// /// 遍历模块查看此模块是否为父模块 /// /// /// /// public bool IsParent(List tempEntities, string strGID) { bool IsExist = false; foreach (ModuleEntity mdle in tempEntities) { if (mdle.ParentID.Trim().Equals(strGID)) { IsExist = true; } } return IsExist; } #region 获取节点JSON值 /// /// 获取节点JSON值 /// /// /// /// public String GetNodeJs(ModuleEntity tempEntity, bool hasChild) { StringBuilder tempNodeBuilder = new StringBuilder(); JSTreeNodeEntity modelData = new JSTreeNodeEntity(); modelData.Gid = tempEntity.Gid.Replace("-", ""); modelData.Text = tempEntity.ModuleDescription; modelData.SetShowCheck = false; modelData.CheckState = 0; modelData.IsExpand = false; modelData.SetClasses = tempEntity.ModuleIcon; String tmpUrl = tempEntity.ModuleUrl.Trim(); //如果数据库模板表Module字段Url设置为"#"则不提供链接 if (!tmpUrl.Equals("#")) { tmpUrl += "?mod=" + tempEntity.ModuleName; tmpUrl = "../" + tmpUrl; modelData.Value = "CreateTab('" + tempEntity.ModuleDescription + "','H','" + tmpUrl + "');"; } else { modelData.Value = "javascript:void(0);"; } //设置是否有子菜单 if (hasChild) { modelData.SetChildNode = 0; modelData.SetHasChild = true; } else { modelData.SetChildNode = 0; modelData.SetHasChild = false; } //recording++; // Response.Write(ConvertToJS(modelData) + ","); return (ConvertToJS(modelData) + ","); } #endregion } }