ソースを参照

【修改】必修课选修课课表同步增加微信推送、飞星推送;

金隅分支
dyy 4年前
コミット
4cac520d80
4個のファイルの変更205行の追加9行の削除
  1. +105
    -7
      Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Controllers/ArrangeLessonTermController.cs
  2. +98
    -0
      Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Controllers/ArrangeLessonTermOfElectiveController.cs
  3. +1
    -1
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/AssetManagementSystem/Ass_AssetsInfoApply/Ass_AssetsInfoApplyService.cs
  4. +1
    -1
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/EADateArrange/EADateArrangeService.cs

+ 105
- 7
Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Controllers/ArrangeLessonTermController.cs ファイルの表示

@@ -1,8 +1,17 @@
using Learun.Application.TwoDevelopment.EducationalAdministration;
using Learun.Application.Organization;
using Learun.Application.TwoDevelopment.EducationalAdministration;
using Learun.Application.TwoDevelopment.LR_Desktop;
using Learun.Util;
using Learun.Util.Operat;
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.Threading.Tasks;
using System.Web;
using System.Web.Mvc;

namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers
@@ -17,6 +26,10 @@ namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers
public class ArrangeLessonTermController : MvcControllerBase
{
private ArrangeLessonTermIBLL arrangeLessonTermIBLL = new ArrangeLessonTermBLL();
private Sys_InformationPushIBLL sys_InformationPushIBLL = new Sys_InformationPushBLL();
private UserIBLL userIbll = new UserBLL();
private WeChatConfigIBLL weChatConfigIbll = new WeChatConfigBLL();
private WeChatTempletIBLL weChatTempletIbll = new WeChatTempletBLL();

#region 视图功能

@@ -27,7 +40,7 @@ namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers
[HttpGet]
public ActionResult Index()
{
return View();
return View();
}
/// <summary>
/// 表单页
@@ -36,7 +49,7 @@ namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers
[HttpGet]
public ActionResult Form()
{
return View();
return View();
}
/// <summary>
/// 按条件清空排课数据
@@ -71,7 +84,7 @@ namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers
/// <returns></returns>
[HttpGet]
[AjaxOnly]
public ActionResult GetList( string queryJson )
public ActionResult GetList(string queryJson)
{
var data = arrangeLessonTermIBLL.GetList(queryJson).ToList()
.OrderBy(x => x.AcademicYearNo).ThenBy(x => x.Semester).ThenBy(x => x.DeptNo).ThenBy(x => x.MajorNo).ThenBy(x => x.LessonNo).ThenBy(x => x.TeachClassNo.Replace(x.LessonName, "")).ThenBy(x => x.EmpNo).ThenBy(x => x.ClassroomNo).ThenBy(x => x.LessonDate);
@@ -133,7 +146,7 @@ namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers
[HttpPost]
[ValidateAntiForgeryToken]
[AjaxOnly]
public ActionResult SaveForm(string keyValue,ArrangeLessonTermEntity entity)
public ActionResult SaveForm(string keyValue, ArrangeLessonTermEntity entity)
{
arrangeLessonTermIBLL.SaveEntity(keyValue, entity);
return Success("保存成功!");
@@ -148,7 +161,7 @@ namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers
[AjaxOnly]
public async Task<ActionResult> AsyncArrangeLessonData()
{
var data =await arrangeLessonTermIBLL.AsyncArrangeLessonData();
var data = await arrangeLessonTermIBLL.AsyncArrangeLessonData();
return Success(data);
}

@@ -185,6 +198,34 @@ namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers
public async Task<ActionResult> AsyncArrangeLessonDataByCondition(ArrangeLessonTermEntity entity)
{
var data = await arrangeLessonTermIBLL.AsyncArrangeLessonDataByCondition(entity);
if (data)
{
//读取信息推送管理-课表同步推送(09)的配置
var informationPushEntity = sys_InformationPushIBLL.GetEntityByPushItem("09");
if (informationPushEntity != null && informationPushEntity.Status == true)
{
var title = string.Format("{0}学年第{1}学期必修课课表同步", entity.AcademicYearNo, entity.Semester);
var needpostuserlist = userIbll.GetAllList().Where(m => m.F_DeleteMark != 1 && m.F_EnabledMark == 1 && m.F_Description == "教师").ToList();
//微信推送
try
{
PushWeixin(needpostuserlist, title);
}
catch (Exception e)
{
}
//飞星推送
await Task.Run(async () =>
{
using (var hubConnection = new HubConnection(ConfigurationManager.AppSettings["CommunicationServeraddress"]))
{
var hubProxy = hubConnection.CreateHubProxy("SignalRHub");
await hubConnection.Start();
await hubProxy.Invoke("PushAnnouncement", LoginUserInfo.Get().userId, "课表同步", Util.Str.ReplaceHtml(HttpUtility.HtmlDecode(title)).Length < 20 ? Util.Str.ReplaceHtml(HttpUtility.HtmlDecode(title)) : Util.Str.ReplaceHtml(HttpUtility.HtmlDecode(title)).Substring(0, 20), "synclesson", string.Join(",", needpostuserlist.Select(m => m.F_UserId)), "");
}
});
}
}
return Success(data);
}
/// <summary>
@@ -194,11 +235,68 @@ namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers
/// <returns></returns>
[HttpPost]
[AjaxOnly]
public ActionResult InitAsyncDataByCondition(ArrangeLessonTermEntity entity)
public ActionResult InitAsyncDataByCondition(ArrangeLessonTermEntity entity)
{
var data = arrangeLessonTermIBLL.InitAsyncDataByCondition(entity);
return Success(data);
}
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 = "ArrangeLessonTermController";
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 = "ArrangeLessonTermController";
operateLogModel.sourceObjectId = "002";
operateLogModel.sourceContentJson = pushresult;
OperatorHelper.Instance.WriteOperateLog(operateLogModel);
}
}
}
}
}
}


}
}

