dyy 3 days ago
parent
commit
429d4eceff
10 changed files with 6247 additions and 15 deletions
  1. +33
    -0
      DigitalSchoolApi/App_Data/LogHelper.cs
  2. +157
    -2
      DigitalSchoolApi/Controllers/HKAttendanceController.cs
  3. +380
    -0
      DigitalSchoolApi/Controllers/HTSchoolController.cs
  4. +61
    -3
      DigitalSchoolApi/Controllers/YKTController.cs
  5. +29
    -1
      DigitalSchoolApi/Controllers/海康考勤机/CHCNetSDK.cs
  6. +5
    -2
      DigitalSchoolApi/DigitalSchoolApi.csproj
  7. +5491
    -0
      DigitalSchoolApi/DigitalSchoolApi.xml
  8. +86
    -0
      DigitalSchoolApi/Models/HtEntity.cs
  9. +4
    -6
      DigitalSchoolApi/Web.config
  10. +1
    -1
      DigitalSchoolApi/packages.config

+ 33
- 0
DigitalSchoolApi/App_Data/LogHelper.cs View File

@@ -0,0 +1,33 @@
using System;
using System.IO;

namespace Util.Log
{
public class LogHelper
{
public static void Info(string msg)
{
try
{
#region log
//文件路径
string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "logs");
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}

//文件
string fileName = Path.Combine(path, $"{DateTime.Now:yyyyMMdd}.log");
string message = $"{DateTime.Now:yyyy-MM-dd HH:mm:ss} logInfo:{msg}。{Environment.NewLine}";
File.AppendAllText(fileName, message);
#endregion
}
catch
{


}
}
}
}

+ 157
- 2
DigitalSchoolApi/Controllers/HKAttendanceController.cs View File

@@ -6,10 +6,17 @@ using System.Data.SqlClient;
using System.Diagnostics.Eventing.Reader;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Runtime.InteropServices;
using System.Text;
using System.Web;
using AlarmCSharpDemo;
using Antlr.Runtime.Misc;
using Dapper;
using Learun.Util;
using Org.BouncyCastle.Asn1.X509;
using Org.BouncyCastle.Ocsp;

