public Update() { InitializeComponent(); WebClient myWebClient = new WebClient(); string myStringWebResource = @"https://bdu.fstec.ru/files/documents/thrlist.xlsx"; List <string> li = new List <string>(); myWebClient.DownloadFile(myStringWebResource, fileName1); filepath1 = Path.GetFullPath(fileName1); Hate_you_excel ex = new Hate_you_excel(filepath1); List <UBI> list = ex.list(); int count = 0; for (int i = 0; i < list.Count; i++) { string s = "Индекс угрозы: "; s += list[i].IndefUBI + "\n Наименование угрозы: " + list[i].NameUBI; if (list[i].AccessibilityViolation != MainWindow.list[i].AccessibilityViolation || list[i].IntegrityViolation != MainWindow.list[i].IntegrityViolation || list[i].BreachConf != MainWindow.list[i].BreachConf || list[i].Description != MainWindow.list[i].Description || list[i].SourceOfThreat != MainWindow.list[i].SourceOfThreat || list[i].Object != MainWindow.list[i].Object) { if (list[i].Description != MainWindow.list[i].Description) { s += "\n\nБыло: \n" + MainWindow.list[i].Description + "\n\nСтало: \n" + list[i].Description; } if (list[i].SourceOfThreat != MainWindow.list[i].SourceOfThreat) { s += "\n\nБыло: \n" + MainWindow.list[i].SourceOfThreat + "\n\nСтало: \n" + list[i].SourceOfThreat; } if (list[i].Object != MainWindow.list[i].Object) { s += "\n\nБыло: \n" + MainWindow.list[i].Object + "\n\nСтало: \n" + list[i].Object; } if (list[i].BreachConf != MainWindow.list[i].BreachConf) { s += "\n\nБыло: \n" + MainWindow.list[i].BreachConf + "\n\nСтало: \n" + list[i].BreachConf; } if (list[i].IntegrityViolation != MainWindow.list[i].IntegrityViolation) { s += "\n\nБыло: \n" + MainWindow.list[i].IntegrityViolation + "\n\nСтало: \n" + list[i].IntegrityViolation; } if (list[i].AccessibilityViolation != MainWindow.list[i].AccessibilityViolation) { s += "\n\nБыло: \n" + MainWindow.list[i].AccessibilityViolation + "\n\nСтало: \n" + list[i].AccessibilityViolation; } count++; } else { s += "\nБез изменений"; } li.Add(s); } MainWindow.DisplayMessageBoxText("Количество изменений: " + count); L.ItemsSource = li; File.Delete(MainWindow.filepath); File.Move(filepath1, MainWindow.filepath); }
public MainWindow() { InitializeComponent(); Message newForm = new Message(); if (File.Exists(filepath) == false) { newForm.Show(); DisplayMessageBoxText("После загрузки файла необходимо будет перезапустить приложение"); } try { Hate_you_excel ex = new Hate_you_excel(filepath); list = ex.list(); this.view = new PagingCollectionView(list, 20); this.DataContext = this.view; //DisplayMessageBoxText(MainWindow.filepath); } catch { } }