/// <summary> /// 获取AccessToken /// </summary> /// <returns></returns> public async Task <string> GetTokenAsync() { string strToken = HttpContext.Session.GetString("token"); if (string.IsNullOrEmpty(strToken)) { //获取访问token AccessTokenModel tokenModel = await ApiHelp.GetAccessTokenAsync(AppId, AppKey, ApiServerAddr); HttpContext.Session.SetString("token", tokenModel.access_token); strToken = tokenModel.access_token; } return(strToken); }
private async Task <List <MenuDto> > GetMenuAsync(UserViewModel user) { string strToken = HttpContext.Session.GetString("token"); if (string.IsNullOrEmpty(strToken)) { //获取访问token AccessTokenModel tokenModel = await ApiHelp.GetAccessTokenAsync(user.JobNumber, user.Pwd, ApiServerAddr); HttpContext.Session.SetString("token", tokenModel.access_token); strToken = tokenModel.access_token; } string strApiUrl = ApiServerAddr + @"/api/v1/manage/querymenu"; SearchMenuParamsDto paramsDto = new SearchMenuParamsDto(); paramsDto.parentId = 0; paramsDto.lstRoleId = user.lstRoleID; string strJson = JsonHelper.SerializeObject(paramsDto); HttpContent content = new StringContent(strJson); string strRes = await ApiHelp.ApiPostWithTokenAsync(strApiUrl, content, strToken); List <MenuDto> lstMenu = new List <MenuDto>(); if (strRes.Contains("网络错误") == false) { lstMenu = JsonHelper.Deserialize <List <MenuDto> >(strRes); } return(lstMenu); //return Task.FromResult(_menuService.MenuGetListHaveSort(0, true, rolelist).Where(c => c.IsLock == 0).ToList()); }