@@ -427,6 +431,9 @@ where DateDiff(dd,t.CheckDate,getdate())=0 and t.OutTime<'{lateReturnTime}' and
}
}
#region 数校同步到oracle中间库
/// <summary>
/// 系部
/// </summary>
@@ -481,7 +488,6 @@ where DateDiff(dd,t.CheckDate,getdate())=0 and t.OutTime<'{lateReturnTime}' and
}
}
}
/// <summary>
/// 专业
/// </summary>
@@ -669,7 +675,6 @@ where DateDiff(dd,t.CheckDate,getdate())=0 and t.OutTime<'{lateReturnTime}' and
var aa = _admsConnection.Split(';').First(x => x.Contains("Initial Catalog="));
basedbname = aa.Substring(aa.IndexOf("=") + 1);
}
var sqlstring = new StringBuilder();
sqlstring.Append("select t.StuId,t.StuNo,t.DeptNo,t.MajorNo,t.Grade,t.ClassNo,t.StuName,t.GenderNo,t.Birthday,t.IdentityCardNo,t.mobile,u.F_UserId from StuInfoBasic t ");
sqlstring.Append(" left join " + basedbname + ".dbo.LR_Base_User u on t.StuNo=u.F_Account and t.StuName=u.F_RealName and t.IdentityCardNo=u.F_IdentityCardNo ");
@@ -844,6 +849,379 @@ where DateDiff(dd,t.CheckDate,getdate())=0 and t.OutTime<'{lateReturnTime}' and
}
}
#endregion
#region oracle同步到数校
/// <summary>
/// 从oracle中间库同步系部数据
/// </summary>
public static void SyncDeptOracle()
{
try
{
IEnumerable<CX_JW_YX> entityList = null;
using (IDbConnection conn = new OracleConnection(_tlmMiddleConnection))
{
entityList = conn.Query<CX_JW_YX>("SELECT * FROM \"CX_JW_YX\" WHERE YXBH in (SELECT YXBH FROM \"CX_JW_ZY\" GROUP BY YXBH)");
}
using (IDbConnection conn = new SqlConnection(_misConnection))
{
try
{
var maxSort = -1;
try
{
maxSort = conn.QueryFirstOrDefault<int>("select MAX(DeptSort) FROM CdDept");
}
catch (Exception e)
{
maxSort = -1;
}
//插入sql
foreach (var item in entityList)
{
CdDeptEntity model = null;
using (IDbConnection xbconn = new SqlConnection(_misConnection))
{
model = xbconn.QueryFirstOrDefault<CdDeptEntity>($"select * from CdDept where DeptNo='{item.YXBH}'");
}
if (model == null)
{
maxSort++;
var id = item.ID.Length == 30 ? Guid.ParseExact(item.ID, "N") : Guid.NewGuid();
var sql = $"UPDATE CdDept SET DeptName='{item.YXMC}' where DeptNo='{model.DeptNo}';";
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,'从超星oracle中间库同步系部信息到数校完成','系部同步数量:" +
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,'从超星oracle中间库同步系部信息到数校异常','" +
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,'从超星oracle中间库同步系部信息到数校异常','错误信息:" +
e.Message + "',getdate())");
}
}
}
/// <summary>
/// 从oracle中间库同步专业数据 Photo数据
/// </summary>
public static void SyncMajorOracle()
{
try
{
IEnumerable<CX_JW_ZY> entityList = null;
using (IDbConnection conn = new OracleConnection(_tlmMiddleConnection))
{
entityList = conn.Query<CX_JW_ZY>("SELECT * FROM \"CX_JW_ZY\"");
}
using (IDbConnection conn = new SqlConnection(_misConnection))
{
try
{
//插入sql
foreach (var item in entityList)
{
CdMajorEntity model = null;
using (IDbConnection xbconn = new SqlConnection(_misConnection))
{
model = xbconn.QueryFirstOrDefault<CdMajorEntity>($"select * from CdMajor where MajorNo='{item.ZYBH}'");
}
if (model == null)
{
var id = item.ID.Length == 30 ? Guid.ParseExact(item.ID, "N") : Guid.NewGuid();
var sql = $"UPDATE CdMajor SET MajorName='{item.ZYMC}',LengthOfSchooling={Convert.ToInt32(item.XZ.Replace("年", ""))},DeptNo='{item.YXBH}',GovMajorName='{item.ZYMC}' where MajorNo='{model.MajorNo}';";
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,'从超星oracle中间库同步专业信息到数校完成','专业同步数量:" +
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,'从超星oracle中间库同步专业信息到数校异常','" +
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,'从超星oracle中间库同步专业信息到数校异常','错误信息:" +
e.Message + "',getdate())");
}
}
}
/// <summary>
/// 从oracle中间库同步班级数据
/// </summary>
public static void SyncClassInfoOracle()
{
try
{
IEnumerable<CX_JW_BJ> entityList = null;
using (IDbConnection conn = new OracleConnection(_tlmMiddleConnection))
{
entityList = conn.Query<CX_JW_BJ>("SELECT * FROM \"CX_JW_BJ\"");
}
using (IDbConnection conn = new SqlConnection(_misConnection))
{
try
{
//插入sql
foreach (var item in entityList)
{
ClassInfoEntity model = null;
using (IDbConnection xbconn = new SqlConnection(_misConnection))
{
model = xbconn.QueryFirstOrDefault<ClassInfoEntity>($"select * from ClassInfo where ClassNo='{item.BJBH}'");
}
if (model == null)
{
var id = item.ID.Length == 30 ? Guid.ParseExact(item.ID, "N") : Guid.NewGuid();
$"UPDATE ClassInfo SET ClassName='{item.BJMC}',DeptNo='{item.YXBH}',MajorNo='{item.ZYBH}',Grade='{item.SZNJ.Substring(item.SZNJ.Length - 2)}' where ClassNo='{model.ClassNo}';";
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,'从超星oracle中间库同步班级信息到数校完成','班级同步数量:" +
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,'从超星oracle中间库同步班级信息到数校异常','" +
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,'从超星oracle中间库同步班级信息到数校异常','错误信息:" +
date = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd");
}
IEnumerable<CX_JW_XSXX> entityList = null;
using (IDbConnection conn = new OracleConnection(_tlmMiddleConnection))
{
entityList = conn.Query<CX_JW_XSXX>($"SELECT ID,XH,KSH,YXBH,ZYBH,BJBH,SZNJ,XM,XMPY,XB,CSRQ,LXDH,SFZX,XJZT,XSDQZT,ZZMM,MZ,SFZJH FROM \"CX_JW_XSXX\" WHERE UPDATE_DATE> TO_DATE('{date}', 'YYYY-MM-DD')");
}
using (IDbConnection conn = new SqlConnection(_misConnection))
{
try
{
//插入sql
foreach (var item in entityList)
{
StuInfoBasicEntity model = null;
using (IDbConnection xbconn = new SqlConnection(_misConnection))
{
model = xbconn.QueryFirstOrDefault<StuInfoBasicEntity>($"select * from StuInfoBasic where StuNo='{item.XH}'");
}
var mzSql =
$"SELECT t.F_ItemValue FROM LR_Base_DataItemDetail t INNER JOIN LR_Base_DataItem t2 ON t.F_ItemId = t2.F_ItemId WHERE t2.F_ItemCode = 'National' AND t.F_ItemName='{item.MZ}'";
var xb = item.XB == "男" ? 1 : 0;
var MZ = "";
if (model == null)
{
var basedbname = string.Empty;
if (_admsConnection.IndexOf("database=") > 0)
{
var aa = _admsConnection.Split(';').First(x => x.Contains("database="));
basedbname = aa.Substring(aa.IndexOf("=") + 1);
}
else if (_admsConnection.IndexOf("Initial Catalog=") > 0)
{
var aa = _admsConnection.Split(';').First(x => x.Contains("Initial Catalog="));
basedbname = aa.Substring(aa.IndexOf("=") + 1);
}
var key = Md5Helper.Encrypt(CreateNo(), 16).ToLower();
var pwd = Md5Helper.Encrypt(DESEncrypt.Encrypt(Md5Helper.Encrypt("tlmzy123456", 32).ToLower(), key).ToLower(), 32).ToLower();
var id= item.ID.Length == 30 ? Guid.ParseExact(item.ID, "N"):Guid.NewGuid();
var sql =
"INSERT INTO StuInfoBasic(StuId,StuNo,StuCode,NoticeNo,GraduateYear,ksh,DeptNo,MajorNo,Grade,ClassNo,StuName,SpellFull,GenderNo,Birthday,PartyFaceNo," +
$"InSchoolStatus='{item.SFZX}', XJZT='{item.XJZT}',XSDQZT='{item.XSDQZT}' where StuNo='{model.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,'从超星oracle中间库同步学生信息到数校完成','学生同步数量:" +
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,'从超星oracle中间库同步学生信息到数校异常','" +
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,'从超星oracle中间库同步学生信息到数校异常','错误信息:" +
e.Message + "',getdate())");
}
}
}
/// <summary>
/// 获取政治面貌代码
/// </summary>
/// <returns></returns>
private static string GetZZMM(string zzmmstr)
{
if (string.IsNullOrEmpty(zzmmstr))
{
return "13";
}
if (zzmmstr.Contains("共青") || zzmmstr.Contains("青年"))
<!--<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" />