예제 #1
0
        private async void EnterDesk(int desk, int seat)
        {
            var httpClient = new HttpClient();
            var url        = Url.Header + Url.EnterDesk;
            var parameters = new List <KeyValuePair <string, string> >
            {
                new KeyValuePair <string, string>("uid", Global.uid),
                new KeyValuePair <string, string>("password", Global.password),
                new KeyValuePair <string, string>("desk", Convert.ToString(desk)),
                new KeyValuePair <string, string>("seat", Convert.ToString(seat)),
                new KeyValuePair <string, string>("attribute", "sitdown")
            };
            var response = await httpClient.PostAsync(new Uri(url), new FormUrlEncodedContent(parameters));

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

            if (!result.Equals("OK"))
            {
                return;
            }
            Global.seat = seat;
            var formDesk = new FormDesk();

            formDesk.Show();
            Dispose();
        }
예제 #2
0
        private async void FormFindDesk_Load(object sender, EventArgs e)
        {
            HttpClient httpClient = new HttpClient();
            string     url        = Url.Header + Url.GetDeskListUrl;
            var        response   = await httpClient.PostAsync(new Uri(url), new FormUrlEncodedContent(new List <KeyValuePair <string, string> >()));

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

            string[] desks = result.Split("\n");
            foreach (var desk in desks)
            {
                var info = desk.Split(" ");
                if (info.Length < 3)
                {
                    break;
                }
                if (info[1].Equals(Global.uid) || info[2].Equals(Global.uid))
                {
                    FormDesk formDesk = new FormDesk();
                    formDesk.Show();
                    Dispose();
                    Global.seat = info[1].Equals(Global.uid) ? 1 : 2;
                    return;
                }
                switch (info[0])
                {
                case "1":
                    if (info[1] != "0")
                    {
                        button2.Text    = info[1];
                        button2.Enabled = false;
                    }

                    if (info[2] != "0")
                    {
                        button3.Text    = info[2];
                        button3.Enabled = false;
                    }

                    break;

                case "2":
                    if (info[1] != "0")
                    {
                        button5.Text    = info[1];
                        button5.Enabled = false;
                    }

                    if (info[2] != "0")
                    {
                        button6.Text    = info[2];
                        button6.Enabled = false;
                    }
                    break;

                case "3":
                    if (info[1] != "0")
                    {
                        button8.Text    = info[1];
                        button8.Enabled = false;
                    }

                    if (info[2] != "0")
                    {
                        button9.Text    = info[2];
                        button9.Enabled = false;
                    }

                    break;

                case "4":
                    if (info[1] != "0")
                    {
                        button11.Text    = info[1];
                        button11.Enabled = false;
                    }

                    if (info[2] != "0")
                    {
                        button12.Text    = info[2];
                        button12.Enabled = false;
                    }

                    break;

                default:
                    break;
                }
            }

            httpClient.Dispose();
        }