Ejemplo n.º 1
0
 private void backgroundWorker1_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
 {
     try
     {
         button3.Enabled = false;
         textBox5.Text   = "";
         label5.Text     = "Авторизация";
         string passmd5 = driver.Encrypt(textBox3.Text);
         driver.ipPart = textBox1.Text;
         if (driver.Auth(textBox1.Text, textBox4.Text, textBox2.Text, passmd5) == "OK")
         {
             nameOfDevice = driver.GetDeviceName(textBox1.Text, textBox4.Text, driver.token);
             string responseTotalCards = driver.ReturnTotalCards(textBox1.Text,
                                                                 textBox4.Text, driver.token);
             if (nameOfDevice == "BAS-IP multi-apartment panel")
             {
                 string responseTotalEvents = driver.ReturnTotalEvents(textBox1.Text, textBox4.Text);
                 label5.Text = "Выгрузка списка всех карт";
                 returnAllListOfCardsBASMAP(textBox1.Text, textBox4.Text, driver.token);
                 label5.Text = "Выгрузка списка всех событий";
                 //returnAllListOfEvents(textBox1.Text, textBox4.Text, driver.token);
                 textBox5.Text += GetRemotes(textBox1.Text, textBox4.Text, driver.token) +
                                  Environment.NewLine;
                 progressBar1.Value = 0;
             }
             else if (nameOfDevice == "BAS-IP device")
             {
                 label5.Text = "Выгрузка списка всех карт";
                 returnAllListOfCardsBASDevice(textBox1.Text, textBox4.Text, driver.token);
                 textBox5.Text += "Журнал событий этой серией домофонов не поддерживается " +
                                  Environment.NewLine;
             }
             string time = driver.GetDeviceTime(textBox1.Text, textBox4.Text, driver.token);
             textBox5.Text += "Time: " + time + Environment.NewLine + "Name: "
                              + nameOfDevice + Environment.NewLine;
             //driver.LogOut(textBox1.Text, textBox4.Text, driver.token);
             backgroundWorker1.ReportProgress(0);
             button3.Enabled = true;
             label5.Text     = "";
         }
         else
         {
             MessageBox.Show("Устройство не на линии");
         }
     }
     catch (WebException ex)
     {
         button3.Enabled = true;
         string definition = driver.HandleException(ex);
         MessageBox.Show(ex.Message + Environment.NewLine +
                         Environment.NewLine + definition);
         backgroundWorker1.CancelAsync();
     }
 }