namespace DigitalSchoolApi.Controllers
{
@@ -57,7 +64,7 @@ namespace DigitalSchoolApi.Controllers
{
//开始自动打卡
//删除今日考勤
connmis.Execute("delete from ADR_Record where ADYear='"+ workDateTime.Year + "' and ADMonth='" + workDateTime.Month.ToString().PadLeft(2,'0') + "' and ADDay='"+ workDateTime.Day.ToString().PadLeft(2,'0') + "' and UserNo='"+ useritem.EmpNo + "'");
connmis.Execute("delete from ADR_Record where ADYear='" + workDateTime.Year + "' and ADMonth='" + workDateTime.Month.ToString().PadLeft(2, '0') + "' and ADDay='" + workDateTime.Day.ToString().PadLeft(2, '0') + "' and UserNo='" + useritem.EmpNo + "'");
//上午上班
ADR_RecordEntity adrRecordEntity = new ADR_RecordEntity();
adrRecordEntity.Create();
@@ -103,7 +110,7 @@ namespace DigitalSchoolApi.Controllers
//adrRecordEntity.ADTime = offworkDateTime.AddMinutes(10);
//adrRecordEntity.ClockTime = offworkDateTime.AddMinutes(10);
//liangkun 2021-05-06 应客户要求改为下午6:00下班
adrRecordEntity.ADTime = Convert.ToDateTime(datenow + " 18:00");
adrRecordEntity.ADTime = Convert.ToDateTime(datenow + " 18:00");
adrRecordEntity.ClockTime = Convert.ToDateTime(datenow + " 18:00");
connmis.Execute("insert into ADR_Record(ID, UserNo, ADType, ADTime, ClockTime, ClockStatus, ClockPlace, ADYear, ADMonth, ADDay, ADPhoto) values(" +
"'" + adrRecordEntity.ID + "','" + adrRecordEntity.UserNo + "','" + adrRecordEntity.ADType + "','" + adrRecordEntity.ADTime + "'," +
@@ -1113,7 +1120,155 @@ namespace DigitalSchoolApi.Controllers
return true;
}
}
/// <summary>
/// 开门
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public static string OpenDoor(string id)
{
using (IDbConnection connmis = new SqlConnection(_misConnection))
{
//获取设备
var device = connmis.QueryFirstOrDefault<ADR_DeviceEntity>($"select * from ADR_Device where F_EnabledMark=1 and Id='{id}'");
if(device!=null)
{
string url = $"http://{device.IpAddress}/ISAPI/AccessControl/RemoteControl/door/1";
string username = device.AdminAccount;
string password = device.AdminPwd;
string data = $"<?xml version=\"1.0\" encoding=\"UTF-8\"?><RemoteControlDoor xmlns=\"http://www.isapi.org/ver20/XMLSchema\" version=\"2.0\"><cmd>open</cmd> <password>{device.AdminPwd}</password><employeeNo>1</employeeNo><channelNo>1</channelNo><controlType>monitor</controlType><personnelChannelGroupInfoList><personnelChannelGroupInfo><personnelChannelGroupID>1</personnelChannelGroupID><personnelChannelInfoList><personnelChannelInfo><personnelChannelID>1</personnelChannelID></personnelChannelInfo></personnelChannelInfoList></personnelChannelGroupInfo></personnelChannelGroupInfoList><lastOpenDoorFlag>true</lastOpenDoorFlag><callNumber>101</callNumber></RemoteControlDoor>";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Method = "PUT";
request.ContentType = "application/xml";
request.Credentials = new NetworkCredential(username, password);
byte[] byteArray = Encoding.UTF8.GetBytes(data);
request.ContentLength = byteArray.Length;
Stream dataStream = request.GetRequestStream();
dataStream.Write(byteArray, 0, byteArray.Length);
dataStream.Close();
HttpWebResponse response;

try
{
response = (HttpWebResponse)request.GetResponse();
}
catch (WebException ex)
{
response = (HttpWebResponse)ex.Response;
}
//Console.WriteLine("Response status: {0}", response.StatusDescription);
dataStream = response.GetResponseStream();
StreamReader reader = new StreamReader(dataStream);

string responseFromServer = reader.ReadToEnd();

//Console.WriteLine(responseFromServer);
reader.Close();
dataStream.Close();

response.Close();
return "开门成功";
}
return "未找到设备";
}

}

/// <summary>
/// 关门
/// </summary>
/// <param name="id"></param>
public static void CloseDoor(string id)
{
using (IDbConnection connmis = new SqlConnection(_misConnection))
{
//获取设备
var device = connmis.QueryFirstOrDefault<ADR_DeviceEntity>($"select * from ADR_Device where F_EnabledMark=1 and Id='{id}'");
if (device != null)
{
string url = $"http://{device.IpAddress}/ISAPI/AccessControl/RemoteControl/door/1";
string username = device.AdminAccount;
string password = device.AdminPwd;
string data = $"<?xml version=\"1.0\" encoding=\"UTF-8\"?><RemoteControlDoor xmlns=\"http://www.isapi.org/ver20/XMLSchema\" version=\"2.0\"><cmd>close</cmd> <password>{device.AdminPwd}</password><employeeNo>1</employeeNo><channelNo>1</channelNo><controlType>monitor</controlType><personnelChannelGroupInfoList><personnelChannelGroupInfo><personnelChannelGroupID>1</personnelChannelGroupID><personnelChannelInfoList><personnelChannelInfo><personnelChannelID>1</personnelChannelID></personnelChannelInfo></personnelChannelInfoList></personnelChannelGroupInfo></personnelChannelGroupInfoList><lastOpenDoorFlag>true</lastOpenDoorFlag><callNumber>101</callNumber></RemoteControlDoor>";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Method = "PUT";
request.ContentType = "application/xml";
request.Credentials = new NetworkCredential(username, password);
byte[] byteArray = Encoding.UTF8.GetBytes(data);
request.ContentLength = byteArray.Length;
Stream dataStream = request.GetRequestStream();
dataStream.Write(byteArray, 0, byteArray.Length);
dataStream.Close();
HttpWebResponse response;

try
{
response = (HttpWebResponse)request.GetResponse();
}
catch (WebException ex)
{
response = (HttpWebResponse)ex.Response;
}
//Console.WriteLine("Response status: {0}", response.StatusDescription);
dataStream = response.GetResponseStream();
StreamReader reader = new StreamReader(dataStream);

string responseFromServer = reader.ReadToEnd();

//Console.WriteLine(responseFromServer);
reader.Close();
dataStream.Close();

response.Close();
}
}
}

public static string CaptureJPEG(string id)
{
try
{
using (IDbConnection connmis = new SqlConnection(_misConnection))
{
uint iBuffSize = 400000;
byte[] byJpegPicBuffer = new byte[iBuffSize];
uint dwSizeReturned = 0;
var deviceEntity = connmis.QueryFirstOrDefault<ADR_DeviceEntity>($"select * from ADR_Device where id='{id}';");
if (deviceEntity == null)
{
return "设备不存在!";
}
if (deviceEntity.F_EnabledMark == 0)
{
return "设备未启用!";
}
#region 登录考勤机
CHCNetSDK.NET_DVR_Init();
CHCNetSDK.NET_DVR_DEVICEINFO_V30 DeviceInfo = new CHCNetSDK.NET_DVR_DEVICEINFO_V30();
var m_lUserID = CHCNetSDK.NET_DVR_Login_V30(deviceEntity.IpAddress, deviceEntity.PortNumber.Value, deviceEntity.AdminAccount, deviceEntity.AdminPwd, ref DeviceInfo);
if (m_lUserID < 0)
{
return "设备登录失败!";
}
#endregion
CHCNetSDK.NET_DVR_JPEGPARA lpJpegPara = new CHCNetSDK.NET_DVR_JPEGPARA();
lpJpegPara.wPicQuality = 0;
lpJpegPara.wPicSize = 0xff;

if (CHCNetSDK.NET_DVR_CaptureJPEGPicture_NEW(m_lUserID, 1 + (int)DeviceInfo.byStartChan, ref lpJpegPara, byJpegPicBuffer,
iBuffSize, ref dwSizeReturned))
{
return "data:image/jpeg;base64," + Convert.ToBase64String(byJpegPicBuffer, 0, (int)dwSizeReturned);
}
return "设备抓图失败!";
}
}
catch (Exception e)
{
return "设备抓图异常:" + e.Message;
}
}
#region 考勤结构体
/// <summary>
/// 考勤设备日志


+ 380
- 0
DigitalSchoolApi/Controllers/HTSchoolController.cs View File

@@ -0,0 +1,380 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.OracleClient;
using System.Data.SqlClient;
using System.Diagnostics;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using System.Web;
using Dapper;
using DigitalSchoolApi.App_Data;
using DigitalSchoolApi.Models;
using Learun.Application.Organization;
using Learun.Util;
using Microsoft.AspNet.SignalR.Client;
using Newtonsoft.Json;
using static DigitalSchoolApi.Controllers.HKAttendanceController;
using Convert = System.Convert;
using DESEncrypt = Learun.Util.DESEncrypt;
using Md5Helper = Learun.Util.Md5Helper;

namespace DigitalSchoolApi.Controllers
{
/// <summary>
/// 塔里木学院定时需求
/// </summary>
public class HTSchoolController
{
private readonly static string _admsConnection = ConfigurationManager.ConnectionStrings["CoreDBString"].ConnectionString;
private readonly static string _misConnection = ConfigurationManager.ConnectionStrings["ConnectionPfcMisDBString"].ConnectionString;
private static string _htMiddleConnection = ConfigurationManager.ConnectionStrings["htMiddleDBString"].ConnectionString;

//private readonly static string _tlmMiddleConnection =ConfigurationManager.ConnectionStrings["TLMMiddleDBString"].ConnectionString;



#region 中间库同步到数校

/// <summary>
/// 从中间库同步系部数据
/// </summary>
public static void SyncDepartment()
{
try
{
IEnumerable<HTMiddleOrganize> entityList = null;
using (IDbConnection conn = new SqlConnection(_htMiddleConnection))
{
entityList = conn.Query<HTMiddleOrganize>("SELECT * FROM nc_orgnization");
}
using (IDbConnection conn = new SqlConnection(_admsConnection))
{
try
{
var maxSort = -1;
try
{
maxSort = conn.QueryFirstOrDefault<int>("select MAX(F_Order) FROM LR_BASE_DEPARTMENT");
}
catch (Exception e)
{
maxSort = -1;
}

//插入sql
foreach (var item in entityList)
{
DepartmentEntity model = null;
using (IDbConnection xbconn = new SqlConnection(_admsConnection))
{
model = xbconn.QueryFirstOrDefault<DepartmentEntity>($"select * from LR_BASE_DEPARTMENT where F_EnCode='{item.CODE}'");
}
if (model == null)
{
maxSort++;
var id = item.ID.Length == 30 ? Guid.ParseExact(item.ID, "N") : Guid.NewGuid();
//没有就新增
var sql =
"INSERT INTO LR_BASE_DEPARTMENT (F_DepartmentId, F_CompanyId, F_ParentId, F_EnCode, F_FullName, F_Order,F_DeleteMark,F_EnabledMark) " +
$"VALUES ('{id}', '207fa1a9-160c-4943-a89b-8fa4db0547ce', '{item.FID}', '{item.CODE}', '{item.NAME}', {maxSort},0,1);";
conn.Execute(sql);
}
else
{
//存在就修改
var sql = $"UPDATE LR_BASE_DEPARTMENT SET F_FullName='{item.NAME}',F_ParentId='{item.FID}' where F_EnCode='{model.F_EnCode}';";
conn.Execute(sql);
}

}
//插入数据同步结果
using (IDbConnection conncore = new SqlConnection(_admsConnection))
{
conncore.Execute(
"insert into LR_Base_Log(F_LogId,F_CategoryId,F_SourceObjectId,F_SourceContentJson,F_OperateTime) values(newid(),999,'从中间库同步部门信息到数校完成','部门同步数量:" +
entityList.Count() + "条',getdate())");
}
}
catch (Exception e)
{
using (IDbConnection conncore = new SqlConnection(_admsConnection))
{
conncore.Execute(
"insert into LR_Base_Log(F_LogId,F_CategoryId,F_SourceObjectId,F_SourceContentJson,F_OperateTime) values(newid(),999,'从中间库同步部门信息到数校异常','" +
e.Message + "',getdate())");
}
}
}
}
catch (Exception e)
{
using (IDbConnection conn = new SqlConnection(_admsConnection))
{
conn.Execute(
"insert into LR_Base_Log(F_LogId,F_CategoryId,F_SourceObjectId,F_SourceContentJson,F_OperateTime) values(newid(),999,'从中间库同步部门信息到数校异常','错误信息:" +
e.Message + "',getdate())");
}
}
}

/// <summary>
/// 从中间库同步学生数据
/// </summary>
public static void SyncStuInfoAcc()
{
try
{

IEnumerable<HTMiddleStuInfo> entityList = null;
using (IDbConnection conn = new SqlConnection(_htMiddleConnection))
{
entityList = conn.Query<HTMiddleStuInfo>($"SELECT * FROM nc_stuInfo");
}

try
{
//插入sql
foreach (var item in entityList)
{
var id = Guid.NewGuid().ToString();
var MZ = "";
var xb = item.GenderNo == "1" ? 1 : 0;


UserEntity model = null;
StuInfoBasicEntity stu = null;
using (IDbConnection xbconn = new SqlConnection(_admsConnection))
{
var dept = xbconn.QueryFirstOrDefault<DepartmentEntity>($"select * from LR_BASE_DEPARTMENT where F_EnCode='{item.DeptNo}'");
var deptId = string.Empty;
if (dept != null)
{
deptId = dept.F_DepartmentId;
}
model = xbconn.QueryFirstOrDefault<UserEntity>($"select * from LR_Base_User where F_Account='{item.USERNAME}'");

if (model == null)
{

var key = Md5Helper.Encrypt(CreateNo(), 16).ToLower();
var pwd = Md5Helper.Encrypt(DESEncrypt.Encrypt(Md5Helper.Encrypt("ht123456", 32).ToLower(), key).ToLower(), 32).ToLower();


var userSql =
$"INSERT INTO LR_Base_User (F_UserId,F_EnCode,F_Account,F_Mobile,F_Password,F_Secretkey,F_RealName,F_Gender,F_CompanyId," +
$"F_DepartmentId,F_DeleteMark,F_EnabledMark,F_Description,F_CreateDate,F_CreateUserId,F_CreateUserName,F_IdentityCardNo) VALUES('{id}'," +
$"'{item.USERNAME}','{item.USERNAME}','{item.MOBILE}','{pwd}','{key}','{item.StuName}',{xb},'207fa1a9-160c-4943-a89b-8fa4db0547ce','{deptId}',0,1,'学生'," +
$"'{DateTime.Now:yyyy-MM-dd hh:mm:ss}','System','数据同步','{item.IdentityCardNo}');";

xbconn.Execute(userSql);

}
else
{
id = model.F_UserId;
var sql = $"UPDATE LR_Base_User SET F_RealName='{item.StuName}',F_Gender={xb},F_DepartmentId='{deptId}' WHERE F_Account='{item.USERNAME}'";
xbconn.Execute(sql);
}
//设置默认角色
var rel = xbconn.QueryFirstOrDefault<LR_Base_UserRelationEntity>($"select * from LR_Base_UserRelation where F_UserId='{id}' and F_ObjectId='0cfc388c-80e6-4cf0-b53b-02201827490a'");
if (rel == null)
{
var sql = $"insert into LR_Base_UserRelation (F_UserRelationId,F_UserId,F_Category,F_ObjectId,F_CreateDate,F_CreateUserId,F_CreateUserName) values ('{Guid.NewGuid()}','{id}',1,'0cfc388c-80e6-4cf0-b53b-02201827490a','{DateTime.Now}','System','同步生成')";
xbconn.Execute(sql);
}
}

using (IDbConnection conn = new SqlConnection(_misConnection))
{
stu = conn.QueryFirstOrDefault<StuInfoBasicEntity>($"select * from StuInfoBasic where StuNo='{item.USERNAME}'");

if (stu == null)
{
var sql = "INSERT INTO StuInfoBasic(StuId,StuNo,StuCode,NoticeNo,GraduateYear,ksh,DeptNo,MajorNo,Grade,ClassNo,StuName,SpellFull,GenderNo,Birthday,PartyFaceNo," +
"FamilyOriginNo,NationalityNo,ResidenceNo,HealthStatusNo,GraduateNo,OverseasChineseNo,GoodAt,IdentityCardNo,InSchoolAddress," +
"InSchoolTelephone,Remark,mobile,CheckMark,InSchoolStatus,F_SchoolId,EduSystem,StudyModality) " +
$"VALUES('{id}','{item.USERNAME}','{item.CODE}','','','', '{item.DeptNo}', '{item.MajorNo}'," +
$"'{item.Grade}','{item.ClassNo}','{item.StuName}', '',{xb},'','',''," +
$"'{item.NationalityNo}','','1','2','0','','{item.IdentityCardNo}','','',''," +
$"'{item.MOBILE}','1','','207fa1a9-160c-4943-a89b-8fa4db0547ce', '2', '1');";
conn.Execute(sql);
}
else
{
var sql =
$"UPDATE StuInfoBasic SET StuName='{item.StuName}',GenderNo={xb},IdentityCardNo='{item.IdentityCardNo}'," +
$"Grade='{item.Grade}',DeptNo='{item.DeptNo}',StuCode='{item.CODE}',mobile='{item.MOBILE}'," +
$"MajorNo='{item.MajorNo}',ClassNo='{item.ClassNo}' where StuNo='{stu.StuNo}';";
conn.Execute(sql);
}

}


}
//插入数据同步结果
using (IDbConnection conncore = new SqlConnection(_admsConnection))
{
conncore.Execute(
"insert into LR_Base_Log(F_LogId,F_CategoryId,F_SourceObjectId,F_SourceContentJson,F_OperateTime) values(newid(),999,'从中间库同步学生信息到数校完成','学生同步数量:" +
entityList.Count() + "条',getdate())");
}
}
catch (Exception e)
{
using (IDbConnection conncore = new SqlConnection(_admsConnection))
{
conncore.Execute(
"insert into LR_Base_Log(F_LogId,F_CategoryId,F_SourceObjectId,F_SourceContentJson,F_OperateTime) values(newid(),998,'从中间库同步学生信息到数校异常','" +
e.ToString() + "',getdate())");
}
}
}
catch (Exception e)
{
using (IDbConnection conn = new SqlConnection(_admsConnection))
{
conn.Execute(
"insert into LR_Base_Log(F_LogId,F_CategoryId,F_SourceObjectId,F_SourceContentJson,F_OperateTime) values(newid(),999,'从中间库同步学生信息到数校异常','错误信息:" +
e.ToString() + "',getdate())");
}
}
}

/// <summary>
/// 从中间库同步教师数据
/// </summary>
public static void SyncEmpInfoAcc()
{
try
{

IEnumerable<HTMiddleEmpInfo> entityList = null;
using (IDbConnection conn = new SqlConnection(_htMiddleConnection))
{
entityList = conn.Query<HTMiddleEmpInfo>($"SELECT * FROM nc_user");
}

try
{
//插入sql
foreach (var item in entityList)
{
var id = Guid.NewGuid().ToString();
var MZ = "";
var xb = item.GENDER == "男性" ? 1 : 0;

UserEntity model = null;
EmpInfoEntity stu = null;
using (IDbConnection xbconn = new SqlConnection(_admsConnection))
{
var dept = xbconn.QueryFirstOrDefault<DepartmentEntity>($"select * from LR_BASE_DEPARTMENT where F_EnCode='{item.MOCODE}'");
var deptId = string.Empty;
if (dept != null)
{
deptId = dept.F_DepartmentId;
}
model = xbconn.QueryFirstOrDefault<UserEntity>($"select * from LR_Base_User where F_Account='{item.USERNAME}'");

if (model == null)
{

var key = Md5Helper.Encrypt(CreateNo(), 16).ToLower();
var pwd = Md5Helper.Encrypt(DESEncrypt.Encrypt(Md5Helper.Encrypt("ht123456", 32).ToLower(), key).ToLower(), 32).ToLower();


var userSql =
$"INSERT INTO LR_Base_User (F_UserId,F_EnCode,F_Account,F_Mobile,F_Password,F_Secretkey,F_RealName,F_Gender,F_CompanyId," +
$"F_DepartmentId,F_DeleteMark,F_EnabledMark,F_Description,F_CreateDate,F_CreateUserId,F_CreateUserName,F_IdentityCardNo) VALUES('{id}'," +
$"'{item.USERNAME}','{item.USERNAME}','{item.MOBILE}','{pwd}','{key}','{item.NAME}',{xb},'207fa1a9-160c-4943-a89b-8fa4db0547ce','{deptId}',0,1,'教师'," +
$"'{DateTime.Now:yyyy-MM-dd hh:mm:ss}','System','数据同步','{item.CARDNO}');";
xbconn.Execute(userSql);


}
else
{
id = model.F_UserId;
var sql = $"UPDATE LR_Base_User SET F_RealName='{item.NAME}',F_Gender={xb},F_DepartmentId='{deptId}' WHERE F_Account='{item.USERNAME}'";
xbconn.Execute(sql);
}
//设置默认角色
var rel = xbconn.QueryFirstOrDefault<LR_Base_UserRelationEntity>($"select * from LR_Base_UserRelation where F_UserId='{id}' and F_ObjectId='ed811d67-59d6-4dfa-8061-299b73388e69'");
if(rel==null)
{
var sql = $"insert into LR_Base_UserRelation (F_UserRelationId,F_UserId,F_Category,F_ObjectId,F_CreateDate,F_CreateUserId,F_CreateUserName) values ('{Guid.NewGuid()}','{id}',1,'ed811d67-59d6-4dfa-8061-299b73388e69','{DateTime.Now}','System','同步生成')";
xbconn.Execute(sql);
}

}
using (IDbConnection conn = new SqlConnection(_misConnection))
{
stu = conn.QueryFirstOrDefault<EmpInfoEntity>($"select * from EmpInfo where EmpNo='{item.USERNAME}'");
if (stu == null)
{
var sql = "INSERT INTO EmpInfo (EmpId,EmpNo,EmpName,GenderNo,DeptNo,IdentityCardNo,mobile,EMail,IsInActiveStatus,CheckMark,F_CompanyId) " +
$"VALUES('{id}','{item.USERNAME}','{item.NAME}',{xb},'{item.MOCODE}','{item.CARDNO}', '{item.MOBILE}', '{item.EMAIL}'," +
$"'{item.STATUS}','1','207fa1a9-160c-4943-a89b-8fa4db0547ce');";
conn.Execute(sql);
}
else
{
var sql =
$"UPDATE EmpInfo SET EmpName='{item.NAME}',GenderNo={xb},IdentityCardNo='{item.CARDNO}'," +
$"DeptNo='{item.MOCODE}',mobile='{item.MOBILE}',EMail='{item.EMAIL}',IsInActiveStatus='{item.STATUS}' where EmpNo='{stu.EmpNo}';";
conn.Execute(sql);
}
}


}
//插入数据同步结果
using (IDbConnection conncore = new SqlConnection(_admsConnection))
{
conncore.Execute(
"insert into LR_Base_Log(F_LogId,F_CategoryId,F_SourceObjectId,F_SourceContentJson,F_OperateTime) values(newid(),000,'从中间库同步老师信息到数校完成','老师同步数量:" +
entityList.Count() + "条',getdate())");
}
}
catch (Exception e)
{
using (IDbConnection conncore = new SqlConnection(_admsConnection))
{
conncore.Execute(
"insert into LR_Base_Log(F_LogId,F_CategoryId,F_SourceObjectId,F_SourceContentJson,F_OperateTime) values(newid(),998,'从中间库同步老师信息到数校异常','" +
e.ToString() + "',getdate())");
}
}
}
catch (Exception e)
{
using (IDbConnection conn = new SqlConnection(_admsConnection))
{
conn.Execute(
"insert into LR_Base_Log(F_LogId,F_CategoryId,F_SourceObjectId,F_SourceContentJson,F_OperateTime) values(newid(),999,'从中间库同步老师信息到数校异常','错误信息:" +
e.ToString() + "',getdate())");
}
}
}
#endregion


private static string CreateNo()
{
Random random = new Random();
string strRandom = random.Next(1000, 10000).ToString(); //生成编号
string code = DateTime.Now.ToString("yyyyMMddHHmmss") + strRandom;//形如
return code;
}



}
}

+ 61
- 3
DigitalSchoolApi/Controllers/YKTController.cs View File

@@ -6,6 +6,8 @@ using System.Data.SqlClient;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using System.Web.Http;
using Dapper;
using DigitalSchoolApi.Models;
@@ -14,7 +16,7 @@ using Learun.Application.Organization;

namespace DigitalSchoolApi.Controllers
{
public class YKTController : BaseController
public class YKTController : BaseController
{
private readonly static string _admsConnection = ConfigurationManager.ConnectionStrings["CoreDBString"].ConnectionString;
private readonly static string _misConnection = ConfigurationManager.ConnectionStrings["ConnectionPfcMisDBString"].ConnectionString;
@@ -273,6 +275,35 @@ namespace DigitalSchoolApi.Controllers
RecurringJob.RemoveIfExists("LeaderAttendance");
return Ok();
}
/// <summary>
/// 开门(延迟5秒后调用关门)
/// </summary>
/// <returns></returns>
public IHttpActionResult OpenCloseDoor(string id,bool c)
{
var r = HKAttendanceController.OpenDoor(id);

if (c)
{
Task.Factory.StartNew(() =>
{

Thread.Sleep(5000);
HKAttendanceController.CloseDoor(id);
});
}
return Ok(r);
}

public IHttpActionResult CaptureJPEG(string id)
{
var result=HKAttendanceController.CaptureJPEG(id);
return Ok(new
{
state = !result.Contains("设备"),
data = result
});
}

#region 长阳报名\晚归预警
/// <summary>
@@ -515,7 +546,7 @@ namespace DigitalSchoolApi.Controllers
//学生
RecurringJob.AddOrUpdate("SyncTLMZYMiddleToStuInfo",
() => TLMSchoolController.SyncStuInfoOracle(null),
Cron.Daily(1), TimeZoneInfo.Local);
Cron.MinuteInterval(5), TimeZoneInfo.Local);
return Ok();
}
/// <summary>
@@ -596,7 +627,7 @@ namespace DigitalSchoolApi.Controllers
() => TLMSchoolController.AssignSendEmail(entityList),
Cron.Daily(entityList[0].F_Hour.Value), TimeZoneInfo.Local);
}
}
}
}
@@ -665,5 +696,32 @@ namespace DigitalSchoolApi.Controllers
}

