using (IDbConnection db =new SqlConnection(_coresqlConnection))
{
#region 部门
List<DepartmentEntity> departments = db.Query<DepartmentEntity>("select * from LR_Base_Department").ToList();
int anumDept = 0;
int unumDept = 0;
foreach (var item in depts)
{
try
{
if(departments.Any(x=>x.F_DepartmentId==item.ID))
{
var sql = $"update LR_Base_Department set F_FullName='{item.NAME_}',F_ParentId='{item.PID}',F_EnCode='{item.ID}',F_ShortName='{item.NAME_SHORT}',F_CreateDate='{DateTime.Now}' where F_DepartmentId='{item.ID}'";
anumDept += db.Execute(sql);
}
else
{
var sql = $"insert into LR_Base_Department (F_DepartmentId,F_CompanyId,F_ParentId,F_EnCode,F_FullName,F_ShortName,F_SortCode,F_DeleteMark,F_EnabledMark,F_CreateDate,F_Order) values ('{item.ID}','207fa1a9-160c-4943-a89b-8fa4db0547ce','{item.PID}','{item.ID}','{item.NAME_}','{item.NAME_SHORT}',0,0,1,'{DateTime.Now}',0)";
anumDept += db.Execute(sql);
}
}
catch (Exception ex)
{
db.Execute(
$"insert into LR_Base_Log(F_LogId,F_CategoryId,F_SourceObjectId,F_SourceContentJson,F_OperateTime) values(newid(),55555,'更新部门数据','编号({item.ID}),姓名({item.NAME_})更新时出现异常:{ex.Message}',getdate())");
}
}
#endregion
}
var teachinfo = new List<TeachModel>();
using (IDbConnection conncores = new SqlConnection(_sqlConnection))
using (IDbConnection conncores = new SqlConnection(_sqlConnection))
if (departments.Any(x => x.F_DepartmentId == item.ID))
{
var sql = $"update LR_Base_Department set F_FullName='{item.NAME_}',F_ParentId='{item.PID}',F_EnCode='{item.CODE_}',F_ShortName='{item.NAME_SHORT}',F_Manager='{manager}',F_Description='{item.LEVEL_TYPE}',F_ModifyDate='{DateTime.Now}' where F_DepartmentId='{item.ID}'";
anumDept += db.Execute(sql);
}
else
{
var sql = $"insert into LR_Base_Department (F_DepartmentId,F_CompanyId,F_ParentId,F_EnCode,F_FullName,F_ShortName,F_Manager,F_Description,F_SortCode,F_DeleteMark,F_EnabledMark,F_CreateDate,F_Order) values ('{item.ID}','207fa1a9-160c-4943-a89b-8fa4db0547ce','{item.PID}','{item.CODE_}','{item.NAME_}','{item.NAME_SHORT}','{manager}','{item.LEVEL_TYPE}',0,0,1,'{DateTime.Now}',0)";
anumDept += db.Execute(sql);
}
}
}
catch (Exception ex)
{
db.Execute(
$"insert into LR_Base_Log(F_LogId,F_CategoryId,F_SourceObjectId,F_SourceContentJson,F_OperateTime) values(newid(),55555,'更新部门数据','编号({item.ID}),姓名({item.NAME_})更新时出现异常:{ex.Message}',getdate())");
//(case when dept_id in ('01','02','03') then dept_id when dept_id='00' then '06' when dept_id='23' then '04' when dept_id='06' then '07' else '' end )as dept_id,
//(case when dept_id in ('01','02','03') then dept_id when dept_id='00' then '06' when dept_id='23' then '04' when dept_id='06' then '07' else '' end )as dept_id,
using (IDbConnection conncore = new SqlConnection(_coresqlConnection))
{
conncore.Execute(
$"insert into LR_Base_Log(F_LogId,F_CategoryId,F_SourceObjectId,F_SourceContentJson,F_OperateTime) values(newid(),55555,'一卡通交易流水1','开始执行',getdate())");
using (IDbConnection conncore = new SqlConnection(_coresqlConnection))
using (IDbConnection conncore = new SqlConnection(_coresqlConnection))
{
{
conncore.Execute(
conncore.Execute(
$"insert into LR_Base_Log(F_LogId,F_CategoryId,F_SourceObjectId,F_SourceContentJson,F_OperateTime) values(newid(),55555,'一卡通交易流水2','Token秘钥获取成功',getdate())");
$"insert into LR_Base_Log(F_LogId,F_CategoryId,F_SourceObjectId,F_SourceContentJson,F_OperateTime) values(newid(),55555,'一卡通交易流水','Token秘钥获取成功',getdate())");
}
}
#endregion
#endregion
#region 插入数据
#region 插入数据
using (IDbConnection conn = new SqlConnection(_sqlConnection))
using (IDbConnection conn = new SqlConnection(_sqlConnection))
var Historylist = Convert.ToInt64(conn.ExecuteScalar("select isnull(Max(centralNo),0) from MealCardRunTab "));
var Historylist = Convert.ToInt64(conn.ExecuteScalar("select isnull(Max(centralNo),0) from MealCardRunTab "));
string data = "{ \"pageNo\":\"1\",\"PageSize\":\"1000\",\"Date\":\"" + DateTime.Now.ToShortDateString() + "\",\"StartTime\":\"00:00:00\",\"EndTime\":\"23:59:59\"}";
string data = "{ \"pageNo\":\"1\",\"PageSize\":\"1000\",\"Date\":\"" + tday + "\",\"StartTime\":\"00:00:00\",\"EndTime\":\"23:59:59\",\"depcode\":\"7D\"}";
var responses = HttpMethods.sendHttpPost(JylsUrl, Token, data);
var responses = HttpMethods.sendHttpPost(JylsUrl, Token, data);
var RequsetList = JsonConvert.DeserializeObject<JSONList>(responses);
var RequsetList = JsonConvert.DeserializeObject<JSONList>(responses);
if (RequsetList.pageTotal > 0)
using (IDbConnection conncore = new SqlConnection(_coresqlConnection))
{
conncore.Execute(
$"insert into LR_Base_Log(F_LogId,F_CategoryId,F_SourceObjectId,F_SourceContentJson,F_OperateTime) values(newid(),55555,'一卡通数据()','本次一共" + RequsetList.total + "条数据',getdate())");
}
for (int k = 0; k <= 23; k++)
{
{
for (int i = 1; i <= RequsetList.pageTotal; i++)
using (IDbConnection conncore = new SqlConnection(_coresqlConnection))
{
conncore.Execute(
$"insert into LR_Base_Log(F_LogId,F_CategoryId,F_SourceObjectId,F_SourceContentJson,F_OperateTime) values(newid(),55555,'一卡通数据','第" + k + "次循环',getdate())");
data = "{ \"pageNo\":\"" + i + " \",\"PageSize\":\"1000\",\"Date\":\"" + DateTime.Now.ToShortDateString() + "\",\"StartTime\":\"00:00:00\",\"EndTime\":\"23:59:59\"}";
var responses1 = HttpMethods.sendHttpPost(JylsUrl, Token, data);
var RequsetList1 = JsonConvert.DeserializeObject<JSONList>(responses1);
var NowCen = RequsetList1.data.flowlist.Max(x => x.centralNo);
if (NowCen > Historylist)
int total = (int)Math.Ceiling((decimal)RequsetList.total / 1000);
using (IDbConnection conncore = new SqlConnection(_coresqlConnection))
{
{
using (IDbConnection conncore = new SqlConnection(_coresqlConnection))
{
conncore.Execute(
$"insert into LR_Base_Log(F_LogId,F_CategoryId,F_SourceObjectId,F_SourceContentJson,F_OperateTime) values(newid(),55555,'一卡通交易流水3','准备开始插入数据',getdate())");
}
for (int j = 0; j < RequsetList1.data.flowlist.Count; j++)
conncore.Execute(
$"insert into LR_Base_Log(F_LogId,F_CategoryId,F_SourceObjectId,F_SourceContentJson,F_OperateTime) values(newid(),55555,'一卡通交易流水1','一共" + RequsetList.total + "条数据',getdate())");
var nowCen = Convert.ToInt32(conn.ExecuteScalar("select Count(*) from MealCardRunTab where centralNo='" + RequsetList1.data.flowlist[j].centralNo + "' "));
if (nowCen <= 0)
var NowCen = RequsetList.data.flowlist.Max(x => x.centralNo);
if (NowCen > Historylist)
{
{
conn.Execute(
"insert into MealCardRunTab(Id,accountNo,accountName,depName,personId,identiName,flowtype,flowamount,balance,cardNo,centralTm,centralNo,occurTime,node,bigGroup,smallGroup,seg,pos) " +
using (IDbConnection conncore = new SqlConnection(_coresqlConnection))
{
conncore.Execute(
$"insert into LR_Base_Log(F_LogId,F_CategoryId,F_SourceObjectId,F_SourceContentJson,F_OperateTime) values(newid(),55555,'一卡通交易流水4','第" + j + "次插入数据完成',getdate())");
for (int j = 0; j < RequsetList.data.flowlist.Count; j++)
{
var nowCen = Convert.ToInt32(conn.ExecuteScalar("select Count(*) from MealCardRunTab where centralNo='" + RequsetList.data.flowlist[j].centralNo + "' "));
if (nowCen <= 0)
{
conn.Execute(
"insert into MealCardRunTab(Id,accountNo,accountName,depName,personId,identiName,flowtype,flowamount,balance,cardNo,centralTm,centralNo,occurTime,node,bigGroup,smallGroup,seg,pos) " +
using (IDbConnection conncore = new SqlConnection(_coresqlConnection))
{
conncore.Execute(
$"insert into LR_Base_Log(F_LogId,F_CategoryId,F_SourceObjectId,F_SourceContentJson,F_OperateTime) values(newid(),55555,'一卡通交易流水5','插入数据',getdate())");
<!--<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=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=123.57.209.16;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="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=123.57.209.16;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="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" />