private void NextButton_Click(object sender, RoutedEventArgs e) { if (++currentPage == DBThreatsService.GetPagesCount()) { NextButton.IsEnabled = false; } ThreatTable.ItemsSource = DBThreatsService.GetThreatsPage(currentPage); PreviousButton.IsEnabled = true; }
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)); } }
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); } }
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; } }
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; }
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; } }