#endregion

#region 和田数据同步

/// <summary>
/// 和田从中间库中同步到数校
/// </summary>
/// <returns></returns>
public IHttpActionResult SyncDataToDs()
{
//部门
RecurringJob.AddOrUpdate("HTSyncDepartmentToDs",
() => HTSchoolController.SyncDepartment(),
Cron.Daily(1), TimeZoneInfo.Local);

//教师
RecurringJob.AddOrUpdate("HTSyncEmpInfoToDs",
() => HTSchoolController.SyncEmpInfoAcc(),
Cron.Daily(1), TimeZoneInfo.Local);
//学生
RecurringJob.AddOrUpdate("HTSyncStuInfoToDs",
() => HTSchoolController.SyncStuInfoAcc(),
Cron.Daily(1), TimeZoneInfo.Local);

return Ok();
}
#endregion
}
}

+ 29
- 1
DigitalSchoolApi/Controllers/海康考勤机/CHCNetSDK.cs View File

@@ -328,7 +328,16 @@ namespace AlarmCSharpDemo
[MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = 24, ArraySubType = UnmanagedType.I1)]
public byte[] byRes;
}

//图片质量
[StructLayoutAttribute(LayoutKind.Sequential)]
public struct NET_DVR_JPEGPARA
{
/*注意:当图像压缩分辨率为VGA时,支持0=CIF, 1=QCIF, 2=D1抓图,
当分辨率为3=UXGA(1600x1200), 4=SVGA(800x600), 5=HD720p(1280x720),6=VGA,7=XVGA, 8=HD900p
仅支持当前分辨率的抓图*/
public ushort wPicSize;/* 0=CIF, 1=QCIF, 2=D1 3=UXGA(1600x1200), 4=SVGA(800x600), 5=HD720p(1280x720),6=VGA*/
public ushort wPicQuality;/* 图片质量系数 0-最好 1-较好 2-一般 */
}
/*********************************************************
Function: NET_DVR_Init
Desc: 初始化SDK,调用其他SDK函数的前提。
@@ -349,11 +358,30 @@ namespace AlarmCSharpDemo
public static extern bool NET_DVR_SetExceptionCallBack_V30(uint nMessage, IntPtr hWnd, EXCEPYIONCALLBACK fExceptionCallBack, IntPtr pUser);
[DllImport(@"HCNetSDK.dll")]
public static extern bool NET_DVR_SetDVRMessageCallBack_V31(MSGCallBack_V31 fMessageCallBack, IntPtr pUser);
/*********************************************************
Function: NET_DVR_Login_V30
Desc:
Input: sDVRIP [in] 设备IP地址
wServerPort [in] 设备端口号
sUserName [in] 登录的用户名
sPassword [in] 用户密码
Output: lpDeviceInfo [out] 设备信息
Return: -1表示失败,其他值表示返回的用户ID值
**********************************************************/
[DllImport(@".\HCNetSDK.dll")]
public static extern Int32 NET_DVR_Login_V30(string sDVRIP, Int32 wDVRPort, string sUserName, string sPassword, ref NET_DVR_DEVICEINFO_V30 lpDeviceInfo);
[DllImport(@"HCNetSDK.dll")]
public static extern int NET_DVR_Login_V40(ref NET_DVR_USER_LOGIN_INFO pLoginInfo, ref NET_DVR_DEVICEINFO_V40 lpDeviceInfo);
[DllImport(@"HCNetSDK.dll")]
public static extern int NET_DVR_SetupAlarmChan_V41(int lUserID, ref NET_DVR_SETUPALARM_PARAM lpSetupParam);
[DllImport(@"HCNetSDK.dll")]
public static extern bool NET_DVR_CloseAlarmChan_V30(int lAlarmHandle);
//2005-09-15
[DllImport(@".\HCNetSDK.dll")]
public static extern bool NET_DVR_CaptureJPEGPicture(int lUserID, int lChannel, ref NET_DVR_JPEGPARA lpJpegPara, string sPicFileName);

