This commit is contained in:
jackchenyang 2024-06-07 15:13:34 +08:00
parent 4dc89c8561
commit 25bfa4fa71
2 changed files with 26 additions and 24 deletions

View File

@ -30,12 +30,12 @@ namespace BLL.APIService
}
public static void GetSyncUserInfo()
{
var token = GetUserToken(); //获取接口token
//var token = GetUserToken(); //获取接口token
var dic = GetDepartList(); //把本地数据库中的部门全部取出作为字典
var dicUser = GetUserInfoByAccount(); //同上把所有用户取出来
//string file = System.Web.HttpContext.Current.Server.MapPath("~/data.txt");
//string result = System.IO.File.ReadAllText(file);
string result = BLL.Common.HttpHelper.HttpPostRequest(GETHRINfOAPI, "", token);
string file = System.Web.HttpContext.Current.Server.MapPath("~/data.txt");
string result = System.IO.File.ReadAllText(file);
//string result = BLL.Common.HttpHelper.HttpPostRequest(GETHRINfOAPI, "", token);
var data = JsonHelper.DeserializeJsonToObject<ResultData<List<UserInfo>>>(result);
List<Model.SyncDataUserLogs> logList = new List<Model.SyncDataUserLogs>();
if (data.code == "200")
@ -246,7 +246,7 @@ namespace BLL.APIService
/// <returns></returns>
private static Dictionary<string,string> GetUserInfoByAccount()
{
return BLL.Funs.DB.Sys_User.Select(t => new { t.UserId, t.Account }).ToList()
return BLL.Funs.DB.Sys_User.Where(t=>t.IsPost==true).Select(t => new { t.UserId, t.Account }).ToList()
.ToDictionary(t => t.Account.ToLower(), t => t.UserId);
}

View File

@ -16,6 +16,9 @@ namespace FineUIPro.Web
protected void Page_Load(object sender, EventArgs e)
{
this.code = Request.Params["code"];
BLL.ErrLogInfo.WriteLog($"获取code={this.code}");
if (!IsPostBack)
{
if (string.IsNullOrEmpty(this.code))
{
Response.Redirect("~/login.aspx");
@ -31,6 +34,7 @@ namespace FineUIPro.Web
Response.Redirect("~/index.aspx");
}
}
private AccessTokenModel GetAccessToken(string _code)
{
@ -44,13 +48,13 @@ namespace FineUIPro.Web
try
{
string postData = $"code={code}&client_id={clientId}&client_secret={clientSecret}&grant_type={grant_type}&redirect_uri={redirect_url}&scope={scope}";
string result = BLL.Common.HttpHelper.HttpPostRequest(baseUrl, postData, string.Empty);
BLL.ErrLogInfo.WriteLog($"参数url={postData}");
BLL.ErrLogInfo.WriteLog($"====================================");
BLL.ErrLogInfo.WriteLog($"结果Result={result}");
var Data = JsonConvert.DeserializeObject<AccessTokenModel>(result);
return Data;
}
catch (Exception ex)
{
@ -67,13 +71,11 @@ namespace FineUIPro.Web
try
{
var result = HttpHelper.HttpGetRequest(baseUrl, token.access_token);
if (result.IndexOf("sub") > -1)
{
var info = JsonConvert.DeserializeObject<UserTokenModel>(result);
//写入session信息
//写入cookie信息
Session["ossInfo"] = info;
return info;
}