|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Web.Mvc;
|
|
|
|
|
using DSWeb.SoftMng.BLL;
|
|
|
|
|
using DSWeb.SoftMng.DBUtility;
|
|
|
|
|
using DSWeb.SoftMng.Model;
|
|
|
|
|
using DSWeb.SoftMng.Filter;
|
|
|
|
|
using System.Reflection;
|
|
|
|
|
// ReSharper disable once CheckNamespace
|
|
|
|
|
namespace DSWeb.SoftMng.Controllers
|
|
|
|
|
{
|
|
|
|
|
public class SignalRController:Controller
|
|
|
|
|
{
|
|
|
|
|
private readonly sys_messageBLL _bll = new sys_messageBLL();
|
|
|
|
|
private readonly op_message_configBLL _bllc = new op_message_configBLL();
|
|
|
|
|
private readonly op_message_moduleBLL _bllm = new op_message_moduleBLL();
|
|
|
|
|
#region View
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 即时通讯页面
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public ActionResult Index()
|
|
|
|
|
{
|
|
|
|
|
if (Session["CODENAME"] == null)
|
|
|
|
|
Response.Redirect("/login.aspx");
|
|
|
|
|
ViewData["USERID"] = Session["USERID"];
|
|
|
|
|
ViewData["CODENAME"] = Session["CODENAME"];
|
|
|
|
|
ViewData["SHOWNAME"] = Session["SHOWNAME"];
|
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 配置页面
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public ActionResult Config()
|
|
|
|
|
{
|
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 模块页面
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public ActionResult Module()
|
|
|
|
|
{
|
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Handler
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取消息提醒配置列表
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="startIndex">开始索引</param>
|
|
|
|
|
/// <param name="limit">分页大小</param>
|
|
|
|
|
/// <param name="search">搜索框的值</param>
|
|
|
|
|
/// <param name="sortName">排序字段</param>
|
|
|
|
|
/// <param name="sortOrder">排序方式</param>
|
|
|
|
|
/// <param name="status">状态(0 | 1)</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器
|
|
|
|
|
public JsonResult GetConfigList(int startIndex, int limit, string search, string sortName, string sortOrder, string status)
|
|
|
|
|
{
|
|
|
|
|
StringBuilder where = new StringBuilder();
|
|
|
|
|
where.Append(string.Format("UserCode='{0}'", Session["USERID"]));
|
|
|
|
|
if (!(String.IsNullOrEmpty(search) || String.IsNullOrWhiteSpace(search)))
|
|
|
|
|
where.Append(string.Format(" And PId in (SELECT GId from op_message_module where Name like '%{0}%' OR Descr like '%{0}%')", search));
|
|
|
|
|
//单独查询 各类别数量
|
|
|
|
|
Dictionary<string, int> dict = new Dictionary<string, int>();
|
|
|
|
|
string[] arr = { "", "0", "1"};
|
|
|
|
|
for (int i = 0; i < arr.Length; i++)
|
|
|
|
|
dict.Add(i.ToString(), _bllc.GetRecordCount(where + (arr[i] == "" ? "" : string.Format(" And IsPush = {0}", arr[i]))));
|
|
|
|
|
if (!String.IsNullOrEmpty(status))
|
|
|
|
|
where.Append(string.Format(" And IsPush = {0}", status));
|
|
|
|
|
var list = _bllc.GetModelList(startIndex, limit, where.ToString(), String.Format("{0} {1}", sortName, sortOrder));
|
|
|
|
|
var result = from p in list
|
|
|
|
|
select new
|
|
|
|
|
{
|
|
|
|
|
p.GId,
|
|
|
|
|
IsPush = p.IsPush == true ? "1" : "0",
|
|
|
|
|
p.UserCode,
|
|
|
|
|
p.UpdateTime,
|
|
|
|
|
p.PId,
|
|
|
|
|
Name = _bllm.GetModel(p.PId).Name,
|
|
|
|
|
PId_Text = _bllm.GetModel(p.PId).Descr
|
|
|
|
|
};
|
|
|
|
|
var count = _bllc.GetRecordCount(where.ToString());//总数
|
|
|
|
|
return Json(new { total = count, groupTotal = dict, rows = result });
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 保存
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="model"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public JsonResult ConfigSave(Model.op_message_config model)
|
|
|
|
|
{
|
|
|
|
|
bool result;
|
|
|
|
|
model.IsPush = Request["IsPush"] != "0";
|
|
|
|
|
if (String.IsNullOrEmpty(model.GId))
|
|
|
|
|
{
|
|
|
|
|
var count = _bllc.GetRecordCount(string.Format("PId='{0}' AND UserCode='{1}'", model.PId, Session["USERID"]));
|
|
|
|
|
if (count == 0)
|
|
|
|
|
{
|
|
|
|
|
int num = _bllc.GetRecordCount("") + 1; //编号
|
|
|
|
|
model.GId = Guid.NewGuid().ToString();
|
|
|
|
|
model.UserCode = Session["USERID"].ToString();
|
|
|
|
|
model.UpdateTime = DateTime.Now;
|
|
|
|
|
result = _bllc.Add(model) > 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
result = false;
|
|
|
|
|
|
|
|
|
|
} //新增
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
//获取原数据
|
|
|
|
|
var oldModel = _bllc.GetModel(model.GId);
|
|
|
|
|
//类反射
|
|
|
|
|
Type type = typeof(Model.op_message_config);
|
|
|
|
|
PropertyInfo[] piArr = type.GetProperties();
|
|
|
|
|
foreach (var pi in piArr)
|
|
|
|
|
{
|
|
|
|
|
if (Array.IndexOf(Request.Params.AllKeys, pi.Name) < 0)
|
|
|
|
|
pi.SetValue(model, pi.GetValue(oldModel, null), null);
|
|
|
|
|
}
|
|
|
|
|
model.UpdateTime = DateTime.Now;
|
|
|
|
|
result = _bllc.Update(model) > 0;
|
|
|
|
|
} //修改
|
|
|
|
|
return Json(new { success = result, message = result ? "操作成功" : "已存在该配置" });
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 删除
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="ids"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public JsonResult ConfigDelete(string ids)
|
|
|
|
|
{
|
|
|
|
|
bool result = _bllc.DeleteListWhere(string.Format("GId in({0})", ids)) > 0;
|
|
|
|
|
return Json(new { success = result, message = result ? "操作成功" : "操作失败" });
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取模块管理列表
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="startIndex">开始索引</param>
|
|
|
|
|
/// <param name="limit">分页大小</param>
|
|
|
|
|
/// <param name="search">搜索框的值</param>
|
|
|
|
|
/// <param name="sortName">排序字段</param>
|
|
|
|
|
/// <param name="sortOrder">排序方式</param>
|
|
|
|
|
/// <param name="status">状态(0 | 1)</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器
|
|
|
|
|
public JsonResult GetModuleList(int startIndex, int limit, string search, string sortName, string sortOrder, string status)
|
|
|
|
|
{
|
|
|
|
|
StringBuilder where = new StringBuilder();
|
|
|
|
|
where.Append("1=1");
|
|
|
|
|
if (!(String.IsNullOrEmpty(search) || String.IsNullOrWhiteSpace(search)))
|
|
|
|
|
where.Append(string.Format(" And (Name like '%{0}%' OR Descr like '%{0}%')", search));
|
|
|
|
|
//单独查询 各类别数量
|
|
|
|
|
Dictionary<string, int> dict = new Dictionary<string, int>();
|
|
|
|
|
string[] arr = { "", "0", "1" };
|
|
|
|
|
for (int i = 0; i < arr.Length; i++)
|
|
|
|
|
dict.Add(i.ToString(), _bllm.GetRecordCount(where + (arr[i] == "" ? "" : string.Format(" And IsDeleted = {0}", arr[i]))));
|
|
|
|
|
if (!String.IsNullOrEmpty(status))
|
|
|
|
|
where.Append(string.Format(" And IsDeleted = {0}", status));
|
|
|
|
|
var list = _bllm.GetModelList(startIndex, limit, where.ToString(), String.Format("{0} {1}", sortName, sortOrder));
|
|
|
|
|
var result = from p in list
|
|
|
|
|
select new
|
|
|
|
|
{
|
|
|
|
|
p.GId,
|
|
|
|
|
IsDeleted = p.IsDeleted == true ? "1" : "0",
|
|
|
|
|
p.CreateTime,
|
|
|
|
|
p.CreateUser,
|
|
|
|
|
p.Name,
|
|
|
|
|
p.Descr
|
|
|
|
|
};
|
|
|
|
|
var count = _bllm.GetRecordCount(where.ToString());//总数
|
|
|
|
|
return Json(new { total = count, groupTotal = dict, rows = result });
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 保存
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="model"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public JsonResult ModuleSave(Model.op_message_module model)
|
|
|
|
|
{
|
|
|
|
|
bool result;
|
|
|
|
|
model.IsDeleted = Request["IsDeleted"] != "0";
|
|
|
|
|
if (String.IsNullOrEmpty(model.GId))
|
|
|
|
|
{
|
|
|
|
|
var count = _bllm.GetRecordCount(string.Format("Name='{0}'", model.Name));
|
|
|
|
|
if (count == 0)
|
|
|
|
|
{
|
|
|
|
|
model.GId = Guid.NewGuid().ToString();
|
|
|
|
|
model.CreateUser = Session["SHOWNAME"].ToString();
|
|
|
|
|
model.CreateTime = DateTime.Now;
|
|
|
|
|
result = _bllm.Add(model) > 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
result = false;
|
|
|
|
|
|
|
|
|
|
} //新增
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
//获取原数据
|
|
|
|
|
var oldModel = _bllm.GetModel(model.GId);
|
|
|
|
|
//类反射
|
|
|
|
|
Type type = typeof(Model.op_message_module);
|
|
|
|
|
PropertyInfo[] piArr = type.GetProperties();
|
|
|
|
|
foreach (var pi in piArr)
|
|
|
|
|
{
|
|
|
|
|
if (Array.IndexOf(Request.Params.AllKeys, pi.Name) < 0)
|
|
|
|
|
pi.SetValue(model, pi.GetValue(oldModel, null), null);
|
|
|
|
|
}
|
|
|
|
|
result = _bllm.Update(model) > 0;
|
|
|
|
|
} //修改
|
|
|
|
|
return Json(new { success = result, message = result ? "操作成功" : "已存在该配置" });
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 删除
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="ids"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public JsonResult ModuleDelete(string ids)
|
|
|
|
|
{
|
|
|
|
|
bool result = _bllm.DeleteListWhere(string.Format("GId in({0})", ids)) > 0;
|
|
|
|
|
return Json(new { success = result, message = result ? "操作成功" : "操作失败" });
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 懒加载模块信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="pageIndex"></param>
|
|
|
|
|
/// <param name="pageSize"></param>
|
|
|
|
|
/// <param name="query"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public JsonResult GetInfoModuleList(int pageIndex, int pageSize, string query)
|
|
|
|
|
{
|
|
|
|
|
StringBuilder where = new StringBuilder();
|
|
|
|
|
if (!String.IsNullOrEmpty(query))
|
|
|
|
|
where.Append(string.Format("Name LIKE '%{0}%' OR Descr LIKE '%{0}%'", query));
|
|
|
|
|
var list = _bllm.GetModelList(pageIndex, pageSize, where.ToString(), "Descr collate Chinese_PRC_CS_AS_KS_WS");
|
|
|
|
|
var total = _bllm.GetRecordCount(where.ToString());
|
|
|
|
|
var result = from p in list
|
|
|
|
|
select new
|
|
|
|
|
{
|
|
|
|
|
id = p.GId,
|
|
|
|
|
text = p.Descr
|
|
|
|
|
};
|
|
|
|
|
return Json(new { data = result, total }, JsonRequestBehavior.AllowGet);
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取历史消息通知
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="userid"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public JsonResult GetHistoryMsg(string userid)
|
|
|
|
|
{
|
|
|
|
|
StringBuilder where = new StringBuilder();
|
|
|
|
|
where.Append(string.Format("RECEIVER ='{0}'", userid));
|
|
|
|
|
var list = _bll.GetModelList(0,200,where.ToString(), "CREATETIME DESC").OrderBy(p=>p.ISREAD).ToList();
|
|
|
|
|
return Json(list);
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 设置消息状态
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public JsonResult SetMsgStatus(string gid,int status)
|
|
|
|
|
{
|
|
|
|
|
var model = _bll.GetModel(gid);
|
|
|
|
|
model.ISREAD = status == 0 ? false : true;
|
|
|
|
|
var result = _bll.Update(model)>0;
|
|
|
|
|
return Json(result);
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|