//JPEG抓图到内存
[DllImport(@".\HCNetSDK.dll")]
public static extern bool NET_DVR_CaptureJPEGPicture_NEW(int lUserID, int lChannel, ref NET_DVR_JPEGPARA lpJpegPara, byte[] sJpegPicBuffer, uint dwPicSize, ref uint lpSizeReturned);
}
}

+ 5
- 2
DigitalSchoolApi/DigitalSchoolApi.csproj View File

@@ -97,8 +97,8 @@
<Reference Include="MySql.Data, Version=8.0.23.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d, processorArchitecture=MSIL">
<HintPath>..\packages\MySql.Data.8.0.23\lib\net452\MySql.Data.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="Owin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f0ebd12fd5e55cc5, processorArchitecture=MSIL">
<HintPath>..\packages\Owin.1.0\lib\net40\Owin.dll</HintPath>
@@ -382,6 +382,7 @@
<ItemGroup>
<Compile Include="App_Data\LicenseChecker.cs" />
<Compile Include="App_Data\LicenseManager.cs" />
<Compile Include="App_Data\LogHelper.cs" />
<Compile Include="App_Data\Mail\MailHelper.cs" />
<Compile Include="App_Data\Mail\Model\MailAccount .cs" />
<Compile Include="App_Data\Mail\Model\MailFile.cs" />
@@ -405,6 +406,7 @@
<Compile Include="Controllers\HLSchoolController.cs" />
<Compile Include="Controllers\PayFeeResultTwoController.cs" />
<Compile Include="Controllers\PayFeeResultController.cs" />
<Compile Include="Controllers\HTSchoolController.cs" />
<Compile Include="Controllers\TLMSchoolController.cs" />
<Compile Include="Controllers\EmailSendController.cs" />
<Compile Include="Controllers\CYDormitoryReturnController.cs" />
@@ -423,6 +425,7 @@
<Compile Include="Models\FinaChargeStuOrderEntity.cs" />
<Compile Include="Models\FinaChargeStuYearEntity.cs" />
<Compile Include="Models\FinaChargeStuYearItemEntity.cs" />
<Compile Include="Models\HtEntity.cs" />
<Compile Include="Models\NewsEntity.cs" />
<Compile Include="Models\EmailManagementEntity.cs" />
<Compile Include="Models\Acc_DormitoryBuildEntity.cs" />


