Exemplo n.º 1
0
        private async void button1_Click(object sender, EventArgs e)
        {
            Person user = new Person();

            user.Login    = textBox1.Text;
            user.Password = textBox2.Text;
            if (user.Password.Length < 4)
            {
                label3.Text    = "Пароль должен быть не менее 4 символов.";
                label3.Visible = true;
            }
            else
            {
                string log_pass_enc = Serialization_Encryption_Certification.Encryption(user);
                try
                {
                    using (HttpClient client = new HttpClient())
                    {
                        Dictionary <string, string> str = new Dictionary <string, string>
                        {
                            { "log_pass_enc", log_pass_enc }
                        };
                        FormUrlEncodedContent cont = new FormUrlEncodedContent(str);
                        using (HttpResponseMessage response = await client.PostAsync("http://localhost:7907/Home/Hello", cont))
                        {
                            using (HttpContent content = response.Content)
                            {
                                string mycontent = await content.ReadAsStringAsync();

                                if (mycontent == "access_denied")
                                {
                                    label3.Text    = "Неправильный логин или пароль";
                                    label3.Visible = true;
                                }
                                else
                                {
                                    Global.person = Serialization_Encryption_Certification.Deserialize(Serialization_Encryption_Certification.Decryption(Convert.FromBase64String(mycontent)));
                                    this.Close();
                                    Thread th = new Thread(opennewform);
                                    th.SetApartmentState(ApartmentState.STA);
                                    th.Start();
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    label3.Text    = "Сервер выключен.";
                    label3.Visible = true;
                }
                finally
                {
                }
            }
        }
Exemplo n.º 2
0
        private async void историяДействийСБДToolStripMenuItem_Click(object sender, EventArgs e)
        {
            button1.Visible   = false;
            comboBox1.Visible = false;
            comboBox2.Visible = false;
            label1.Visible    = false;
            listBox1.Items.Clear();
            try
            {
                using (HttpClient client = new HttpClient())
                {
                    using (HttpResponseMessage response = await client.GetAsync("http://*****:*****@"C:\Users\Adons_\Desktop\ceritif-cert-public.pem");
                            if (Serialization_Encryption_Certification.ValidateXmlDocumentWithCertificate(doc, pubCert))
                            {
                                label1.Text    = "fine";
                                label1.Visible = true;
                            }
                            else
                            {
                                label1.Text    = "В процессе передачи данные были повреждены";
                                label1.Visible = true;
                            }
                            actions_list = Serialization_Encryption_Certification.DeserializeAction(results);

                            foreach (Action p in actions_list)
                            {
                                listBox1.Items.Add(Convert.ToString(p.idAction) + "\t" + Convert.ToString(p.ActionId) + "\t" + Convert.ToString(p.ActionDescription) + "\t" + Convert.ToString(p.PersonId) + "\t" + Convert.ToString(p.Date));
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                listBox1.Items.Add(ex.Message);
            }
            finally
            {
            }
        }
Exemplo n.º 3
0
        private async void списокТоваровToolStripMenuItem_Click(object sender, EventArgs e)
        {
            label1.Visible = false;
            listBox1.Items.Clear();
            try
            {
                using (HttpClient client = new HttpClient())
                {
                    using (HttpResponseMessage response = await client.GetAsync("http://*****:*****@"C:\Users\Adons_\Desktop\ceritif-cert-public.pem");
                            if (Serialization_Encryption_Certification.ValidateXmlDocumentWithCertificate(doc, pubCert))
                            {
                                label1.Text    = "fine";
                                label1.Visible = true;
                            }
                            else
                            {
                                label1.Text    = "В процессе передачи данные были повреждены";
                                label1.Visible = true;
                            }
                            products_list = Serialization_Encryption_Certification.Deserialize0(results);
                            int c = 0;
                            comboBox1.Items.Add("Любой");
                            comboBox2.Items.Add("Любой");
                            foreach (Product p in products_list)
                            {
                                listBox1.Items.Add(Convert.ToString(p.ProductId) + "\t" + Convert.ToString(p.ProductName) + "\t" + Convert.ToString(p.Addres) + "\t" + Convert.ToString(p.Weigth) + "\t" + Convert.ToString(p.Price));

                                button1.Visible   = true;
                                comboBox1.Visible = true;
                                comboBox2.Visible = true;

                                if (goods.IndexOf(p.ProductName) == -1)
                                {
                                    comboBox1.Items.Add(p.ProductName);
                                }
                                goods.Add(p.ProductName);
                                if (adres.IndexOf(p.Addres) == -1)
                                {
                                    comboBox2.Items.Add(p.Addres);
                                }
                                adres.Add(p.Addres);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                listBox1.Items.Add(ex.Message);
            }
            finally
            {
            }
        }