Пример #1
0
        public static async Task <Dictionary <string, StatusResponsePair> > UploadReport(Report house, Period p)
        {
            Dictionary <string, StatusResponsePair> d = new Dictionary <string, StatusResponsePair>();
            var handBook = await HttpController.GetHandbook();

            Dictionary <string, int> housesDic = new Dictionary <string, int>();
            var definition = new[]
            {
                new{
                    Name = "",
                    Id   = -1
                }
            }.ToList();

            var houses = JsonConvert.DeserializeAnonymousType(handBook.response, definition);

            HttpController http   = new HttpController();
            var            result = await http.CreateReport(0, houses.Where(a => a.Name == house.House).FirstOrDefault().Id, p.From, p.To, p.AnualPeriod);

            d.Add("create", result);
            if (result.code == System.Net.HttpStatusCode.OK)
            {
                Dictionary <string, string> values = new Dictionary <string, string>();
                foreach (var e in house.Data)
                {
                    values.Add(e.Key.ValueName.RequestName, Math.Round(e.Value).ToString());
                }
                foreach (var e in house.TextData)
                {
                    values.Add(e.Key.ValueName.RequestName, e.Value);
                }
                var response = JsonConvert.DeserializeObject <Dictionary <string, string> >(result.response);

                var t = await http.EditReport(response["Id"], values);

                d.Add("edit", t);
            }
            return(d);
        }
Пример #2
0
        private async void LoginButton_ClickAsync(object sender, EventArgs e)
        {
            try
            {
                HttpController http = new HttpController();
                var            code = await http.LoginAsync(binField.Text, passwordField.Text);

                if (code.code == HttpStatusCode.OK)
                {
                    if (remember.Checked)
                    {
                        Properties.Settings.Default.LoginPassword = JsonConvert.SerializeObject(new LoginPassword(binField.Text,
                                                                                                                  passwordField.Text));
                        Properties.Settings.Default.Save();
                    }
                    if (form != null)
                    {
                        form.RefreshInfo(null, null);
                    }
                    Close();
                }
                else
                {
                    DialogResult result = MessageBox.Show(
                        "Проверьте введенные данные",
                        "Ошибка!",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error);
                }
            }
            catch
            {
                DialogResult result = MessageBox.Show(
                    "Повторите попытку",
                    "Ошибка!",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
            }
        }