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.
389 lines
14 KiB
389 lines
14 KiB
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<DeskTopItem> items = null;
|
|
|
|
//获取菜单
|
|
List<MenuInfo> menus = helper.GetAllMenus().OrderBy(p=>p.Seq).ToList();
|
|
|
|
//构建颜色
|
|
List<string> color = new List<string>();
|
|
//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<List<DeskTopItem>>("DeskTopItemBLL_GetList");
|
|
|
|
//获取末级菜单
|
|
List<MenuInfo> 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("<div class='dIcon' style=\"background: {0};\" value=\"{1}\" id=ico{2} onclick=\"gotoMenu('{1}','{3}');\">\r\n", color[indexColor % color.Count], menu.MenuID, indexColor, menu.SystemID));
|
|
|
|
sBuilder.Append(string.Format(" <table style=\"height: 100%;width:100%;\">\r\n"));
|
|
sBuilder.Append(string.Format(" <tr>\r\n"));
|
|
sBuilder.Append(string.Format(" <td colspan=\"2\" valign=middle>\r\n"));
|
|
sBuilder.Append(string.Format(" <div style=\"margin-left: 10px; margin-top: 8px;height:30px;color: #fff; font-size: 18px; font-weight: 900;font-family:黑体;\">\r\n"));
|
|
sBuilder.Append(string.Format(" {0}</div>\r\n", menu.MenuDes));
|
|
sBuilder.Append(string.Format(" </td>\r\n"));
|
|
sBuilder.Append(string.Format(" </tr>\r\n"));
|
|
sBuilder.Append(string.Format(" <tr>\r\n"));
|
|
sBuilder.Append(string.Format(" <td>\r\n"));
|
|
sBuilder.Append(string.Format(" <img style=\"width: 60px;border:none;\" src=\"../../Content/default/desk_set.png\" title=\"{1}\" />\r\n", "1111", "系统菜单"));
|
|
sBuilder.Append(string.Format(" </td>\r\n"));
|
|
sBuilder.Append(string.Format(" <td align=left width=\"100%\">\r\n"));
|
|
sBuilder.Append(string.Format(" <div style=\"color: #fff; font-size: 14px;font-family:黑体;left: 1px; position: relative;\">\r\n"));
|
|
sBuilder.Append(string.Format(" {0}</div>\r\n", parentMenu!=null?parentMenu.MenuDes:menu.MenuDes));
|
|
sBuilder.Append(string.Format(" </td>\r\n"));
|
|
sBuilder.Append(string.Format(" </tr>\r\n"));
|
|
sBuilder.Append(string.Format(" </table>\r\n"));
|
|
|
|
sBuilder.Append(string.Format(" </div>\r\n"));
|
|
indexColor++;
|
|
}
|
|
model.MenuHtml = sBuilder.ToString();
|
|
|
|
#endregion
|
|
|
|
return View(model);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 菜单树
|
|
/// <summary>
|
|
/// 菜单树
|
|
/// </summary>
|
|
/// <returns>处理结果</returns>
|
|
public ActionResult GetMenus()
|
|
{
|
|
List<TreeNodeResult> list = new List<TreeNodeResult>();
|
|
List<MenuInfo> menus = null;
|
|
string systemID = Request.QueryString["SystemID"];
|
|
LoginInfo login = null;
|
|
List<DeskTopItem> items = null;
|
|
try
|
|
{
|
|
login = AccountController.GetLoginInfo();
|
|
|
|
//获取已添加的菜单
|
|
QMAPP.ServicesAgent.ServiceAgent agent = this.GetServiceAgent();
|
|
items = agent.InvokeServiceFunction<List<DeskTopItem>>("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;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 创建子权限
|
|
/// </summary>
|
|
/// <param name="parentNode">父节点</param>
|
|
/// <param name="childPowers">子权限</param>
|
|
/// <param name="pu">已经选中的权限列表</param>
|
|
private void BuildChildItems(TreeNodeResult parentNode, List<MenuInfo> childMenus, LoginInfo login, List<DeskTopItem> 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 保存桌面快捷方式
|
|
|
|
/// <summary>
|
|
/// 保存桌面快捷方式
|
|
/// </summary>
|
|
/// <param name="model">桌面快捷方式信息</param>
|
|
/// <returns></returns>
|
|
[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 交换桌面项位置
|
|
|
|
/// <summary>
|
|
/// 交换桌面项位置
|
|
/// </summary>
|
|
/// <returns>结果</returns>
|
|
[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 删除桌面显示项
|
|
|
|
/// <summary>
|
|
/// 删除桌面显示项
|
|
/// </summary>
|
|
/// <returns>结果</returns>
|
|
[HandleException]
|
|
public int Delete(string guid)
|
|
{
|
|
if (string.IsNullOrEmpty(guid))
|
|
{
|
|
return 0;
|
|
}
|
|
QMAPP.ServicesAgent.ServiceAgent agent = new QController().GetServiceAgent();
|
|
int count = agent.InvokeServiceFunction<int>("DeskTopItemBLL_Delete", guid);
|
|
|
|
return count;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 获取未读通知 王丹丹
|
|
/// <summary>
|
|
/// 获取未读通知
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
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<List<NoticeInfo>>("NoticeManageBll_GetNotReadNotice", notice);
|
|
|
|
//获取未读通知的数量
|
|
noticeNoReadCount = model.listNoticeModel.Count(item => item.ISREAD == "0").ToString();
|
|
noticestr = "<li class=\"purple\"><a data-toggle=\"dropdown\" class=\"dropdown-toggle\" href=\"#\"> ";
|
|
noticestr += "<i class=\"ace-icon fa fa-bell icon-animated-bell\"></i><span class=\"badge badge-important\"> " + noticeNoReadCount + " </span> </a>";
|
|
noticestr += "<ul class=\"dropdown-menu-right dropdown-navbar navbar-pink dropdown-menu dropdown-caret dropdown-close\">";
|
|
noticestr += "<li class=\"dropdown-header\"><i class=\"ace-icon fa fa-exclamation-triangle\"></i>" + noticeNoReadCount + "条通知</li>";
|
|
|
|
foreach (var item in model.listNoticeModel)
|
|
{
|
|
string noticeTitle = "";
|
|
string noticeTime = "";
|
|
string noticeID = "";
|
|
noticeTitle = item.NOTICETITLE;
|
|
noticeTime = item.USETIME.ToShortDateString();
|
|
noticeID = item.NOTICEID;
|
|
noticestr += "<li><a href=\"#\" onclick=\"ClickNotice('" + noticeID + "');\"><div class=\"clearfix\"><span class=\"pull-left\">";
|
|
noticestr += "<i class=\"btn btn-xs no-hover btn-success fa fa-bell\"></i> " + noticeTitle + "</span>";
|
|
noticestr += "<span class=\"pull-right badge badge-success\">" + noticeTime + "</span></div></a></li>";
|
|
}
|
|
|
|
noticestr += "<li class=\"dropdown-footer\"><a href=\"#\" onclick=\"MoreNotice();\">查看所有通告<i class=\"ace-icon fa fa-arrow-right\">";
|
|
noticestr += "</i></a></li></ul></li>";
|
|
|
|
return noticestr;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 判断是否有过期问题没有处理
|
|
|
|
/// <summary>
|
|
/// 判断是否有过期问题没有处理
|
|
/// </summary>
|
|
public void CheckOverTimeProblem()
|
|
{
|
|
//获取未读通知
|
|
QMAPP.ServicesAgent.ServiceAgent agent = new QController().GetServiceAgent();
|
|
agent.InvokeServiceFunction<bool>("OverTimeRemindBLL_CheckCurrenUserOverTime1Remind");
|
|
//Object result = agent.InvokeServiceFunction<Object>("OverTimeRemindBLL_CheckCurrenUserOverTime2Remind");
|
|
//Console.WriteLine(Convert.ToString(result));
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|
|
|