using System; using System.Collections.Generic; using System.Linq; using System.Web; using Estsh.Web.Util; using System.Data; using Estsh.Web.Dal; using System.Collections; using Estsh.Web.Models; /*************************************************************************************************** * * 作者:王勇 * * *************************************************************************************************/ namespace Estsh.Core.Services { /// /// 菜单业务处理类 /// public class NoticeService { private NoticeDal dal = new NoticeDal(RemotingProxyProvider._remotingProxy); /// /// 获取菜单列表 /// /// /// /// public List getNoticeList(UserInfo userInfo, String rootPath) { DataTable dt = new DataTable(); dt = dal.getListByUser(userInfo.empId); List treeNodes = new List(); TreeNode node; for (int i = 0; i < dt.Rows.Count; i++) { node = new TreeNode(); node.id = dt.Rows[i]["Notice_id"].ToString(); node.name = dt.Rows[i]["name"] != null ? dt.Rows[i]["name"].ToString() : ""; node.parentId = dt.Rows[i]["parent_id"] != null ? dt.Rows[i]["parent_id"].ToString() : "0"; node.icon = dt.Rows[i]["icon_url"] != null ? dt.Rows[i]["icon_url"].ToString() : ""; if (node.parentId.Equals("10")) { node.iconSkin = dt.Rows[i]["icon_skin"] != null ? dt.Rows[i]["icon_skin"].ToString() : ""; } else { node.tabUrl = rootPath + (dt.Rows[i]["url"] != null ? dt.Rows[i]["url"].ToString() : ""); } node.target = "frmright"; treeNodes.Add(node); } return treeNodes; } /// /// 获取首页菜单列表 /// /// /// public Hashtable getHomeNoticeList(UserInfo userInfo, string NoticeId) { Hashtable result = new Hashtable(); result = dal.getHomeNoticeListByUser(userInfo.empId, NoticeId); return result; } /// /// 获取Main页主菜单列表 /// /// /// public Hashtable getMainNoticeList(UserInfo userInfo, string NoticeId) { DataTable dt = new DataTable(); dt = dal.getMainNoticeListByUser(userInfo.empId, NoticeId); Hashtable result = new Hashtable(); List dataList = new List(); Hashtable node; for (int i = 0; i < dt.Rows.Count; i++) { node = new Hashtable(); node.Add("id", dt.Rows[i]["Notice_id"].ToString()); node.Add("name",dt.Rows[i]["name"] != null ? dt.Rows[i]["name"].ToString() : ""); node.Add("className", dt.Rows[i]["icon_skin"] != null ? dt.Rows[i]["icon_skin"].ToString() : ""); dataList.Add(node); } result.Add("list", dataList); return result; } /// /// 获取Main页子菜单列表 /// /// /// public Hashtable getChildNoticeList(UserInfo userInfo, string NoticeId,string rootPath) { DataTable dt = new DataTable(); dt = dal.getMainNoticeListByUser(userInfo.empId, NoticeId); Hashtable result = new Hashtable(); List treeNodes = new List(); TreeNode node; for (int i = 0; i < dt.Rows.Count; i++) { node = new TreeNode(); node.id = dt.Rows[i]["Notice_id"].ToString(); node.name = dt.Rows[i]["name"] != null ? dt.Rows[i]["name"].ToString() : ""; node.parentId = dt.Rows[i]["parent_id"] != null ? dt.Rows[i]["parent_id"].ToString() : "0"; node.icon = dt.Rows[i]["icon_url"] != null ? dt.Rows[i]["icon_url"].ToString() : ""; node.tabUrl = rootPath + (dt.Rows[i]["url"] != null ? dt.Rows[i]["url"].ToString() : ""); node.target = "frmright"; treeNodes.Add(node); } result.Add("treeNodes", treeNodes); return result; } /// /// 获取非tab的Main页子菜单列表 /// /// /// public Hashtable getNoNTabChildNoticeList(UserInfo userInfo, string NoticeId, string rootPath) { DataTable dt = new DataTable(); dt = dal.getMainNoticeListByUser(userInfo.empId, NoticeId); Hashtable result = new Hashtable(); List treeNodes = new List(); TreeNode node; for (int i = 0; i < dt.Rows.Count; i++) { node = new TreeNode(); node.id = dt.Rows[i]["Notice_id"].ToString(); node.name = dt.Rows[i]["name"] != null ? dt.Rows[i]["name"].ToString() : ""; node.parentId = dt.Rows[i]["parent_id"] != null ? dt.Rows[i]["parent_id"].ToString() : "0"; node.icon = dt.Rows[i]["icon_url"] != null ? dt.Rows[i]["icon_url"].ToString() : ""; node.url = rootPath + (dt.Rows[i]["url"] != null ? dt.Rows[i]["url"].ToString() : ""); node.target = "frmright"; treeNodes.Add(node); } result.Add("treeNodes", treeNodes); return result; } /// /// 根据分页条件获取分页数据 /// /// /// /// /// /// public Hashtable getNoticeListByPage(String NoticeName, Pager pager, String direction, String sort, string str) { Hashtable result = new Hashtable(); result = dal.getListByPage(pager.pageSize, pager.pageNo, str); return result; } /// /// 获取下拉框中的菜单数据 /// /// public ArrayList getSelectNotice() { Hashtable result = new Hashtable(); DataTable dt = dal.getSelectNotice(); return DataTypeConvert.NewObject.DataTableToArrayList(dt); } /// /// 保存菜单数据 /// /// /// public int saveNotice(Hashtable htParams) { return dal.saveNotice(htParams); } /// /// 更新菜单数据 /// /// /// public int updateNotice(Hashtable htParams) { return dal.updateNotice(htParams); } /// /// 查看菜单详情 /// /// /// public ArrayList getNoticeDetail(String CONTENT_NO) { DataTable dt = dal.getList(CONTENT_NO); ArrayList result = DataTypeConvert.NewObject.DataTableToArrayList(dt); return result; } /// /// 删除菜单 /// /// /// public int deleteNotice(String ids) { String[] idArray = ids.Split(','); int count = 0; foreach (String id in idArray) { if (!"".Equals(id)) { count += this.dal.deleteNotice(id); } } return count; } } }