+ 98
- 0
Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Controllers/ArrangeLessonTermOfElectiveController.cs ファイルの表示

@@ -4,6 +4,15 @@ using Learun.Application.TwoDevelopment.EducationalAdministration;
using System.Web.Mvc;
using System.Collections.Generic;
using System.Threading.Tasks;
using System;
using Microsoft.AspNet.SignalR.Client;
using System.Configuration;
using System.Web;
using System.Linq;
using Learun.Application.Organization;
using Learun.Util.Operat;
using Newtonsoft.Json;
using Learun.Application.TwoDevelopment.LR_Desktop;

namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers
{
@@ -17,6 +26,10 @@ namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers
public class ArrangeLessonTermOfElectiveController : MvcControllerBase
{
private ArrangeLessonTermOfElectiveIBLL arrangeLessonTermOfElectiveIBLL = new ArrangeLessonTermOfElectiveBLL();
private Sys_InformationPushIBLL sys_InformationPushIBLL = new Sys_InformationPushBLL();
private UserIBLL userIbll = new UserBLL();
private WeChatConfigIBLL weChatConfigIbll = new WeChatConfigBLL();
private WeChatTempletIBLL weChatTempletIbll = new WeChatTempletBLL();

#region 视图功能

@@ -165,8 +178,93 @@ namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers
public async Task<ActionResult> AsyncArrangeLessonDataByCondition(ArrangeLessonTermOfElectiveEntity entity)
{
var data = await arrangeLessonTermOfElectiveIBLL.AsyncArrangeLessonDataByCondition(entity);
if (data)
{
//读取信息推送管理-课表同步推送(09)的配置
var informationPushEntity = sys_InformationPushIBLL.GetEntityByPushItem("09");
if (informationPushEntity != null && informationPushEntity.Status == true)
{
var title = string.Format("{0}学年第{1}学期选修课课课表同步", entity.AcademicYearNo, entity.Semester);
var needpostuserlist = userIbll.GetAllList().Where(m => m.F_DeleteMark != 1 && m.F_EnabledMark == 1 && m.F_Description == "教师").ToList();
//微信推送
try
{
PushWeixin(needpostuserlist, title);
}
catch (Exception e)
{
}
//飞星推送
await Task.Run(async () =>
{
using (var hubConnection = new HubConnection(ConfigurationManager.AppSettings["CommunicationServeraddress"]))
{
var hubProxy = hubConnection.CreateHubProxy("SignalRHub");
await hubConnection.Start();
await hubProxy.Invoke("PushAnnouncement", LoginUserInfo.Get().userId, "课表同步", Util.Str.ReplaceHtml(HttpUtility.HtmlDecode(title)).Length < 20 ? Util.Str.ReplaceHtml(HttpUtility.HtmlDecode(title)) : Util.Str.ReplaceHtml(HttpUtility.HtmlDecode(title)).Substring(0, 20), "synclesson", string.Join(",", needpostuserlist.Select(m => m.F_UserId)), "");
}
});
}
}
return Success(data);
}
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 = "ArrangeLessonTermOfElectiveController";
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 = "ArrangeLessonTermOfElectiveController";
operateLogModel.sourceObjectId = "002";
operateLogModel.sourceContentJson = pushresult;
OperatorHelper.Instance.WriteOperateLog(operateLogModel);
}
}
}
}
}
}

#endregion

}


+ 1
- 1
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/AssetManagementSystem/Ass_AssetsInfoApply/Ass_AssetsInfoApplyService.cs ファイルの表示

@@ -278,7 +278,7 @@ namespace Learun.Application.TwoDevelopment.AssetManagementSystem
var assinfoapp = db.FindEntity<Ass_AssetsInfoApplyEntity>(m => m.AAProcessId == processId);
var assPurchase = db.FindEntity<Ass_PurchaseEntity>(a => a.PId == assinfoapp.PId);
//通知申请人
var purchaseApplyEntity = db.FindEntity<Ass_PurchaseApplyEntity>(a => a.PAId = assPurchase.PAId);
var purchaseApplyEntity = db.FindEntity<Ass_PurchaseApplyEntity>(a => a.PAId == assPurchase.PAId);
purchaseApplyEntity.PIsInStorage = "已入库";
db.Update(purchaseApplyEntity);
if (null != assPurchase)


+ 1
- 1
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/EADateArrange/EADateArrangeService.cs ファイルの表示

@@ -187,11 +187,11 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration
var entity = this.BaseRepository("CollegeMIS").FindEntity<EADateArrangeEntity>(keyValue);
if (entity != null)
{
var needpostuserlist = this.BaseRepository().FindList<UserEntity>(m => m.F_DeleteMark != 1 && m.F_EnabledMark == 1 && m.F_Description == "教师").ToList();
//读取信息推送管理-教学工作安排推送(08)的配置
var informationPushEntity = this.BaseRepository().FindEntity<Sys_InformationPushEntity>(x => x.PushItem == "08");
if (informationPushEntity != null && informationPushEntity.Status == true)
{
var needpostuserlist = this.BaseRepository().FindList<UserEntity>(m => m.F_DeleteMark != 1 && m.F_EnabledMark == 1 && m.F_Description == "教师").ToList();
//微信推送
try
{


読み込み中…
キャンセル
保存