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.
DS7/DSCustomer/Default.aspx.cs

722 lines
31 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;
namespace DSCustomer
{
public partial class _Default : System.Web.UI.Page
{
//private string strUserName;
private string strUserID;
private string strShowName;
private string strRoleName;
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 == "34B7EFA1-AAA8-4576-95C7-7891B6252398")
{
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);
CRMClientDA crmClientDA = new CRMClientDA();
CRMClientEntity crmClientEntity = new CRMClientEntity();
crmClientEntity = crmClientDA.GetCrmClientInfoByGID(strUserID);
object obj = (object)crmClientEntity;
AuthorityManage authorityManage = new AuthorityManage(AuthorityManage.AuthorityType.CRMCLIENT, obj);
userActionEntities = authorityManage.GetCrmClientAction();
#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</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("<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>");
string strIntervalCount = System.Configuration.ConfigurationSettings.AppSettings["messageinterval"].ToString() as string;
if (strIntervalCount != null)
{
int iTempCount = int.Parse(strIntervalCount);
if (iTempCount < 1000)
{
strIntervalCount = "1500";
}
}
htmlBuilder.Append("<script type=\"text/javascript\" src=\"../../theme/default/js/loaderframework.js\"></script></head><body onload=\"recycleCount(" + strIntervalCount + ")\">");
/*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;\">");
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 + ")";
}
htmlBuilder.Append("<div class=\"HTitle\" style=\"position:absolute;right:0px;top:18px;\">用户名: " + strShowName + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"javascript:void(0)\" id=\"dvMessage\" style=\"color:#D6E8FF\" onclick=\"openDialog('message')\">" + strReadTotal + "</a>&nbsp;&nbsp;&nbsp;&nbsp;");
htmlBuilder.Append("<a href=\"javascript:void(0)\" onclick=\"window.open('tools/download.aspx','_blank','height=100, width=200, toolbar=no, menubar=no,scrollbars=no, resizable=1,location=no, status=no'");
htmlBuilder.Append(")\" style=\"color:#D6E8FF\">下载</a>&nbsp;&nbsp;&nbsp;&nbsp;");
htmlBuilder.Append("<a href=\"../SignOn/Logout.aspx\" style=\"color:#D6E8FF\">[退出]</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);
htmlBuilder.Append("<script type=\"text/javascript\">CreateTab(\" 首页 \",'H','MainPortal.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)
{
leftNav.Append("<li id=\"nav" + mdel.Gid + "\"");
leftNav.Append(" title=\"" + mdel.ModuleDescription + "\"");
leftNav.Append(" onclick=\"selectmainMenu(this);\">");
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\":1"); //+ (tempJSTreeEntity.IsExpand ? 1 : 0).ToString() + "");
nodeJS.Append(",");
nodeJS.Append("\"checkstate\":" + tempJSTreeEntity.CheckState + "");
nodeJS.Append(",");
nodeJS.Append("\"hasChildren\":" + (tempJSTreeEntity.SetHasChild ? 1 : 0).ToString() + "");
nodeJS.Append(",");
string classes = tempJSTreeEntity.SetClasses;
string ChildNodes = "";
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 = true;
rootData.SetChildNode = -1;
rootData.SetHasChild = true;
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
}
}