软测单独项目
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.
 
 
 
 
 
 

562 lines
25 KiB

using System;
using System.Data;
using System.Web;
namespace FangYar.WebUI.ashx
{
/// <summary>
/// SysMessageLogHandler APP消息通知(日志)
/// </summary>
public class SysMessageLogHandler : IHttpHandler
{
private FangYar.BLL.TBL.SysMessageLogBLL bll = new FangYar.BLL.TBL.SysMessageLogBLL();
public void ProcessRequest(HttpContext context)
{
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Other, "APP消息通知操作请求", "");
context.Response.ContentType = "text/plain";
string action = context.Request.Params["Action"];
string returnstr = "";
switch (action)
{
case "GetPendingCountByReceiveId":
returnstr = GetPendingCountByReceiveId(context);
break;
case "GetListByReceiveId":
returnstr = GetListByReceiveId(context);
break;
case "Add":
returnstr = Add(context);
break;
case "Edit":
returnstr = Edit(context);
break;
case "EditState":
returnstr = EditState(context);
break;
case "GetListByOrgId":
returnstr = GetListByOrgId(context);
break;
case "GetListByPartyOrgId":
returnstr = GetListByPartyOrgId(context);
break;
case "GetListByMettingId":
returnstr = GetListByMettingId(context);
break;
}
context.Response.Write(returnstr);
}
//根据接收人uid获取未读数
private string GetPendingCountByReceiveId(HttpContext context)
{
return "{\"code\":200,\"msg\":\"操作成功!\",\"count\":0}";
//string returnstr = "";
//try
//{
// string receiveId = context.Request.Params["receiveId"];
// if (string.IsNullOrEmpty(receiveId))
// {
// return "{\"code\":\"-1\",\"msg\":\"请求异常,请联系平台管理员。\",\"error\":\"receiveId参数不能为空!\",\"count\":0}";
// }
// int pendingCount = bll.GetPendingCount(receiveId);
// returnstr = "{\"code\":200,\"msg\":\"操作成功!\",\"count\":" + pendingCount + "}";
//}
//catch (Exception e)
//{
// returnstr = "{\"code\":-2,\"msg\":\"网络异常!\",\"error\":\"" + e.Message + "\",\"count\":0}";
// // 记录操作日志
// BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP消息通知操作请求", "根据接收人uid获取未读数异常:" + e);
//}
//// 记录操作日志
//BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP消息通知操作请求", "根据接收人uid获取未读数");
//return returnstr;
}
//根据接收人uid获取消息通知(日志)(包含分页)
private string GetListByReceiveId(HttpContext context)
{
string returnstr = "";
try
{
string receiveId = context.Request.Params["receiveId"];
string orderById = context.Request.Params["orderById"];
string state = context.Request.Params["state"];
string page = context.Request.Params["page"];
string limit = context.Request.Params["limit"];
if (string.IsNullOrEmpty(receiveId))
{
return "{\"code\":\"-1\",\"msg\":\"请求异常,请联系平台管理员。\",\"error\":\"receiveId参数不能为空!\",\"data\":[]}";
}
int pageIndex = 1;
int pageSize = 10;
if (!string.IsNullOrEmpty(page)) { pageIndex = int.Parse(page); }
if (!string.IsNullOrEmpty(limit)) { pageSize = int.Parse(limit); }
string whereStr = " RECEIVEID = '" + receiveId + "' and STATE = '" + state + "'";
int count = bll.GetListCount(whereStr);
returnstr = "{\"code\":200,\"msg\":\"操作成功!\",\"count\":" + count + ",\"data\":";
if (count > 0)
{
DataTable dt = bll.GetList(pageIndex, pageSize, receiveId, state, orderById);
returnstr += FangYar.Common.JsonHelper.ToJson(dt);
}
else
{
returnstr += "[]";
}
returnstr += "}";
}
catch (Exception e)
{
returnstr = "{\"code\":-2,\"msg\":\"网络异常!\",\"error\":\"" + e.Message + "\",\"data\":[]}";
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP消息通知操作请求", "根据接收人uid获取消息通知异常:" + e);
}
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP消息通知操作请求", "根据接收人uid获取消息通知");
return returnstr;
}
//添加
private string Add(HttpContext context)
{
string returnstr = "";
int code = -1;
string msg = "";
string id = "";
try
{
string TITLE = context.Request.Params["TITLE"];
string CONTENT = context.Request.Params["CONTENT"];
string SENDID = context.Request.Params["SENDID"];
string SENDNAME = context.Request.Params["SENDNAME"];
string SENDTIME = context.Request.Params["SENDTIME"];
string TYPE = context.Request.Params["TYPE"];
string URL = context.Request.Params["MESSAGEURL"];
string PARAM = context.Request.Params["PARAM"];
string RECEIVEID = context.Request.Params["RECEIVEID"];
string RECEIVENAME = context.Request.Params["RECEIVENAME"];
string OPENTIME = context.Request.Params["OPENTIME"];
string STATE = context.Request.Params["STATE"];
string ORG_ID = context.Request.Params["ORG_ID"];
string PARTY_ORG_ID = context.Request.Params["PARTY_ORG_ID"];
string IS_CAMP = context.Request.Params["IS_CAMP"];
string METTING_ID = context.Request.Params["METTING_ID"];
string EXTENDCODE1 = context.Request.Params["EXTENDCODE1"];
string EXTENDCODE2 = context.Request.Params["EXTENDCODE2"];
string EXTENDCODE3 = context.Request.Params["EXTENDCODE3"];
string EXTENDCODE4 = context.Request.Params["EXTENDCODE4"];
string EXTENDCODE5 = context.Request.Params["EXTENDCODE5"];
string EXTENDCODE6 = context.Request.Params["EXTENDCODE6"];
FangYar.Model.TBL.TBL_MESSAGE_LOG model = new Model.TBL.TBL_MESSAGE_LOG();
model.ID = Guid.NewGuid().ToString("N");
model.TITLE = TITLE;
model.CONTENT = CONTENT;
model.SENDID = SENDID;
model.SENDNAME = SENDNAME;
model.SENDTIME = SENDTIME;
model.TYPE = TYPE;
model.URL = URL;
model.PARAM = PARAM;
model.RECEIVEID = RECEIVEID;
model.RECEIVENAME = RECEIVENAME;
model.OPENTIME = OPENTIME;
model.STATE = STATE;
model.ORG_ID = ORG_ID;
model.PARTY_ORG_ID = PARTY_ORG_ID;
model.IS_CAMP = IS_CAMP;
model.METTING_ID = METTING_ID;
model.EXTENDCODE1 = EXTENDCODE1;
model.EXTENDCODE2 = EXTENDCODE2;
model.EXTENDCODE3 = EXTENDCODE3;
model.EXTENDCODE4 = EXTENDCODE4;
model.EXTENDCODE5 = EXTENDCODE5;
model.EXTENDCODE6 = EXTENDCODE6;
if (bll.AddLog(model))
{
msg = "添加成功!";
code = 1;
id = model.ID;
}
else { msg = "添加失败!"; }
}
catch (Exception e)
{
msg = e.Message;
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP消息通知操作请求", "添加异常:" + e);
}
returnstr = "{\"msg\":\"" + msg + "\",\"code\":" + code + ",\"id\":\"" + id + "\"}";
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Add, "APP消息通知操作请求", "添加");
return returnstr;
}
//修改
private string Edit(HttpContext context)
{
string returnstr = "";
int code = -1;
string msg = "";
try
{
string ID = context.Request.Params["ID"];
string TITLE = context.Request.Params["TITLE"];
string CONTENT = context.Request.Params["CONTENT"];
string SENDID = context.Request.Params["SENDID"];
string SENDNAME = context.Request.Params["SENDNAME"];
string SENDTIME = context.Request.Params["SENDTIME"];
string TYPE = context.Request.Params["TYPE"];
string URL = context.Request.Params["MESSAGEURL"];
string PARAM = context.Request.Params["PARAM"];
string RECEIVEID = context.Request.Params["RECEIVEID"];
string RECEIVENAME = context.Request.Params["RECEIVENAME"];
string OPENTIME = context.Request.Params["OPENTIME"];
string STATE = context.Request.Params["STATE"];
string ORG_ID = context.Request.Params["ORG_ID"];
string PARTY_ORG_ID = context.Request.Params["PARTY_ORG_ID"];
string IS_CAMP = context.Request.Params["IS_CAMP"];
string METTING_ID = context.Request.Params["METTING_ID"];
string EXTENDCODE1 = context.Request.Params["EXTENDCODE1"];
string EXTENDCODE2 = context.Request.Params["EXTENDCODE2"];
string EXTENDCODE3 = context.Request.Params["EXTENDCODE3"];
string EXTENDCODE4 = context.Request.Params["EXTENDCODE4"];
string EXTENDCODE5 = context.Request.Params["EXTENDCODE5"];
string EXTENDCODE6 = context.Request.Params["EXTENDCODE6"];
FangYar.Model.TBL.TBL_MESSAGE_LOG model = new Model.TBL.TBL_MESSAGE_LOG();
model.ID = ID;
model.TITLE = TITLE;
model.CONTENT = CONTENT;
model.SENDID = SENDID;
model.SENDNAME = SENDNAME;
model.SENDTIME = SENDTIME;
model.TYPE = TYPE;
model.URL = URL;
model.PARAM = PARAM;
model.RECEIVEID = RECEIVEID;
model.RECEIVENAME = RECEIVENAME;
model.OPENTIME = OPENTIME;
model.STATE = STATE;
model.ORG_ID = ORG_ID;
model.PARTY_ORG_ID = PARTY_ORG_ID;
model.IS_CAMP = IS_CAMP;
model.METTING_ID = METTING_ID;
model.EXTENDCODE1 = EXTENDCODE1;
model.EXTENDCODE2 = EXTENDCODE2;
model.EXTENDCODE3 = EXTENDCODE3;
model.EXTENDCODE4 = EXTENDCODE4;
model.EXTENDCODE5 = EXTENDCODE5;
model.EXTENDCODE6 = EXTENDCODE6;
if (bll.EditLog(model))
{
msg = "修改成功!";
code = 1;
}
else { msg = "修改失败!"; }
}
catch (Exception e)
{
msg = "修改失败!";
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP消息通知操作请求", "修改异常:" + e);
}
returnstr = "{\"msg\":\"" + msg + "\",\"code\":" + code + "}";
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Update, "APP消息通知操作请求", "修改");
return returnstr;
}
//修改状态 0:未读;1:已读
private string EditState(HttpContext context)
{
string returnstr = "";
int code = -1;
string msg = "";
try
{
string ID = context.Request.Params["ID"];
string receiveId = context.Request.Params["receiveId"];
string cls = context.Request.Params["cls"]; //0单条 1 全部
string openTime = DateTime.Now.ToString("G");
if (string.IsNullOrEmpty(cls))
{
return "{\"code\":\"-1\",\"msg\":\"请求异常,请联系平台管理员。\",\"error\":\"cls参数不能为空!\",\"count\":0}";
}
if (cls == "0")
{
if (bll.EditLog(ID, openTime, "1")) //更新为已读
{
msg = "修改成功!";
code = 1;
}
else { msg = "修改失败!"; }
}
else if (cls == "1")
{
if (bll.EditReceiveLog(receiveId, openTime, "1")) //更新为已读
{
msg = "修改成功!";
code = 1;
}
else { msg = "修改失败!"; }
}
}
catch (Exception e)
{
msg = "修改失败!";
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP消息通知操作请求", "修改状态 0:未读;1:已读异常:" + e);
}
returnstr = "{\"msg\":\"" + msg + "\",\"code\":" + code + "}";
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Update, "APP消息通知操作请求", "修改状态 0:未读;1:已读");
return returnstr;
}
//根据机构ID获取消息通知(日志)(包含分页)
private string GetListByOrgId(HttpContext context)
{
string returnstr = "";
try
{
string orgId = context.Request.Params["orgId"];
string treeId = context.Request.Params["treeId"];
string searchVal = context.Request.Params["searchVal"];
string startDate = context.Request.Params["startDate"];
string endDate = context.Request.Params["endDate"];
string isContent = context.Request.Params["isContent"];
string page = context.Request.Params["page"];
string limit = context.Request.Params["limit"];
if (string.IsNullOrEmpty(orgId))
{
return "{\"code\":\"-1\",\"msg\":\"请求异常,请联系平台管理员。\",\"error\":\"orgId参数不能为空!\",\"data\":[]}";
}
int pageIndex = 1;
int pageSize = 10;
if (!string.IsNullOrEmpty(page)) { pageIndex = int.Parse(page); }
if (!string.IsNullOrEmpty(limit)) { pageSize = int.Parse(limit); }
if (!string.IsNullOrEmpty(treeId) && treeId != orgId)
{
orgId = treeId;
}
string sql = "select t.*,(select o.org_name from fire_org o where o.org_id = t.org_id) as org_name from tbl_message_log t ,(select get_Org_child_list('" + orgId + "') cids) s ";
string where = "";
if (isContent == "1")
{
where = " ( find_in_set(org_id, cids) ) ";
}
else
{
where = " ORG_ID = '" + orgId + "'";
}
if (!string.IsNullOrEmpty(searchVal))
{
where += " and SENDNAME like '%" + searchVal + "%' ";
}
if (!string.IsNullOrEmpty(startDate))
{
where += " and date_format(SENDTIME,'%Y-%m-%d') >= date_format('" + startDate + "','%Y-%m-%d') ";
}
if (!string.IsNullOrEmpty(endDate))
{
where += " and date_format(SENDTIME,'%Y-%m-%d') <= date_format('" + endDate + "','%Y-%m-%d') ";
}
object obj = FangYar.Common.MySqlHelper.GetSingle("select count(1) from tbl_message_log ,(select get_Org_child_list('" + orgId + "') cids) s " + " where " + where);
int count = 0;
if (obj != null) { count = Convert.ToInt32(obj); }
returnstr = "{\"code\":0,\"msg\":\"操作成功!\",\"count\":" + count + ",\"data\":";
if (count > 0)
{
where += " order by state,sendtime desc ";
where += " limit " + (pageIndex - 1) * pageSize + ", " + pageSize;
DataTable dt = FangYar.Common.MySqlHelper.QueryTable(sql + " where " + where);
returnstr += FangYar.Common.JsonHelper.ToJson(dt) + "}";
}
else
{
returnstr += "[]}";
}
}
catch (Exception e)
{
returnstr = "{\"code\":-2,\"msg\":\"网络异常!\",\"error\":\"" + e.Message + "\",\"data\":[]}";
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP消息通知操作请求", "根据机构ID获取消息通知异常:" + e);
}
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP消息通知操作请求", "根据机构ID获取消息通知");
return returnstr;
}
#region 党建专属接口
//根据所属党组织ID获取消息通知(日志)(包含分页)
private string GetListByPartyOrgId(HttpContext context)
{
string returnstr = "";
try
{
string partyOrgId = context.Request.Params["partyOrgId"];
string treeId = context.Request.Params["treeId"];
string searchVal = context.Request.Params["searchVal"];
string startDate = context.Request.Params["startDate"];
string endDate = context.Request.Params["endDate"];
string isContent = context.Request.Params["isContent"];
string page = context.Request.Params["page"];
string limit = context.Request.Params["limit"];
if (string.IsNullOrEmpty(partyOrgId))
{
return "{\"code\":\"-1\",\"msg\":\"请求异常,请联系平台管理员。\",\"error\":\"partyOrgId参数不能为空!\",\"data\":[]}";
}
int pageIndex = 1;
int pageSize = 10;
if (!string.IsNullOrEmpty(page)) { pageIndex = int.Parse(page); }
if (!string.IsNullOrEmpty(limit)) { pageSize = int.Parse(limit); }
if (!string.IsNullOrEmpty(treeId) && treeId != partyOrgId)
{
partyOrgId = treeId;
}
string sql = "select t.* from tbl_message_log t ";
string where = " ";
//if (isContent == "1")
//{
// where = " instr(',' || PARTY_ORG_PIDS || ',',',' || '" + partyOrgId + "' || ',')<> 0 ";
//}
//else
//{
where = " PARTY_ORG_ID = '" + partyOrgId + "'";
//}
if (!string.IsNullOrEmpty(searchVal))
{
where += " and SENDNAME like '%" + searchVal + "%' ";
}
if (!string.IsNullOrEmpty(startDate))
{
where += " and date_format(SENDTIME,'%Y-%m-%d') >= date_format('" + startDate + "','%Y-%m-%d') ";
}
if (!string.IsNullOrEmpty(endDate))
{
where += " and date_format(SENDTIME,'%Y-%m-%d') <= date_format('" + endDate + "','%Y-%m-%d') ";
}
object obj = FangYar.Common.MySqlHelper.GetSingle("select count(1) from tbl_message_log " + " where " + where);
int count = 0;
if (obj != null) { count = Convert.ToInt32(obj); }
returnstr = "{\"code\":0,\"msg\":\"操作成功!\",\"count\":" + count + ",\"data\":";
if (count > 0)
{
where += " order by state,sendtime desc ";
where += " limit " + (pageIndex - 1) * pageSize + ", " + pageSize;
DataTable dt = FangYar.Common.MySqlHelper.QueryTable(sql + " where " + where);
returnstr += FangYar.Common.JsonHelper.ToJson(dt) + "}";
}
else
{
returnstr += "[]}";
}
}
catch (Exception e)
{
returnstr = "{\"code\":-2,\"msg\":\"网络异常!\",\"error\":\"" + e.Message + "\",\"data\":[]}";
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP消息通知操作请求", "根据所属党组织ID获取消息通知异常:" + e);
}
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP消息通知操作请求", "根据所属党组织ID获取消息通知");
return returnstr;
}
//根据清单ID获取消息通知(日志)
private string GetListByMettingId(HttpContext context)
{
string returnstr = "";
try
{
string mettingId = context.Request.Params["mettingId"];
string searchVal = context.Request.Params["searchVal"];
string startDate = context.Request.Params["startDate"];
string endDate = context.Request.Params["endDate"];
if (string.IsNullOrEmpty(mettingId))
{
return "{\"code\":\"-1\",\"msg\":\"请求异常,请联系平台管理员。\",\"error\":\"mettingId参数不能为空!\",\"data\":[]}";
}
string sql = "select t.* from tbl_message_log t ";
string where = " METTING_ID = '" + mettingId + "'";
if (!string.IsNullOrEmpty(searchVal))
{
where += " and SENDNAME like '%" + searchVal + "%' ";
}
if (!string.IsNullOrEmpty(startDate))
{
where += " and date_format(SENDTIME,'%Y-%m-%d') >= date_format('" + startDate + "','%Y-%m-%d') ";
}
if (!string.IsNullOrEmpty(endDate))
{
where += " and date_format(SENDTIME,'%Y-%m-%d') <= date_format('" + endDate + "','%Y-%m-%d') ";
}
object obj = FangYar.Common.MySqlHelper.GetSingle("select count(1) from tbl_message_log " + " where " + where);
int count = 0;
if (obj != null) { count = Convert.ToInt32(obj); }
returnstr = "{\"code\":0,\"msg\":\"操作成功!\",\"count\":" + count + ",\"data\":";
if (count > 0)
{
where += " order by state,sendtime desc ";
DataTable dt = FangYar.Common.MySqlHelper.QueryTable(sql + " where " + where);
returnstr += FangYar.Common.JsonHelper.ToJson(dt) + "}";
}
else
{
returnstr += "[]}";
}
}
catch (Exception e)
{
returnstr = "{\"code\":-2,\"msg\":\"网络异常!\",\"error\":\"" + e.Message + "\",\"data\":[]}";
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP消息通知操作请求", "根据清单ID获取消息通知异常:" + e);
}
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP消息通知操作请求", "根据清单ID获取消息通知");
return returnstr;
}
#endregion
public bool IsReusable
{
get
{
return false;
}
}
}
}