diff --git a/SGGL/BLL/ZHGL/RealName/SynchroSetService.cs b/SGGL/BLL/ZHGL/RealName/SynchroSetService.cs
index 51465b94..9c9a1f04 100644
--- a/SGGL/BLL/ZHGL/RealName/SynchroSetService.cs
+++ b/SGGL/BLL/ZHGL/RealName/SynchroSetService.cs
@@ -1116,92 +1116,269 @@ namespace BLL
///
/// 是否写日志
///
- public static string PushPersonsByIdentityCard(string type, string proCode, string identityCard,bool isLog)
+ //public static string PushPersonsByIdentityCard(string type, string proCode, string identityCard,bool isLog)
+ //{
+ // using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
+ // {
+ // try
+ // {
+ // string mess = string.Empty;
+ // string sucess = string.Empty;
+ // string code = string.Empty;
+ // string data = string.Empty;
+ // string pushContent = string.Empty;
+ // string contenttype = "application/json;charset=unicode";
+ // var getData = (from x in db.SitePerson_Person
+ // join y in db.Base_Project on x.ProjectId equals y.ProjectId
+ // join z in db.RealName_Project on y.JTProjectCode equals z.ProCode
+ // join v in db.ProjectData_TeamGroup on x.TeamGroupId equals v.TeamGroupId
+ // join w in db.Base_WorkPost on x.WorkPostId equals w.WorkPostId
+ // where x.IdentityCard == identityCard && y.JTProjectCode == proCode
+ // && v.TeamId.HasValue && z.JTproCode != null
+ // && ((type == Const.BtnAdd && x.HeadImage != null && x.HeadImage.Length > 0) || type == Const.BtnModify && x.RealNameAddTime.HasValue)
+ // select new
+ // {
+ // name = x.PersonName,
+ // idcardType = "SHENFEN_ZHENGJIAN",
+ // idcardNumber = x.IdentityCard,
+ // idcardStartDate = x.IdcardStartDate.HasValue ? string.Format("{0:yyyy-MM-dd}", x.IdcardStartDate) : null,
+ // idcardEndDate = x.IdcardEndDate.HasValue ? string.Format("{0:yyyy-MM-dd}", x.IdcardEndDate) : null,
+ // idcardForever = "Y",
+ // politicsStatus = x.PoliticsStatus,
+ // eduLevel = x.EduLevel,
+ // maritalStatus = x.MaritalStatus,
+ // sex = (x.Sex == "2" ? "F" : "M"),
+ // idcardAddress = x.IdcardAddress,
+ // homeAddress = x.Address,
+ // birthday = x.Birthday.HasValue ? string.Format("{0:yyyy-MM-dd}", x.Birthday) : null,
+ // nation = x.Nation,
+ // countryCode = x.CountryCode,
+ // provinceCode = x.ProvinceCode,
+ // headImage = x.HeadImage,
+ // proCode = z.JTproCode,
+ // teamId = v.TeamId,
+ // mobile = x.Telephone,
+ // teamLeaderFlag = (v.GroupLeaderId == x.PersonId ? "Y" : "N"),
+ // userType = ((w.PostType == "1" || w.PostType == "4") ? "LAB_USER_MANAGE" : "LAB_USER_BULIDER"),
+ // workType = w.WorkPostCode,
+ // isLeave = x.OutTime.HasValue ? "Y" : "N",
+ // entryTime = x.InTime.HasValue ? string.Format("{0:yyyy-MM-dd}", x.InTime) : null,
+ // exitTime = x.OutTime.HasValue ? string.Format("{0:yyyy-MM-dd}", x.OutTime) : null,
+ // x.RealNameAddTime,
+ // x.RealNameUpdateTime,
+ // x.PersonId,
+ // }).ToList();
+ // if (getData.Count() > 0)
+ // {
+ // string returndata = string.Empty;
+ // Hashtable newToken = new Hashtable
+ // {
+ // { "token", getaccess_token(proCode) }
+ // };
+ // if (type == Const.BtnModify)
+ // {
+ // var updatelistObject = new
+ // {
+ // list = getData.Select(x => new { x.name, x.idcardType, x.idcardNumber, x.idcardStartDate, x.idcardEndDate, x.idcardForever, x.politicsStatus, x.eduLevel, x.maritalStatus, x.sex, x.idcardAddress, x.homeAddress, x.birthday, x.nation, x.countryCode, x.provinceCode, x.proCode, x.teamId, x.mobile, x.teamLeaderFlag, x.userType, x.workType, x.isLeave, x.entryTime, x.exitTime })
+ // };
+ // pushContent = JsonConvert.SerializeObject(updatelistObject);
+ // returndata = BLL.APIGetHttpService.OutsideHttp(Funs.RealNameApiUrl + "/foreignApi/accept/updatePersons", "POST", contenttype, newToken, pushContent);
+ // }
+ // else
+ // {
+ // var addlistObject = new
+ // {
+ // list = getData.Select(x => new { x.name, x.idcardType, x.idcardNumber, x.idcardStartDate, x.idcardEndDate, x.idcardForever, x.politicsStatus, x.eduLevel, x.maritalStatus, x.sex, x.idcardAddress, x.homeAddress, x.birthday, x.nation, x.countryCode, x.provinceCode, x.headImage, x.proCode, x.teamId, x.mobile, x.teamLeaderFlag, x.userType, x.workType, x.isLeave, x.entryTime, x.exitTime })
+ // };
+ // pushContent = JsonConvert.SerializeObject(addlistObject);
+ // returndata = BLL.APIGetHttpService.OutsideHttp(Funs.RealNameApiUrl + "/foreignApi/accept/persons", "POST", contenttype, newToken, pushContent);
+ // }
+
+ // if (!string.IsNullOrEmpty(returndata))
+ // {
+ // JObject obj = JObject.Parse(returndata);
+ // mess = obj["message"].ToString();
+ // code = obj["code"].ToString();
+ // sucess = obj["success"].ToString();
+ // data = obj["data"].ToString();
+ // if (obj["success"] != null && Convert.ToBoolean(obj["success"].ToString()))
+ // {
+ // foreach (var item in getData)
+ // {
+ // var getPerson = db.SitePerson_Person.FirstOrDefault(x => x.PersonId == item.PersonId);
+ // if (getPerson != null)
+ // {
+ // if (!getPerson.RealNameAddTime.HasValue)
+ // {
+ // getPerson.RealNameAddTime = DateTime.Now;
+ // }
+ // getPerson.RealNameUpdateTime = DateTime.Now;
+ // db.SubmitChanges();
+ // }
+ // }
+ // }
+ // else
+ // {
+ // if (data.Contains("历史项目进退场时间重合") || data.Contains("已推送"))
+ // {
+ // foreach (var item in getData)
+ // {
+ // var getPerson = db.SitePerson_Person.FirstOrDefault(x => x.PersonId == item.PersonId);
+ // if (getPerson != null)
+ // {
+ // if (!getPerson.RealNameAddTime.HasValue)
+ // {
+ // getPerson.RealNameAddTime = DateTime.Now;
+ // }
+ // if (type == Const.BtnModify)
+ // {
+ // getPerson.RealNameUpdateTime = DateTime.Now;
+ // }
+ // db.SubmitChanges();
+ // }
+ // }
+ // }
+ // else if (data.Contains("人员不存在"))
+ // {
+ // SynchroSetService.PushPersonsByIdentityCard(Const.BtnAdd, proCode, identityCard, isLog);
+ // }
+ // else
+ // {
+ // if (isLog)
+ // {
+ // InsertRealNamePushLog(null, proCode, "推送人员数据", sucess, code, mess, data, pushContent);
+ // }
+ // }
+ // }
+ // }
+ // else
+ // {
+ // if (isLog)
+ // {
+ // InsertRealNamePushLog(null, proCode, "推送人员数据", sucess, code, mess, data, pushContent);
+ // }
+ // }
+
+ // if (data.Contains("已存在") || mess.Contains("已存在"))
+ // {
+ // foreach (var item in getData)
+ // {
+ // if (data.Contains(item.idcardNumber) || mess.Contains(item.idcardNumber))
+ // {
+ // var getPerson = db.SitePerson_Person.FirstOrDefault(x => x.PersonId == item.PersonId);
+ // if (getPerson != null)
+ // {
+ // if (!getPerson.RealNameAddTime.HasValue)
+ // {
+ // getPerson.RealNameAddTime = DateTime.Now;
+ // }
+ // db.SubmitChanges();
+ // }
+ // }
+ // }
+ // }
+ // }
+ // else
+ // {
+ // mess = "没有符合条件的数据!";
+ // }
+
+ // return mess;
+ // }
+ // catch (Exception ex)
+ // {
+ // ErrLogInfo.WriteLog(ex, "推送人员数据", "SynchroSetService.PushPersons");
+ // return "";
+ // }
+ // }
+ //}
+
+ public static string PushPersonsByIdentityCard(string type, string proCode, string identityCard, bool isLog)
{
- using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
+ try
{
- try
+ string mess = string.Empty;
+ string sucess = string.Empty;
+ string code = string.Empty;
+ string data = string.Empty;
+ string pushContent = string.Empty;
+ string contenttype = "application/json;charset=unicode";
+ var getData = (from x in Funs.DB.SitePerson_Person
+ join y in Funs.DB.Base_Project on x.ProjectId equals y.ProjectId
+ join z in Funs.DB.RealName_Project on y.ContractNo equals z.ProCode
+ join v in Funs.DB.ProjectData_TeamGroup on x.TeamGroupId equals v.TeamGroupId
+ join w in Funs.DB.Base_WorkPost on x.WorkPostId equals w.WorkPostId
+ where x.IdentityCard == identityCard && y.ContractNo == proCode
+ && v.TeamId.HasValue && z.JTproCode != null
+ && ((type == Const.BtnAdd && x.HeadImage != null && x.HeadImage.Length > 0) || (type == Const.BtnModify && x.RealNameAddTime.HasValue))
+ select new
+ {
+ name = x.PersonName,
+ idcardType = "SHENFEN_ZHENGJIAN",
+ idcardNumber = x.IdentityCard,
+ idcardStartDate = x.IdcardStartDate.HasValue ? string.Format("{0:yyyy-MM-dd}", x.IdcardStartDate) : null,
+ idcardEndDate = x.IdcardEndDate.HasValue ? string.Format("{0:yyyy-MM-dd}", x.IdcardEndDate) : (x.IdcardStartDate.HasValue ? string.Format("{0:yyyy-MM-dd}", x.IdcardStartDate.Value.AddYears(30)) : null),
+ idcardForever = x.IdcardStartDate.HasValue ? "N" : "Y",
+ politicsStatus = x.PoliticsStatus,
+ eduLevel = x.EduLevel,
+ maritalStatus = x.MaritalStatus,
+ sex = (x.Sex == "2" ? "F" : "M"),
+ idcardAddress = x.IdcardAddress,
+ homeAddress = x.Address,
+ birthday = x.Birthday.HasValue ? string.Format("{0:yyyy-MM-dd}", x.Birthday) : null,
+ nation = x.Nation,
+ countryCode = x.CountryCode,
+ provinceCode = x.ProvinceCode,
+ headImage = x.HeadImage,
+ proCode = z.JTproCode,
+ teamId = v.TeamId,
+ mobile = x.Telephone,
+ teamLeaderFlag = (v.GroupLeaderId == x.PersonId ? "Y" : "N"),
+ userType = ((w.PostType == "1" || w.PostType == "4") ? "LAB_USER_MANAGE" : "LAB_USER_BULIDER"),
+ workType = w.WorkPostCode,
+ isLeave = x.OutTime.HasValue ? "Y" : "N",
+ entryTime = x.InTime.HasValue ? string.Format("{0:yyyy-MM-dd}", x.InTime) : null,
+ exitTime = x.OutTime.HasValue ? string.Format("{0:yyyy-MM-dd}", x.OutTime) : null,
+ x.RealNameAddTime,
+ x.RealNameUpdateTime,
+ x.PersonId,
+ }).ToList();
+ if (getData.Count() > 0)
{
- string mess = string.Empty;
- string sucess = string.Empty;
- string code = string.Empty;
- string data = string.Empty;
- string pushContent = string.Empty;
- string contenttype = "application/json;charset=unicode";
- var getData = (from x in db.SitePerson_Person
- join y in db.Base_Project on x.ProjectId equals y.ProjectId
- join z in db.RealName_Project on y.JTProjectCode equals z.ProCode
- join v in db.ProjectData_TeamGroup on x.TeamGroupId equals v.TeamGroupId
- join w in db.Base_WorkPost on x.WorkPostId equals w.WorkPostId
- where x.IdentityCard == identityCard && y.JTProjectCode == proCode
- && v.TeamId.HasValue && z.JTproCode != null
- && ((type == Const.BtnAdd && x.HeadImage != null && x.HeadImage.Length > 0) || type == Const.BtnModify && x.RealNameAddTime.HasValue)
- select new
- {
- name = x.PersonName,
- idcardType = "SHENFEN_ZHENGJIAN",
- idcardNumber = x.IdentityCard,
- idcardStartDate = x.IdcardStartDate.HasValue ? string.Format("{0:yyyy-MM-dd}", x.IdcardStartDate) : null,
- idcardEndDate = x.IdcardEndDate.HasValue ? string.Format("{0:yyyy-MM-dd}", x.IdcardEndDate) : null,
- idcardForever = "Y",
- politicsStatus = x.PoliticsStatus,
- eduLevel = x.EduLevel,
- maritalStatus = x.MaritalStatus,
- sex = (x.Sex == "2" ? "F" : "M"),
- idcardAddress = x.IdcardAddress,
- homeAddress = x.Address,
- birthday = x.Birthday.HasValue ? string.Format("{0:yyyy-MM-dd}", x.Birthday) : null,
- nation = x.Nation,
- countryCode = x.CountryCode,
- provinceCode = x.ProvinceCode,
- headImage = x.HeadImage,
- proCode = z.JTproCode,
- teamId = v.TeamId,
- mobile = x.Telephone,
- teamLeaderFlag = (v.GroupLeaderId == x.PersonId ? "Y" : "N"),
- userType = ((w.PostType == "1" || w.PostType == "4") ? "LAB_USER_MANAGE" : "LAB_USER_BULIDER"),
- workType = w.WorkPostCode,
- isLeave = x.OutTime.HasValue ? "Y" : "N",
- entryTime = x.InTime.HasValue ? string.Format("{0:yyyy-MM-dd}", x.InTime) : null,
- exitTime = x.OutTime.HasValue ? string.Format("{0:yyyy-MM-dd}", x.OutTime) : null,
- x.RealNameAddTime,
- x.RealNameUpdateTime,
- x.PersonId,
- }).ToList();
- if (getData.Count() > 0)
- {
- string returndata = string.Empty;
- Hashtable newToken = new Hashtable
+ string returndata = string.Empty;
+ Hashtable newToken = new Hashtable
{
{ "token", getaccess_token(proCode) }
};
- if (type == Const.BtnModify)
+ if (type == Const.BtnModify)
+ {
+ var updatelistObject = new
{
- var updatelistObject = new
- {
- list = getData.Select(x => new { x.name, x.idcardType, x.idcardNumber, x.idcardStartDate, x.idcardEndDate, x.idcardForever, x.politicsStatus, x.eduLevel, x.maritalStatus, x.sex, x.idcardAddress, x.homeAddress, x.birthday, x.nation, x.countryCode, x.provinceCode, x.proCode, x.teamId, x.mobile, x.teamLeaderFlag, x.userType, x.workType, x.isLeave, x.entryTime, x.exitTime })
- };
- pushContent = JsonConvert.SerializeObject(updatelistObject);
- returndata = BLL.APIGetHttpService.OutsideHttp(Funs.RealNameApiUrl + "/foreignApi/accept/updatePersons", "POST", contenttype, newToken, pushContent);
- }
- else
+ list = getData.Select(x => new { x.name, x.idcardType, x.idcardNumber, x.idcardStartDate, x.idcardEndDate, x.idcardForever, x.politicsStatus, x.eduLevel, x.maritalStatus, x.sex, x.idcardAddress, x.homeAddress, x.birthday, x.nation, x.countryCode, x.provinceCode, x.proCode, x.teamId, x.mobile, x.teamLeaderFlag, x.userType, x.workType, x.isLeave, x.entryTime, x.exitTime })
+ };
+ pushContent = JsonConvert.SerializeObject(updatelistObject);
+ returndata = BLL.APIGetHttpService.OutsideHttp(Funs.RealNameApiUrl + "/foreignApi/accept/updatePersons", "POST", contenttype, newToken, pushContent);
+ }
+ else
+ {
+ var addlistObject = new
{
- var addlistObject = new
- {
- list = getData.Select(x => new { x.name, x.idcardType, x.idcardNumber, x.idcardStartDate, x.idcardEndDate, x.idcardForever, x.politicsStatus, x.eduLevel, x.maritalStatus, x.sex, x.idcardAddress, x.homeAddress, x.birthday, x.nation, x.countryCode, x.provinceCode, x.headImage, x.proCode, x.teamId, x.mobile, x.teamLeaderFlag, x.userType, x.workType, x.isLeave, x.entryTime, x.exitTime })
- };
- pushContent = JsonConvert.SerializeObject(addlistObject);
- returndata = BLL.APIGetHttpService.OutsideHttp(Funs.RealNameApiUrl + "/foreignApi/accept/persons", "POST", contenttype, newToken, pushContent);
- }
+ list = getData.Select(x => new { x.name, x.idcardType, x.idcardNumber, x.idcardStartDate, x.idcardEndDate, x.idcardForever, x.politicsStatus, x.eduLevel, x.maritalStatus, x.sex, x.idcardAddress, x.homeAddress, x.birthday, x.nation, x.countryCode, x.provinceCode, x.headImage, x.proCode, x.teamId, x.mobile, x.teamLeaderFlag, x.userType, x.workType, x.isLeave, x.entryTime, x.exitTime })
+ };
+ pushContent = JsonConvert.SerializeObject(addlistObject);
+ returndata = BLL.APIGetHttpService.OutsideHttp(Funs.RealNameApiUrl + "/foreignApi/accept/persons", "POST", contenttype, newToken, pushContent);
+ }
- if (!string.IsNullOrEmpty(returndata))
+ if (!string.IsNullOrEmpty(returndata))
+ {
+ JObject obj = JObject.Parse(returndata);
+ mess = obj["message"].ToString();
+ code = obj["code"].ToString();
+ sucess = obj["success"].ToString();
+ data = obj["data"].ToString();
+ if (obj["success"] != null && Convert.ToBoolean(obj["success"].ToString()))
{
- JObject obj = JObject.Parse(returndata);
- mess = obj["message"].ToString();
- code = obj["code"].ToString();
- sucess = obj["success"].ToString();
- data = obj["data"].ToString();
- if (obj["success"] != null && Convert.ToBoolean(obj["success"].ToString()))
+ using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
foreach (var item in getData)
{
@@ -1212,54 +1389,28 @@ namespace BLL
{
getPerson.RealNameAddTime = DateTime.Now;
}
- getPerson.RealNameUpdateTime = DateTime.Now;
- db.SubmitChanges();
- }
- }
- }
- else
- {
- if (data.Contains("历史项目进退场时间重合") || data.Contains("已推送"))
- {
- foreach (var item in getData)
- {
- var getPerson = db.SitePerson_Person.FirstOrDefault(x => x.PersonId == item.PersonId);
- if (getPerson != null)
+ if (type == Const.BtnModify)
{
- if (!getPerson.RealNameAddTime.HasValue)
- {
- getPerson.RealNameAddTime = DateTime.Now;
- }
- if (type == Const.BtnModify)
- {
- getPerson.RealNameUpdateTime = DateTime.Now;
- }
- db.SubmitChanges();
+ getPerson.RealNameUpdateTime = DateTime.Now;
}
- }
- }
- else if (data.Contains("人员不存在"))
- {
- SynchroSetService.PushPersonsByIdentityCard(Const.BtnAdd, proCode, identityCard, isLog);
- }
- else
- {
- if (isLog)
- {
- InsertRealNamePushLog(null, proCode, "推送人员数据", sucess, code, mess, data, pushContent);
+ db.SubmitChanges();
}
}
}
}
else
{
- if (isLog)
+ if (mess.Contains("token无效"))
{
- InsertRealNamePushLog(null, proCode, "推送人员数据", sucess, code, mess, data, pushContent);
+ getaccess_token_New(proCode);
}
}
+ }
- if (data.Contains("已存在") || mess.Contains("已存在"))
+ InsertRealNamePushLog(null, proCode, "推送人员数据", sucess, code, mess, data, pushContent);
+ if (data.Contains("已存在") || mess.Contains("已存在"))
+ {
+ using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
foreach (var item in getData)
{
@@ -1278,18 +1429,28 @@ namespace BLL
}
}
}
- else
- {
- mess = "没有符合条件的数据!";
- }
-
- return mess;
}
- catch (Exception ex)
+ else
{
- ErrLogInfo.WriteLog(ex, "推送人员数据", "SynchroSetService.PushPersons");
- return "";
+ mess = "没有符合条件的数据!";
}
+
+ return mess;
+ }
+ catch (Exception ex)
+ {
+ ErrLogInfo.WriteLog(ex, "推送人员数据", "SynchroSetService.PushPersons");
+ return "推送人员异常";
+ }
+ }
+
+ public static void getaccess_token_New(string proCode)
+ {
+ string access_token = string.Empty;
+ var getToken = Funs.DB.RealName_SynchroSet.FirstOrDefault(x => x.ProCode == proCode);
+ if (getToken != null)
+ {
+ SaveToken(getToken);
}
}
diff --git a/SGGL/FineUIPro.Web/ZHGL/RealName/SynchroSet.aspx.cs b/SGGL/FineUIPro.Web/ZHGL/RealName/SynchroSet.aspx.cs
index 512d86db..82614252 100644
--- a/SGGL/FineUIPro.Web/ZHGL/RealName/SynchroSet.aspx.cs
+++ b/SGGL/FineUIPro.Web/ZHGL/RealName/SynchroSet.aspx.cs
@@ -482,6 +482,7 @@ namespace FineUIPro.Web.ZHGL.RealName
select x.IdentityCard).Take(100);
foreach (var item in getIdentityCards)
{
+ //string mes = BLL.SynchroSetService.PushPersonsByIdentityCard(Const.BtnModify, getRProjects.ProCode, item, true) ?? "";
string mes = BLL.SynchroSetService.PushPersonsByIdentityCard(Const.BtnModify, getRProjects.ProCode, item, true) ?? "";
if (mes.Contains("不合法"))
{