/// <summary> /// 获取应用详情 /// </summary> /// <param name="QyID">企业ID</param> /// <returns></returns> public GetAppListResult GetAppList(string QyID) { GetAppListResult result = null; try { result = AppApi.GetAppList(GetAccessToken(QyID)); } catch (Exception ex) { LogWriter.Error(ex, string.Format("获取QyID为{0}的应用列表失败", QyID)); result = AppApi.GetAppList(GetAccessToken(QyID, true)); } if (result.errcode != ReturnCode_QY.请求成功) { LogWriter.Info(string.Format("获取QyID为{0}的应用列表失败,原因:{1}", QyID, result.errmsg)); } return(result); }
private async Task <GetAppListResult> getagentlist(string token) { return(AppApi.GetAppList(token)); }
///// <summary> ///// 获取所有App信息 ///// </summary> ///// <param name="appid"></param> ///// <returns></returns> /// <summary> /// 取得并同步一个微信号(企业号)下所有App信息 /// </summary> /// <param name="accountManageId"></param> /// <returns></returns> public List <GetAppInfoResult> GetAndSyncApps(int accountManageId, bool?isSyncMenu) { var result = new List <GetAppInfoResult>(); var appSelected = Request["APPList"]; // ------------从微信服务器获取所有的App,以此为基础同步我们的App管理表 // 取得accessToken var config = WeChatCommonService.lstSysWeChatConfig.FirstOrDefault(a => a.AccountManageId == accountManageId); var accessToken = WeChatCommonService.GetWeiXinToken(config.Id); // 如果是搜索App if (!string.IsNullOrEmpty(appSelected)) { var app = WeChatCommonService.lstSysWeChatConfig.FirstOrDefault(a => a.AccountManageId == accountManageId && a.WeixinAppId == appSelected); var appInfo = AppApi.GetAppInfo(accessToken, int.Parse(appSelected)); // 取得平台内AppId appInfo.agentid = app.Id.ToString(); result.Add(appInfo); return(result); } var wxApps = AppApi.GetAppList(accessToken); var applist = WeChatCommonService.lstSysWeChatConfig.Where(a => a.AccountManageId == accountManageId).ToList(); // 同步App // TODO:目前的效率不高,在每次刷新页面或者翻页时都会重新去同步App _sysWechatConfigService.SyncWechatApps(accountManageId, accessToken, wxApps.agentlist, applist, isSyncMenu ?? true); // 将Session中的Menu更新 var loginUser = (SysUser)Session["UserInfo"]; var newMenus = _sysMenuService.GetMenusByUserID(loginUser, null); loginUser.Menus = newMenus; Session["UserInfo"] = loginUser; // 返回List var newAppList = WeChatCommonService.lstSysWeChatConfig.Where(a => a.AccountManageId == accountManageId).ToList(); //这段代码完全没必要了 //foreach (var newApp in newAppList) //{ // try // { // var appInfo = AppApi.GetAppInfo(accessToken, int.Parse(newApp.WeixinAppId)); // // 前台需要的是平台的AppID,而不是微信的agentId // // 所以此处借用agentid字段来存储appId(因为类GetAppInfoResult已经打包为dll作为底层了,修改的话势必可能会影响到别的地方) // appInfo.agentid = newApp.Id.ToString(); // result.Add(appInfo); // } // catch // { // } //} return(result); }