@@ -30,14 +30,7 @@ namespace Learun.Application.Web.Areas.LR_OAModule.Controllers | |||
public class NoticeController : MvcControllerBase | |||
{ | |||
private NoticeIBLL noticeIBLL = new NoticeBLL(); | |||
private WeChatConfigIBLL weChatConfigIbll = new WeChatConfigBLL(); | |||
private WeChatTempletIBLL weChatTempletIbll = new WeChatTempletBLL(); | |||
private UserIBLL userIbll = new UserBLL(); | |||
private UserRelationIBLL userRelationIBLL = new UserRelationBLL(); | |||
private DataItemIBLL dataItemIbll = new DataItemBLL(); | |||
private DepartmentIBLL departmentIbll = new DepartmentBLL(); | |||
private Sys_InformationPushIBLL sys_InformationPushIBLL = new Sys_InformationPushBLL(); | |||
private MessageRindIBLL messageRindIBLL = new MessageRindBLL(); | |||
private DepartmentReleasePermissionsIBLL departmentReleasePermissionsIbll = | |||
new DepartmentReleasePermissionsBLL(); | |||
@@ -318,113 +311,12 @@ namespace Learun.Application.Web.Areas.LR_OAModule.Controllers | |||
{ | |||
entity.F_NewsContent = WebHelper.HtmlEncode(entity.F_NewsContent); | |||
noticeIBLL.SaveEntity(keyValue, entity); | |||
//读取信息推送管理-通知公告推送(01)的配置 | |||
var informationPushEntity = sys_InformationPushIBLL.GetEntityByPushItem("01"); | |||
if (informationPushEntity != null && informationPushEntity.Status == true) | |||
{ | |||
//推送微信 | |||
Task.Run(async () => { await DoWeixinPush(entity); }); | |||
} | |||
if (entity.F_IsSendFX.HasValue && entity.F_IsSendFX == true) | |||
{ | |||
Task.Run(async () => | |||
{ | |||
using (var hubConnection = new HubConnection(ConfigurationManager.AppSettings["CommunicationServeraddress"])) | |||
{ | |||
var hubProxy = hubConnection.CreateHubProxy("SignalRHub"); | |||
await hubConnection.Start(); | |||
await hubProxy.Invoke("PushAnnouncement", entity.F_NewsId, entity.F_FullHead, Util.Str.ReplaceHtml(HttpUtility.HtmlDecode(entity.F_NewsContent)).Length < 20 ? Util.Str.ReplaceHtml(HttpUtility.HtmlDecode(entity.F_NewsContent)) : Util.Str.ReplaceHtml(HttpUtility.HtmlDecode(entity.F_NewsContent)).Substring(0, 20), "news", entity.F_SendPostId, entity.F_SendDeptId); | |||
} | |||
}); | |||
} | |||
return Success("保存成功!"); | |||
} | |||
Task DoWeixinPush(NewsEntity entity) | |||
{ | |||
//微信推送 | |||
try | |||
{ | |||
var allteacherlist = userIbll.GetAllList().Where(m => | |||
m.F_DeleteMark != 1 && m.F_EnabledMark == 1 && m.F_Description == "教师"); | |||
var userralationlist = userRelationIBLL.GetUserIdList("2"); | |||
var needpostuserlist = new List<UserEntity>(); | |||
if (!string.IsNullOrEmpty(entity.F_SendDeptId)) | |||
{ | |||
if (!entity.F_SendDeptId.Contains(",")) | |||
{ | |||
var departteacherlist = allteacherlist.Where(m => entity.F_SendDeptId == m.F_DepartmentId); | |||
needpostuserlist.AddRange(departteacherlist.ToList()); | |||
if (!string.IsNullOrEmpty(entity.F_SendPostId)) | |||
{ | |||
var newpostuserlist = new List<UserEntity>(); | |||
foreach (var uuitem in needpostuserlist) | |||
{ | |||
var postids = userralationlist?.Count(m => m.F_UserId == uuitem.F_UserId && entity.F_SendPostId.Contains(m.F_ObjectId)); | |||
if (postids > 0) | |||
{ | |||
newpostuserlist.Add(uuitem); | |||
} | |||
} | |||
needpostuserlist = newpostuserlist; | |||
} | |||
} | |||
else | |||
{ | |||
foreach (var senddeptid in entity.F_SendDeptId.Split(',')) | |||
{ | |||
var departteacherlist = allteacherlist.Where(m => senddeptid == m.F_DepartmentId); | |||
needpostuserlist.AddRange(departteacherlist.ToList()); | |||
if (!string.IsNullOrEmpty(entity.F_SendPostId)) | |||
{ | |||
var newpostuserlist = new List<UserEntity>(); | |||
foreach (var uuitem in needpostuserlist) | |||
{ | |||
var postids = userralationlist?.Count(m => m.F_UserId == uuitem.F_UserId && entity.F_SendPostId.Contains(m.F_ObjectId)); | |||
if (postids > 0) | |||
{ | |||
newpostuserlist.Add(uuitem); | |||
} | |||
} | |||
needpostuserlist = newpostuserlist; | |||
} | |||
} | |||
} | |||
} | |||
else | |||
{ | |||
if (!string.IsNullOrEmpty(entity.F_SendPostId)) | |||
{ | |||
//岗位下发 | |||
var newpostuserlist = new List<UserEntity>(); | |||
foreach (var uuitem in allteacherlist) | |||
{ | |||
var postids = userralationlist?.Count(m => m.F_UserId == uuitem.F_UserId && entity.F_SendPostId.Contains(m.F_ObjectId)); | |||
if (postids > 0) | |||
{ | |||
newpostuserlist.Add(uuitem); | |||
} | |||
} | |||
needpostuserlist = newpostuserlist; | |||
} | |||
else | |||
{ | |||
//全员下发 | |||
needpostuserlist = allteacherlist.ToList(); | |||
} | |||
} | |||
PushWeixin(needpostuserlist, entity.F_FullHead); | |||
//消息提醒表 | |||
PushMessageRemind(needpostuserlist, entity); | |||
return Task.CompletedTask; | |||
} | |||
catch (Exception e) | |||
{ | |||
return Task.FromException(e); | |||
} | |||
} | |||
/// <summary> | |||
/// 删除表单数据 | |||
@@ -438,87 +330,7 @@ namespace Learun.Application.Web.Areas.LR_OAModule.Controllers | |||
noticeIBLL.DeleteEntity(keyValue); | |||
return Success("删除成功!"); | |||
} | |||
public void PushWeixin(List<UserEntity> needpostuserlist, string title) | |||
{ | |||
var WeChatConfigentity = weChatConfigIbll.GetEnableEntity(); | |||
string appid = WeChatConfigentity.APPId; | |||
string secret = WeChatConfigentity.secret; | |||
var wechatemplete = weChatTempletIbll.GetWeChatTemplateEntityByCodeConfigId(WeChatConfigentity.ID, "task"); | |||
string weixintaskurl = wechatemplete.TUrl; | |||
string weixintasktempid = wechatemplete.TempId; | |||
var responsejson = Util.HttpMethods.HttpGet("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" + appid + "&secret=" + secret); | |||
OperateLogModel operateLogModel = new OperateLogModel(); | |||
operateLogModel.title = title; | |||
operateLogModel.type = OperationType.Other; | |||
operateLogModel.url = "NoticeController"; | |||
operateLogModel.sourceObjectId = "002"; | |||
operateLogModel.sourceContentJson = responsejson; | |||
OperatorHelper.Instance.WriteOperateLog(operateLogModel); | |||
foreach (UserEntity userinfo in needpostuserlist) | |||
{ | |||
if (userinfo != null && !string.IsNullOrEmpty(userinfo.OpenIdForWeixin)) | |||
{ | |||
//执行推送任务 | |||
if (!string.IsNullOrEmpty(appid) && !string.IsNullOrEmpty(secret) && !string.IsNullOrEmpty(weixintaskurl) && !string.IsNullOrEmpty(weixintasktempid)) | |||
{ | |||
if (!string.IsNullOrEmpty(responsejson)) | |||
{ | |||
var weixintokenobj = JsonConvert.DeserializeObject<dynamic>(responsejson); | |||
if (string.IsNullOrEmpty(weixintokenobj.errcode)) | |||
{ | |||
string access_token = weixintokenobj.access_token; | |||
string jsondata = "{\"touser\":\"" + userinfo.OpenIdForWeixin + "\"," + | |||
"\"template_id\":\"" + weixintasktempid + "\"," + | |||
"\"url\":\"" + weixintaskurl + "\"," + | |||
"\"data\":{" + | |||
"\"first\": {\"value\":\"您有新的未读通知公告\",\"color\":\"#173177\"}," + | |||
"\"keyword1\":{\"value\":\"未读通知公告\",\"color\":\"#173177\"}," + | |||
"\"keyword2\": {\"value\":\"" + title + "\",\"color\":\"#173177\"}," + | |||
"\"keyword3\": {\"value\":\"待查看\",\"color\":\"#173177\"}," + | |||
"\"keyword4\": {\"value\":\"您有新的未读通知公告【" + title + "】\",\"color\":\"#173177\"}" + | |||
"}" + | |||
"}"; | |||
string pushresult = Util.HttpMethods.HttpPost("https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + access_token, jsondata); | |||
operateLogModel.title = title; | |||
operateLogModel.type = OperationType.Other; | |||
operateLogModel.url = "NoticeController"; | |||
operateLogModel.sourceObjectId = "002"; | |||
operateLogModel.sourceContentJson = pushresult; | |||
OperatorHelper.Instance.WriteOperateLog(operateLogModel); | |||
} | |||
} | |||
} | |||
} | |||
} | |||
} | |||
/// <summary> | |||
/// 消息提醒 | |||
/// </summary> | |||
/// <param name="needpostuserlist"></param> | |||
/// <param name="title"></param> | |||
public void PushMessageRemind(List<UserEntity> needpostuserlist, NewsEntity model) | |||
{ | |||
foreach (UserEntity userinfo in needpostuserlist) | |||
{ | |||
MessageRemindEntity entity = new MessageRemindEntity(); | |||
entity.ReceiptId = userinfo.F_UserId; | |||
entity.ReceiptName = userinfo.F_RealName; | |||
entity.SenderId = model.F_CreateUserId; | |||
entity.SenderName = model.F_CreateUserName; | |||
entity.TheTitle = "通知公告"; | |||
entity.TheContent = model.F_FullHead; | |||
entity.InstanceId = model.F_NewsId; | |||
entity.ConnectionUrl = "/Utility/ListContentIndex?id="; | |||
entity.SendTime = DateTime.Now; | |||
entity.ReadSigns = false; | |||
messageRindIBLL.SaveEntity("", entity); | |||
} | |||
} | |||
#endregion | |||
@@ -547,11 +359,8 @@ namespace Learun.Application.Web.Areas.LR_OAModule.Controllers | |||
public ActionResult GetFormDataByProcessId(string processId) | |||
{ | |||
NewsEntity OANewsData = noticeIBLL.GetEntityByProcessId(processId); | |||
var jsonData = new | |||
{ | |||
OANews = OANewsData, | |||
}; | |||
return Success(jsonData); | |||
OANewsData.F_NewsContent = WebHelper.HtmlDecode(OANewsData.F_NewsContent); | |||
return Success(OANewsData); | |||
} | |||
#endregion | |||
@@ -61,17 +61,21 @@ var bootstrap = function ($, learun) { | |||
setFormData = function (processId) { | |||
if (!!processId) { | |||
$.lrSetForm(top.$.rootUrl + '/LR_OAModule/Notice/GetFormDataByProcessId?processId=' + processId, function (data) { | |||
for (var id in data) { | |||
if (!!data[id] && data[id].length > 0) { | |||
$('#' + id).jfGridSet('refreshdata', data[id]); | |||
} | |||
else { | |||
if (id == 'Sys_ReceiveFile') { | |||
keyValue = data[id].F_DeptRelationId; | |||
} | |||
$('[data-table="' + id + '"]').lrSetFormData(data[id]); | |||
} | |||
} | |||
$('#form').lrSetFormData(data); | |||
setTimeout(function () { | |||
ue.setContent(data.F_NewsContent); | |||
}, 100); | |||
//for (var id in data) { | |||
// if (!!data[id] && data[id].length > 0) { | |||
// $('#' + id).jfGridSet('refreshdata', data[id]); | |||
// } | |||
// else { | |||
// if (id == 'Sys_ReceiveFile') { | |||
// keyValue = data[id].F_DeptRelationId; | |||
// } | |||
// $('[data-table="' + id + '"]').lrSetFormData(data[id]); | |||
// } | |||
//} | |||
}); | |||
} | |||
} | |||
@@ -84,17 +88,62 @@ var bootstrap = function ($, learun) { | |||
}; | |||
// 保存数据 | |||
save = function (processId, callBack, i) { | |||
if (!$('#form').lrValidform()) { | |||
return false; | |||
} | |||
var formData = $('body').lrGetFormData(); | |||
if (!!processId) { | |||
formData.RProcessId = processId; | |||
} | |||
$.lrSaveForm(top.$.rootUrl + '/LR_OAModule/Notice/SaveForm?keyValue=' + keyValue, formData, function (res) { | |||
// 保存成功后才回调 | |||
if (!!callBack) { | |||
callBack(res, formData, i); | |||
learun.clientdata.getAsync('dataItem', | |||
{ | |||
key: $("#F_CategoryId").lrselectGet(), | |||
code: 'NoticeCategory', | |||
callback: function (_data) { | |||
$("#F_Category").val(_data.text); | |||
var postData = $('#form').lrGetFormData(keyValue); | |||
postData["F_NewsContent"] = ue.getContent(null, null, true); | |||
$.lrSaveForm(top.$.rootUrl + '/LR_OAModule/Notice/SaveForm?keyValue=' + keyValue, | |||
postData, | |||
function (res) { | |||
// 保存成功后才回调 | |||
if (!!callBack) { | |||
callBack(res, formData, i); | |||
} | |||
}); | |||
} | |||
}); | |||
//$.lrSaveForm(top.$.rootUrl + '/LR_OAModule/Notice/SaveForm?keyValue=' + keyValue, formData, function (res) { | |||
// // 保存成功后才回调 | |||
// if (!!callBack) { | |||
// callBack(res, formData, i); | |||
// } | |||
//}); | |||
}; | |||
acceptClick = function (callBack) { | |||
if (!$('#form').lrValidform()) { | |||
return false; | |||
} | |||
learun.clientdata.getAsync('dataItem', { | |||
key: $("#F_CategoryId").lrselectGet(), | |||
code: 'NoticeCategory', | |||
callback: function (_data) { | |||
$("#F_Category").val(_data.text); | |||
var postData = $('#form').lrGetFormData(keyValue); | |||
postData["F_NewsContent"] = ue.getContent(null, null, true); | |||
$.lrSaveForm(top.$.rootUrl + '/LR_OAModule/Notice/SaveForm?keyValue=' + keyValue, postData, function (res) { | |||
// 保存成功后才回调 | |||
if (!!callBack) { | |||
callBack(); | |||
} | |||
}); | |||
} | |||
}); | |||
}; | |||
} | |||
page.init(); | |||
} | |||
@@ -60,14 +60,10 @@ var bootstrap = function ($, learun) { | |||
setFormData = function (processId, param, callback) { | |||
if (!!processId) { | |||
$.lrSetForm(top.$.rootUrl + '/LR_OAModule/Notice/GetFormDataByProcessId?processId=' + processId, function (data) { | |||
for (var id in data) { | |||
if (!!data[id] && data[id].length > 0) { | |||
$('#' + id).jfGridSet('refreshdata', data[id]); | |||
} | |||
else { | |||
$('[data-table="' + id + '"]').lrSetFormData(data[id]); | |||
} | |||
} | |||
$('#form').lrSetFormData(data); | |||
setTimeout(function () { | |||
ue.setContent(data.F_NewsContent); | |||
}, 100); | |||
}); | |||
} | |||
callback && callback(); | |||
@@ -84,9 +84,7 @@ var bootstrap = function ($, learun) { | |||
url: top.$.rootUrl + '/Permission/DepartmentReleasePermissions/Index?departmentId=' + keyValue, | |||
width: 700, | |||
height: 400, | |||
callBack: function (id) { | |||
return top[id].acceptClick(refreshGirdData); | |||
} | |||
btn:null | |||
}); | |||
} | |||
}); | |||
@@ -16,7 +16,7 @@ | |||
<img style="height: 40px;" width="95%" src="~/LR_SystemModule/LogoImg/GetImg?code=headbg" alt="经典风格"> | |||
</div> | |||
<div> | |||
<iframe style="position: absolute; top: 18px; right: 150px; height: 25px;" id="fancybox-frame" name="fancybox-frame1591155087436" frameborder="0" scrolling="no" hspace="0" src="http://i.tianqi.com/index.php?c=code&a=getcode&id=34&h=25&w=280"></iframe> | |||
<iframe style="position: absolute; top: 18px; right: 150px; height: 25px;" id="fancybox-frame" name="fancybox-frame1591155087436" frameborder="0" scrolling="no" hspace="0" src="http://i.tianqi.com/index.php?c=code&py=akesu&a=getcode&id=34&h=25&w=280"></iframe> | |||
</div> | |||
</div> | |||
@*<div class="lr-lg-setting" id="lr_lg_setting"> | |||
@@ -225,7 +225,7 @@ namespace Learun.Application.OA | |||
this.F_CreateDate = DateTime.Now; | |||
this.F_ReleaseTime = DateTime.Now; | |||
this.F_DeleteMark = 0; | |||
this.F_EnabledMark = 1; | |||
this.F_EnabledMark = 0; | |||
this.F_PV = 0; | |||
UserInfo userInfo = LoginUserInfo.Get(); | |||
@@ -184,6 +184,10 @@ namespace Learun.Application.OA | |||
if (null != newEntity) | |||
{ | |||
newEntity.F_Status = status.ToString(); | |||
if (status==2) | |||
{ | |||
newEntity.F_EnabledMark = 1; | |||
} | |||
} | |||
this.BaseRepository().Update(newEntity); | |||
@@ -328,18 +328,18 @@ and s.Academicyearno='" + entity.AcademicYearNo + "' and s.Semester='" + entity. | |||
//dyy:20190722 | |||
//初始化教师成绩单提交表 | |||
string sql3 = @"insert into EmpReportCard | |||
(Id, LessonNo, LessonName, ClassNo, ClassName, EmpNo, EmpName, AcademicYearNo, Semester,LessonSortNo, CreateTime, ElectronicStatus, ElectronicTime, PaperStatus, PaperTime) | |||
select NEWID(),LessonNo,LessonName,ClassNo,ClassName,EmpNo,EmpName,AcademicYearNo,Semester,LessonSortNo,GETDATE(),0,null,0,null from | |||
(Id, LessonNo, LessonName, ClassNo, ClassName, EmpNo, EmpName, AcademicYearNo, Semester,LessonSortNo, CreateTime, ElectronicStatus, ElectronicTime, PaperStatus, PaperTime,F_SchoolId) | |||
select NEWID(),LessonNo,LessonName,ClassNo,ClassName,EmpNo,EmpName,AcademicYearNo,Semester,LessonSortNo,GETDATE(),0,null,0,null,F_SchoolId from | |||
( | |||
select distinct s.LessonNo,s.LessonName,s.TeachClassNo as ClassNo,c.ClassName,s.EmpNo,e.EmpName,s.AcademicYearNo,s.Semester,s.LessonSortNo | |||
select distinct s.LessonNo,s.LessonName,s.TeachClassNo as ClassNo,c.ClassName,s.EmpNo,e.EmpName,s.AcademicYearNo,s.Semester,s.LessonSortNo,s.F_SchoolId | |||
from stuscore s | |||
left join classinfo c on s.teachclassno=c.classno | |||
left join empinfo e on s.empno=e.empno | |||
where s.lessonsortno='1' | |||
) as bb | |||
where bb.EmpNo not in | |||
(select a.EmpNo from EmpReportCard a where a.AcademicYearNo=bb.AcademicYearNo and a.Semester=bb.Semester and a.LessonNo=bb.LessonNo and a.ClassNo=bb.ClassNo and a.LessonSortNo=bb.LessonSortNo and a.LessonSortNo='1' | |||
and a.Academicyearno='" + entity.AcademicYearNo + "' and a.Semester='" + entity.Semester + "') and bb.AcademicYearNo='" + entity.AcademicYearNo + "' and bb.Semester='" + entity.Semester + "' order by bb.EmpNo"; | |||
(select a.EmpNo from EmpReportCard a where a.AcademicYearNo=bb.AcademicYearNo and a.Semester=bb.Semester and a.LessonNo=bb.LessonNo and a.ClassNo=bb.ClassNo and a.LessonSortNo=bb.LessonSortNo and a.LessonSortNo='1' and a.F_SchoolId=bb.F_SchoolId | |||
and a.Academicyearno='" + entity.AcademicYearNo + "' and a.Semester='" + entity.Semester + "') and bb.AcademicYearNo='" + entity.AcademicYearNo + "' and bb.Semester='" + entity.Semester + "' and bb.F_SchoolId='"+entity.F_SchoolId+"' order by bb.EmpNo"; | |||
BaseRepository("CollegeMIS").ExecuteBySql(sql3); | |||
} | |||
//选修课 | |||
@@ -364,17 +364,17 @@ and s.Academicyearno='" + entity.AcademicYearNo + "' and s.Semester='" + entity. | |||
//初始化教师成绩单提交表【选修课】 | |||
string sql3OfElective = @"insert into EmpReportCard | |||
(Id, LessonNo, LessonName, EmpNo, EmpName, AcademicYearNo, Semester,LessonSortNo, LessonSection, ClassRoomNo, ClassRoomName, CreateTime, ElectronicStatus, ElectronicTime, PaperStatus, PaperTime) | |||
select NEWID(),LessonNo,LessonName,EmpNo,EmpName,AcademicYearNo,Semester,LessonSortNo, LessonSection, ClassRoomNo, ClassRoomName,GETDATE(),0,null,0,null from | |||
(Id, LessonNo, LessonName, EmpNo, EmpName, AcademicYearNo, Semester,LessonSortNo, LessonSection, ClassRoomNo, ClassRoomName, CreateTime, ElectronicStatus, ElectronicTime, PaperStatus, PaperTime,F_SchoolId) | |||
select NEWID(),LessonNo,LessonName,EmpNo,EmpName,AcademicYearNo,Semester,LessonSortNo, LessonSection, ClassRoomNo, ClassRoomName,GETDATE(),0,null,0,null,F_SchoolId from | |||
( | |||
select distinct s.LessonNo,s.LessonName,s.EmpNo,e.EmpName,s.AcademicYearNo,s.Semester,s.LessonSortNo,s.LessonSection,s.ClassRoomNo,s.ClassRoomName | |||
select distinct s.LessonNo,s.LessonName,s.EmpNo,e.EmpName,s.AcademicYearNo,s.Semester,s.LessonSortNo,s.LessonSection,s.ClassRoomNo,s.ClassRoomName,s.F_SchoolId | |||
from stuscore s | |||
left join empinfo e on s.empno=e.empno | |||
where s.lessonsortno='2' | |||
) as bb | |||
where bb.EmpNo not in | |||
(select a.EmpNo from EmpReportCard a where a.AcademicYearNo=bb.AcademicYearNo and a.Semester=bb.Semester and a.LessonNo=bb.LessonNo and a.LessonSection=bb.LessonSection and a.ClassRoomNo=bb.ClassRoomNo and a.LessonSortNo=bb.LessonSortNo and a.LessonSortNo='2' | |||
and a.Academicyearno='" + entity.AcademicYearNo + "' and a.Semester='" + entity.Semester + "') and bb.AcademicYearNo='" + entity.AcademicYearNo + "' and bb.Semester='" + entity.Semester + "' order by bb.EmpNo"; | |||
(select a.EmpNo from EmpReportCard a where a.AcademicYearNo=bb.AcademicYearNo and a.Semester=bb.Semester and a.LessonNo=bb.LessonNo and a.LessonSection=bb.LessonSection and a.ClassRoomNo=bb.ClassRoomNo and a.LessonSortNo=bb.LessonSortNo and a.LessonSortNo='2' and a.F_SchoolId=bb.F_SchoolId | |||
and a.Academicyearno='" + entity.AcademicYearNo + "' and a.Semester='" + entity.Semester + "') and bb.AcademicYearNo='" + entity.AcademicYearNo + "' and bb.Semester='" + entity.Semester + "' and bb.F_SchoolId='"+entity.F_SchoolId+"' order by bb.EmpNo"; | |||
BaseRepository("CollegeMIS").ExecuteBySql(sql3OfElective); | |||
} | |||
} | |||
@@ -77,6 +77,7 @@ | |||
<Reference Include="System.Configuration" /> | |||
<Reference Include="System.Core" /> | |||
<Reference Include="System.Runtime.Serialization" /> | |||
<Reference Include="System.Web" /> | |||
<Reference Include="System.Xml.Linq" /> | |||
<Reference Include="System.Data.DataSetExtensions" /> | |||
<Reference Include="Microsoft.CSharp" /> | |||
@@ -220,6 +221,10 @@ | |||
<Project>{81c03609-ae0d-414c-829b-16b990487add}</Project> | |||
<Name>Learun.Ioc</Name> | |||
</ProjectReference> | |||
<ProjectReference Include="..\..\Learun.Util\Learun.Util.Operat\Learun.Util.Operat.csproj"> | |||
<Project>{ad556b7a-e0d1-41bd-9d5b-18f8502e9f33}</Project> | |||
<Name>Learun.Util.Operat</Name> | |||
</ProjectReference> | |||
<ProjectReference Include="..\..\Learun.Util\Learun.Util\Learun.Util.csproj"> | |||
<Project>{cf8ae293-88ab-436c-9720-a8386ba5d7b7}</Project> | |||
<Name>Learun.Util</Name> | |||
@@ -1,9 +1,19 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Configuration; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using System.Web; | |||
using Learun.Application.Base.AuthorizeModule; | |||
using Learun.Application.Base.SystemModule; | |||
using Learun.Application.OA; | |||
using Learun.Application.Organization; | |||
using Learun.Application.TwoDevelopment.EducationalAdministration; | |||
using Learun.Application.TwoDevelopment.LR_Desktop; | |||
using Learun.Util.Operat; | |||
using Microsoft.AspNet.SignalR.Client; | |||
using Newtonsoft.Json; | |||
namespace Learun.Application.WorkFlow | |||
{ | |||
@@ -11,16 +21,211 @@ namespace Learun.Application.WorkFlow | |||
{ | |||
NewsIBLL newsIBLL=new NewsBLL(); | |||
private NoticeIBLL noticeIBLL = new NoticeBLL(); | |||
private WeChatConfigIBLL weChatConfigIbll = new WeChatConfigBLL(); | |||
private WeChatTempletIBLL weChatTempletIbll = new WeChatTempletBLL(); | |||
private UserIBLL userIbll = new UserBLL(); | |||
private UserRelationIBLL userRelationIBLL = new UserRelationBLL(); | |||
private Sys_InformationPushIBLL sys_InformationPushIBLL = new Sys_InformationPushBLL(); | |||
private MessageRindIBLL messageRindIBLL = new MessageRindBLL(); | |||
public void Execute(WfMethodParameter parameter) | |||
{ | |||
if (parameter.code == "agree") | |||
{ | |||
newsIBLL.ChangeStatusByProcessId(parameter.processId, 2); | |||
var entity = noticeIBLL.GetEntityByProcessId(parameter.processId); | |||
//推送通知 | |||
//读取信息推送管理-通知公告推送(01)的配置 | |||
var informationPushEntity = sys_InformationPushIBLL.GetEntityByPushItem("01"); | |||
if (informationPushEntity != null && informationPushEntity.Status == true) | |||
{ | |||
//推送微信 | |||
Task.Run(async () => { await DoWeixinPush(entity); }); | |||
} | |||
if (entity.F_IsSendFX.HasValue && entity.F_IsSendFX == true) | |||
{ | |||
Task.Run(async () => | |||
{ | |||
using (var hubConnection = new HubConnection(ConfigurationManager.AppSettings["CommunicationServeraddress"])) | |||
{ | |||
var hubProxy = hubConnection.CreateHubProxy("SignalRHub"); | |||
await hubConnection.Start(); | |||
await hubProxy.Invoke("PushAnnouncement", entity.F_NewsId, entity.F_FullHead, Util.Str.ReplaceHtml(HttpUtility.HtmlDecode(entity.F_NewsContent)).Length < 20 ? Util.Str.ReplaceHtml(HttpUtility.HtmlDecode(entity.F_NewsContent)) : Util.Str.ReplaceHtml(HttpUtility.HtmlDecode(entity.F_NewsContent)).Substring(0, 20), "news", entity.F_SendPostId, entity.F_SendDeptId); | |||
} | |||
}); | |||
} | |||
} | |||
else | |||
{ | |||
newsIBLL.ChangeStatusByProcessId(parameter.processId, 0); | |||
} | |||
} | |||
Task DoWeixinPush(NewsEntity entity) | |||
{ | |||
//微信推送 | |||
try | |||
{ | |||
var allteacherlist = userIbll.GetAllList().Where(m => | |||
m.F_DeleteMark != 1 && m.F_EnabledMark == 1 && m.F_Description == "教师"); | |||
var userralationlist = userRelationIBLL.GetUserIdList("2"); | |||
var needpostuserlist = new List<UserEntity>(); | |||
if (!string.IsNullOrEmpty(entity.F_SendDeptId)) | |||
{ | |||
if (!entity.F_SendDeptId.Contains(",")) | |||
{ | |||
var departteacherlist = allteacherlist.Where(m => entity.F_SendDeptId == m.F_DepartmentId); | |||
needpostuserlist.AddRange(departteacherlist.ToList()); | |||
if (!string.IsNullOrEmpty(entity.F_SendPostId)) | |||
{ | |||
var newpostuserlist = new List<UserEntity>(); | |||
foreach (var uuitem in needpostuserlist) | |||
{ | |||
var postids = userralationlist?.Count(m => m.F_UserId == uuitem.F_UserId && entity.F_SendPostId.Contains(m.F_ObjectId)); | |||
if (postids > 0) | |||
{ | |||
newpostuserlist.Add(uuitem); | |||
} | |||
} | |||
needpostuserlist = newpostuserlist; | |||
} | |||
} | |||
else | |||
{ | |||
foreach (var senddeptid in entity.F_SendDeptId.Split(',')) | |||
{ | |||
var departteacherlist = allteacherlist.Where(m => senddeptid == m.F_DepartmentId); | |||
needpostuserlist.AddRange(departteacherlist.ToList()); | |||
if (!string.IsNullOrEmpty(entity.F_SendPostId)) | |||
{ | |||
var newpostuserlist = new List<UserEntity>(); | |||
foreach (var uuitem in needpostuserlist) | |||
{ | |||
var postids = userralationlist?.Count(m => m.F_UserId == uuitem.F_UserId && entity.F_SendPostId.Contains(m.F_ObjectId)); | |||
if (postids > 0) | |||
{ | |||
newpostuserlist.Add(uuitem); | |||
} | |||
} | |||
needpostuserlist = newpostuserlist; | |||
} | |||
} | |||
} | |||
} | |||
else | |||
{ | |||
if (!string.IsNullOrEmpty(entity.F_SendPostId)) | |||
{ | |||
//岗位下发 | |||
var newpostuserlist = new List<UserEntity>(); | |||
foreach (var uuitem in allteacherlist) | |||
{ | |||
var postids = userralationlist?.Count(m => m.F_UserId == uuitem.F_UserId && entity.F_SendPostId.Contains(m.F_ObjectId)); | |||
if (postids > 0) | |||
{ | |||
newpostuserlist.Add(uuitem); | |||
} | |||
} | |||
needpostuserlist = newpostuserlist; | |||
} | |||
else | |||
{ | |||
//全员下发 | |||
needpostuserlist = allteacherlist.ToList(); | |||
} | |||
} | |||
PushWeixin(needpostuserlist, entity.F_FullHead); | |||
//消息提醒表 | |||
PushMessageRemind(needpostuserlist, entity); | |||
return Task.CompletedTask; | |||
} | |||
catch (Exception e) | |||
{ | |||
return Task.FromException(e); | |||
} | |||
} | |||
public void PushWeixin(List<UserEntity> needpostuserlist, string title) | |||
{ | |||
var WeChatConfigentity = weChatConfigIbll.GetEnableEntity(); | |||
string appid = WeChatConfigentity.APPId; | |||
string secret = WeChatConfigentity.secret; | |||
var wechatemplete = weChatTempletIbll.GetWeChatTemplateEntityByCodeConfigId(WeChatConfigentity.ID, "task"); | |||
string weixintaskurl = wechatemplete.TUrl; | |||
string weixintasktempid = wechatemplete.TempId; | |||
var responsejson = Util.HttpMethods.HttpGet("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" + appid + "&secret=" + secret); | |||
OperateLogModel operateLogModel = new OperateLogModel(); | |||
operateLogModel.title = title; | |||
operateLogModel.type = OperationType.Other; | |||
operateLogModel.url = "NoticeController"; | |||
operateLogModel.sourceObjectId = "002"; | |||
operateLogModel.sourceContentJson = responsejson; | |||
OperatorHelper.Instance.WriteOperateLog(operateLogModel); | |||
foreach (UserEntity userinfo in needpostuserlist) | |||
{ | |||
if (userinfo != null && !string.IsNullOrEmpty(userinfo.OpenIdForWeixin)) | |||
{ | |||
//执行推送任务 | |||
if (!string.IsNullOrEmpty(appid) && !string.IsNullOrEmpty(secret) && !string.IsNullOrEmpty(weixintaskurl) && !string.IsNullOrEmpty(weixintasktempid)) | |||
{ | |||
if (!string.IsNullOrEmpty(responsejson)) | |||
{ | |||
var weixintokenobj = JsonConvert.DeserializeObject<dynamic>(responsejson); | |||
if (string.IsNullOrEmpty(weixintokenobj.errcode)) | |||
{ | |||
string access_token = weixintokenobj.access_token; | |||
string jsondata = "{\"touser\":\"" + userinfo.OpenIdForWeixin + "\"," + | |||
"\"template_id\":\"" + weixintasktempid + "\"," + | |||
"\"url\":\"" + weixintaskurl + "\"," + | |||
"\"data\":{" + | |||
"\"first\": {\"value\":\"您有新的未读通知公告\",\"color\":\"#173177\"}," + | |||
"\"keyword1\":{\"value\":\"未读通知公告\",\"color\":\"#173177\"}," + | |||
"\"keyword2\": {\"value\":\"" + title + "\",\"color\":\"#173177\"}," + | |||
"\"keyword3\": {\"value\":\"待查看\",\"color\":\"#173177\"}," + | |||
"\"keyword4\": {\"value\":\"您有新的未读通知公告【" + title + "】\",\"color\":\"#173177\"}" + | |||
"}" + | |||
"}"; | |||
string pushresult = Util.HttpMethods.HttpPost("https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + access_token, jsondata); | |||
operateLogModel.title = title; | |||
operateLogModel.type = OperationType.Other; | |||
operateLogModel.url = "NoticeController"; | |||
operateLogModel.sourceObjectId = "002"; | |||
operateLogModel.sourceContentJson = pushresult; | |||
OperatorHelper.Instance.WriteOperateLog(operateLogModel); | |||
} | |||
} | |||
} | |||
} | |||
} | |||
} | |||
/// <summary> | |||
/// 消息提醒 | |||
/// </summary> | |||
/// <param name="needpostuserlist"></param> | |||
/// <param name="title"></param> | |||
public void PushMessageRemind(List<UserEntity> needpostuserlist, NewsEntity model) | |||
{ | |||
foreach (UserEntity userinfo in needpostuserlist) | |||
{ | |||
MessageRemindEntity entity = new MessageRemindEntity(); | |||
entity.ReceiptId = userinfo.F_UserId; | |||
entity.ReceiptName = userinfo.F_RealName; | |||
entity.SenderId = model.F_CreateUserId; | |||
entity.SenderName = model.F_CreateUserName; | |||
entity.TheTitle = "通知公告"; | |||
entity.TheContent = model.F_FullHead; | |||
entity.InstanceId = model.F_NewsId; | |||
entity.ConnectionUrl = "/Utility/ListContentIndex?id="; | |||
entity.SendTime = DateTime.Now; | |||
entity.ReadSigns = false; | |||
messageRindIBLL.SaveEntity("", entity); | |||
} | |||
} | |||
} | |||
} |