/// <summary> /// 初始化登陆窗体, 创建登录策略 /// </summary> private void InitLoginWindow() { rdUser.Checked = true; timer1.Interval = 2000; this.BindingOrganization(); //绑定组织机构 //this.BindingDataSet();//绑定帐套数据源 this.ReadLoginInfo(); //读取保存的登录信息 this.Text += " (后台连接:" + BridgeFactory.BridgeType.ToString() + ")"; SystemAuthentication.Current = null; LoginAuthType authType = (LoginAuthType)SystemConfig.CurrentConfig.LoginAuthType; //系统设置 if (authType == LoginAuthType.LocalSystemAuth) { _CurrentAuthorization = new LoginSystemAuth(); btnLogin.Text = "登录 (&L)"; this.Update();//自动显示窗体 } else if (authType == LoginAuthType.NovellUserAuth) { _CurrentAuthorization = new LoginNovellAuth(txtUser, lblLoadingInfo); btnLogin.Text = "Novell自动登录"; this.txtPwd.Enabled = false; this.txtUser.Enabled = false; this.Visible = true; this.Update(); //自动显示窗体 btnLogin.PerformClick(); //直接登录系统 } else if (authType == LoginAuthType.WindowsDomainAuth) { _CurrentAuthorization = new LoginWindowsDomainAuth(txtUser, lblLoadingInfo); btnLogin.Text = "域用户自动登录"; this.txtPwd.Enabled = false; this.txtUser.Enabled = false; this.Visible = true; this.Update(); //自动显示窗体 btnLogin.PerformClick(); //直接登录系统 } else //不明类型,禁止登录 { pcInputArea.Enabled = false; btnLogin.Enabled = false; } }
/*此接口不提供异步方法*/ /// <summary> /// 获取授权地址 /// </summary> /// <param name="componentAppId">第三方平台方appid</param> /// <param name="preAuthCode">预授权码</param> /// <param name="redirectUrl">回调URL</param> /// <param name="authType">要授权的帐号类型</param> /// <param name="bizAppId">指定授权唯一的小程序或公众号</param> /// <returns></returns> public static string GetComponentLoginPageUrl(string componentAppId, string preAuthCode, string redirectUrl, LoginAuthType authType = LoginAuthType.默认, string bizAppId = "") { /* * 授权流程完成后,会进入回调URI,并在URL参数中返回授权码和过期时间(redirect_url?auth_code=xxx&expires_in=600) */ var url = string.Format( "https://mp.weixin.qq.com/cgi-bin/componentloginpage?component_appid={0}&pre_auth_code={1}&redirect_uri={2}", componentAppId.AsUrlData(), preAuthCode.AsUrlData(), redirectUrl.AsUrlData()); if (authType != LoginAuthType.默认) { url = string.Format("{0}&auth_type={1}", url, (int)authType); } if (!string.IsNullOrEmpty(bizAppId)) { url = string.Format("{0}&biz_appid={1}", url, bizAppId); } return(url); }