+ 5491
- 0
DigitalSchoolApi/DigitalSchoolApi.xml
File diff suppressed because it is too large
View File


+ 86
- 0
DigitalSchoolApi/Models/HtEntity.cs View File

@@ -0,0 +1,86 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DigitalSchoolApi.Models
{
internal interface HtEntity
{
}

public class HTMiddleOrganize
{
public string ID { get; set; }

public string NAME { get; set; }

public string FID { get; set; }

public string CODE { get; set; }
}

public class HTMiddleStuInfo
{

public string ID { get; set; }
public string USERNAME { get; set; }

public string StuName { get; set; }

public string IdentityCardNo { get; set; }

public string NationalityNo { get; set; }

public string Grade { get; set; }

public string EntranceDate { get; set; }

public string RegisterDate { get; set; }

public string MailAddress { get; set; }

public string DeptNo { get; set; }
public string DeptName { get; set; }

public string MajorNo { get; set; }
public string MajorName { get; set; }

public string ClassNo { get; set; }
public string ClassName { get; set; }

public string GenderNo { get; set; }

public string CODE { get; set; }

public string MOBILE { get; set; }

public string EMAIL { get; set; }
}

public class HTMiddleEmpInfo
{

public string ID { get; set; }

public string CODE { get; set; }


public string NAME { get; set; }
public string USERNAME { get; set; }

public string MOCODE { get; set; }

public string GENDER { get; set; }

public string CARDNO { get; set; }

public string MOBILE { get; set; }

public string EMAIL { get; set; }

public string STATUS { get; set; }

}
}

