private static string GetEmployee(string userid) { string json = ""; try { GetEmployee Result = EmployeeBll.Get(userid); if (Result != null) { if (Result.errcode == "0") { json = Result.ToJson(); } else { Console.Write(Result.errmsg); } } else { Console.Write("无返回数据"); } } catch (Exception ex) { Console.Write(ex.Message); } return(json); }
public static string GetEmployee(string userid) { LogHelper log = LogFactory.GetLogger("GetEmployee"); string json = ""; try { GetEmployee Result = EmployeeBll.Get(userid); if (Result != null) { if (Result.errcode == "0") { json = Result.ToJson(); //Console.Write(json + "\r\n"); } else if (Result.errcode == "90002") { System.Threading.Thread.Sleep(1500); json = GetEmployee(userid); } else { if (Result.errcode != "60121") { //Console.Write(Result.errmsg); log.Error("\r\n EmployeeForDingTalkBll-GetEmployee() " + Result.errmsg + "\r\n"); } return("-1"); } } else { //Console.Write("无返回数据"); } } catch (Exception ex) { log.Error("\r\n EmployeeForDingTalkBll-GetEmployee() " + ex + "\r\n"); //Console.Write(ex.Message); } return(json); }
public static void UpdateEmployeePhoneByUserId(string userid, string MobilePhone) { SqlSugarClient Edb = new SqlSugarClient(new ConnectionConfig() { ConnectionString = Config.ESBConnectionString, DbType = DbType.SqlServer, IsAutoCloseConnection = true }); SqlSugarClient Ddb = new SqlSugarClient(new ConnectionConfig() { ConnectionString = Config.DingTalkConnectionString, DbType = DbType.SqlServer, IsAutoCloseConnection = true, InitKeyType = InitKeyType.Attribute }); Ddb.CodeFirst.InitTables(typeof(DepartmentResult)); LogHelper log = LogFactory.GetLogger("UpdateEmployeePhoneByUserId"); try { GetEmployee emp = EmployeeBll.Get(userid); EmployeeEntity model = JsonHelper.JsonToModel <EmployeeEntity>(emp.ToJson()); string oldMobile = model.mobile; model.mobile = MobilePhone; string param = model.ToJson(); Result Result = EmployeeBll.Update(param); if (Result != null) { if (Result.errcode == "0") { //Console.Write("更新成功\r\n"); } else if (Result.errcode == "40022" || Result.errcode == "40021") { //40021 更换的号码已注册过钉钉,无法使用该号码 //40022 企业中的手机号码和登陆钉钉的手机号码不一致,暂时不支持修改用户信息,可以删除后重新添加 string Deletecode = EmployeeBll.Delete(model.userid).errcode; string Createcode = EmployeeBll.Create(model.ToJson()).errcode; if (Createcode != "0") { Createcode = EmployeeBll.Create(model.ToJson()).errcode; if (Createcode != "0" && Createcode != "40021") { log.Error("\r\n UpdateEmployeePhoneByUserId - 行号666 更新钉钉人员信息时,成功删除员工信息,但是创建员工信息时报错,错误编码如下:" + Createcode); } } if (Deletecode != "0") { InsertErroUpdateEmployee(Ddb, model.userid, oldMobile, MobilePhone, "删除失败,错误编号:" + Deletecode); } if (Createcode != "0") { InsertErroUpdateEmployee(Ddb, model.userid, oldMobile, MobilePhone, "执行删除后创建失败,错误编号:" + Createcode); } //Console.Write("更新成功,Userid=" + m.userid + "\r\n"); } else { log.Error("\r\n EmployeeForDingTalkBll-UpdateEmployeePhoneByUserId() " + Result.errmsg); Task.Factory.StartNew(() => { InsertErroUpdateEmployee(Ddb, model.userid, oldMobile, MobilePhone, "更新用户时失败,错误编号:" + Result.errcode); }); } } else { //Console.Write("无返回数据"); } } catch (Exception ex) { log.Error("\r\n EmployeeForDingTalkBll-UpdateEmployeePhoneByUserId() " + ex); //Console.Write(ex.Message); } }