private static void DoLaodTree(FineUI.Tree tree,
bool EnableCheckBox = false,
bool AutoPostBack = false,
bool Expanded = true,
bool LoadAllNodeFirst = false,
bool IsLoadByDuty = false)
{
Obosoft.BLL.oBo_NavForDeveloper bll = new BLL.oBo_NavForDeveloper();
DataSet ds = bll.GetList("");
List<string> listMenu = new List<string>();
if (IsLoadByDuty == true)
{
listMenu = GetDutyList();
}
if (ds != null && ds.Tables[0].Rows.Count > 0)
{
tree.Nodes.Clear();
FineUI.TreeNode topNode = new FineUI.TreeNode(); ;
if (LoadAllNodeFirst == true)
{
topNode.SingleClickExpand = true;
topNode.Text = "全部";
topNode.NodeID = "Total";
topNode.EnableCheckBox = EnableCheckBox;
topNode.AutoPostBack = true;
topNode.Expanded = Expanded;
tree.Nodes.Add(topNode);
}
DataRow[] data = ds.Tables[0].Select("ParentID = 0 ", "Sort");
foreach (DataRow drRow in data)
{
int id = Util.ToInt(drRow["ID"]);
string title = Util.ToStr(drRow["TITLE"]);
string parentID = Util.ToStr(drRow["PARENTID"]);
int Rank = Util.ToInt(drRow["REMARK"]);
int Sort = Util.ToInt(drRow["SORT"]);
FineUI.TreeNode parentNode = new FineUI.TreeNode();
parentNode.SingleClickExpand = true;
parentNode.Text = title;
//设置是否显示单选框
parentNode.EnableCheckBox = EnableCheckBox;
parentNode.NodeID = id.ToString();
parentNode.AutoPostBack = true;
parentNode.Expanded = Expanded;
//如果根据权限读取树节点 并且当前节点不在能打开的权限列表中 则不执行添加节点操作
if (IsLoadByDuty == true && listMenu.Contains(id.ToString()) == false)
{
continue;
}
if (LoadAllNodeFirst == true)
{
topNode.Nodes.Add(parentNode);
}
else
{
tree.Nodes.Add(parentNode);
}
LoadProductTypeTree(ds, parentNode, id.ToString(), EnableCheckBox, AutoPostBack, Expanded, IsLoadByDuty);
}
}
}
/// <summary>
/// 获取当前用户可访问权限列表
/// </summary>
/// <returns></returns>
private static List<string> GetDutyList()
{
//加载当前用户所拥有的权限列表
List<string> listMenu = new List<string>();
//如果根据权限读取树
//if (Util.IsNullOrEmpty(System.Web.HttpContext.Current.Session[SessionNames.UserData]) == false)
//{
Obosoft.Model.oBo_AdminGroup adminGroupModel = new Obosoft.Model.oBo_AdminGroup();
BLL.oBo_Admin bll = new BLL.oBo_Admin();
BLL.oBo_AdminGroup logic = new BLL.oBo_AdminGroup();
int ID = Util.ToInt(System.Web.HttpContext.Current.Session["ID"]);
Model.oBo_Admin model = bll.GetModel(ID);
if (Util.IsNullOrEmpty(model) == false)
{
DataSet dsDuty = logic.GetList(" id in (" + model.AdmPower + ")");
if (Util.IsDataSetHasDataRow(dsDuty) == true)
{
string strDutys = Util.GetFirstRowValue(dsDuty, Model.oBo_AdminGroup_Def.m_PowerList_Def);
string[] menus = strDutys.Replace("[", "").Replace("]", "").Split(',');
foreach (string item in menus)
{
listMenu.Add(item);
}
}
}
if (listMenu.Count <= 0)
{
//Model.oBo_AdminGroup dutyModel = logic.GetModel(4);
//string[] menus = dutyModel.PowerList.Replace("[", "").Replace("]", "").Split(',');
//foreach (string item in menus)
//{
// listMenu.Add(item);
//}
}
//}
return listMenu;
} |