+ 4
- 6
DigitalSchoolApi/Web.config View File

@@ -53,11 +53,9 @@
</appSettings>
<connectionStrings>
<!--<add name="ConnectionPfcMisDBString" connectionString="server=112.45.152.8;database=CollegeMIS;Max Pool Size=1000;Min Pool Size=5;UID=sa;Pwd=qj@2018;" providerName="System.Data.SqlClient" />-->
<!--<add name="ConnectionPfcMisDBString" connectionString="server=8.141.155.183,53314;database=CollegeMIS_长阳;Max Pool Size=1000;Min Pool Size=5;UID=sa;Pwd=bjqjkj@2014~2015!;" providerName="System.Data.SqlClient" />-->
<add name="ConnectionPfcMisDBString" connectionString="server=8.141.155.183,53314;database=CollegeMIS_塔里木;Max Pool Size=1000;Min Pool Size=5;UID=sa;Pwd=bjqjkj@2014~2015!;" providerName="System.Data.SqlClient" />
<add name="ConnectionPfcMisDBString" connectionString="server=8.141.155.183,53314;database=CollegeMIS_芮城;Max Pool Size=1000;Min Pool Size=5;UID=sa;Pwd=bjqjkj@2014~2015!;" providerName="System.Data.SqlClient" />
<add name="ConnectionPfcMisDBString2" connectionString="server=192.168.100.225;database=CollegeMIS;Max Pool Size=1000;Min Pool Size=5;UID=sa;Pwd=Jykj@2019;" providerName="System.Data.SqlClient" />
<!--<add name="CoreDBString" connectionString="server=8.141.155.183,53314;database=adms7ultimate2_长阳;Max Pool Size=1000;Min Pool Size=5;UID=sa;Pwd=bjqjkj@2014~2015!;" providerName="System.Data.SqlClient" />-->
<add name="CoreDBString" connectionString="server=8.141.155.183,53314;database=adms7ultimate2_塔里木;Max Pool Size=1000;Min Pool Size=5;UID=sa;Pwd=bjqjkj@2014~2015!;" providerName="System.Data.SqlClient" />
<add name="CoreDBString" connectionString="server=8.141.155.183,53314;database=adms7ultimate2_芮城;Max Pool Size=1000;Min Pool Size=5;UID=sa;Pwd=bjqjkj@2014~2015!;" providerName="System.Data.SqlClient" />
<add name="CoreDBString2" connectionString="server=192.168.100.225;database=adms7ultimate2;Max Pool Size=1000;Min Pool Size=5;UID=sa;Pwd=Jykj@2019;" providerName="System.Data.SqlClient" />
<add name="hangfireString" connectionString="Server=8.141.155.183,53314;Initial Catalog=Hangfire;User ID=sa;Password=bjqjkj@2014~2015!" providerName="System.Data.SqlClient" />
<add name="YKTDBString" connectionString="Data Source=xcykt;Persist Security Info=True;User ID=xcysdata;Password=xcysdata2019;Unicode=True" providerName="System.Data.OracleClient" />
@@ -70,7 +68,7 @@
<add name="XCMiddleDBString" connectionString="Data Source=FSZJK;Persist Security Info=True;User ID=fszjk;Password=fszjk20220705;Unicode=True" providerName="System.Data.OracleClient" />
<add name="HLZJMiddleDBString" connectionString="Data Source=ORCL;Persist Security Info=True;User ID=digitalschool;Password=digitalschool;Unicode=True" providerName="System.Data.OracleClient" />
<add name="TLMMiddleDBString" connectionString="Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=libraries.chaoxing.com)(PORT=38023)))(CONNECT_DATA=(SERVICE_NAME=jwxt01)));User Id=TLM_XG;Password=bbfc2d7e4fd0bd829b2f;Pooling='true';Max Pool Size=150" providerName="System.Data.OracleClient" />
<add name="htMiddleDBString" connectionString="Server=112.45.152.8,17049;Initial Catalog=tsgxtjh;User ID=tsgxtjh;Password=Qs6cYOzFoQupbr12MFZm" providerName="System.Data.SqlClient" />
</connectionStrings>
<!--
For a description of web.config changes see http://go.microsoft.com/fwlink/?LinkId=235367.
@@ -101,7 +99,7 @@
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" />
<bindingRedirect oldVersion="0.0.0.0-11.0.0.0" newVersion="11.0.0.0" />
<bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />


+ 1
- 1
DigitalSchoolApi/packages.config View File

@@ -30,7 +30,7 @@
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net461" />
<package id="Modernizr" version="2.6.2" targetFramework="net461" />
<package id="MySql.Data" version="8.0.23" targetFramework="net461" />
<package id="Newtonsoft.Json" version="11.0.2" targetFramework="net472" />
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net461" />
<package id="Owin" version="1.0" targetFramework="net452" />
<package id="SSH.NET" version="2020.0.0" targetFramework="net461" />
<package id="Swagger-Net" version="8.3.20.403" targetFramework="net472" />


Loading…
Cancel
Save