コード例 #1
0
        public static void Update()
        {
            var oldThreats =
                ((ThreatListViewModel)((ThreatList)MainWindow.Instance.MainThreatList.Content).DataContext)
                .AllThreats;
            String tempPath = Path.Combine(Path.GetTempPath(), Path.GetFileName(OpenManager.OpenedFilePath));

            if (!DownloadManager.DownloadFile(tempPath))
            {
                return;
            }
            if (!XlsxThreatReader.ReadThreats(tempPath, out IEnumerable <Threat> temp))
            {
                return;
            }
            var newThreats    = temp.ToList();
            var updateReport  = UpdateReport.CreateUpdateReport(oldThreats, newThreats);
            var newMainWindow = new MainWindow(newThreats);

            newMainWindow.Show();
            MainWindow.Instance.Close();
            MainWindow.Instance = newMainWindow;
            try
            {
                UpdateFile(OpenManager.OpenedFilePath, tempPath, newThreats);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "Не удалось обновить файл");
                return;
            }
            new UpdateReportWindow(updateReport).ShowDialog();
        }
コード例 #2
0
        public UpdateReportWindow(UpdateReport report)
        {
            InitializeComponent();
            AddedNumber.Text   = report.AddedThreats.Count.ToString();
            RemovedNumber.Text = report.RemovedThreats.Count.ToString();
            UpdatedNumber.Text = report.UpdateThreatInfos.Count.ToString();
            var addedThreatViewer = new ThreatViewer();

            AddedThreatViewer.Content = addedThreatViewer;
            AddedThreatList.Content   = new ThreatList(report.AddedThreats, addedThreatViewer);
            var removedThreatViewer = new ThreatViewer();

            RemovedThreatViewer.Content = removedThreatViewer;
            RemovedThreatList.Content   = new ThreatList(report.RemovedThreats, removedThreatViewer);
            var updatedNewThreatViewer = new ThreatViewer();
            var updatedOldThreatViewer = new ThreatViewer();

            UpdatedNewThreatViewer.Content = updatedNewThreatViewer;
            UpdatedOldThreatViewer.Content = updatedOldThreatViewer;
            UpdatedThreatList.Content      = new UpdatedThreatList(report.UpdateThreatInfos, updatedOldThreatViewer, updatedNewThreatViewer);
        }