示例#1
0
 private void NextButton_Click(object sender, RoutedEventArgs e)
 {
     if (++currentPage == DBThreatsService.GetPagesCount())
     {
         NextButton.IsEnabled = false;
     }
     ThreatTable.ItemsSource  = DBThreatsService.GetThreatsPage(currentPage);
     PreviousButton.IsEnabled = true;
 }
示例#2
0
 private UpdateAnswer UpdateThreats()
 {
     try
     {
         var savedThreats = DBThreatsService.GetAllThreats();
         var newThreats   = GetThreatsFromFile(DownloadFile(FILE_LINK));
         DBThreatsService.ClearSavedThreats();
         DBThreatsService.SaveThreats(newThreats);
         var compareResult = CompareThreatLists(savedThreats, newThreats);
         return(new UpdateAnswer(compareResult));
     } catch (Exception ex) {
         return(new UpdateAnswer(ex.Message));
     }
 }
示例#3
0
        private void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            SaveFileDialog fd = new SaveFileDialog();

            fd.Filter = "Excel file (*.xlsx)|*.xlsx";
            if (fd.ShowDialog() == true && fd.FileName != "")
            {
                string path = fd.FileName;
                MessageBox.Show(path);
                var    threatlist = DBThreatsService.GetAllThreats();
                Mapper mapper     = new Mapper();
                mapper.Save(path, threatlist);
            }
        }
示例#4
0
        private void CreateButton_Click(object sender, RoutedEventArgs e)
        {
            string        path = DownloadFile(FILE_LINK);
            List <Threat> lt   = GetThreatsFromFile(path);

            DBThreatsService.SaveThreats(lt);
            lt = DBThreatsService.GetThreatsPage(currentPage);
            ThreatTable.ItemsSource  = lt;
            CreateButton.IsEnabled   = false;
            UpdateButton.IsEnabled   = true;
            PreviousButton.IsEnabled = false;
            SaveButton.IsEnabled     = true;
            if (DBThreatsService.GetPagesCount() > 1)
            {
                NextButton.IsEnabled = true;
            }
        }
示例#5
0
 public MainWindow()
 {
     InitializeComponent();
     currentPage = 1;
     if (DBThreatsService.GetPagesCount() > 0)
     {
         CreateButton.IsEnabled  = false;
         ThreatTable.ItemsSource = DBThreatsService.GetThreatsPage(currentPage);
         if (DBThreatsService.GetPagesCount() < 2)
         {
             NextButton.IsEnabled = false;
         }
     }
     else
     {
         UpdateButton.IsEnabled = false;
         NextButton.IsEnabled   = false;
         SaveButton.IsEnabled   = false;
     }
     PreviousButton.IsEnabled = false;
 }
示例#6
0
        private void UpdateButton_Click(object sender, RoutedEventArgs e)
        {
            var answer = UpdateThreats();

            if (answer.status == UpdateStatuses.Failed)
            {
                MessageBox.Show(answer.error, "Возникла ошибка при обновлении базы данных");
            }
            else
            {
                DisplayUpdateReport(answer.changes);
            }
            ThreatTable.ItemsSource = DBThreatsService.GetThreatsPage(1);
            if (DBThreatsService.GetPagesCount() > 1)
            {
                NextButton.IsEnabled = true;
            }
            else
            {
                NextButton.IsEnabled = false;
            }
        }