From 23a7a41196c3476e61270217e01d026430e54140 Mon Sep 17 00:00:00 2001 From: bekodeg Date: Tue, 28 Nov 2023 17:17:38 +0400 Subject: [PATCH 1/5] =?UTF-8?q?=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=207?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LocomotiveNotFoundException .cs | 19 +++++ .../Exceptions/StorageOverflowException.cs | 19 +++++ .../Generics/LocomotivesGenericStorage.cs | 10 +-- ElectricLocomotive/Generics/SetGeneric.cs | 10 ++- .../LogicFormLocomotiveCollection.cs | 78 ++++++++++++------- ElectricLocomotive/Program.cs | 19 ++++- .../ProjectElectricLocomotive.csproj | 5 ++ ElectricLocomotive/nlog.config | 13 ++++ 8 files changed, 135 insertions(+), 38 deletions(-) create mode 100644 ElectricLocomotive/Exceptions/LocomotiveNotFoundException .cs create mode 100644 ElectricLocomotive/Exceptions/StorageOverflowException.cs create mode 100644 ElectricLocomotive/nlog.config diff --git a/ElectricLocomotive/Exceptions/LocomotiveNotFoundException .cs b/ElectricLocomotive/Exceptions/LocomotiveNotFoundException .cs new file mode 100644 index 0000000..6b84022 --- /dev/null +++ b/ElectricLocomotive/Exceptions/LocomotiveNotFoundException .cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectElectricLocomotive.Exceptions +{ + [Serializable] + internal class LocomotiveNotFoundException : ApplicationException + { + public LocomotiveNotFoundException(int i) : base($"Не найден объект по позиции {i}") { } + public LocomotiveNotFoundException() : base() { } + public LocomotiveNotFoundException (string message) : base(message) { } + public LocomotiveNotFoundException(string message, Exception innerException) : base(message, innerException) { } + protected LocomotiveNotFoundException(SerializationInfo info, StreamingContext contex) : base(info, contex) { } + } +} diff --git a/ElectricLocomotive/Exceptions/StorageOverflowException.cs b/ElectricLocomotive/Exceptions/StorageOverflowException.cs new file mode 100644 index 0000000..73c104f --- /dev/null +++ b/ElectricLocomotive/Exceptions/StorageOverflowException.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectElectricLocomotive.Exceptions +{ + [Serializable] + internal class StorageOverflowException : ApplicationException + { + public StorageOverflowException(int count) : base($"В наборе превышено допустимое количество: { count}") { } + public StorageOverflowException() : base() { } + public StorageOverflowException(string message) : base(message) { } + public StorageOverflowException(string message, Exception exception) : base(message, exception) { } + protected StorageOverflowException(SerializationInfo info, StreamingContext contex) : base(info, contex) { } + } +} diff --git a/ElectricLocomotive/Generics/LocomotivesGenericStorage.cs b/ElectricLocomotive/Generics/LocomotivesGenericStorage.cs index ddc84fb..adfc6fa 100644 --- a/ElectricLocomotive/Generics/LocomotivesGenericStorage.cs +++ b/ElectricLocomotive/Generics/LocomotivesGenericStorage.cs @@ -133,7 +133,7 @@ namespace ProjectElectricLocomotive.Generics } if (data.Length == 0) { - return false; + throw new Exception("Невалиданя операция, нет данных длясохранения"); } using FileStream fs = new(filename, FileMode.Create); byte[] info = new @@ -151,7 +151,7 @@ namespace ProjectElectricLocomotive.Generics { if (!File.Exists(filename)) { - return false; + throw new FileNotFoundException($"Файл {filename} не найден"); } string bufferTextFromFile = ""; using (FileStream fs = new(filename, FileMode.Open)) @@ -167,12 +167,12 @@ namespace ProjectElectricLocomotive.Generics StringSplitOptions.RemoveEmptyEntries); if (strs == null || strs.Length == 0) { - return false; + throw new FileLoadException("Нет данных для загрузки"); } if (!strs[0].StartsWith("LocomotiveStorage")) { //если нет такой записи, то это не те данные - return false; + throw new ArgumentException("Неверный формат данных"); } _locomotiveStorage.Clear(); foreach (string data in strs) @@ -197,7 +197,7 @@ namespace ProjectElectricLocomotive.Generics { if ((collection + locomotive) == 0) { - return false; + throw new InvalidOperationException("Ошибкадобавления в коллекцию"); } } } diff --git a/ElectricLocomotive/Generics/SetGeneric.cs b/ElectricLocomotive/Generics/SetGeneric.cs index 6ca43f5..6cb07b4 100644 --- a/ElectricLocomotive/Generics/SetGeneric.cs +++ b/ElectricLocomotive/Generics/SetGeneric.cs @@ -1,4 +1,5 @@ -using System; +using ProjectElectricLocomotive.Exceptions; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -43,7 +44,7 @@ namespace ProjectElectricLocomotive.Generics public bool Insert(T locomotive) { if (_places.Count >= _maxCount) { - return false; + throw new StorageOverflowException(_maxCount); } _places.Insert(0, locomotive); return true; @@ -74,7 +75,10 @@ namespace ProjectElectricLocomotive.Generics { return false; } - + if (_places[position] == null) + { + throw new LocomotiveNotFoundException(position); + } _places.RemoveAt(position); return true; diff --git a/ElectricLocomotive/LogicFormLocomotiveCollection.cs b/ElectricLocomotive/LogicFormLocomotiveCollection.cs index 1acefcd..8285d0f 100644 --- a/ElectricLocomotive/LogicFormLocomotiveCollection.cs +++ b/ElectricLocomotive/LogicFormLocomotiveCollection.cs @@ -1,12 +1,8 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; +using Microsoft.Extensions.Logging; using ProjectElectricLocomotive.DrawningObjects; +using ProjectElectricLocomotive.Exceptions; using ProjectElectricLocomotive.Generics; -using ProjectElectricLocomotive.MovementStrategy; +using System.Xml.Linq; namespace ProjectElectricLocomotive { @@ -21,15 +17,20 @@ namespace ProjectElectricLocomotive /// private readonly LocomotivesGenericStorage _storage; /// + /// Логер + /// + private readonly ILogger _logger; + /// /// Конструктор /// - public FormLocomotiveCollection() + public FormLocomotiveCollection(ILogger logger) { InitializeComponent(); _storage = new LocomotivesGenericStorage( pictureBoxCollection.Width, pictureBoxCollection.Height ); + _logger = logger; } /// @@ -67,6 +68,7 @@ namespace ProjectElectricLocomotive } _storage.AddSet(textBoxStorageName.Text); ReloadObjects(); + _logger.LogInformation($"Добавлен набор:{textBoxStorageName.Text}"); } /// @@ -90,12 +92,14 @@ namespace ProjectElectricLocomotive { return; } - if (MessageBox.Show($"Удалить объект {listBoxStorages.SelectedItem}?", + string name = listBoxStorages.SelectedItem.ToString() ?? string.Empty; + if (MessageBox.Show($"Удалить объект {name}?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { - _storage.DelSet(listBoxStorages.SelectedItem.ToString() ?? string.Empty); + _storage.DelSet(name); ReloadObjects(); + _logger.LogInformation($"Удален набор: {name}"); } } @@ -122,15 +126,22 @@ namespace ProjectElectricLocomotive return; } SelectedLocomotive.SetPictureSize(pictureBoxCollection.Size); - if (obj + SelectedLocomotive > 0) + try { - MessageBox.Show("Объект добавлен"); + if (obj + SelectedLocomotive > 0) + { + MessageBox.Show("Объект добавлен"); - pictureBoxCollection.Image = obj.ShowLocomotives(); + pictureBoxCollection.Image = obj.ShowLocomotives(); + } + else + { + MessageBox.Show("Не удалось добавить объект"); + } } - else + catch (StorageOverflowException ex) { - MessageBox.Show("Не удалось добавить объект"); + MessageBox.Show(ex.Message); } } @@ -165,14 +176,21 @@ namespace ProjectElectricLocomotive { pos = 0; } - if (obj - pos != -1) + try { - MessageBox.Show("Объект удален"); - pictureBoxCollection.Image = obj.ShowLocomotives(); + if (obj - pos != -1) + { + MessageBox.Show("Объект удален"); + pictureBoxCollection.Image = obj.ShowLocomotives(); + } + else + { + MessageBox.Show("Не удалось удалить объект"); + } } - else + catch (LocomotiveNotFoundException ex) { - MessageBox.Show("Не удалось удалить объект"); + MessageBox.Show(ex.Message); } } /// @@ -205,15 +223,16 @@ namespace ProjectElectricLocomotive saveFileDialog.Title = "Сохранение"; if (saveFileDialog.ShowDialog() == DialogResult.OK) { - if (_storage.SaveData(saveFileDialog.FileName)) + try { + _storage.SaveData(saveFileDialog.FileName); MessageBox.Show("Сохранение прошло успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error); } - else - { - MessageBox.Show("Не сохранилось", "Результат", - MessageBoxButtons.OK, MessageBoxIcon.Error); + catch (Exception ex) + { + MessageBox.Show($"Не сохранилось: {ex.Message}", + "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } @@ -225,16 +244,17 @@ namespace ProjectElectricLocomotive openFileDialog.Title = "Загрузка"; if (openFileDialog.ShowDialog() == DialogResult.OK) { - if (_storage.LoadData(openFileDialog.FileName)) + try { + _storage.LoadData(openFileDialog.FileName); MessageBox.Show("Загрузка прошла успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error); ReloadObjects(); } - else + catch(Exception ex) { - MessageBox.Show("Не загрузилось", "Результат", - MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show($"Не загрузилось: {ex.Message}", + "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } diff --git a/ElectricLocomotive/Program.cs b/ElectricLocomotive/Program.cs index 5def1ba..daae88b 100644 --- a/ElectricLocomotive/Program.cs +++ b/ElectricLocomotive/Program.cs @@ -1,3 +1,7 @@ +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using NLog.Extensions.Logging; + namespace ProjectElectricLocomotive { internal static class Program @@ -11,7 +15,20 @@ namespace ProjectElectricLocomotive // To customize application configuration such as set high DPI settings or default font, // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); - Application.Run(new FormLocomotiveCollection()); + var services = new ServiceCollection(); + ConfigureServices(services); + using (ServiceProvider serviceProvider = services.BuildServiceProvider()) + { + Application.Run(serviceProvider.GetRequiredService()); + } + } + private static void ConfigureServices(ServiceCollection services) + { + services.AddSingleton().AddLogging(option => + { + option.SetMinimumLevel(LogLevel.Information); + option.AddNLog("nlog.config"); + }); } } } \ No newline at end of file diff --git a/ElectricLocomotive/ProjectElectricLocomotive.csproj b/ElectricLocomotive/ProjectElectricLocomotive.csproj index 13ee123..eb2b961 100644 --- a/ElectricLocomotive/ProjectElectricLocomotive.csproj +++ b/ElectricLocomotive/ProjectElectricLocomotive.csproj @@ -8,6 +8,11 @@ enable + + + + + True diff --git a/ElectricLocomotive/nlog.config b/ElectricLocomotive/nlog.config new file mode 100644 index 0000000..54e4ba6 --- /dev/null +++ b/ElectricLocomotive/nlog.config @@ -0,0 +1,13 @@ + + + + + + + + + + + \ No newline at end of file -- 2.25.1 From ce2f998244eebb7bd92ecec750d9a478a6df1300 Mon Sep 17 00:00:00 2001 From: bekodeg Date: Wed, 6 Dec 2023 09:33:39 +0400 Subject: [PATCH 2/5] =?UTF-8?q?=D0=B4=D0=BE=D1=80=D0=B0=D0=B1=D0=BE=D1=82?= =?UTF-8?q?=D0=BA=D0=B0=20=D0=BF=D0=BE=20=D1=82=D1=80=D0=B5=D0=B1=D0=BE?= =?UTF-8?q?=D0=B2=D0=B0=D0=BD=D0=B8=D1=8F=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Generics/LocomotivesGenericStorage.cs | 2 +- .../LogicFormLocomotiveCollection.cs | 13 +++++++++++ ElectricLocomotive/Program.cs | 23 +++++++++++++++---- .../ProjectElectricLocomotive.csproj | 8 +++++++ ElectricLocomotive/serilog.json | 20 ++++++++++++++++ 5 files changed, 61 insertions(+), 5 deletions(-) create mode 100644 ElectricLocomotive/serilog.json diff --git a/ElectricLocomotive/Generics/LocomotivesGenericStorage.cs b/ElectricLocomotive/Generics/LocomotivesGenericStorage.cs index adfc6fa..4254b70 100644 --- a/ElectricLocomotive/Generics/LocomotivesGenericStorage.cs +++ b/ElectricLocomotive/Generics/LocomotivesGenericStorage.cs @@ -133,7 +133,7 @@ namespace ProjectElectricLocomotive.Generics } if (data.Length == 0) { - throw new Exception("Невалиданя операция, нет данных длясохранения"); + throw new InvalidOperationException("Невалиданя операция, нет данных длясохранения"); } using FileStream fs = new(filename, FileMode.Create); byte[] info = new diff --git a/ElectricLocomotive/LogicFormLocomotiveCollection.cs b/ElectricLocomotive/LogicFormLocomotiveCollection.cs index 8285d0f..75ad021 100644 --- a/ElectricLocomotive/LogicFormLocomotiveCollection.cs +++ b/ElectricLocomotive/LogicFormLocomotiveCollection.cs @@ -2,6 +2,7 @@ using ProjectElectricLocomotive.DrawningObjects; using ProjectElectricLocomotive.Exceptions; using ProjectElectricLocomotive.Generics; +using System.Windows.Forms; using System.Xml.Linq; namespace ProjectElectricLocomotive @@ -133,15 +134,18 @@ namespace ProjectElectricLocomotive MessageBox.Show("Объект добавлен"); pictureBoxCollection.Image = obj.ShowLocomotives(); + _logger.LogInformation($"Объект {obj.GetType()} добавлен"); } else { MessageBox.Show("Не удалось добавить объект"); + _logger.LogInformation($"Не удалось добавить объект"); } } catch (StorageOverflowException ex) { MessageBox.Show(ex.Message); + _logger.LogError(ex.ToString()); } } @@ -182,15 +186,18 @@ namespace ProjectElectricLocomotive { MessageBox.Show("Объект удален"); pictureBoxCollection.Image = obj.ShowLocomotives(); + _logger.LogInformation($"Объект {pos} удален"); } else { MessageBox.Show("Не удалось удалить объект"); + _logger.LogInformation($"Не удалось удалить объект {pos}"); } } catch (LocomotiveNotFoundException ex) { MessageBox.Show(ex.Message); + _logger.LogError(ex.ToString()); } } /// @@ -228,11 +235,14 @@ namespace ProjectElectricLocomotive _storage.SaveData(saveFileDialog.FileName); MessageBox.Show("Сохранение прошло успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error); + _logger.LogInformation($"Сохранение в {saveFileDialog.FileName} прошло успешно"); } catch (Exception ex) { MessageBox.Show($"Не сохранилось: {ex.Message}", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error); + _logger.LogInformation($"Не удалось сохранить в {saveFileDialog.FileName}: {ex.Message}"); + _logger.LogDebug(ex.ToString()); } } } @@ -250,11 +260,14 @@ namespace ProjectElectricLocomotive MessageBox.Show("Загрузка прошла успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error); ReloadObjects(); + _logger.LogInformation($"Загрузка из {openFileDialog.FileName} прошла успешно"); } catch(Exception ex) { MessageBox.Show($"Не загрузилось: {ex.Message}", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error); + _logger.LogInformation($"Не удалось загрузить из {openFileDialog.FileName}: {ex.Message}"); + _logger.LogDebug(ex.ToString()); } } } diff --git a/ElectricLocomotive/Program.cs b/ElectricLocomotive/Program.cs index daae88b..a29f79a 100644 --- a/ElectricLocomotive/Program.cs +++ b/ElectricLocomotive/Program.cs @@ -1,6 +1,7 @@ +using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; -using NLog.Extensions.Logging; +using Serilog; namespace ProjectElectricLocomotive { @@ -12,8 +13,7 @@ namespace ProjectElectricLocomotive [STAThread] static void Main() { - // To customize application configuration such as set high DPI settings or default font, - // see https://aka.ms/applicationconfiguration. + ApplicationConfiguration.Initialize(); var services = new ServiceCollection(); ConfigureServices(services); @@ -21,14 +21,29 @@ namespace ProjectElectricLocomotive { Application.Run(serviceProvider.GetRequiredService()); } + } + private static void ConfigureServices(ServiceCollection services) { services.AddSingleton().AddLogging(option => { + string[] path = Directory.GetCurrentDirectory().Split('\\'); + string pathNeed = ""; + for (int i = 0; i < path.Length - 3; i++) + { + pathNeed += path[i] + "\\"; + } + var configuration = new ConfigurationBuilder().SetBasePath( + Directory.GetCurrentDirectory()).AddJsonFile( + path: $"{pathNeed}serilog.json", optional: false, reloadOnChange: true + ).Build(); + var logger = new LoggerConfiguration().ReadFrom.Configuration(configuration).CreateLogger(); + option.SetMinimumLevel(LogLevel.Information); - option.AddNLog("nlog.config"); + option.AddSerilog(logger); }); } + } } \ No newline at end of file diff --git a/ElectricLocomotive/ProjectElectricLocomotive.csproj b/ElectricLocomotive/ProjectElectricLocomotive.csproj index eb2b961..c8d4348 100644 --- a/ElectricLocomotive/ProjectElectricLocomotive.csproj +++ b/ElectricLocomotive/ProjectElectricLocomotive.csproj @@ -9,8 +9,16 @@ + + + + + + + + diff --git a/ElectricLocomotive/serilog.json b/ElectricLocomotive/serilog.json new file mode 100644 index 0000000..44c260c --- /dev/null +++ b/ElectricLocomotive/serilog.json @@ -0,0 +1,20 @@ +{ + "Serilog": { + "Using": [ "Serilog.Sinks.File" ], + "MinimumLevel": "Information", + "WriteTo": [ + { + "Name": "File", + "Args": { + "path": "Logs/log_.log", + "rollingInterval": "Day", + "outputTemplate": "[{Timestamp:HH:mm:ss.fff}]{Level:u4}: {Message:lj}{NewLine}{Exception}" + } + } + ], + "Enrich": [ "FromLogContext", "WithMachineName", "WithThreadId" ], + "Properties": { + "Application": "GasolineTanker" + } + } +} \ No newline at end of file -- 2.25.1 From 7a3a4b66ca1fda4e502b313695a638254211bd04 Mon Sep 17 00:00:00 2001 From: bekodeg Date: Wed, 6 Dec 2023 10:12:42 +0400 Subject: [PATCH 3/5] =?UTF-8?q?=D0=B1=D0=BE=D0=BB=D0=B5=D0=B5=20=D0=BC?= =?UTF-8?q?=D0=B5=D0=BD=D0=B5=D0=B5=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=B0?= =?UTF-8?q?=D0=B5=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ElectricLocomotive/Generics/LocomotivesGenericStorage.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ElectricLocomotive/Generics/LocomotivesGenericStorage.cs b/ElectricLocomotive/Generics/LocomotivesGenericStorage.cs index 4731b30..c270f19 100644 --- a/ElectricLocomotive/Generics/LocomotivesGenericStorage.cs +++ b/ElectricLocomotive/Generics/LocomotivesGenericStorage.cs @@ -123,7 +123,7 @@ namespace ProjectElectricLocomotive.Generics sw.WriteLine("LocomotiveStorage"); if (_locomotiveStorage.Count == 0) { - return false; + throw new InvalidOperationException("Невалиданя операция, нет данных длясохранения"); } foreach ( KeyValuePair Date: Wed, 6 Dec 2023 10:42:21 +0400 Subject: [PATCH 4/5] =?UTF-8?q?7=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=20?= =?UTF-8?q?=D1=84=D0=B8=D0=BD=D0=B0=D0=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ElectricLocomotive/Generics/LocomotivesGenericStorage.cs | 2 +- ElectricLocomotive/Generics/SetGeneric.cs | 8 ++------ ElectricLocomotive/LogicFormLocomotiveCollection.cs | 8 ++++---- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/ElectricLocomotive/Generics/LocomotivesGenericStorage.cs b/ElectricLocomotive/Generics/LocomotivesGenericStorage.cs index c270f19..d5faa52 100644 --- a/ElectricLocomotive/Generics/LocomotivesGenericStorage.cs +++ b/ElectricLocomotive/Generics/LocomotivesGenericStorage.cs @@ -158,7 +158,7 @@ namespace ProjectElectricLocomotive.Generics using (StreamReader sr = new(filename)) { string line; - if (!((line = sr.ReadLine() != null) && line.StartsWith("LocomotiveStorage"))) + if (!(((line = sr.ReadLine()) != null) && line.StartsWith("LocomotiveStorage"))) { //если нет такой записи, то это не те данные throw new ArgumentException("Неверный формат данных"); diff --git a/ElectricLocomotive/Generics/SetGeneric.cs b/ElectricLocomotive/Generics/SetGeneric.cs index 6cb07b4..fbaf54f 100644 --- a/ElectricLocomotive/Generics/SetGeneric.cs +++ b/ElectricLocomotive/Generics/SetGeneric.cs @@ -71,11 +71,7 @@ namespace ProjectElectricLocomotive.Generics /// public bool Remove(int position) { - if (position >= Count || position < 0) - { - return false; - } - if (_places[position] == null) + if (position >= Count || position < 0 || _places[position] == null) { throw new LocomotiveNotFoundException(position); } @@ -94,7 +90,7 @@ namespace ProjectElectricLocomotive.Generics { if (position >= Count || position < 0) { - return null; + throw new LocomotiveNotFoundException(position); } return _places[position]; } diff --git a/ElectricLocomotive/LogicFormLocomotiveCollection.cs b/ElectricLocomotive/LogicFormLocomotiveCollection.cs index 75ad021..ba3cb51 100644 --- a/ElectricLocomotive/LogicFormLocomotiveCollection.cs +++ b/ElectricLocomotive/LogicFormLocomotiveCollection.cs @@ -145,7 +145,7 @@ namespace ProjectElectricLocomotive catch (StorageOverflowException ex) { MessageBox.Show(ex.Message); - _logger.LogError(ex.ToString()); + _logger.LogWarning(ex.ToString()); } } @@ -197,7 +197,7 @@ namespace ProjectElectricLocomotive catch (LocomotiveNotFoundException ex) { MessageBox.Show(ex.Message); - _logger.LogError(ex.ToString()); + _logger.LogWarning(ex.ToString()); } } /// @@ -242,7 +242,7 @@ namespace ProjectElectricLocomotive MessageBox.Show($"Не сохранилось: {ex.Message}", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error); _logger.LogInformation($"Не удалось сохранить в {saveFileDialog.FileName}: {ex.Message}"); - _logger.LogDebug(ex.ToString()); + _logger.LogWarning(ex.ToString()); } } } @@ -267,7 +267,7 @@ namespace ProjectElectricLocomotive MessageBox.Show($"Не загрузилось: {ex.Message}", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error); _logger.LogInformation($"Не удалось загрузить из {openFileDialog.FileName}: {ex.Message}"); - _logger.LogDebug(ex.ToString()); + _logger.LogWarning(ex.ToString()); } } } -- 2.25.1 From c18af275cddb7914c584098fa832d5dad8201ffc Mon Sep 17 00:00:00 2001 From: bekodeg Date: Tue, 12 Dec 2023 16:13:01 +0400 Subject: [PATCH 5/5] =?UTF-8?q?=D0=BA=D0=BE=D1=80=D0=B5=D0=BA=D1=82=D0=B8?= =?UTF-8?q?=D1=80=D0=BE=D0=B2=D0=BA=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DrawningObjects/ExtentionDrawningLocomotive.cs | 2 +- .../Generics/LocomotivesGenericCollection.cs | 2 +- .../Generics/LocomotivesGenericStorage.cs | 2 +- ElectricLocomotive/nlog.config | 13 ------------- 4 files changed, 3 insertions(+), 16 deletions(-) delete mode 100644 ElectricLocomotive/nlog.config diff --git a/ElectricLocomotive/DrawningObjects/ExtentionDrawningLocomotive.cs b/ElectricLocomotive/DrawningObjects/ExtentionDrawningLocomotive.cs index 112673f..309d591 100644 --- a/ElectricLocomotive/DrawningObjects/ExtentionDrawningLocomotive.cs +++ b/ElectricLocomotive/DrawningObjects/ExtentionDrawningLocomotive.cs @@ -8,7 +8,7 @@ using System.Threading.Tasks; namespace ProjectElectricLocomotive.DrawningObjects { /// - /// Расширение для класса EntityCar + /// Расширение для класса EntityLocomotive /// public static class ExtentionDrawningLocomotive { diff --git a/ElectricLocomotive/Generics/LocomotivesGenericCollection.cs b/ElectricLocomotive/Generics/LocomotivesGenericCollection.cs index 43335fa..6df5d63 100644 --- a/ElectricLocomotive/Generics/LocomotivesGenericCollection.cs +++ b/ElectricLocomotive/Generics/LocomotivesGenericCollection.cs @@ -149,6 +149,6 @@ namespace ProjectElectricLocomotive.Generics /// /// Получение объектов коллекции /// - public IEnumerable GetCars => _collection.GetLocomotives(); + public IEnumerable GetLocomotives => _collection.GetLocomotives(); } } \ No newline at end of file diff --git a/ElectricLocomotive/Generics/LocomotivesGenericStorage.cs b/ElectricLocomotive/Generics/LocomotivesGenericStorage.cs index d5faa52..012d4ce 100644 --- a/ElectricLocomotive/Generics/LocomotivesGenericStorage.cs +++ b/ElectricLocomotive/Generics/LocomotivesGenericStorage.cs @@ -132,7 +132,7 @@ namespace ProjectElectricLocomotive.Generics { sw.Write(record.Key); sw.Write(_separatorForKeyValue); - foreach (DrawningLocomotive? elem in record.Value.GetCars) + foreach (DrawningLocomotive? elem in record.Value.GetLocomotives) { sw.Write( $"{elem?.GetDataForSave(_separatorForObject)}" + diff --git a/ElectricLocomotive/nlog.config b/ElectricLocomotive/nlog.config deleted file mode 100644 index 54e4ba6..0000000 --- a/ElectricLocomotive/nlog.config +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - \ No newline at end of file -- 2.25.1