You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

789 lines
35 KiB
C#

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<UserActionEntity> userActionEntities = new List<UserActionEntity>();
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("<script>javascript:window.opener.location='Login.aspx';window.opener = window.opener;</script>");
// Response.End();
//}
//if (strUserID != null)
//{
// UserAttributeDA userAttributeDA = new UserAttributeDA();
// IList<UserAttributeEntity> userAttributeEntities = new List<UserAttributeEntity>();
// 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");
}
}
/// <summary>
///
/// </summary>
/// <param name="moduleEntites"></param>
/// <returns></returns>
private List<ModuleEntity> ActionFilter(List<ModuleEntity> moduleEntites)
{
List<ModuleEntity> ActionFilter = new List<ModuleEntity>();
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<ModuleEntity> 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("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">");
htmlBuilder.Append("<html><head><title>Manager 版本:" + Assembly.GetExecutingAssembly().GetName().Version.ToString() + "</title><meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">");
//根据不同的浏览器加载不同的css样式
if (strBVersion.Equals("6.0") && strBName.Equals("ie"))
{
htmlBuilder.Append("<link type=\"text/css\" rel=\"stylesheet\" href=\"../../theme/default/styles/default/globle.css\"/>");
htmlBuilder.Append("<link type=\"text/css\" rel=\"stylesheet\" href=\"../../theme/default/styles/default/icons.css\"/>");
}
//if (strBName.Equals("firefox"))
//{
// htmlBuilder.Append("<link type=\"text/css\" rel=\"stylesheet\" href=\"../../theme/default/styles/default/globle.css\"/>");
// htmlBuilder.Append("<link type=\"text/css\" rel=\"stylesheet\" href=\"../../theme/default/styles/default/icons.css\"/>");
//}
else
{
htmlBuilder.Append("<link type=\"text/css\" rel=\"stylesheet\" href=\"../../theme/default/styles/IE8/globle.css\"/>");
htmlBuilder.Append("<link type=\"text/css\" rel=\"stylesheet\" href=\"../../theme/default/styles/IE8/icons.css\"/>");
}
htmlBuilder.Append("<link type=\"text/css\" rel=\"stylesheet\" href=\"../../treeview/thickbox.css\" />");
htmlBuilder.Append("<link type=\"text/css\" rel=\"stylesheet\" href=\"../styles/jquery.tree.css\"/>");
htmlBuilder.Append("<Link rel=\"icon name\" href=\"TruckMng/Content/Images/dsico.ico\">");
htmlBuilder.Append("<link rel=\"shortcut icon\" href=\"TruckMng/Content/Images/ds.png\" type=\"image/x-icon\" />");
htmlBuilder.Append("<script type=\"text/javascript\" src=\"../js/jquery/js/jquery.js\"></script>");
htmlBuilder.Append("<script type=\"text/javascript\" src=\"../js/jquery/js/jquery.tree.js\"></script>");
htmlBuilder.Append("<script type=\"text/javascript\" src=\"../js/dhtmlxcommon.js\" type=\"text/javascript\"></script>");
htmlBuilder.Append("<script type=\"text/javascript\">var $j = jQuery.noConflict();</script>");
//htmlBuilder.Append("<script type=\"text/javascript\" src=\"../../theme/default/js/util.js\"></script>");
//htmlBuilder.Append("<script type=\"text/javascript\" src=\"../../treeview/MzTreeView12.js\"></script>");
htmlBuilder.Append("<script type=\"text/javascript\" src=\"../js/default.js\"></script>");
//htmlBuilder.Append("<script type=\"text/javascript\" src=\"../js/browser.js\"></script>");
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("<script type=\"text/javascript\" src=\"../../theme/default/js/loaderframework.js\"></script></head><body onload=\"recycleCount(" + strIntervalCount + ");");
if (isOpenAnnounce == 1)
{
htmlBuilder.Append("recycleCountAnnounce(" + strIntervalCountAnnounce + ");");
}
htmlBuilder.Append("\">");
/*htmlBuilder.Append("<link type=\"text/css\" rel=\"stylesheet\" href=\"../../theme/default/styles/globle.css\"/>");
htmlBuilder.Append("<link type=\"text/css\" rel=\"stylesheet\" href=\"../../treeview/thickbox.css\" />");
htmlBuilder.Append("<link type=\"text/css\" rel=\"stylesheet\" href=\"../../styles/jquery.tree.css\"/>");
htmlBuilder.Append("<script type=\"text/javascript\" src=\"../../scripts/jquery/js/jquery.js\"></script>");
htmlBuilder.Append("<script type=\"text/javascript\" src=\"../../scripts/jquery/js/jquery.tree.js\"></script>");
htmlBuilder.Append("<link type=\"text/css\" rel=\"stylesheet\" href=\"../../theme/default/styles/icons.css\"/>");
htmlBuilder.Append("<script type=\"text/javascript\">var $j = jQuery.noConflict();</script>");
htmlBuilder.Append("<script type=\"text/javascript\" src=\"../../theme/default/js/util.js\"></script>");
htmlBuilder.Append("<script type=\"text/javascript\" src=\"../../treeview/MzTreeView12.js\"></script>");
htmlBuilder.Append("<script type=\"text/javascript\" src=\"../../theme/default/js/loaderframework.js\"></script></head><body>");*/
//htmlBuilder.Append("<table width=\"100%\" height=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"background-image: url(../../images/mast_back.gif);background-repeat: repeat-x;\">");
//2013-04-09 吴工为了解决窗口滚动条的显示问题的修改
if (strBVersion.Equals("9.0") && strBName.Equals("ie"))
htmlBuilder.Append("<table width=\"100%\" height=\"88%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"background-image: url(../../images/mast_back.gif);background-repeat: repeat-x;\">");
else if (strBVersion.Equals("8.0") && strBName.Equals("ie"))
htmlBuilder.Append("<table width=\"100%\" height=\"89%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"background-image: url(../../images/mast_back.gif);background-repeat: repeat-x;\">");
else if (strBVersion.Equals("7.0") && strBName.Equals("ie"))
htmlBuilder.Append("<table width=\"100%\" height=\"89%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"background-image: url(../../images/mast_back.gif);background-repeat: repeat-x;\">");
else
htmlBuilder.Append("<table width=\"100%\" height=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"background-image: url(../../images/mast_back.gif);background-repeat: repeat-x;\">");
//END
htmlBuilder.Append("<tr><td height=\"60\" colspan=\"3\" valign=\"top\" class=\"topBanner topBannerLog\">");
htmlBuilder.Append("<table width=\"100%\" height=\"70\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"mainTopTB\">");//
htmlBuilder.Append("<tr><td width=\"180\" align=\"center\" ><img src=\"../../images/logo-white.gif\" width=\"177\" height=\"42\" align=\"absmiddle\" /></td>");//世腾
htmlBuilder.Append("<td align=\"right\" valign=\"top\" height=\"100%\">");
htmlBuilder.Append("<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">");
htmlBuilder.Append("<tr><td height=\"37\" valign=\"middle\">");
htmlBuilder.Append("<table width=\"100%\" border=\"0\" height=\"37\" cellpadding=\"0\" cellspacing=\"0\"><tr>");
htmlBuilder.Append("<td align=\"right\" valign=\"bottom\">&nbsp;");
//消息
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("<div class=\"HTitle\" style=\"position:absolute;right:0px;top:18px;color:#FFFFFF;\">用户名: " + strShowName + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
htmlBuilder.Append("<a href=\"javascript:void(0)\" id=\"dvMessage\" style=\"color:#FFFFFF\" onclick=\"openDialog('message')\">" + strReadTotal + "</a>&nbsp;&nbsp;&nbsp;&nbsp;");
if (isOpenAnnounce == 1)
{
htmlBuilder.Append("<a href=\"javascript:void(0)\" id=\"dvAnnounce\" style=\"color:#FFFFFF\" onclick=\"openDialog('announce')\">" + strAnnounce + "</a>&nbsp;&nbsp;&nbsp;&nbsp;");
}
htmlBuilder.Append("<a href=\"javascript:void(0)\" onclick=\"window.open('tools/download.aspx','_blank','height=130, width=260, toolbar=no, menubar=no,scrollbars=no, resizable=1,location=no, status=no'");
htmlBuilder.Append(")\" style=\"color:#FFFFFF\">下载</a>&nbsp;&nbsp;&nbsp;&nbsp;");
htmlBuilder.Append("<a href=\"../SignOn/Logout.aspx\" style=\"color:#FFFFFF\">[退出]</a>&nbsp;&nbsp;&nbsp;&nbsp;</div></td></tr></table></td></tr>");
htmlBuilder.Append("<tr><td align=\"left\" height=\"23\"><div id=\"dvTab\"><ul id=\"tags\"></ul></div></td></tr></table></td></tr></table></td></tr>");
htmlBuilder.Append("<tr><td class=\"space\" colspan=\"3\" valign=\"top\"></td></tr>");
htmlBuilder.Append("<tr><td width=\"180px\" valign=\"top\"><ul id=\"toolsBig\" style=\"display:\" class=\"bigbtn\">");
htmlBuilder.Append("<li id=\"btnRec\"><a id = \"ExchangeLab\" href=\"javascript:void(0);\" title=\"\"><b></b></a></li>");
htmlBuilder.Append("</ul></li></ul>");
htmlBuilder.Append("<div id=\"tree\"></div><ul id=\"nav\">");
string strValue = GetTreeView(moduleEntites);
htmlBuilder.Append(leftNav.ToString());
htmlBuilder.Append("</ul></td><td width=\"4px\" valign=\"top\" bgcolor=\"#D7EDF4\"></td>");
htmlBuilder.Append("<td valign=\"top\" align=\"left\" id=\"tdContent\"><div id=\"dvContent\"></div></td></tr></table>");//<div id=\"dvContentHead\" style=\"background: url(../../images/content-header.gif)\"></div>
htmlBuilder.Append(strValue);
//
string sCrmPlatform = "";
sCrmPlatform = System.Configuration.ConfigurationSettings.AppSettings["crmplatform"].ToString();//“crmplatform”代表crm系统的登录平台“crmsale”代表显示“销售平台”按钮
if (sCrmPlatform.Trim() == "")
{
htmlBuilder.Append("<script type=\"text/javascript\">CreateTab(\" 首页 \",'H','MainPortal.aspx');</script>");
}
else if (sCrmPlatform.Trim() == "crmsale")
{
htmlBuilder.Append("<script type=\"text/javascript\">CreateTab(\" 首页 \",'H','../CRM/CRMClientSaleIndex.aspx');</script>");
}
//
//htmlBuilder.Append("<div id=\"dvContentHead\" style=\"background: url(../../images/content-header.gif)\">");
htmlBuilder.Append("</body></html>");
Response.Clear();
Response.Write(htmlBuilder.ToString());
}
/// <summary>
/// 获取左侧展开树内容
/// </summary>
/// <param name="tempEntities">实体类ModuleEntity<List></param>
/// <returns></returns>
public String GetTreeView(List<ModuleEntity> 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("<li id=\"nav" + mdel.Gid + "\"");
leftNav.Append(" title=\"" + mdel.ModuleDescription + "\"");
leftNav.Append(" onclick=\"selectmainMenu(this);" + turl + "\">");
leftNav.Append("<img src=\"../../images/icons/" + mdel.ModuleIcon + "\" align=\"absmiddle\" />&nbsp;");
leftNav.Append(mdel.ModuleDescription);
leftNav.Append("</li>");
tmpLeftTree = new StringBuilder();// class=\"TreeMenu\"
tmpLeftTree.Append("<div class=\"TreeMenu\" style=\"width:178px;height:300px;background:#FFFFEE;overflow-y:auto;overflow-x:auto\" id=\"tree" + mdel.Gid + "\">");
tmpLeftTree.Append("</div>");
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<ModuleEntity> tempEntities)
{
StringBuilder navBuilder = new StringBuilder();
if (tempEntities.Count > 0)
{
foreach (ModuleEntity mdel in tempEntities)
{
if (mdel.ParentID.Trim().Equals(0))
{
navBuilder.Append("<li id=\"nav" + mdel.Gid + "\"");
navBuilder.Append(" title=\"" + mdel.ModuleName + "\"");
navBuilder.Append(" onclick=\"selectmainMenu(this);\">");
navBuilder.Append("<img src=\"../../images/icons/" + mdel.ModuleIcon + "\" align=\"absmiddle\" />&nbsp;");
navBuilder.Append(mdel.ModuleName);
navBuilder.Append("</li>");
}
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<ModuleEntity> subModule = moduleDA.GetSubModule(tempEntity.Gid);
List<ModuleEntity> tempEntities = moduleDA.GetAllSubModules();
appTreeData.Append("<script type=\"text/javascript\">");
String strAppModelGid = "root" + tempEntity.Gid.Replace("-", "");
JSTreeNodeEntity rootData = new JSTreeNodeEntity();
rootData.Gid = strAppModelGid;
rootData.Value = tempEntity.Gid;
rootData.Text = tempEntity.ModuleDescription;
rootData.SetShowCheck = false;
rootData.CheckState = 0;
rootData.IsExpand = true;
rootData.SetChildNode = -1;
rootData.SetHasChild = true;
StringBuilder resultBuilder = new StringBuilder();
string getStr = GetSubJs(tempEntity.Gid, tempEntities);
if (tempEntity.ModuleDescription.Equals(""))
{
}
if (getStr.Length > 1)
{
//getStr = getStr.Replace("-----", "-");
getStr = getStr.Replace("--", "-");
getStr = getStr.Replace(",-", "<");
getStr = getStr.Replace("},", "}>");
//拆分同级模块
string[] strSplit = getStr.Split(new char[] { '<' });
int strLength = strSplit.Length;
for (int i = 0; i < strLength - 1; i++)
{
//拆分上下级模块以符号">"为标准
string[] strSubSplit = strSplit[i].Split(new char[] { '>' });
int strSubLength = strSubSplit.Length;
if (strSubLength > 1 )
{
for (int j = 0; j < strSubLength; j++)
{
//strSubSplit[0] = strSubSplit[0].Replace("\"null\"", "[" + strSubSplit[j] + "]");
resultBuilder.Append(strSubSplit[j] + ",");
}
}
else
{
resultBuilder.Append(strSplit[i] + ",");
}
}
}
else
{
//如果模板为主模板,自动生成相关同名子模板
JSTreeNodeEntity modelData = new JSTreeNodeEntity();
modelData.Gid = tempEntity.Gid.Replace("-", "");
modelData.Text = tempEntity.ModuleDescription;
modelData.SetShowCheck = false;
modelData.CheckState = 0;
modelData.IsExpand = false;
modelData.SetChildNode = 0;
modelData.SetClasses = tempEntity.ModuleIcon;
String tmpUrl = tempEntity.ModuleUrl.Trim();
if (!tmpUrl.Equals("#"))
{
tmpUrl = "../" + tmpUrl;
modelData.Value = "CreateTab('" + tempEntity.ModuleDescription + "','H','" + tmpUrl + "');";
modelData.SetHasChild = false;
}
else
{
modelData.Value = "javascript:void(0);";
modelData.SetHasChild = false;
}
resultBuilder.Append(ConvertToJS(modelData) + ",");
}
String strchilderData = resultBuilder.ToString();
//Response.Write(strchilderData.Length);
// Response.End();
if (strchilderData.Length > 1)
{
strchilderData = strchilderData.Substring(0, strchilderData.Length - 1);
}
else
{
strchilderData = strchilderData.Substring(0, strchilderData.Length);
}
appTreeData.Append("" + strAppModelGid + "=[" + strchilderData + "];");
appTreeData.Append("</script>");
return appTreeData.ToString();
}*/
#endregion
public String LeftTreeNodeData(ModuleEntity tempEntity)
{
StringBuilder appTreeData = new StringBuilder();
StringBuilder childerData = new StringBuilder();
ModuleDA moduleDA = new ModuleDA();
//List<ModuleEntity> subModule = moduleDA.GetSubModule(tempEntity.Gid);
//List<ModuleEntity> tempEntities = moduleDA.GetAllUserBaseSubModules();
List<ModuleEntity> subModule = moduleDA.GetSubModule(tempEntity.Gid);
List<ModuleEntity> tempEntities = moduleDA.GetAllSubModules();
if (userActionEntities.Count > 0)
{
tempEntities = null;
tempEntities = new List<ModuleEntity>();
foreach (UserActionEntity userActionEntity in userActionEntities)
{
if (userActionEntity.ActionEntity.ModuleEntity.ParentID.Trim() != "0")
{
tempEntities.Add(userActionEntity.ActionEntity.ModuleEntity);
}
}
}
appTreeData.Append("<script type=\"text/javascript\">");
String strAppModelGid = "root" + tempEntity.Gid.Replace("-", "");
JSTreeNodeEntity rootData = new JSTreeNodeEntity();
rootData.Gid = strAppModelGid;
rootData.Value = tempEntity.Gid;
rootData.Text = tempEntity.ModuleDescription;
rootData.SetShowCheck = false;
rootData.CheckState = 0;
rootData.IsExpand = false;
rootData.SetChildNode = -1;
rootData.SetHasChild = false;
StringBuilder resultBuilder = new StringBuilder();
StringBuilder tempBuilder = new StringBuilder();
string getStr = GetSubJs(tempEntity.Gid, tempEntities, "");
if (getStr.Length > 1)
{
resultBuilder.Append(getStr);
}
else
{
//如果模板为主模板,自动生成相关同名子模板
JSTreeNodeEntity modelData = new JSTreeNodeEntity();
modelData.Gid = tempEntity.Gid.Replace("-", "");
modelData.Text = tempEntity.ModuleDescription;
modelData.SetShowCheck = false;
modelData.CheckState = 0;
modelData.IsExpand = false;
modelData.SetChildNode = 0;
modelData.SetClasses = tempEntity.ModuleIcon;
String tmpUrl = tempEntity.ModuleUrl.Trim() + "?mod=" + tempEntity.ModuleName;
if (!tmpUrl.Equals("#"))
{
tmpUrl = "../" + tmpUrl;
modelData.Value = "CreateTab('" + tempEntity.ModuleDescription + "','H','" + tmpUrl + "');";
modelData.SetHasChild = true;
}
else
{
modelData.Value = "javascript:void(0);";
modelData.SetHasChild = true;
}
resultBuilder.Append(ConvertToJS(modelData) + ",");
}
////临时增加测试,正式系统删除
//string strTempTest = "{\"id\":\"root13D3C23DA46E49E5B0C4FB446534244777\",\"text\":\"系统流程\",\"value\":\"CreateTab('系统流程','H','../users/userinfo.aspx');\","
// + " \"showcheck\":0,\"complete\":1,\"isexpand\":0,\"checkstate\":0,\"hasChildren\":0,\"classes\":\"fax\",\"ChildNodes\":\"null\"}";
//resultBuilder.Append(strTempTest + ",");
String strchilderData = resultBuilder.ToString();
//Response.Write(strchilderData.Length);
// Response.End();
if (strchilderData.Length > 1 && strchilderData.EndsWith(","))
{
strchilderData = strchilderData.Substring(0, strchilderData.Length - 1);
}
else
{
strchilderData = strchilderData.Substring(0, strchilderData.Length);
}
appTreeData.Append("" + strAppModelGid + "=[" + strchilderData + "];");
appTreeData.Append("</script>");
return appTreeData.ToString();
}
/// <summary>
/// 返回
/// </summary>
/// <param name="parentGid"></param>
/// <param name="tempEntities"></param>
/// <returns></returns>
public String GetSubJs(string parentGid, List<ModuleEntity> 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<ModuleEntity> 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();
}*/
/// <summary>
/// 遍历模块查看此模块是否为父模块
/// </summary>
/// <param name="tempEntities"></param>
/// <param name="strGID"></param>
/// <returns></returns>
public bool IsParent(List<ModuleEntity> tempEntities, string strGID)
{
bool IsExist = false;
foreach (ModuleEntity mdle in tempEntities)
{
if (mdle.ParentID.Trim().Equals(strGID))
{
IsExist = true;
}
}
return IsExist;
}
#region 获取节点JSON值
/// <summary>
/// 获取节点JSON值
/// </summary>
/// <param name="tempEntity"></param>
/// <param name="hasChild"></param>
/// <returns></returns>
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
}
}