一厂MES,含注塑,喷涂,冲孔
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

83 lines
2.8 KiB

using MESClassLibrary.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MESClassLibrary.BLL.Log;
using System.Reflection;
using System.Data;
using MESClassLibrary.DAL.User;
namespace MESClassLibrary.BLL.User
{
public class Sys_NavMenuService
{
/// <summary>
/// 根据userID查询用户菜单
/// </summary>
/// <param name="userID"></param>
/// <returns></returns>
public List<Sys_NavMenuInfo> BuilderLeftMenu(string userID)
{
try
{
List<Sys_NavMenuInfo> returnList = new List<Sys_NavMenuInfo>();
Sys_NavMenuData dal = new Sys_NavMenuData();
DataTable dt = new DataTable();
List<Sys_NavMenuInfo> navList = new List<Sys_NavMenuInfo>();
dt = dal.BuilderLeftMenu(userID);
navList = Tool.ConvertTo<Sys_NavMenuInfo>(dt).OrderBy(p=>p.OrderNum).ToList();
foreach (Sys_NavMenuInfo item in navList)
{
Sys_NavMenuInfo menuItem = BuilderItem(item, navList);
if (menuItem != null)
returnList.Add(menuItem);
}
return returnList;
}
catch(Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
/// <summary>
/// 生成菜单list
/// </summary>
/// <param name="powers"></param>
/// <param name="item"></param>
/// <param name="allItem"></param>
/// <returns></returns>
public Sys_NavMenuInfo BuilderItem(Sys_NavMenuInfo item, List<Sys_NavMenuInfo> allItem)
{
Sys_NavMenuInfo returnItem = new Sys_NavMenuInfo();
returnItem.ItemPic = item.ItemPic;
returnItem.MenuID = item.MenuID;
returnItem.MenuName = item.MenuName;
returnItem.OrderNum = item.OrderNum;
returnItem.ParentMenuID = item.ParentMenuID;
returnItem.PowerID = item.PowerID;
returnItem.URLStr = item.URLStr;
List<Sys_NavMenuInfo> subItemList = new List<Sys_NavMenuInfo>();
StringBuilder sb = new StringBuilder();
List<Sys_NavMenuInfo> subList = allItem.FindAll(p => p.ParentMenuID == item.MenuID).OrderBy(p=>p.OrderNum).ToList();
if (subList.Count > 0)
{
foreach (Sys_NavMenuInfo subItem in subList.OrderBy(p => p.OrderNum))
{
returnItem.SubNavMenuList.Add(subItem);
}
}
if (returnItem.SubNavMenuList.Count == 0)
return null;
else
return returnItem;
}
}
}