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.
428 lines
17 KiB
428 lines
17 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Data;
|
|
|
|
namespace FangYar.WebUI.ashx
|
|
{
|
|
/// <summary>
|
|
/// FireAnnHandler 的摘要说明
|
|
/// </summary>
|
|
public class FireAnnHandler : IHttpHandler
|
|
{
|
|
private FangYar.BLL.FIRE.FIRE_ANNOUNCEMENT bll = new FangYar.BLL.FIRE.FIRE_ANNOUNCEMENT();
|
|
private FangYar.BLL.TBL.SysDicdetailBLL detailbll = new FangYar.BLL.TBL.SysDicdetailBLL();
|
|
public void ProcessRequest(HttpContext context)
|
|
{
|
|
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Other, "通知公告操作请求", "");
|
|
|
|
context.Response.ContentType = "text/plain";
|
|
string action = context.Request.Params["Action"];
|
|
string returnstr = "";
|
|
|
|
switch (action)
|
|
{
|
|
case "AnnList":
|
|
returnstr = GetAnnList(context);
|
|
break;
|
|
case "Add":
|
|
returnstr = AddAnn(context);
|
|
break;
|
|
case "Edit":
|
|
returnstr = EditAnn(context);
|
|
break;
|
|
case "Del":
|
|
returnstr = DelAnn(context);
|
|
break;
|
|
case "DicdetailList":
|
|
returnstr = DicdetailList(context);
|
|
break;
|
|
case "GetAnn":
|
|
returnstr = GetAnn(context);
|
|
break;
|
|
case "HomeAnnList":
|
|
returnstr = HomeAnnList(context);
|
|
break;
|
|
}
|
|
context.Response.Write(returnstr);
|
|
}
|
|
|
|
|
|
//查询
|
|
private string GetAnnList(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string OrgId = context.Request.Params["OrgId"];
|
|
string keyword = context.Request.Params["keywords"];
|
|
string STATE = context.Request.Params["STATE"];
|
|
string page = context.Request.Params["page"];
|
|
string limit = context.Request.Params["limit"];
|
|
int pageIndex = 1;
|
|
int pageSize = 10;
|
|
if (!string.IsNullOrEmpty(page)) { pageIndex = int.Parse(page); }
|
|
if (!string.IsNullOrEmpty(limit)) { pageSize = int.Parse(limit); }
|
|
string where = " 1=1 ";
|
|
if (!string.IsNullOrEmpty(OrgId))
|
|
{
|
|
where += " and (ORG_ID ='" + OrgId + "' or ORG_ID in (select o.org_id from fire_org o where o.pid = '" + OrgId + "') )";
|
|
}
|
|
if (!string.IsNullOrEmpty(STATE))
|
|
{
|
|
if (where != null)
|
|
{
|
|
where += " and ";
|
|
}
|
|
where += " STATE = '" + STATE + "' ";
|
|
}
|
|
if (!string.IsNullOrEmpty(keyword))
|
|
{
|
|
if (where != null)
|
|
{
|
|
where += " and ";
|
|
}
|
|
where += "( TITLE like '%" + keyword + "%' or RELEASE_NAME like '%" + keyword + "%')";
|
|
}
|
|
returnstr = "{\"code\":0,\"msg\":\"\",";
|
|
int count = bll.GetRecordCount(where);
|
|
returnstr += "\"count\":" + count + ",\"data\":";
|
|
if (count == 0)
|
|
{
|
|
returnstr += "[]";
|
|
}
|
|
else
|
|
{
|
|
List<FangYar.Model.FIRE.FIRE_ANNOUNCEMENT> list = bll.QueryList(pageIndex, pageSize, where, " priority desc ,A_TIME desc");
|
|
returnstr += FangYar.Common.JsonHelper.ToJson(list);
|
|
}
|
|
returnstr += "}";
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "通知公告操作请求", "查询异常:" + e);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "通知公告操作请求", "查询");
|
|
return returnstr;
|
|
}
|
|
|
|
//添加
|
|
private string AddAnn(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
int code = -1;
|
|
string msg = "";
|
|
try
|
|
{
|
|
string type = context.Request.Params["type"];
|
|
string title = context.Request.Params["title"];
|
|
string relese_id = context.Request.Params["relese_id"];
|
|
string relese_name = context.Request.Params["relese_name"];
|
|
string relese_time = context.Request.Params["relese_time"];
|
|
|
|
string dept_id = context.Request.Params["dept_id"];
|
|
string dept_name = context.Request.Params["dept_name"];
|
|
string priority = context.Request.Params["priority"];
|
|
|
|
string state = context.Request.Params["state"];
|
|
string is_visible = context.Request.Params["is_visible"];
|
|
string is_revoke = context.Request.Params["is_revoke"];
|
|
string User_Id = context.Request.Params["User_Id"];
|
|
|
|
string ORG_ID = context.Request.Params["ORG_ID"];
|
|
string content = context.Request.Params["content"];
|
|
|
|
//表
|
|
FangYar.Model.FIRE.FIRE_ANNOUNCEMENT model = new Model.FIRE.FIRE_ANNOUNCEMENT();
|
|
model.ID = Guid.NewGuid().ToString("N");
|
|
model.TYPE = type;
|
|
model.TITLE = title;
|
|
model.RELEASE_ID = relese_id;
|
|
model.RELEASE_NAME = relese_name;
|
|
model.RELEASE_TIME = relese_time;
|
|
model.DEPT_ID = dept_id;
|
|
model.DEPT_NAME = dept_name;
|
|
model.PRIORITY = decimal.Parse(priority);
|
|
|
|
model.STATE = state;
|
|
model.IS_VISIBLE = is_visible;
|
|
model.IS_REVOKE = is_revoke;
|
|
model.A_PER = User_Id;
|
|
model.A_TIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
model.ORG_ID = ORG_ID;
|
|
model.CONTENT = content;
|
|
|
|
if (bll.Add(model))
|
|
{
|
|
msg = "添加成功!";
|
|
code = 1;
|
|
}
|
|
else { msg = "添加失败!"; }
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
msg = "添加失败!";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "通知公告操作请求", "添加异常:" + e);
|
|
}
|
|
returnstr = "{\"msg\":\"" + msg + "\",\"code\":" + code + "}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Add, "通知公告操作请求", "添加");
|
|
return returnstr;
|
|
}
|
|
|
|
//修改
|
|
private string EditAnn(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
int code = -1;
|
|
string msg = "";
|
|
try
|
|
{
|
|
|
|
string id = context.Request.Params["ID"];
|
|
string type = context.Request.Params["type"];
|
|
string title = context.Request.Params["title"];
|
|
string relese_id = context.Request.Params["relese_id"];
|
|
string relese_name = context.Request.Params["relese_name"];
|
|
string relese_time = context.Request.Params["relese_time"];
|
|
|
|
string dept_id = context.Request.Params["dept_id"];
|
|
string dept_name = context.Request.Params["dept_name"];
|
|
string priority = context.Request.Params["priority"];
|
|
|
|
string state = context.Request.Params["state"];
|
|
string is_visible = context.Request.Params["is_visible"];
|
|
string is_revoke = context.Request.Params["is_revoke"];
|
|
string User_Id = context.Request.Params["User_Id"];
|
|
|
|
string ORG_ID = context.Request.Params["ORG_ID"];
|
|
string content = context.Request.Params["content"];
|
|
|
|
//表
|
|
FangYar.Model.FIRE.FIRE_ANNOUNCEMENT model = new Model.FIRE.FIRE_ANNOUNCEMENT();
|
|
|
|
model = bll.GetModel(id);
|
|
|
|
if (model != null)
|
|
{
|
|
model.TITLE = title;
|
|
model.RELEASE_ID = relese_id;
|
|
model.RELEASE_NAME = relese_name;
|
|
model.RELEASE_TIME = relese_time;
|
|
model.DEPT_ID = dept_id;
|
|
model.DEPT_NAME = dept_name;
|
|
model.PRIORITY = decimal.Parse(priority);
|
|
|
|
model.STATE = state;
|
|
model.IS_VISIBLE = is_visible;
|
|
model.IS_REVOKE = is_revoke;
|
|
model.U_PER = User_Id;
|
|
model.U_TIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
model.ORG_ID = ORG_ID;
|
|
model.CONTENT = content;
|
|
if (bll.Update(model))
|
|
{
|
|
msg = "修改成功!";
|
|
code = 1;
|
|
}
|
|
else { msg = "修改失败!"; }
|
|
}
|
|
else
|
|
{
|
|
code = -1;
|
|
msg = "修改失败!";
|
|
}
|
|
|
|
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
msg = "修改失败!";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "通知公告操作请求", "修改异常:" + e);
|
|
}
|
|
returnstr = "{\"msg\":\"" + msg + "\",\"code\":" + code + "}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Update, "通知公告操作请求", "修改");
|
|
return returnstr;
|
|
}
|
|
|
|
//删除
|
|
private string DelAnn(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
int code = -1;
|
|
string msg = "";
|
|
try
|
|
{
|
|
string AnnList = context.Request.Params["AnnList"];
|
|
string[] AnnArray = AnnList.Split(',');
|
|
string AnnListString = "";
|
|
for (int i = 0; i < AnnArray.Length; i++)
|
|
{
|
|
if (i == 0)
|
|
{
|
|
AnnListString = "'" + AnnArray[i] + "'";
|
|
}
|
|
else
|
|
{
|
|
AnnListString += ",'" + AnnArray[i] + "'";
|
|
}
|
|
}
|
|
if (bll.DeleteList(AnnListString))
|
|
{
|
|
msg = "删除成功!";
|
|
code = 1;
|
|
}
|
|
else
|
|
{
|
|
msg = "删除失败!";
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
msg = "删除失败!";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "通知公告操作请求", "删除异常:" + e);
|
|
}
|
|
returnstr = "{\"code\":" + code + ",\"msg\":\"" + msg + "\"}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Delete, "通知公告操作请求", "删除");
|
|
return returnstr;
|
|
}
|
|
|
|
//获取公告类型
|
|
private string DicdetailList(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
|
|
try
|
|
{ //MOD_CODE: "ANN_TYPE"
|
|
string MOD_CODE = context.Request.Params["MOD_CODE"];
|
|
string where = " 1=1 ";
|
|
if (!string.IsNullOrEmpty(MOD_CODE))
|
|
{
|
|
where += " and MOD_CODE='" + MOD_CODE + "' ORDER BY DIC_ORDER DESC";
|
|
}
|
|
|
|
returnstr = "{\"code\":0,\"msg\":\"\",";
|
|
int count = detailbll.Count(where);
|
|
returnstr += "\"count\":" + count + ",\"data\":";
|
|
if (count == 0)
|
|
{
|
|
returnstr += "[]";
|
|
}
|
|
else
|
|
{
|
|
DataTable dt = detailbll.GetList(where).Tables[0];
|
|
returnstr += FangYar.Common.JsonHelper.ToJson(dt);
|
|
}
|
|
returnstr += "}";
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "通知公告操作请求", "获取公告类型异常:" + e);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "通知公告操作请求", "获取公告类型");
|
|
return returnstr;
|
|
}
|
|
|
|
|
|
private string GetAnn(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string ID = context.Request.Params["ann_id"];
|
|
|
|
|
|
returnstr = "{\"code\":0,\"msg\":\"\",";
|
|
|
|
returnstr += "\"count\":1,\"data\":";
|
|
|
|
|
|
FangYar.Model.FIRE.FIRE_ANNOUNCEMENT model = bll.GetModel(ID);
|
|
if (model != null)
|
|
{
|
|
returnstr += FangYar.Common.JsonHelper.ToJson(model);
|
|
returnstr += "}";
|
|
}
|
|
else
|
|
{
|
|
returnstr = "{\"code\":-1,\"msg\":\"error\",\"count\":0,\"data\":[]}";
|
|
}
|
|
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
returnstr = "{\"code\":-1,\"msg\":\"error\",\"count\":0,\"data\":[]}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "通知公告操作请求", "获取公告信息异常:" + e);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "通知公告操作请求", "获取公告信息");
|
|
return returnstr;
|
|
}
|
|
//查询
|
|
private string HomeAnnList(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string OrgId = context.Request.Params["OrgId"];
|
|
string DeptId = context.Request.Params["DeptId"];
|
|
string page = context.Request.Params["page"];
|
|
string limit = context.Request.Params["limit"];
|
|
int pageIndex = 1;
|
|
int pageSize = 10;
|
|
if (!string.IsNullOrEmpty(page)) { pageIndex = int.Parse(page); }
|
|
if (!string.IsNullOrEmpty(limit)) { pageSize = int.Parse(limit); }
|
|
string where = " ";
|
|
if (!string.IsNullOrEmpty(OrgId))
|
|
{
|
|
where += " org_id='" + OrgId + "' and is_del = '0' and state = '1' and (is_visible='1' or instr(dept_id,'[" + DeptId + "]')>0) ";
|
|
}
|
|
|
|
returnstr = "{\"code\":0,\"msg\":\"\",";
|
|
int count = bll.GetRecordCount(where);
|
|
returnstr += "\"count\":" + count + ",\"data\":";
|
|
if (count == 0)
|
|
{
|
|
returnstr += "[]";
|
|
}
|
|
else
|
|
{
|
|
List<FangYar.Model.FIRE.FIRE_ANNOUNCEMENT> list = bll.QueryList(pageIndex, pageSize, where, " priority desc , RELEASE_TIME desc");
|
|
returnstr += FangYar.Common.JsonHelper.ToJson(list);
|
|
}
|
|
returnstr += "}";
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "通知公告操作请求", "查询异常:" + e);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "通知公告操作请求", "查询");
|
|
return returnstr;
|
|
}
|
|
public bool IsReusable
|
|
{
|
|
get
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|