Bladeren bron

【修改】教学工作安排增加微信推送、飞星推送;

西昌缴费二期
dyy 4 jaren geleden
bovenliggende
commit
758d66624f
1 gewijzigde bestanden met toevoegingen van 88 en 3 verwijderingen
  1. +88
    -3
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/EADateArrange/EADateArrangeService.cs

+ 88
- 3
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/EADateArrange/EADateArrangeService.cs Bestand weergeven

@@ -1,10 +1,18 @@
using Dapper;
using Learun.Application.Organization;
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.EducationalAdministration
{
@@ -174,6 +182,38 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration
try
{
this.BaseRepository("CollegeMIS").ExecuteBySql("update EADateArrange set CheckMark=" + checkMark + " where dm='" + keyValue + "'");
if (checkMark == 1)//审核
{
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)
{
//微信推送
try
{
PushWeixin(needpostuserlist, entity.WorkName);
}
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", LoginUserInfo.Get().userId, entity.WorkName, Util.Str.ReplaceHtml(HttpUtility.HtmlDecode(entity.WorkName)).Length < 20 ? Util.Str.ReplaceHtml(HttpUtility.HtmlDecode(entity.WorkName)) : Util.Str.ReplaceHtml(HttpUtility.HtmlDecode(entity.WorkName)).Substring(0, 20), "eadatearrange", string.Join(",", needpostuserlist.Select(m => m.F_UserId)), "");
}
});
}

}
}
}
catch (Exception ex)
{
@@ -269,7 +309,7 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration
{
//成绩录入前初始化数据
//必修课
if (string.IsNullOrEmpty(entity.LessonSortNo) ||entity.LessonSortNo=="1")
if (string.IsNullOrEmpty(entity.LessonSortNo) || entity.LessonSortNo == "1")
{
//dyy:20190429
string sql = @"insert into stuscore(NoticeBookNo,StuNo,DeptNo,MajorNo,ClassNo,StuName,GenderNo,AcademicYearNo,Semester,OpenLessonDeptNo,OpenLessonMajorNo,LessonNo,LessonName,LessonNameEn,TeachClassNo,LessonSortNo,StuSortNo,Grade,StudyScore,TotalStudyHour,OrdinaryScore,TermInScore,TermEndScore,OtherScore,IsInEffect,Remark,ConflictLessonNo,IsPitchOn,CheckMark,TechPlanNo,EmpNo,PartCode,ScoreRecordStyleNo,TestModeNo,zysx,TestKindNo,IsEditable,F_SchoolId)
@@ -283,7 +323,7 @@ where s.CheckMark='1'
) as sl
where StuNo not in(Select StuNo from stuscore s where s.Academicyearno=sl.Academicyearno
and s.Semester=sl.Semester and s.lessonno=sl.lessonno and s.teachclassno=sl.teachclassno and s.LessonSortNo='1'
and s.Academicyearno='"+entity.AcademicYearNo+ "' and s.Semester='"+entity.Semester+ "') and sl.AcademicYearNo='"+entity.AcademicYearNo+ "' and sl.Semester='"+entity.Semester+"'";
and s.Academicyearno='" + entity.AcademicYearNo + "' and s.Semester='" + entity.Semester + "') and sl.AcademicYearNo='" + entity.AcademicYearNo + "' and sl.Semester='" + entity.Semester + "'";
BaseRepository("CollegeMIS").ExecuteBySql(sql);
//dyy:20190722
//初始化教师成绩单提交表
@@ -299,7 +339,7 @@ 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";
and a.Academicyearno='" + entity.AcademicYearNo + "' and a.Semester='" + entity.Semester + "') and bb.AcademicYearNo='" + entity.AcademicYearNo + "' and bb.Semester='" + entity.Semester + "' order by bb.EmpNo";
BaseRepository("CollegeMIS").ExecuteBySql(sql3);
}
//选修课
@@ -350,5 +390,50 @@ and a.Academicyearno='" + entity.AcademicYearNo + "' and a.Semester='" + entity.
}
}
}


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 + "\"," +
"\"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);
}
}
}
}
}
}


}
}

Laden…
Annuleren
Opslaan