private void UpdateButton_Click(object sender, RoutedEventArgs e) { if (CheckInternet() == true) { threats = XLSXImport.EnumerateThreats("thrlist.xlsx").ToList(); WebClient webClient = new WebClient(); webClient.DownloadFile("https://bdu.fstec.ru/files/documents/thrlist.xlsx", "thrlist.xlsx"); threatsNew = XLSXImport.EnumerateThreats("thrlist.xlsx").ToList(); List <Threat> threatsList = threats.ToList(); List <Threat> threatsNewList = threatsNew.ToList(); int count = 0; for (int i = 0; i < threatsList.Count; i++) { if (!threatsList[i].Equals(threatsNewList[i])) { isUpdated = true; threatsBefore.Add(threatsList[i]); threatsAfter.Add(threatsNewList[i]); count++; } } if (threatsList.Count < threatsNewList.Count) { for (int i = threatsList.Count; i < threatsNewList.Count; i++) { threatsAfter.Add(threatsNewList[i]); count++; } } if (count == 0) { UpdateFail uf = new UpdateFail(); uf.Show(); } else { UpdateSuccess us = new UpdateSuccess(); us.UpdateText.Text = $"Обновлено следующее количество записей: {count}"; us.Show(); } threats = XLSXImport.EnumerateThreats("thrlist.xlsx").ToList(); PagedTable.PageIndex = 0; DataTable firstTable = PagedTable.SetPaging(threats, numberOfRecPerPage); ThreatsDataGrid.ItemsSource = firstTable.DefaultView; PageInfoLabel.Content = PageNumberDisplay(); } else { UpdateFail uf = new UpdateFail(); uf.UpdateText.Text = "Проверьте подключение к интернету!"; uf.Show(); } }
private void UploadButton_Click(object sender, RoutedEventArgs e) { ThreatsDataGrid.Visibility = Visibility.Visible; threats = XLSXImport.EnumerateThreats("thrlist.xlsx").ToList(); PagedTable.PageIndex = 0; DataTable firstTable = PagedTable.SetPaging(threats, numberOfRecPerPage); ThreatsDataGrid.ItemsSource = firstTable.DefaultView; PageInfoLabel.Content = PageNumberDisplay(); PrevPageButton.Visibility = Visibility.Visible; NextPageButton.Visibility = Visibility.Visible; UpdateButton.IsEnabled = true; SaveButton.IsEnabled = true; }