using System; using System.Text; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using QMFrameWork.Data; using QMFrameWork.Common.Serialization; using QMFrameWork.WebUI.Attribute; using QMFrameWork.WebUI.Menu; using QMFrameWork.WebUI.DataSource; using QMAPP.Web.Models; using QMAPP.Web.Models.Sys; using QMAPP.Entity.Sys; using QMAPP.Common.Web.Util; using QMAPP.Common.Web.Controllers; namespace QMAPP.Web.Controllers { [SessionState(System.Web.SessionState.SessionStateBehavior.ReadOnly)] public class AppDesktopController : QController { // // GET: /Desktop/ public ActionResult Index() { //获取未读通知页面显示html字符串 string unReadNoticeStr = NoticeRemind(); ViewData["unReadNoticeStr"] = unReadNoticeStr; //判断是否存在过期的问题没有处理 CheckOverTimeProblem(); DefaultModel model = new DefaultModel(); model.UserDes = AccountController.GetLoginInfo().UserName; return View(model); } #region 构建桌面 [HandleException] public ActionResult Main() { DefaultModel model = new DefaultModel(); MenuHelper helper = new MenuHelper(); List items = null; //获取菜单 List menus = helper.GetAllMenus().OrderBy(p=>p.Seq).ToList(); //构建颜色 List color = new List(); //color.Add("#6EBB21"); //color.Add("#414141"); //color.Add("#01AD63"); //color.Add("#9F8701"); color.Add("#B3C1CC"); color.Add("#2889CA"); color.Add("#84B356"); //color.Add("#013668"); color.Add("#FFB251"); color.Add("#67ACD3"); color.Add("#9889C1"); color.Add("#D54D7F"); //color.Add("#C139B5"); StringBuilder sBuilder = new StringBuilder(); int indexColor = 0; //获取用户设置信息 QMAPP.ServicesAgent.ServiceAgent agent = this.GetServiceAgent(); items = agent.InvokeServiceFunction>("DeskTopItemBLL_GetList"); //获取末级菜单 List lastLevelMenus = menus.Where(p => p.Action != ""&&items.Exists(i=>i.MENUID==p.MenuID)==true).ToList(); foreach (MenuInfo menu in lastLevelMenus) { DeskTopItem find = items.Find(p => p.MENUID == menu.MenuID); if (find != null) menu.Seq = find.SORT; } lastLevelMenus = lastLevelMenus.OrderBy(p => p.Seq).ToList(); #region 构建桌面快捷方式 foreach (MenuInfo menu in lastLevelMenus) { MenuInfo parentMenu = menus.Find(p => p.MenuID == menu.SuperID); if (indexColor > color.Count - 1) { indexColor = 0; } if (menu.MenuID == "Support030000") { menu.MenuDes += "(3)"; } if (menu.MenuID == "01060000") { menu.MenuDes += "(1)"; } sBuilder.Append(string.Format("
\r\n", color[indexColor % color.Count], menu.MenuID, indexColor, menu.SystemID)); sBuilder.Append(string.Format(" \r\n")); sBuilder.Append(string.Format(" \r\n")); sBuilder.Append(string.Format(" \r\n")); sBuilder.Append(string.Format(" \r\n")); sBuilder.Append(string.Format(" \r\n")); sBuilder.Append(string.Format(" \r\n")); sBuilder.Append(string.Format(" \r\n")); sBuilder.Append(string.Format(" \r\n")); sBuilder.Append(string.Format("
\r\n")); sBuilder.Append(string.Format("
\r\n")); sBuilder.Append(string.Format(" {0}
\r\n", menu.MenuDes)); sBuilder.Append(string.Format("
\r\n")); sBuilder.Append(string.Format(" \r\n", "1111", "系统菜单")); sBuilder.Append(string.Format(" \r\n")); sBuilder.Append(string.Format("
\r\n")); sBuilder.Append(string.Format(" {0}
\r\n", parentMenu!=null?parentMenu.MenuDes:menu.MenuDes)); sBuilder.Append(string.Format("
\r\n")); sBuilder.Append(string.Format("
\r\n")); indexColor++; } model.MenuHtml = sBuilder.ToString(); #endregion return View(model); } #endregion #region 菜单树 /// /// 菜单树 /// /// 处理结果 public ActionResult GetMenus() { List list = new List(); List menus = null; string systemID = Request.QueryString["SystemID"]; LoginInfo login = null; List items = null; try { login = AccountController.GetLoginInfo(); //获取已添加的菜单 QMAPP.ServicesAgent.ServiceAgent agent = this.GetServiceAgent(); items = agent.InvokeServiceFunction>("DeskTopItemBLL_GetList"); //获取系统权限信息 if (string.IsNullOrEmpty(systemID)==true) systemID = "Main"; menus = new MenuHelper().GetMenuInfos(); menus = menus.Where(p => p.SystemID == systemID).ToList(); foreach (MenuInfo info in menus) { if (login.LoginUserID != "admin" && login.Powers.Contains(info.PowerID) == false) { continue; } TreeNodeResult node = new TreeNodeResult(); node.Tid = info.MenuID; node.Ttext = info.MenuDes; //添加子权限 this.BuildChildItems(node, info.ChildMenus,login,items); list.Add(node); } return Content(TreeNodeResult.GetResultJosnS(list.ToArray())); } catch (Exception ex) { throw ex; } } /// /// 创建子权限 /// /// 父节点 /// 子权限 /// 已经选中的权限列表 private void BuildChildItems(TreeNodeResult parentNode, List childMenus, LoginInfo login, List items) { foreach (MenuInfo info in childMenus) { if (items.Exists(p => p.MENUID == info.MenuID) == true) { continue; } if (login.LoginUserID != "admin" && login.Powers.Contains(info.PowerID) == false) { continue; } TreeNodeResult node = new TreeNodeResult(); node.Tid = info.PowerID; node.Ttext = info.MenuDes; //如果为空,那么结束循环 if (info.ChildMenus != null) { //添加子权限 this.BuildChildItems(node, info.ChildMenus,login,items); } parentNode.AddchildNode(node); } } #endregion #region 添加桌面快捷方式 public ActionResult AddDesktopItem() { return View("AddDesktopItem",new DesktopModel()); } #endregion #region 保存桌面快捷方式 /// /// 保存桌面快捷方式 /// /// 桌面快捷方式信息 /// [HandleException] public ActionResult SaveItem(DesktopModel model) { string list = ""; if (string.IsNullOrEmpty(model.SelectedMenus1)==false) list += ":" + model.SelectedMenus1; if (string.IsNullOrEmpty(model.SelectedMenus2)==false) list += ":" + model.SelectedMenus2; if (string.IsNullOrEmpty(model.SelectedMenus3)==false) list += ":" + model.SelectedMenus3; if (string.IsNullOrEmpty(model.SelectedMenus4)==false) list += ":" + model.SelectedMenus4; if (string.IsNullOrEmpty(model.SelectedMenus5)==false) list += ":" + model.SelectedMenus5; QMAPP.ServicesAgent.ServiceAgent agent = this.GetServiceAgent(); agent.InvokeServiceFunction("DeskTopItemBLL_Inserts",list); return this.GetJsViewResult(string.Format("parent.submitByButton(\"Main\");parent.showTitle('{0}');parent.closeAppWindow1();" , AppResource.SaveMessge)); } #endregion #region 交换桌面项位置 /// /// 交换桌面项位置 /// /// 结果 [HandleException] public int ExchangeSort(string guid1, string guid2) { if (string.IsNullOrEmpty(guid1) || string.IsNullOrEmpty(guid2)) { return 0; } if (guid1 == "undefined" || guid2 == "undefined") { return 0; } QMAPP.ServicesAgent.ServiceAgent agent = new QController().GetServiceAgent(); agent.InvokeServiceFunction("DeskTopItemBLL_ExchangeSort", guid1, guid2); return 1; } #endregion #region 删除桌面显示项 /// /// 删除桌面显示项 /// /// 结果 [HandleException] public int Delete(string guid) { if (string.IsNullOrEmpty(guid)) { return 0; } QMAPP.ServicesAgent.ServiceAgent agent = new QController().GetServiceAgent(); int count = agent.InvokeServiceFunction("DeskTopItemBLL_Delete", guid); return count; } #endregion #region 获取未读通知 王丹丹 /// /// 获取未读通知 /// /// public string NoticeRemind() { NoticeInfoModel model = new NoticeInfoModel(); NoticeInfo notice = new NoticeInfo(); string noticestr = ""; string noticeNoReadCount = ""; try { notice.UserID = AccountController.GetLoginInfo().UserID; //获取未读通知 QMAPP.ServicesAgent.ServiceAgent agent = new QController().GetServiceAgent(); model.listNoticeModel = agent.InvokeServiceFunction>("NoticeManageBll_GetNotReadNotice", notice); //获取未读通知的数量 noticeNoReadCount = model.listNoticeModel.Count(item => item.ISREAD == "0").ToString(); noticestr = "
  • "; noticestr += " " + noticeNoReadCount + " "; noticestr += "
  • "; return noticestr; } catch (Exception ex) { throw ex; } } #endregion #region 判断是否有过期问题没有处理 /// /// 判断是否有过期问题没有处理 /// public void CheckOverTimeProblem() { //获取未读通知 QMAPP.ServicesAgent.ServiceAgent agent = new QController().GetServiceAgent(); agent.InvokeServiceFunction("OverTimeRemindBLL_CheckCurrenUserOverTime1Remind"); //Object result = agent.InvokeServiceFunction("OverTimeRemindBLL_CheckCurrenUserOverTime2Remind"); //Console.WriteLine(Convert.ToString(result)); } #endregion } }