using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using PMS.BusinessModels.Account;
using PMS.Interface;
using PMS.Interface.Problems;
using PMS.Interface.SysManager;
using QWPlatform.SystemLibrary.LogManager;
using QWPlatform.SystemLibrary;
using PMS.Interface.MessageManage;
namespace PMS.WebUI.Controllers
{
///
/// 创 建 人:王海洋
/// 创建日期:2018-12-10
/// 功能描述:系统首页控制器
///
public class HomeController : BaseController
{
//todo:test
ISystemModule systemModule = InterfaceFactory.CreateBusinessInstance();
//问题查询接口
IProjectProblems problems = InterfaceFactory.CreateBusinessInstance();
IMessageManage notice = InterfaceFactory.CreateBusinessInstance();
// GET: Home
public ActionResult Index()
{
//var user = ViewData["Account"] as UserInfo;
var user = this.GetCurrentUser();
if (user != null)
{//显示用户姓名
ViewBag.Name = user.Name;
ViewBag.Company = user.Company;
ViewBag.Email = user.Email;
ViewBag.Account = user.Account;
ViewBag.UserProp = string.Format("{0}({1})", user.PersonPropertyString(), user.PersonJob);
ViewBag.UserId = user.PersonID;//人员ID
ViewBag.PersonProperty = user.PersonProperty;
}
return View();
}
//GET:首页
public ActionResult Dashboard()
{
ViewBag.RYXZ = GetCurrentUser().PersonProperty;
return View();
}
//未完成的问题列表
public ActionResult NotFinishProblem(string Type)
{
ViewBag.Type = Type;
ViewBag.PersonProperty = GetCurrentUser().PersonProperty;
return View();
}
//查询未完成的数量:首页使用
public ActionResult QueryNotFinishCount()
{
var user = this.GetCurrentUser();
var dt = problems.QueryNotFinishProblem(user.PersonID, user.PersonProperty, user.CompanyID, user.DefaultProjectID, user.OrgID);
return Content(dt.ToJson(), "text/json");
}
[HttpGet]
//查询未完成问题列表:首页使用
public ActionResult NotFinishProblemList(int Type,int page = 1, int rows = 20 )
{
var user = this.GetCurrentUser();
var json = problems.NotFinishProblemList(user.PersonID, user.PersonProperty, user.CompanyID, user.DefaultProjectID, user.OrgID, Type, page, rows);
return Content(json, "text/json");
}
//查询各渠道的问题数量
public ActionResult QueryCompanyProblemCount()
{
System.Data.DataTable dt = null;
var user = this.GetCurrentUser();
if (user.PersonProperty == 1)
{//中联人员显示所有渠道信息
dt = problems.QueryCompanyProblemCount();
}
else if (user.PersonProperty == 2 || user.PersonProperty == 5)
{//渠道人员(渠道卫计委显示所有机构问题)
dt = problems.QueryOrgProblemCount(user.CompanyID);
}
else
{//机构管理员与用户显示该机构所有用户问题数量
dt = problems.QueryOrgPersonProblemCount(user.OrgID);
}
return Content(dt.ToJson(), "text/json");
}
//查询我的问题
public ActionResult QueryMyProblemList()
{
var user = this.GetCurrentUser();
var dt = problems.QueryMyProblemList(user.PersonID);
return Content(dt.ToJson(), "text/json");
}
//查询出问题停留位置
public ActionResult QueryAllProblemStopWorkFlow()
{
var user = this.GetCurrentUser();
var dt = problems.QueryAllProblemStopWorkFlow(user.PersonProperty, user.CompanyID, user.OrgID, user.PersonID);
return Content(dt.ToJson(), "text/json");
}
//常见问题top5
public ActionResult QueryOftenProblemList()
{
var dt = problems.QueryOftenProblemList();
return Content(dt.ToJson(), "text/json");
}
//我的配置信息
public ActionResult MyConfigInfo()
{
var user = this.GetCurrentUser();
var obj = account_obj.GetConfigInfo(user.ID);
ViewBag.PersonProperty = user.PersonProperty;
if (obj == null)
{
obj = new NotefiyConfigInfo()
{
Assign = new ConfigInfo(),
BackTime = new ConfigInfo(),
SolveTime = new ConfigInfo(),
StopTime = new ConfigInfo()
};
}
return View(obj);
}
//保存个人配置信息
public ActionResult SaveConfigInfo(my_configinfo myconfiginfo)
{
var user = this.GetCurrentUser();
var r = account_obj.SaveConfig(myconfiginfo, user.ID);
return Content(r ? "1" : "0");
}
[HttpGet]
public ActionResult GetMenus()
{//todo:需要获取用户信息
var user = this.GetCurrentUser();
if (user != null)
{
var str = systemModule.GetTreeMenu(user.Roles, user.IsSuperAdmin);
return Content(str, "application/json");
}
else
{
Logger.Instance.Warn("登录用户信息为空,请重新登录");
return null;
}
}
#region 消息
public ActionResult MessageDeatil(string id)
{
ViewBag.ID = id;
return View();
}
public ActionResult GetMessageDeatilById(string id)
{
var json = notice.SelecteMessageById(id);
return Content(json, "text/json");
}
public ActionResult MessageList()
{
var user= this.GetCurrentUser();
var config = account_obj.GetMessageInfo(user.ID);
if(config!=null )
{
ViewBag.IsOpen = config.IsOpen;
}
else
{
ViewBag.IsOpen = "true";
}
return View();
}
public ActionResult MessageSet()
{
return View();
}
//保存消息配置
public ActionResult SaveMessageInfo(Mssage_config Mssage_config)
{
var user = this.GetCurrentUser();
var r = account_obj.SaveMessageInfo(Mssage_config, user.ID);
return Content(r ? "1" : "0");
}
#endregion
}
}