From 170e4abff07453aa496eb11adeef619cb873b0bf Mon Sep 17 00:00:00 2001 From: sqdselo <147947144+sqdselo@users.noreply.github.com> Date: Mon, 6 May 2024 17:35:33 +0400 Subject: [PATCH] =?UTF-8?q?=D0=A3=D0=B1=D1=80=D0=B0=D0=BB=20=D0=BB=D0=B8?= =?UTF-8?q?=D1=88=D0=BD=D0=B8=D0=B5=20=D1=8E=D0=B7=D0=B8=D0=BD=D0=B3=D0=B8?= =?UTF-8?q?,=20=D1=81=D0=B4=D0=B5=D0=BB=D0=B0=D0=BB=20=D0=B8=D1=81=D0=BA?= =?UTF-8?q?=D0=BB=D1=8E=D1=87=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=BD=D0=B0=20?= =?UTF-8?q?=D0=BE=D0=BF=D0=B5=D1=80=D0=B0=D1=86=D0=B8=D0=B8=20(=D0=B4?= =?UTF-8?q?=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D1=82=D1=8C,=20=D1=83=D0=B4?= =?UTF-8?q?=D0=B0=D0=BB=D0=B8=D1=82=D1=8C,=20=D0=BF=D0=BE=D0=BB=D1=83?= =?UTF-8?q?=D1=87=D0=B8=D1=82=D1=8C)=20=D0=B8=20=D1=81=D0=B4=D0=B5=D0=BB?= =?UTF-8?q?=D0=B0=D0=BB=20=D0=B8=D1=81=D0=BA=D0=BB=D1=8E=D1=87=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D1=8F=20=D0=BD=D0=B0=20=D0=B7=D0=B0=D0=B3=D1=80=D1=83?= =?UTF-8?q?=D0=B7=D0=BA=D1=83=20=D0=B8=20=D0=B2=D1=8B=D0=B3=D1=80=D1=83?= =?UTF-8?q?=D0=B7=D0=BA=D1=83=20=D1=84=D0=B0=D0=B9=D0=BB=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AbstractCompany.cs | 1 - .../CollectionType.cs | 3 +- .../CollectionGenericObjects/Garage.cs | 12 +- .../ICollectionGenericObjects.cs | 3 +- .../ListGenericObjects.cs | 71 +++------- .../MassivGenericObjects.cs | 101 +++++--------- .../StorageCollection.cs | 27 ++-- .../Exceptions/CollectionOverflowException.cs | 8 +- .../Exceptions/ObjectNotFoundException.cs | 8 +- .../PositionOutOfCollectionException.cs | 8 +- .../HoistingCrane/FormCarCollection.cs | 125 +++++++----------- 11 files changed, 121 insertions(+), 246 deletions(-) diff --git a/HoistingCrane/HoistingCrane/CollectionGenericObjects/AbstractCompany.cs b/HoistingCrane/HoistingCrane/CollectionGenericObjects/AbstractCompany.cs index 1c50f33..e56d990 100644 --- a/HoistingCrane/HoistingCrane/CollectionGenericObjects/AbstractCompany.cs +++ b/HoistingCrane/HoistingCrane/CollectionGenericObjects/AbstractCompany.cs @@ -1,5 +1,4 @@ using HoistingCrane.Drawning; -using System; namespace HoistingCrane.CollectionGenericObjects { public abstract class AbstractCompany diff --git a/HoistingCrane/HoistingCrane/CollectionGenericObjects/CollectionType.cs b/HoistingCrane/HoistingCrane/CollectionGenericObjects/CollectionType.cs index 22ffa84..93433c2 100644 --- a/HoistingCrane/HoistingCrane/CollectionGenericObjects/CollectionType.cs +++ b/HoistingCrane/HoistingCrane/CollectionGenericObjects/CollectionType.cs @@ -1,5 +1,4 @@ -using System; -namespace HoistingCrane.CollectionGenericObjects +namespace HoistingCrane.CollectionGenericObjects { public enum CollectionType { diff --git a/HoistingCrane/HoistingCrane/CollectionGenericObjects/Garage.cs b/HoistingCrane/HoistingCrane/CollectionGenericObjects/Garage.cs index 0cf29d7..4927dd5 100644 --- a/HoistingCrane/HoistingCrane/CollectionGenericObjects/Garage.cs +++ b/HoistingCrane/HoistingCrane/CollectionGenericObjects/Garage.cs @@ -1,6 +1,5 @@ using HoistingCrane.Drawning; -using System; -using System.Collections.Specialized; +using HoistingCrane.Exceptions; namespace HoistingCrane.CollectionGenericObjects { @@ -36,9 +35,12 @@ namespace HoistingCrane.CollectionGenericObjects { if (arr?.Get(i) != null) { - arr?.Get(i)?.SetPictureSize(pictureWidth, pictureHeight); - arr?.Get(i)?.SetPosition(_placeSizeWidth * currentPosWidth + 25, _placeSizeHeight * currentPosHeight + 15); - + try + { + arr?.Get(i)?.SetPictureSize(pictureWidth, pictureHeight); + arr?.Get(i)?.SetPosition(_placeSizeWidth * currentPosWidth + 25, _placeSizeHeight * currentPosHeight + 15); + } + catch (ObjectNotFoundException) { } } if (currentPosWidth > 0) diff --git a/HoistingCrane/HoistingCrane/CollectionGenericObjects/ICollectionGenericObjects.cs b/HoistingCrane/HoistingCrane/CollectionGenericObjects/ICollectionGenericObjects.cs index 04b8de7..ae99e89 100644 --- a/HoistingCrane/HoistingCrane/CollectionGenericObjects/ICollectionGenericObjects.cs +++ b/HoistingCrane/HoistingCrane/CollectionGenericObjects/ICollectionGenericObjects.cs @@ -1,5 +1,4 @@ -using System; -namespace HoistingCrane.CollectionGenericObjects +namespace HoistingCrane.CollectionGenericObjects { public interface ICollectionGenericObjects where T: class diff --git a/HoistingCrane/HoistingCrane/CollectionGenericObjects/ListGenericObjects.cs b/HoistingCrane/HoistingCrane/CollectionGenericObjects/ListGenericObjects.cs index 73f740c..7503bb0 100644 --- a/HoistingCrane/HoistingCrane/CollectionGenericObjects/ListGenericObjects.cs +++ b/HoistingCrane/HoistingCrane/CollectionGenericObjects/ListGenericObjects.cs @@ -1,7 +1,4 @@ using HoistingCrane.Exceptions; -using System; -using System.CodeDom.Compiler; - namespace HoistingCrane.CollectionGenericObjects { public class ListGenericObjects : ICollectionGenericObjects where T : class @@ -45,72 +42,34 @@ namespace HoistingCrane.CollectionGenericObjects public T? Get(int position) { - try - { - if (position >= Count || position < 0) - { - throw new PositionOutOfCollectionException(position); - } - return list[position]; - } - catch (PositionOutOfCollectionException ex) - { - MessageBox.Show(ex.Message); - return null; - } + if (position >= Count || position < 0) throw new PositionOutOfCollectionException(position); + return list[position]; } - + public int Insert(T obj) { - try + if (Count == _maxCount) { - if (Count == _maxCount) throw new CollectionOverflowException(Count); - list.Add(obj); - return Count; - } - catch(CollectionOverflowException ex) - { - MessageBox.Show(ex.Message); - return -1; + throw new CollectionOverflowException(Count); } + list.Add(obj); + return Count; } public int Insert(T obj, int position) { - try - { - if (position < 0 || position >= _maxCount) throw new PositionOutOfCollectionException(position); - if (Count == _maxCount) throw new CollectionOverflowException(Count); - list.Insert(position, obj); - return position; - } - catch (CollectionOverflowException ex) - { - MessageBox.Show(ex.Message); - return -1; - } - catch (PositionOutOfCollectionException ex) - { - MessageBox.Show(ex.Message); - return -1; - } - + if (position < 0 || position >= Count) throw new PositionOutOfCollectionException(position); + if (Count == _maxCount) throw new CollectionOverflowException(Count); + list.Insert(position, obj); + return position; } public T? Remove(int position) { - try - { - if (position < 0 || position >= Count) throw new PositionOutOfCollectionException(position); - T? temp = list[position]; - list.RemoveAt(position); - return temp; - } - catch (PositionOutOfCollectionException ex) - { - MessageBox.Show(ex.Message); - return null; - } + if (position < 0 || position >= list.Count) throw new PositionOutOfCollectionException(position); + T? temp = list[position]; + list.RemoveAt(position); + return temp; } public IEnumerable GetItems() diff --git a/HoistingCrane/HoistingCrane/CollectionGenericObjects/MassivGenericObjects.cs b/HoistingCrane/HoistingCrane/CollectionGenericObjects/MassivGenericObjects.cs index 7680ae0..43df118 100644 --- a/HoistingCrane/HoistingCrane/CollectionGenericObjects/MassivGenericObjects.cs +++ b/HoistingCrane/HoistingCrane/CollectionGenericObjects/MassivGenericObjects.cs @@ -1,6 +1,4 @@ using HoistingCrane.Exceptions; -using System; - namespace HoistingCrane.CollectionGenericObjects { public class MassivGenericObjects : ICollectionGenericObjects where T : class @@ -40,96 +38,63 @@ namespace HoistingCrane.CollectionGenericObjects public T? Get(int position) { - try - { - if (position < 0 || position >= Count) throw new PositionOutOfCollectionException(position); - //if (arr[position] == null) throw new ObjectNotFoundException(position); - return arr[position]; - } - catch (PositionOutOfCollectionException ex) - { - MessageBox.Show(ex.Message); - return null; - } - //catch (ObjectNotFoundException ex) - //{ - // MessageBox.Show(ex.Message); - // return null; - //} - } - - public IEnumerable GetItems() - { - for(int i = 0; i < arr.Length; i++) - { - yield return arr[i]; - } + if (position < 0 || position >= Count) throw new PositionOutOfCollectionException(position); + return arr[position]; } public int Insert(T obj) { - try + int countObjectNotNull = 0; + for(int i = 0; i < Count; i++) { - if (arr.Count(x => x != null) == MaxCount) throw new CollectionOverflowException(Count); - return Insert(obj, 0); - } - catch(CollectionOverflowException ex) - { - MessageBox.Show(ex.Message); - return -1; + if (arr[i] != null) countObjectNotNull += 1; } + if(countObjectNotNull == MaxCount) throw new CollectionOverflowException(Count); + return Insert(obj, 0); } - public int Insert(T obj, int position) { - try + if (position < 0 || position >= Count) { - if (position < 0 || position > Count) throw new PositionOutOfCollectionException(position); + throw new PositionOutOfCollectionException(position); + } + int copyPos = position - 1; + while (position < Count) + { if (arr[position] == null) { arr[position] = obj; return position; } - else - { - if (Insert(obj, position + 1) != -1) - { - return position; - } - if (Insert(obj, position - 1) != -1) - { - return position; - } - return -1; - } + position++; } - catch (PositionOutOfCollectionException ex) + while (copyPos > 0) { - MessageBox.Show(ex.Message); - return -1; + if (arr[copyPos] == null) + { + arr[copyPos] = obj; + return copyPos; + } + copyPos--; } + throw new CollectionOverflowException(Count); } public T? Remove(int position) { - try + if (position < 0 || position >= Count) throw new PositionOutOfCollectionException(position); + if (arr[position] == null) throw new ObjectNotFoundException(position); + T? temp = arr[position]; + arr[position] = null; + return temp; + } + + public IEnumerable GetItems() + { + for (int i = 0; i < arr.Length; i++) { - if (position < 0 || position >= MaxCount) throw new PositionOutOfCollectionException(position); - if (arr[position] == null) throw new ObjectNotFoundException(position); - T? temp = arr[position]; - arr[position] = null; - return temp; - } - catch (ObjectNotFoundException ex) - { - MessageBox.Show(ex.Message); - return null; - } - catch (PositionOutOfCollectionException ex) - { - MessageBox.Show(ex.Message); - return null; + yield return arr[i]; } } } diff --git a/HoistingCrane/HoistingCrane/CollectionGenericObjects/StorageCollection.cs b/HoistingCrane/HoistingCrane/CollectionGenericObjects/StorageCollection.cs index cb6a3f0..7ac7b49 100644 --- a/HoistingCrane/HoistingCrane/CollectionGenericObjects/StorageCollection.cs +++ b/HoistingCrane/HoistingCrane/CollectionGenericObjects/StorageCollection.cs @@ -1,8 +1,6 @@ using HoistingCrane.Drawning; using HoistingCrane.Exceptions; -using System; using System.Text; - namespace HoistingCrane.CollectionGenericObjects { public class StorageCollection where T : DrawningTrackedVehicle @@ -84,7 +82,7 @@ namespace HoistingCrane.CollectionGenericObjects { if (dict.Count == 0) { - throw new Exception("В хранилище отсутствуют коллекции для сохранения"); + throw new InvalidOperationException("В хранилище отсутствуют коллекции для сохранения"); } if (File.Exists(filename)) @@ -95,6 +93,7 @@ namespace HoistingCrane.CollectionGenericObjects using (StreamWriter writer = new StreamWriter(filename)) { writer.Write(_collectionKey); + foreach (KeyValuePair> value in dict) { StringBuilder sb = new(); @@ -105,7 +104,6 @@ namespace HoistingCrane.CollectionGenericObjects { continue; } - sb.Append(value.Key); sb.Append(_separatorForKeyValue); sb.Append(value.Value.GetCollectionType); @@ -124,31 +122,30 @@ namespace HoistingCrane.CollectionGenericObjects } writer.Write(sb); } - } } /// - // /// Загрузка информации по грузовикам в хранилище из файла - // /// - // /// Путь и имя файла - // /// true - загрузка прошла успешно, false - ошибка при загрузке данных + /// Загрузка информации по грузовикам в хранилище из файла + /// + /// + /// public void LoadData(string filename) { if (!File.Exists(filename)) { - throw new Exception("Файл не существует"); + throw new FileNotFoundException("Файл не существует"); } using (StreamReader fs = File.OpenText(filename)) { string str = fs.ReadLine(); if (str == null || str.Length == 0) { - throw new Exception("В файле не присутствуют данные"); + throw new InvalidOperationException("В файле не присутствуют данные"); } if (!str.StartsWith(_collectionKey)) { - throw new Exception("В файле неверные данные"); + throw new FormatException("В файле неверные данные"); } dict.Clear(); string strs = ""; @@ -163,7 +160,7 @@ namespace HoistingCrane.CollectionGenericObjects ICollectionGenericObjects? collection = StorageCollection.CreateCollection(collectionType); if (collection == null) { - throw new Exception("Не удалось создать коллекцию"); + throw new InvalidOperationException("Не удалось определить тип коллекции:" + record[1]); } collection.MaxCount = Convert.ToInt32(record[2]); string[] set = record[3].Split(_separatorItems, StringSplitOptions.RemoveEmptyEntries); @@ -175,12 +172,12 @@ namespace HoistingCrane.CollectionGenericObjects { if (collection.Insert(crane) == -1) { - throw new Exception("Объект не удалось добавить в коллекцию: " + record[3]); + throw new InvalidOperationException("Объект не удалось добавить в коллекцию: " + record[3]); } } catch(CollectionOverflowException ex) { - throw new Exception("Коллекция переполнена"); + throw new CollectionOverflowException("Коллекция переполнена", ex); } } } diff --git a/HoistingCrane/HoistingCrane/Exceptions/CollectionOverflowException.cs b/HoistingCrane/HoistingCrane/Exceptions/CollectionOverflowException.cs index da3c19f..44eaf0a 100644 --- a/HoistingCrane/HoistingCrane/Exceptions/CollectionOverflowException.cs +++ b/HoistingCrane/HoistingCrane/Exceptions/CollectionOverflowException.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.Serialization; -using System.Text; -using System.Threading.Tasks; - +using System.Runtime.Serialization; namespace HoistingCrane.Exceptions { [Serializable] diff --git a/HoistingCrane/HoistingCrane/Exceptions/ObjectNotFoundException.cs b/HoistingCrane/HoistingCrane/Exceptions/ObjectNotFoundException.cs index c833095..bd43581 100644 --- a/HoistingCrane/HoistingCrane/Exceptions/ObjectNotFoundException.cs +++ b/HoistingCrane/HoistingCrane/Exceptions/ObjectNotFoundException.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.Serialization; -using System.Text; -using System.Threading.Tasks; - +using System.Runtime.Serialization; namespace HoistingCrane.Exceptions { [Serializable] diff --git a/HoistingCrane/HoistingCrane/Exceptions/PositionOutOfCollectionException.cs b/HoistingCrane/HoistingCrane/Exceptions/PositionOutOfCollectionException.cs index e35263d..15796e2 100644 --- a/HoistingCrane/HoistingCrane/Exceptions/PositionOutOfCollectionException.cs +++ b/HoistingCrane/HoistingCrane/Exceptions/PositionOutOfCollectionException.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.Serialization; -using System.Text; -using System.Threading.Tasks; - +using System.Runtime.Serialization; namespace HoistingCrane.Exceptions { [Serializable] diff --git a/HoistingCrane/HoistingCrane/FormCarCollection.cs b/HoistingCrane/HoistingCrane/FormCarCollection.cs index 8fb3fa7..623ad8f 100644 --- a/HoistingCrane/HoistingCrane/FormCarCollection.cs +++ b/HoistingCrane/HoistingCrane/FormCarCollection.cs @@ -1,17 +1,7 @@ using HoistingCrane.CollectionGenericObjects; using HoistingCrane.Drawning; -using HoistingCrane.Entities; +using HoistingCrane.Exceptions; using Microsoft.Extensions.Logging; -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; - namespace HoistingCrane { public partial class FormCarCollection : Form @@ -34,46 +24,13 @@ namespace HoistingCrane { panelCompanyTool.Enabled = false; } - private void CreateObject(string type) - { - DrawningTrackedVehicle drawning; - if (_company == null) return; - Random rand = new(); - switch (type) - { - case nameof(DrawningHoistingCrane): - drawning = new DrawningHoistingCrane(rand.Next(100, 300), rand.Next(1000, 3000), GetColor(rand), GetColor(rand), true, true); - break; - - case nameof(DrawningTrackedVehicle): - drawning = new DrawningTrackedVehicle(rand.Next(100, 300), rand.Next(1000, 3000), GetColor(rand)); - break; - default: - return; - } - if ((_company + drawning) != -1) - { - MessageBox.Show("Объект добавлен"); - pictureBox.Image = _company.Show(); - } - } - private static Color GetColor(Random random) - { - Color color = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)); - ColorDialog dialog = new(); - if (dialog.ShowDialog() == DialogResult.OK) - { - color = dialog.Color; - } - return color; - } private void buttonCreateHoistingCrane_Click(object sender, EventArgs e) { FormCarConfig form = new(); form.Show(); - form.AddEvent(SetCar); + form.AddEvent(SetCrane); } - private void SetCar(DrawningTrackedVehicle drawningTrackedVehicle) + private void SetCrane(DrawningTrackedVehicle drawningTrackedVehicle) { if (_company == null || drawningTrackedVehicle == null) return; try @@ -86,37 +43,53 @@ namespace HoistingCrane } else { - throw new Exception("Не удалось добавить объект. Заполнено максимальное количество ячеек"); + MessageBox.Show("Не удалось добавить объект"); + logger.LogInformation("Не удалось добавить корабль {ship} в коллекцию", drawningTrackedVehicle.GetType().Name); } } - catch (Exception ex) + catch (CollectionOverflowException ex) { - logger.LogInformation(ex.Message); - return; + MessageBox.Show("Ошибка переполнения коллекции"); + logger.LogError("Ошибка: {Message}", ex.Message); } } private void buttonDeleteCar_Click(object sender, EventArgs e) { - //if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) return; - //if (string.IsNullOrEmpty(maskedTextBox.Text) || _company == null) return; - //try - //{ - // int pos = Convert.ToInt32(maskedTextBox.Text); - // if ((_company - pos) != null) - // { - // MessageBox.Show("Объект удален!"); - // pictureBox.Image = _company.Show(); - // logger.LogInformation("Удален объект по позиции: {pos} ", pos); - // } - // else throw new Exception(); - //} - //catch(Exception ex) - //{ - // logger.LogInformation("Не удалось удалить объект по позиции: {pos}", Convert.ToInt32(maskedTextBox.Text)); - // return; - //} + if (string.IsNullOrEmpty(maskedTextBox.Text) || _company == null) + { + return; + } + if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) + { + return; + } + try + { + int pos = Convert.ToInt32(maskedTextBox.Text); + if ((_company - pos) != null) + { + MessageBox.Show("Объект удален!"); + pictureBox.Image = _company.Show(); + logger.LogInformation("Удаление авто по индексу {pos}", pos); + } + else + { + MessageBox.Show("Не удалось удалить объект"); + logger.LogInformation("Не удалось удалить авто из коллекции по индексу {pos}", pos); + } + } + catch (ObjectNotFoundException ex) + { + MessageBox.Show("Ошибка: отсутствует объект"); + logger.LogError("Ошибка: {Message}", ex.Message); + } + catch (PositionOutOfCollectionException ex) + { + MessageBox.Show("Ошибка: неправильная позиция"); + logger.LogError("Ошибка: {Message}", ex.Message); + } } private void buttonRefresh_Click(object sender, EventArgs e) { @@ -162,20 +135,20 @@ namespace HoistingCrane { if (string.IsNullOrEmpty(textBoxCollectionName.Text) || (!radioButtonList.Checked && !radioButtonMassive.Checked)) { - MessageBox.Show("Не все данные заполнены", "Ошибка", - MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show("Не все данные заполнены", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + logger.LogInformation("Не удалось добавить коллекцию: не все данные заполнены"); return; } CollectionType collectionType = CollectionType.None; if (radioButtonMassive.Checked) { collectionType = CollectionType.Massive; - logger.LogInformation("Создана коллекция типа: {name}", collectionType); + logger.LogInformation("Создана коллекция типа: {name}, название: {name}", collectionType, textBoxCollectionName.Text); } else if (radioButtonList.Checked) { collectionType = CollectionType.List; - logger.LogInformation("Создана коллекция типа: {name}", collectionType); + logger.LogInformation("Создана коллекция типа: {name}, название: {name}", collectionType, textBoxCollectionName.Text); } _storageCollection.AddCollection(textBoxCollectionName.Text,collectionType);RerfreshListBoxItems(); } @@ -190,7 +163,7 @@ namespace HoistingCrane return; _storageCollection.DelCollection(listBoxCollection.SelectedItem.ToString()); RerfreshListBoxItems(); - logger.LogInformation("Коллекция успешно удалена"); + logger.LogInformation("Коллекция {name} успешно удалена", listBoxCollection.SelectedItem.ToString()); } private void buttonCreateCompany_Click(object sender, EventArgs e) { @@ -233,7 +206,7 @@ namespace HoistingCrane MessageBox.Show("Сохранение прошло успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information); logger.LogInformation("Сохранение в файл: {filename}", saveFileDialog.FileName); } - catch (FileNotFoundException ex) + catch (Exception ex) { MessageBox.Show(ex.Message, "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error); logger.LogError("Ошибка: {Message}", ex.Message); @@ -253,11 +226,11 @@ namespace HoistingCrane try { _storageCollection.LoadData(openFileDialog.FileName); - MessageBox.Show("Загрузка прошла успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information); RerfreshListBoxItems(); + MessageBox.Show("Загрузка прошла успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information); logger.LogInformation("Загрузка в файл: {filename}", saveFileDialog.FileName); } - catch(FileNotFoundException ex) + catch(Exception ex) { MessageBox.Show(ex.Message, "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error); logger.LogError("Ошибка: {Message}", ex.Message);