|
|
@@ -1,11 +1,19 @@ |
|
|
|
using Dapper; |
|
|
|
using Learun.Application.Organization; |
|
|
|
using Learun.Application.TwoDevelopment.EducationalAdministration; |
|
|
|
using Learun.Application.TwoDevelopment.LR_Desktop; |
|
|
|
using Learun.DataBase.Repository; |
|
|
|
using Learun.Util; |
|
|
|
using Microsoft.AspNet.SignalR.Client; |
|
|
|
using Newtonsoft.Json; |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Configuration; |
|
|
|
using System.Data; |
|
|
|
using System.Linq; |
|
|
|
using System.Text; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using System.Web; |
|
|
|
|
|
|
|
namespace Learun.Application.TwoDevelopment.PersonnelManagement |
|
|
|
{ |
|
|
@@ -467,7 +475,101 @@ namespace Learun.Application.TwoDevelopment.PersonnelManagement |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public void ReceivedList(string processId) |
|
|
|
{ |
|
|
|
var Received = GetMeetingManagementEntityByProcessId(processId); |
|
|
|
List<UserEntity> userInfos = new List<UserEntity>(); |
|
|
|
foreach (var rid in Received.InternalParticipants.Split(',')) |
|
|
|
{ |
|
|
|
var user = this.BaseRepository().FindEntity<UserEntity>(m => m.F_UserId == rid); |
|
|
|
if (!userInfos.Contains(user)) |
|
|
|
{ |
|
|
|
userInfos.Add(user); |
|
|
|
} |
|
|
|
} |
|
|
|
//foreach (var uitem in userInfos) |
|
|
|
//{ |
|
|
|
// SYS_ReceiveMessageEntity receiveMessageEntity = new SYS_ReceiveMessageEntity(); |
|
|
|
// receiveMessageEntity.Create(); |
|
|
|
// receiveMessageEntity.SENDERID = Received.SENDERID; |
|
|
|
// receiveMessageEntity.SENDER = messageentity.SENDER; |
|
|
|
// receiveMessageEntity.RECEIVERID = uitem.F_UserId; |
|
|
|
// receiveMessageEntity.RECEIVER = uitem.F_RealName; |
|
|
|
// receiveMessageEntity.TITLE = messageentity.TITLE; |
|
|
|
// receiveMessageEntity.CONTENTS = messageentity.CONTENTS; |
|
|
|
// receiveMessageEntity.URL = messageentity.URL; |
|
|
|
// receiveMessageEntity.READFLAG = 0; |
|
|
|
// receiveMessageEntity.SENDTIME = DateTime.Now; |
|
|
|
// receiveMessageEntity.DelFlag = false; |
|
|
|
// this.BaseRepository().Insert(receiveMessageEntity); |
|
|
|
//} |
|
|
|
|
|
|
|
//读取信息推送管理-会议申请推送(03)的配置 |
|
|
|
var informationPushEntity = this.BaseRepository().FindEntity<Sys_InformationPushEntity>(x => x.PushItem == "03"); |
|
|
|
if (informationPushEntity != null && informationPushEntity.Status == true) |
|
|
|
{ |
|
|
|
//微信推送 |
|
|
|
try |
|
|
|
{ |
|
|
|
PushWeixin(userInfos, Received.MeetingTitle); |
|
|
|
} |
|
|
|
catch (Exception e) |
|
|
|
{ |
|
|
|
} |
|
|
|
//飞星推送 |
|
|
|
Task.Run(async () => |
|
|
|
{ |
|
|
|
using (var hubConnection = new HubConnection(ConfigurationManager.AppSettings["CommunicationServeraddress"])) |
|
|
|
{ |
|
|
|
var hubProxy = hubConnection.CreateHubProxy("SignalRHub"); |
|
|
|
await hubConnection.Start(); |
|
|
|
await hubProxy.Invoke("PushAnnouncement", Received.InternalParticipants, Received.MeetingTitle, Util.Str.ReplaceHtml(HttpUtility.HtmlDecode(Received.Content)).Length < 20 ? Util.Str.ReplaceHtml(HttpUtility.HtmlDecode(Received.Content)) : Util.Str.ReplaceHtml(HttpUtility.HtmlDecode(Received.Content)).Substring(0, 20), "mail", string.Join(",", userInfos.Select(m => m.F_UserId)), ""); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public void PushWeixin(List<UserEntity> needpostuserlist, string title) |
|
|
|
{ |
|
|
|
var WeChatConfigentity = BaseRepository().FindEntity<WeChatConfigEntity>(m => m.IsEnable == true); |
|
|
|
string appid = WeChatConfigentity.APPId; |
|
|
|
string secret = WeChatConfigentity.secret; |
|
|
|
var wechatemplete = BaseRepository() |
|
|
|
.FindEntity<WeChatTemplateEntity>(m => m.WeID == WeChatConfigentity.ID && m.TCode == "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); |
|
|
|
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 + "/#/?page=mail\"," + |
|
|
|
"\"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); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
#endregion |
|
|
|
|
|
|
|
} |
|
|
|