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.
832 lines
34 KiB
832 lines
34 KiB
using FangYar.BLL.TBL;
|
|
using FangYar.FYMQTT;
|
|
using FangYar.Model.TBL;
|
|
using Platform.Infrastructure;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.IO;
|
|
using System.Linq.Expressions;
|
|
using System.Text;
|
|
using System.Web;
|
|
|
|
namespace FangYar.WebUI.ashx
|
|
{
|
|
/// <summary>
|
|
/// NoticeHandler 的摘要说明
|
|
/// </summary>
|
|
public class NoticeHandler : IHttpHandler
|
|
{
|
|
private FangYar.BLL.OA.OA_NOTICE bll = new BLL.OA.OA_NOTICE();
|
|
private BLL.OA.OA_DUTYMANAGE dutymanage = new BLL.OA.OA_DUTYMANAGE();
|
|
SysEmpBLL sysEmp = new SysEmpBLL();
|
|
|
|
SysNoticeBLL noticBLL = new SysNoticeBLL();
|
|
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 "List":
|
|
returnstr = List(context);
|
|
break;
|
|
case "Add":
|
|
returnstr = Add(context);
|
|
break;
|
|
case "Edit":
|
|
returnstr = Edit(context);
|
|
break;
|
|
case "Del":
|
|
returnstr = Del(context);
|
|
break;
|
|
case "getDicdetail":
|
|
returnstr = getDicdetail(context);
|
|
break;
|
|
case "GetDeptAndPersonTree":
|
|
returnstr = GetDeptAndPersonTree(context);
|
|
break;
|
|
case "QueryUnReadNotice":
|
|
returnstr = QueryUnReadNoticeListByUserId(context);
|
|
break;
|
|
case "UnReadList":
|
|
returnstr = QueryUnReadList(context);
|
|
break;
|
|
case "AlreadRead":
|
|
returnstr = QueryAlreadReadList(context);
|
|
break;
|
|
case "UpdateStatus":
|
|
returnstr = UpdateStatus(context);
|
|
break;
|
|
}
|
|
|
|
context.Response.Write(returnstr);
|
|
}
|
|
//查询
|
|
private string List(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string orgId = context.Request.Params["orgId"];
|
|
string type = context.Request.Params["cls"];
|
|
|
|
string keyword = context.Request.Params["keywords"];
|
|
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); }
|
|
Expression<Func<TBL_SYS_NOTICE, bool>> expression = PredicateExtensions.True<TBL_SYS_NOTICE>();
|
|
string where = "1=1 ";
|
|
|
|
if (!String.IsNullOrWhiteSpace(orgId))
|
|
{
|
|
where += " and ORGID = '" + orgId + "' ";
|
|
}
|
|
if (!String.IsNullOrWhiteSpace(keyword))
|
|
{
|
|
where += " and Title like '" + keyword + "'";
|
|
}
|
|
if (!String.IsNullOrWhiteSpace(type))
|
|
{
|
|
where += " and type= '" + type + "'";
|
|
}
|
|
int count = noticBLL.Count(where);
|
|
var list = noticBLL.QueryList(pageIndex, pageSize, where, "SendTime desc");
|
|
|
|
returnstr = "{\"code\":0,\"msg\":\"\",";
|
|
returnstr += "\"count\":" + count + ",\"data\":";
|
|
if (list.Count > 0)
|
|
{
|
|
returnstr += Common.JsonHelper.ToJson(list);
|
|
}
|
|
else
|
|
{
|
|
returnstr += "[]";
|
|
}
|
|
returnstr += "}";
|
|
}
|
|
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 getDicdetail(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string mod_code = context.Request.Params["mod_code"];
|
|
|
|
string where = " mod_code = '" + mod_code + "' ";
|
|
FangYar.BLL.TBL.SysDicdetailBLL dicbll = new BLL.TBL.SysDicdetailBLL();
|
|
|
|
returnstr = "{\"code\":0,\"msg\":\"\",";
|
|
returnstr += "\"count\":-1,\"data\":";
|
|
|
|
DataTable dt = dicbll.GetList(where).Tables[0];
|
|
returnstr += FangYar.Common.JsonHelper.ToJson(dt);
|
|
|
|
returnstr += "}";
|
|
}
|
|
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 Add(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
int code = -1;
|
|
string msg = "";
|
|
MQTT mqttPush = new MQTT();
|
|
try
|
|
{
|
|
string id = Guid.NewGuid().ToString("N");
|
|
|
|
string type = context.Request.Params["type"];//类型
|
|
string title = context.Request.Params["title"];//标题
|
|
string receiver = context.Request.Params["receiver"];//接收人
|
|
string receiverName = context.Request.Params["receiverName"];//接收人名称
|
|
string isPublic = context.Request.Params["isPublic"];//是否发布
|
|
string artst_time = context.Request.Params["artst_time"];
|
|
string arten_time = context.Request.Params["arten_time"];
|
|
string source = context.Request.Params["source"];//;来源
|
|
string pic = context.Request.Params["pic"];//图片
|
|
string digest = context.Request.Params["digest"];//摘要
|
|
string content = context.Request.Params["content"];
|
|
string orgId = context.Request.Params["org_id"];
|
|
string org_name = context.Request.Params["org_name"];
|
|
string uid = context.Request.Params["uid"];
|
|
string uname = context.Request.Params["uname"];
|
|
string receiverType = context.Request.Params["receiverType"];
|
|
byte[] outputb = Convert.FromBase64String(content);
|
|
string orgStr = Encoding.Default.GetString(outputb);
|
|
string text = HttpUtility.UrlDecode(orgStr);//将Url中的编码转换为简体汉字 , System.Text.Encoding.GetEncoding("GB2312")
|
|
|
|
////存储图片
|
|
string picture = GetUploadImg(context);
|
|
TBL_SYS_NOTICE model = new TBL_SYS_NOTICE();
|
|
model.Id = id;
|
|
model.Sender = uid;
|
|
model.SenderName = uname;
|
|
model.OrgId = orgId;
|
|
model.SendTime = DateTime.Now;
|
|
model.Title = title;
|
|
model.Content = text;
|
|
model.Receiver = receiver;
|
|
model.ReceiverName = receiverName;
|
|
model.AttachFile = picture;
|
|
model.Type = type;
|
|
model.Category = "1";
|
|
model.IsPublic = isPublic;
|
|
model.Digest = digest;
|
|
model.Source = source;
|
|
List<TBL_SYS_NOTICESENDRECORD> noticeSendRecord = new List<TBL_SYS_NOTICESENDRECORD>();
|
|
List<TBL_SYS_EMP_Model> userList = new List<TBL_SYS_EMP_Model>();
|
|
if (receiverType == "org")
|
|
{
|
|
userList = sysEmp.QueryListByOrgIdOrDeptId(receiver);
|
|
for (int i = 0; i < userList.Count; i++)
|
|
{
|
|
noticeSendRecord.Add(new TBL_SYS_NOTICESENDRECORD
|
|
{
|
|
Id = Guid.NewGuid().ToString("N"),
|
|
NoticeId = id,
|
|
Receiver = userList[i].USERS_UID,
|
|
ReceiverName = userList[i].EMP_NAME,
|
|
CreateDate = DateTime.Now,
|
|
Status = "0"
|
|
});
|
|
}
|
|
}
|
|
else
|
|
{
|
|
noticeSendRecord.Add(new TBL_SYS_NOTICESENDRECORD
|
|
{
|
|
Id = Guid.NewGuid().ToString("N"),
|
|
NoticeId = id,
|
|
Receiver = receiver,
|
|
ReceiverName = receiverName,
|
|
CreateDate = DateTime.Now,
|
|
Status = "0"
|
|
});
|
|
}
|
|
try
|
|
{
|
|
List<FangYar.Model.OA.CommonSql> sqls = noticBLL.Add(model, noticeSendRecord);
|
|
|
|
if (FangYar.Common.MySqlHelper.ExecuteSqlTranBool(sqls))
|
|
{
|
|
msg = "添加成功!";
|
|
code = 1;
|
|
if (isPublic == "1")
|
|
{
|
|
var jsonstr = "{\"Title\":\"" + title + "\",\"Type\":\"Remind\",\"Url\":\"" + "/OA/Notice/List.html" + "\"}";
|
|
if (userList.Count > 0)
|
|
{
|
|
for (int i = 0; i < userList.Count; i++)
|
|
{
|
|
mqttPush.messagePublished(jsonstr, "XJYQ/" + userList[i].ORG_ID + "/" + userList[i].USERS_UID + "/PC/PushMsg");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
mqttPush.messagePublished(jsonstr, "XJYQ/" + orgId + "/" + receiver + "/PC/PushMsg");
|
|
}
|
|
|
|
}
|
|
}
|
|
else
|
|
{
|
|
msg = "添加失败!";
|
|
code = -1;
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
msg = "添加失败!";
|
|
code = -1;
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "通知公告操作请求", "添加内异常:" + e);
|
|
}
|
|
//if (common.Insert(model))
|
|
//{
|
|
// mqttPush.messagePublished("", "");
|
|
// msg = "添加成功!";
|
|
// code = 1;
|
|
//}
|
|
//else { msg = "添加失败!"; }
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
msg = "添加失败!";
|
|
code = -1;
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "通知公告操作请求", "添加异常:" + e);
|
|
}
|
|
returnstr = "{\"msg\":\"" + msg + "\",\"code\":" + code + "}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Add, "通知公告操作请求", "添加");
|
|
return returnstr;
|
|
}
|
|
|
|
|
|
//图片上传
|
|
private string GetUploadImg(HttpContext context)
|
|
{
|
|
string returnStr = "";
|
|
|
|
try
|
|
{
|
|
string serverPath = "Upload/OA/Kon/";
|
|
string base64Str = context.Request.Params["pic"];
|
|
if (!String.IsNullOrWhiteSpace(base64Str))
|
|
{
|
|
base64Str = base64Str.Replace("data:image/png;base64,", "").Replace("data:image/jgp;base64,", "")
|
|
.Replace("data:image/jpg;base64,", "").Replace("data:image/jpeg;base64,", ""); //将base64头部信息替换
|
|
|
|
|
|
byte[] imageBytes = Convert.FromBase64String(base64Str);
|
|
using (MemoryStream ms = new MemoryStream(imageBytes, 0, imageBytes.Length))
|
|
{
|
|
ms.Write(imageBytes, 0, imageBytes.Length);
|
|
|
|
System.Drawing.Image img = Image.FromStream(ms, true);//将流中的图片转换为Image图片对象
|
|
//ms.Close();
|
|
//ms.Dispose();
|
|
Random ran = new Random((int)DateTime.Now.Ticks);//利用时间种子解决伪随机数短时间重复问题
|
|
if (!Directory.Exists(context.Server.MapPath("~/" + serverPath)))
|
|
{
|
|
DirectoryInfo directoryInfo = new DirectoryInfo(context.Server.MapPath("~/" + serverPath));
|
|
directoryInfo.Create();
|
|
}
|
|
|
|
//文件保存位置及命名,精确到毫秒并附带一组随机数,防止文件重名,数据库保存路径为此变量
|
|
//string serverPath = "Upload/Device/";
|
|
string filename = serverPath + DateTime.Now.ToString("yyyyMMddhhmmssms") + ran.Next(99999) + ".jpg";
|
|
//路径映射为绝对路径
|
|
string path = context.Server.MapPath("~/") + filename;
|
|
|
|
img.Save(path);//图片保存,JPEG格式图片较小
|
|
returnStr = filename;
|
|
}
|
|
|
|
}
|
|
}
|
|
catch (Exception ex) { }
|
|
return returnStr;
|
|
}
|
|
|
|
//修改
|
|
private string Edit(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 receiver = context.Request.Params["receiver"];
|
|
string receiverName = context.Request.Params["receiverName"];
|
|
string isPublic = context.Request.Params["isPublic"];
|
|
string artst_time = context.Request.Params["artst_time"];
|
|
string arten_time = context.Request.Params["arten_time"];
|
|
|
|
string source = context.Request.Params["source"];
|
|
string art_pic = context.Request.Params["pic"];
|
|
string art_pictype = context.Request.Params["art_pictype"];
|
|
string digest = context.Request.Params["digest"];
|
|
string content = context.Request.Params["content"];
|
|
|
|
string orgId = context.Request.Params["org_id"];
|
|
string orgName = context.Request.Params["org_name"];
|
|
string sender = context.Request.Params["uid"];
|
|
string senderName = context.Request.Params["uname"];
|
|
string receiverType = context.Request.Params["receiverType"];
|
|
|
|
byte[] outputb = Convert.FromBase64String(content);
|
|
string orgStr = Encoding.Default.GetString(outputb);
|
|
|
|
string text = System.Web.HttpUtility.UrlDecode(orgStr);//将Url中的编码转换为简体汉字 , System.Text.Encoding.GetEncoding("GB2312")
|
|
|
|
//存储图片
|
|
string picture = "";
|
|
if (art_pictype == "0")
|
|
{
|
|
picture = GetUploadImg(context);
|
|
}
|
|
else
|
|
{
|
|
picture = art_pic;
|
|
}
|
|
Expression<Func<TBL_SYS_NOTICE, bool>> expression = PredicateExtensions.True<TBL_SYS_NOTICE>();
|
|
Expression<Func<TBL_SYS_NOTICESENDRECORD, bool>> noticeRecordExpr = PredicateExtensions.True<TBL_SYS_NOTICESENDRECORD>();
|
|
TBL_SYS_NOTICE model = new TBL_SYS_NOTICE();
|
|
List<TBL_SYS_NOTICESENDRECORD> noticeSendRecord = new List<TBL_SYS_NOTICESENDRECORD>();
|
|
List<TBL_SYS_EMP_Model> userList = new List<TBL_SYS_EMP_Model>();
|
|
|
|
|
|
if (receiverType == "org")
|
|
{
|
|
userList = sysEmp.QueryListByOrgIdOrDeptId(receiver);
|
|
for (int i = 0; i < userList.Count; i++)
|
|
{
|
|
noticeSendRecord.Add(new TBL_SYS_NOTICESENDRECORD
|
|
{
|
|
Id = Guid.NewGuid().ToString("N"),
|
|
NoticeId = id,
|
|
Receiver = userList[i].USERS_UID,
|
|
ReceiverName = userList[i].EMP_NAME,
|
|
CreateDate = DateTime.Now,
|
|
Status = "0"
|
|
});
|
|
}
|
|
}
|
|
else
|
|
{
|
|
noticeSendRecord.Add(new TBL_SYS_NOTICESENDRECORD
|
|
{
|
|
Id = Guid.NewGuid().ToString("N"),
|
|
NoticeId = id,
|
|
Receiver = receiver,
|
|
ReceiverName = receiverName,
|
|
CreateDate = DateTime.Now,
|
|
Status = "0"
|
|
});
|
|
}
|
|
model = noticBLL.GetModelByID(id);
|
|
if (model != null)
|
|
{
|
|
int ifUpdateReciver = 0; //判断是否需要更改接收人员表 0 无需更改 1 需要更改
|
|
//model.Id = id;
|
|
model.UpdateTime = DateTime.Now;
|
|
model.Type = type;
|
|
model.IsPublic = isPublic;
|
|
model.Title = title;
|
|
model.Content = text;
|
|
model.AttachFile = picture;
|
|
model.Digest = digest;
|
|
model.Source = source;
|
|
|
|
if (model.Receiver != receiver)
|
|
{
|
|
model.Receiver = receiver;
|
|
model.ReceiverName = receiverName;
|
|
ifUpdateReciver = 1;
|
|
}
|
|
|
|
|
|
model.Sender = sender;
|
|
model.SenderName = senderName;
|
|
model.OrgId = orgId;
|
|
MQTT mqttPush = new MQTT();
|
|
try
|
|
{
|
|
List<FangYar.Model.OA.CommonSql> sqls = noticBLL.Edit(model, noticeSendRecord, ifUpdateReciver);
|
|
|
|
if (FangYar.Common.MySqlHelper.ExecuteSqlTranBool(sqls))
|
|
{
|
|
msg = "修改成功!";
|
|
code = 1;
|
|
if (isPublic == "1")
|
|
{
|
|
//var jsonstr = "{\"Title\":\"" + title + "\",\"Type\":\"Remind\",\"Url\":\"" + "/OA/Notice/List.html" + "\"}";
|
|
//if (userList.Count > 0)
|
|
//{
|
|
// for (int i = 0; i < userList.Count; i++)
|
|
// {
|
|
// mqttPush.messagePublished(jsonstr, "XJYQ/" + userList[i].ORG_ID + "/" + userList[i].USERS_UID + "/PC/PushMsg");
|
|
// }
|
|
//}
|
|
//else
|
|
//{
|
|
// mqttPush.messagePublished(jsonstr, "XJYQ/" + orgId + "/" + receiver + "/PC/PushMsg");
|
|
//}
|
|
|
|
}
|
|
}
|
|
else
|
|
{
|
|
msg = "修改失败!";
|
|
code = -1;
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
code = -1;
|
|
msg = "修改失败!";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "通知公告操作请求", "修改内异常:" + e);
|
|
}
|
|
|
|
//if (common.Update<TBL_SYS_NOTICE>(model, x => x.Id == id))
|
|
//{
|
|
// msg = "修改成功!";
|
|
// code = 1;
|
|
//}
|
|
//else { msg = "修改失败!"; }
|
|
}
|
|
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.Update, "通知公告操作请求", "修改");
|
|
return returnstr;
|
|
}
|
|
|
|
//删除
|
|
private string Del(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
int code = -1;
|
|
string msg = "";
|
|
try
|
|
{
|
|
string id = context.Request.Params["id"];
|
|
|
|
List<string> sqlList = new List<string>();
|
|
sqlList.Add(" delete from TBL_SYS_NOTICE where ID ='" + id + "'");
|
|
sqlList.Add(" delete from tbl_sys_NoticeSendRecord where NOTICEID = '" + id + "' ");
|
|
|
|
if (FangYar.Common.MySqlHelper.ExecuteSqlTran(sqlList))
|
|
{
|
|
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;
|
|
}
|
|
/// </summary>
|
|
/// 文件上传
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public string UploadImage(HttpContext context)
|
|
{
|
|
|
|
var imgFile = context.Request.Files[0];
|
|
if (imgFile != null && !string.IsNullOrEmpty(imgFile.FileName))
|
|
{
|
|
long size = imgFile.ContentLength;
|
|
string filename = imgFile.FileName;
|
|
string extname = filename.Substring(filename.LastIndexOf("."));
|
|
string filenewname = System.Guid.NewGuid().ToString() + extname;
|
|
string filepath = "Upload/NoticePage/" + DateTime.Now.ToString("yyyy-MM-dd") + "/" + filenewname;
|
|
string Dirpath = context.Server.MapPath(@"/Upload/NoticePage/" + DateTime.Now.ToString("yyyy-MM-dd") + "/");
|
|
CreateDir(Dirpath);
|
|
imgFile.SaveAs(Dirpath + "/" + filenewname);
|
|
return filepath;
|
|
}
|
|
return "false";
|
|
}
|
|
//根据文件夹全路径创建文件夹
|
|
public static void CreateDir(string subdir)
|
|
{
|
|
if (!Directory.Exists(subdir))
|
|
{
|
|
Directory.CreateDirectory(subdir);
|
|
}
|
|
}
|
|
public bool IsReusable
|
|
{
|
|
get
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取组织机构及人员Tree
|
|
/// </summary>
|
|
/// <param name="context"></param>
|
|
/// <returns></returns>
|
|
public string GetDeptAndPersonTree(HttpContext context)
|
|
{
|
|
string orgId = context.Request.Params["OrgId"];
|
|
string returnStr = string.Empty;
|
|
try
|
|
{
|
|
returnStr = "{\"code\":0,\"msg\":\"\",\"data\":";
|
|
DataTable data = dutymanage.GetOrgTree(orgId);
|
|
returnStr += Common.JsonHelper.ToJson(data);
|
|
returnStr += "}";
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
returnStr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "通知公告操作请求", "获取组织机构及人员Tree异常:" + e);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "通知公告操作请求", "获取组织机构及人员Tree");
|
|
return returnStr;
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 获取当前登录人未读信息
|
|
/// </summary>
|
|
/// <param name="context"></param>
|
|
/// <returns></returns>
|
|
public string QueryUnReadNoticeListByUserId(HttpContext context)
|
|
{
|
|
string userId = context.Request.Params["Id"].Trim().ToString();
|
|
string returnStr = string.Empty;
|
|
try
|
|
{
|
|
string where = "1=1 ";
|
|
if (!String.IsNullOrWhiteSpace(userId))
|
|
{
|
|
where += String.Format(" and record.receiver='{0}' and status='0'", userId);
|
|
int count = noticBLL.UnReadNoticeCount(where);
|
|
var list = noticBLL.UnReadNoticeList(where);
|
|
returnStr = "{\"code\":0,\"msg\":\"\",\"count\":" + count + ",\"data\":";
|
|
if (list.Count > 0)
|
|
{
|
|
returnStr += Common.JsonHelper.ToJson(list);
|
|
}
|
|
else
|
|
{
|
|
returnStr += "[]";
|
|
}
|
|
|
|
returnStr += ",\"Url\":\"/OA/Notice/UnReadList.html\"}";
|
|
}
|
|
else
|
|
{
|
|
returnStr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}";
|
|
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "通知公告操作请求", "获取当前登录人未读信息异常:" + e);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "通知公告操作请求", "获取当前登录人未读信息");
|
|
|
|
|
|
return returnStr;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 未读列表
|
|
/// </summary>
|
|
/// <param name="context"></param>
|
|
/// <returns></returns>
|
|
public string QueryUnReadList(HttpContext context)
|
|
{
|
|
string orgId = context.Request.Params["orgId"];
|
|
string type = context.Request.Params["cls"];
|
|
string userId = context.Request.Params["Id"].Trim().ToString();
|
|
string keyWord = context.Request.Params["keywords"];
|
|
string page = context.Request.Params["page"];
|
|
string limit = context.Request.Params["limit"];
|
|
string returnStr = string.Empty;
|
|
try
|
|
{
|
|
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.IsNullOrWhiteSpace(userId))
|
|
{
|
|
where += String.Format(" and record.receiver='{0}' and status='0'", userId);
|
|
if (!String.IsNullOrWhiteSpace(type))
|
|
{
|
|
where += string.Format(" and type={0}", type);
|
|
}
|
|
if (!String.IsNullOrWhiteSpace(keyWord))
|
|
{
|
|
where += string.Format(" AND Title LIKE '%{0}%'", keyWord);
|
|
}
|
|
where += " and ISPUBLIC = '1'";
|
|
|
|
int count = noticBLL.UnReadNoticeCount(where);
|
|
var list = noticBLL.QueryJoinPageList(pageIndex, pageSize, where, "SendTime desc");
|
|
returnStr = "{\"code\":0,\"msg\":\"\",\"count\":" + count + ",\"data\":";
|
|
if (list.Count > 0)
|
|
{
|
|
returnStr += Common.JsonHelper.ToJson(list);
|
|
}
|
|
else
|
|
{
|
|
returnStr += "[]";
|
|
}
|
|
|
|
returnStr += "}";
|
|
}
|
|
else
|
|
{
|
|
returnStr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}";
|
|
|
|
}
|
|
|
|
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "通知公告操作请求", "未读列表异常:" + e);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "通知公告操作请求", "未读列表");
|
|
|
|
return returnStr;
|
|
}
|
|
public string QueryAlreadReadList(HttpContext context)
|
|
{
|
|
string orgId = context.Request.Params["orgId"];
|
|
string type = context.Request.Params["cls"];
|
|
string userId = context.Request.Params["Id"].Trim().ToString();
|
|
string keyWord = context.Request.Params["keywords"];
|
|
string page = context.Request.Params["page"];
|
|
string limit = context.Request.Params["limit"];
|
|
string returnStr = string.Empty;
|
|
try
|
|
{
|
|
|
|
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.IsNullOrWhiteSpace(userId))
|
|
{
|
|
where += String.Format(" and record.receiver='{0}' and status='1'", userId);
|
|
if (!String.IsNullOrWhiteSpace(type))
|
|
{
|
|
where += string.Format(" and type={0}", type);
|
|
}
|
|
if (!String.IsNullOrWhiteSpace(keyWord))
|
|
{
|
|
where += string.Format(" AND Title LIKE '%{0}%'", keyWord);
|
|
}
|
|
|
|
int count = noticBLL.UnReadNoticeCount(where);
|
|
var list = noticBLL.QueryJoinPageList(pageIndex, pageSize, where, "SendTime desc");
|
|
returnStr = "{\"code\":0,\"msg\":\"\",\"count\":" + count + ",\"data\":";
|
|
if (list.Count > 0)
|
|
{
|
|
returnStr += Common.JsonHelper.ToJson(list);
|
|
}
|
|
else
|
|
{
|
|
returnStr += "[]";
|
|
}
|
|
|
|
returnStr += "}";
|
|
}
|
|
else
|
|
{
|
|
returnStr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}";
|
|
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "通知公告操作请求", "查询异常:" + e);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "通知公告操作请求", "查询");
|
|
return returnStr;
|
|
}
|
|
|
|
public string UpdateStatus(HttpContext context)
|
|
{
|
|
SysNoticeSendrecordBLL noticSendBLL = new SysNoticeSendrecordBLL();
|
|
int code = 0;
|
|
string msg = string.Empty;
|
|
string userId = context.Request.Params["userId"].Trim();
|
|
string noticeId = context.Request.Params["noticeId"].Trim();
|
|
string returnStr = string.Empty;
|
|
Expression<Func<TBL_SYS_NOTICESENDRECORD, bool>> expression = PredicateExtensions.True<TBL_SYS_NOTICESENDRECORD>();
|
|
try
|
|
{
|
|
bool flag = false;
|
|
TBL_SYS_NOTICESENDRECORD record = new TBL_SYS_NOTICESENDRECORD();
|
|
if (!String.IsNullOrWhiteSpace(noticeId))
|
|
{
|
|
record = noticSendBLL.GetModelByID(noticeId, userId);
|
|
record.Status = "1";
|
|
flag = noticSendBLL.Edit(record);
|
|
}
|
|
if (flag)
|
|
{
|
|
code = 1;
|
|
msg = "更新成功";
|
|
}
|
|
else
|
|
{
|
|
code = -1;
|
|
msg = "更新失败";
|
|
}
|
|
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
|
|
code = -1;
|
|
msg = "更新失败";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "通知公告操作请求", "更新状态异常:" + e);
|
|
}
|
|
returnStr = "{\"code\":" + code + ",\"msg\":\"" + msg + "\"}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Update, "通知公告操作请求", "更新状态");
|
|
return returnStr;
|
|
}
|
|
}
|
|
}
|