예제 #1
0
        private IList <KeyValuePair <String, String> > buildHeaderParams(HGUser hgu)
        {
            IList <KeyValuePair <String, String> > headers = new List <KeyValuePair <String, String> >();

            headers.Add(new KeyValuePair <string, string>("Content-Type", "application/json"));
            if (DebugHelper.getInstance().FastUserLogin)
            {
                // headers.Add(new KeyValuePair<string,string>("Content-Type", "application/json"));
                headers.Add(new KeyValuePair <string, string>("id", "180919101033025850632"));
                headers.Add(new KeyValuePair <string, string>("userType", "2"));
                headers.Add(new KeyValuePair <string, string>("orgid", "18091910104183120964"));
                headers.Add(new KeyValuePair <string, string>("orgType", "2"));
                headers.Add(new KeyValuePair <string, string>("token", "9a893d4d-a80f-4d68-ab30-10f4a5b6193c"));
                return(headers);
            }
            else if (hgu != null)
            {
                // headers.Add(new KeyValuePair<string, string>("Content-Type", "application/json"));
                headers.Add(new KeyValuePair <string, string>("id", hgu.Id));
                headers.Add(new KeyValuePair <string, string>("userType", hgu.UserType));
                headers.Add(new KeyValuePair <string, string>("orgid", hgu.Orgid));
                headers.Add(new KeyValuePair <string, string>("orgType", hgu.OrgType));
                headers.Add(new KeyValuePair <string, string>("token", hgu.Token));
                return(headers);
            }
            return(null);
        }
예제 #2
0
        private void m_bte_login_Click(object sender, EventArgs e)
        {
            String mobile   = m_tbx_mobile.Text;   // "13488613602";// "15811208494";
            String password = m_tbx_password.Text; // "hongka1018";
            String vcode    = m_tbx_captcha.Text;

            if (DebugHelper.getInstance().FastUserLogin)
            {
                mobile   = "13488613602";
                password = "******";
                vcode    = "eq32";
            }

            if (mobile.Equals("请输入手机号"))
            {
                MessageBox.Show("手机号不能为空");
                return;
            }
            if (password.Equals("请输入密码"))
            {
                MessageBox.Show("密码不能为空");
                return;
            }
            if (vcode.Equals("请输入验证码"))
            {
                MessageBox.Show("验证码不能为空");
                return;
            }
            // TODO: don't do the following, just for debug
            if (DebugHelper.getInstance().IsServerFail&& mobile != null)
            {
                MainForm mf = new MainForm();
                this.Hide();
                mf.ShowDialog();
                Application.ExitThread(); // mainthread change to MainForm
                return;
            }

            if (!isValidMobileNo(mobile))
            {
                MessageBox.Show("请输入正确的手机号");
                m_tbx_mobile.Focus();
                return;
            }

            if (m_hg_captcha == null)
            {
                MessageBox.Show("验证码未更新,请点击验证码图片,重新更新验证码");
                return;
            }

            String vtoken = m_hg_captcha.Vtoken;

            try
            {
                HGUser hgu = HGRestfulAPI.getInstance().login(mobile, password, vcode, vtoken);

                if (hgu != null)
                {
                    HGData.getInstance().User = hgu;
                    MainForm mf = new MainForm();
                    this.Hide();
                    mf.ShowDialog();
                    Application.ExitThread(); // mainthread change to MainForm
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }