Ejemplo n.º 1
0
        private void button_submit_Click(object sender, EventArgs e)
        {
            HttpClient httpClient = new HttpClient();
            string     url        = Url.Header + Url.LoginUrl;
            string     username   = textBox_uid.Text;
            string     password   = MD5.GetMD5Hash(textBox_password.Text);
            List <KeyValuePair <string, string> > paramList = new List <KeyValuePair <string, string> >
            {
                new KeyValuePair <string, string>("uid", username),
                new KeyValuePair <string, string>("password", password)
            };

            var response = httpClient.PostAsync(new Uri(url), new FormUrlEncodedContent(paramList)).Result;
            var result   = response.Content.ReadAsStringAsync().Result;

            if (result.Equals("OK"))
            {
                Global.uid      = textBox_uid.Text;
                Global.password = password;
                Hide();
                var formFindDesk = new FormFindDesk();

                formFindDesk.Show();
            }
            else
            {
                MessageBox.Show("登录遇到了问题,请检查账号或密码");
            }
            httpClient.Dispose();
        }
Ejemplo n.º 2
0
        private async void button_standup_Click(object sender, EventArgs e)
        {
            HttpClient httpClient = new HttpClient();
            string     url        = Url.Header + Url.EnterDesk;
            var        parameters = new List <KeyValuePair <string, string> >();

            parameters.Add(new KeyValuePair <string, string>("uid", Global.uid));
            parameters.Add(new KeyValuePair <string, string>("password", Global.password));
            parameters.Add(new KeyValuePair <string, string>("seat", Global.seat.ToString()));

            parameters.Add(new KeyValuePair <string, string>("attribute", "standup"));

            var response = await httpClient.PostAsync(new Uri(url), new FormUrlEncodedContent(parameters));

            var result = await response.Content.ReadAsStringAsync();

            if (result.Equals("OK"))
            {
                FormFindDesk formDesk = new FormFindDesk();
                formDesk.Show();
                Dispose();
            }
        }