From f08c447c243ae4a603528af6113eec81980b5367 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BC=D0=B8=D1=80=20=D0=9D=D1=83=D0=B3=D0=B0?= =?UTF-8?q?=D0=B5=D0=B2?= Date: Sat, 19 Nov 2022 03:35:10 +0400 Subject: [PATCH 1/5] =?UTF-8?q?=D0=B3=D0=B5=D0=BD=D0=B5=D1=80=D0=B0=D1=86?= =?UTF-8?q?=D0=B8=D1=8F=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BE=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Bus/Bus/BusNotFoundException.cs | 22 +++++++++++++ Bus/Bus/FormMapWithSetDoubleDeckerBus.cs | 39 ++++++++++++++++-------- Bus/Bus/MapsCollection.cs | 10 +++--- Bus/Bus/SetDoubleDeckerBusGeneric.cs | 14 ++++++++- Bus/Bus/StorageOverflowException.cs | 22 +++++++++++++ 5 files changed, 88 insertions(+), 19 deletions(-) create mode 100644 Bus/Bus/BusNotFoundException.cs create mode 100644 Bus/Bus/StorageOverflowException.cs diff --git a/Bus/Bus/BusNotFoundException.cs b/Bus/Bus/BusNotFoundException.cs new file mode 100644 index 0000000..dd467fb --- /dev/null +++ b/Bus/Bus/BusNotFoundException.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization; +using System.Text; +using System.Threading.Tasks; + +namespace Bus +{ + internal class BusNotFoundException : ApplicationException + { + public BusNotFoundException(int i) : base($"Не найден объект по позиции {i}") { } + + public BusNotFoundException() : base() { } + + public BusNotFoundException(string message) : base(message) { } + + public BusNotFoundException(string message, Exception exception) : base(message, exception) { } + + protected BusNotFoundException(SerializationInfo info, StreamingContext contex) : base(info, contex) { } + } +} diff --git a/Bus/Bus/FormMapWithSetDoubleDeckerBus.cs b/Bus/Bus/FormMapWithSetDoubleDeckerBus.cs index 9d1e7aa..7a516c7 100644 --- a/Bus/Bus/FormMapWithSetDoubleDeckerBus.cs +++ b/Bus/Bus/FormMapWithSetDoubleDeckerBus.cs @@ -111,14 +111,25 @@ namespace Bus return; } int pos = Convert.ToInt32(maskedTextBoxPosition.Text); - if (_mapBusCollectionGeneric - pos != null) + try { - MessageBox.Show("Объект удален"); - pictureBox.Image = _mapBusCollectionGeneric.ShowSet(); + if (_mapBusCollectionGeneric - pos != null) + { + MessageBox.Show("Объект удален"); + pictureBox.Image = _mapBusCollectionGeneric.ShowSet(); + } + else + { + MessageBox.Show("Не удалось удалить объект"); + } } - else + catch (BusNotFoundException ex) { - MessageBox.Show("Не удалось удалить объект"); + MessageBox.Show($"Ошибка удаления: {ex.Message}"); + } + catch (Exception ex) + { + MessageBox.Show($"Неизвестная ошибка: {ex.Message}"); } } @@ -206,13 +217,14 @@ namespace Bus { if (saveFileDialog.ShowDialog() == DialogResult.OK) { - if (_mapsCollection.SaveData(saveFileDialog.FileName)) + try { + _mapsCollection.SaveData(saveFileDialog.FileName); MessageBox.Show("Сохранение прошло успешно!", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information); } - else + catch (Exception ex) { - MessageBox.Show("Не сохранилось", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show($"Не сохранилось: {ex.Message}", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } @@ -221,14 +233,17 @@ namespace Bus { if (openFileDialog.ShowDialog() == DialogResult.OK) { - if (_mapsCollection.LoadData(openFileDialog.FileName)) + try { - MessageBox.Show("Загрузка прошла успешно!", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information); + _mapsCollection.LoadData(openFileDialog.FileName); + MessageBox.Show("Загрузка данных прошла успешно", "Результат", + MessageBoxButtons.OK, MessageBoxIcon.Information); ReloadMaps(); } - else + catch (Exception ex) { - MessageBox.Show("Не загрузилось", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show($"Не загрузилось: {ex.Message}", "Результат", + MessageBoxButtons.OK, MessageBoxIcon.Error); } } } diff --git a/Bus/Bus/MapsCollection.cs b/Bus/Bus/MapsCollection.cs index a218ed2..afe6844 100644 --- a/Bus/Bus/MapsCollection.cs +++ b/Bus/Bus/MapsCollection.cs @@ -60,7 +60,7 @@ namespace Bus stream.Write(info, 0, info.Length); } - public bool SaveData(string filename) + public void SaveData(string filename) { if (File.Exists(filename)) { @@ -74,14 +74,13 @@ namespace Bus fs.Write($"{storage.Key}{separatorDict}{storage.Value.GetData(separatorDict, separatorData)}{Environment.NewLine}"); } } - return true; } - public bool LoadData(string filename) + public void LoadData(string filename) { if (!File.Exists(filename)) { - return false; + throw new FileNotFoundException("Файл не найден"); } using (StreamReader sr = new(filename)) { @@ -89,7 +88,7 @@ namespace Bus if ((str = sr.ReadLine()) == null || !str.Contains("MapsCollection")) { //если нет такой записи, то это не те данные - return false; + throw new FileFormatException("Формат данных в файле неправильный"); } //очищаем записи _mapStorages.Clear(); @@ -110,7 +109,6 @@ namespace Bus _mapStorages[elem[0]].LoadData(elem[2].Split(separatorData, StringSplitOptions.RemoveEmptyEntries)); } } - return true; } } } diff --git a/Bus/Bus/SetDoubleDeckerBusGeneric.cs b/Bus/Bus/SetDoubleDeckerBusGeneric.cs index 3551703..e34e350 100644 --- a/Bus/Bus/SetDoubleDeckerBusGeneric.cs +++ b/Bus/Bus/SetDoubleDeckerBusGeneric.cs @@ -33,10 +33,18 @@ namespace Bus public int Insert(T bus, int position) { - if (!isCorrectPosition(position)) + if (position > _maxCount && position < 0) { return -1; } + if (_places.Contains(bus)) + { + throw new ArgumentException($"Объект {bus} уже есть в наборе"); + } + if (Count == _maxCount) + { + throw new StorageOverflowException(_maxCount); + } _places.Insert(position, bus); return position; } @@ -47,6 +55,10 @@ namespace Bus { return null; } + if (position >= Count || position < 0) + { + throw new BusNotFoundException(position); + } var result = _places[position]; _places.RemoveAt(position); return result; diff --git a/Bus/Bus/StorageOverflowException.cs b/Bus/Bus/StorageOverflowException.cs new file mode 100644 index 0000000..f111655 --- /dev/null +++ b/Bus/Bus/StorageOverflowException.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization; +using System.Text; +using System.Threading.Tasks; + +namespace Bus +{ + 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) { } + } +} -- 2.25.1 From 8d8c8fb2e0c8b8949d2d776e25c72e0e117de28b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BC=D0=B8=D1=80=20=D0=9D=D1=83=D0=B3=D0=B0?= =?UTF-8?q?=D0=B5=D0=B2?= Date: Sat, 19 Nov 2022 13:33:16 +0400 Subject: [PATCH 2/5] =?UTF-8?q?=D0=BB=D0=BE=D0=B3=D0=B8=D1=80=D0=BE=D0=B2?= =?UTF-8?q?=D0=B0=D0=BD=D0=B8=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Bus/Bus/Bus.csproj | 18 +++++++++ Bus/Bus/FormMapWithSetDoubleDeckerBus.cs | 47 ++++++++++++++++++------ Bus/Bus/Program.cs | 22 ++++++++++- Bus/Bus/nlog.config | 15 ++++++++ 4 files changed, 90 insertions(+), 12 deletions(-) create mode 100644 Bus/Bus/nlog.config diff --git a/Bus/Bus/Bus.csproj b/Bus/Bus/Bus.csproj index 13ee123..38d723d 100644 --- a/Bus/Bus/Bus.csproj +++ b/Bus/Bus/Bus.csproj @@ -8,6 +8,24 @@ enable + + + + + + + Always + + + + + + + + + + + True diff --git a/Bus/Bus/FormMapWithSetDoubleDeckerBus.cs b/Bus/Bus/FormMapWithSetDoubleDeckerBus.cs index 7a516c7..79205ec 100644 --- a/Bus/Bus/FormMapWithSetDoubleDeckerBus.cs +++ b/Bus/Bus/FormMapWithSetDoubleDeckerBus.cs @@ -1,4 +1,5 @@ -using System; +using Microsoft.Extensions.Logging; +using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; @@ -21,10 +22,11 @@ namespace Bus }; private readonly MapsCollection _mapsCollection; - - public FormMapWithSetDoubleDeckerBus() + private readonly ILogger _logger; + public FormMapWithSetDoubleDeckerBus(ILogger logger) { InitializeComponent(); + _logger = logger; _mapsCollection = new MapsCollection(pictureBox.Width, pictureBox.Height); comboBoxSelectorMap.Items.Clear(); foreach (var item in _mapsDict) @@ -83,19 +85,34 @@ namespace Bus private void AddBus(DrawingBus bus) { - if (listBoxMaps.SelectedIndex == -1) + try { - return; + if (listBoxMaps.SelectedIndex == -1) + { + return; + } + DrawingObjectBus boat = new(bus); + if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] + boat >= 0) + { + MessageBox.Show("Объект добавлен"); + _logger.LogInformation("Добавлен объект {@Airbus}", bus); + pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet(); + } + else + { + MessageBox.Show("Не удалось добавить объект"); + _logger.LogInformation("Не удалось добавить объект"); + } } - DrawingObjectBus boat = new(bus); - if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] + boat >= 0) + catch (StorageOverflowException ex) { - MessageBox.Show("Объект добавлен"); - pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet(); + _logger.LogWarning("Ошибка, переполнение хранилища: {0}", ex.Message); + MessageBox.Show($"Ошибка, хранилище переполнено: {ex.Message}", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error); } - else + catch (ArgumentException ex) { - MessageBox.Show("Не удалось добавить объект"); + _logger.LogWarning("Ошибка добавления: {0}. Объект: {@Airbus}", ex.Message, bus); + MessageBox.Show(ex.Message, "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error); } } @@ -183,20 +200,25 @@ namespace Bus if (comboBoxSelectorMap.SelectedIndex == -1 || string.IsNullOrEmpty(textBoxNewMapName.Text)) { MessageBox.Show("Не все данные заполнены", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + _logger.LogInformation("При добавлении карты {0}", comboBoxSelectorMap.SelectedIndex == -1 ? "Не была выбрана карта" : "Не была названа карта"); return; } if (!_mapsDict.ContainsKey(comboBoxSelectorMap.Text)) { MessageBox.Show("Нет такой карты", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + _logger.LogInformation("При добавлении карты {0}", comboBoxSelectorMap.SelectedIndex == -1 ? "Не была выбрана карта" : "Не была названа карта"); return; } _mapsCollection.AddMap(textBoxNewMapName.Text, _mapsDict[comboBoxSelectorMap.Text]); ReloadMaps(); + _logger.LogInformation("Добавлена карта {0}", textBoxNewMapName.Text); + } private void ListBoxMaps_SelectedIndexChanged(object sender, EventArgs e) { pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet(); + _logger.LogInformation("Осуществлён переход на карту под названием {0}", listBoxMaps.SelectedItem?.ToString() ?? string.Empty); } private void ButtonDeleteMap_Click(object sender, EventArgs e) @@ -210,6 +232,7 @@ namespace Bus { _mapsCollection.DelMap(listBoxMaps.SelectedItem?.ToString() ?? string.Empty); ReloadMaps(); + _logger.LogInformation("Удалена карта {0}", listBoxMaps.SelectedItem?.ToString() ?? string.Empty); } } @@ -236,6 +259,7 @@ namespace Bus try { _mapsCollection.LoadData(openFileDialog.FileName); + _logger.LogInformation("Загрузка данных из файла '{0}' прошла успешно", openFileDialog.FileName); MessageBox.Show("Загрузка данных прошла успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information); ReloadMaps(); @@ -244,6 +268,7 @@ namespace Bus { MessageBox.Show($"Не загрузилось: {ex.Message}", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error); + _logger.LogInformation("Не удалось загрузить файл '{0}'. Текст ошибки: {1}", openFileDialog.FileName, ex.Message); } } } diff --git a/Bus/Bus/Program.cs b/Bus/Bus/Program.cs index 265ea7c..5a1d210 100644 --- a/Bus/Bus/Program.cs +++ b/Bus/Bus/Program.cs @@ -1,3 +1,7 @@ +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using NLog.Extensions.Logging; + namespace Bus { internal static class Program @@ -11,7 +15,23 @@ namespace Bus // To customize application configuration such as set high DPI settings or default font, // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); - Application.Run(new FormMapWithSetDoubleDeckerBus()); + var services = new ServiceCollection(); + ConfigureServices(services); + using (ServiceProvider serviceProvider = services.BuildServiceProvider()) + { + Application.Run(serviceProvider.GetRequiredService()); + } + /*Application.Run(new FormMapWithSetDoubleDeckerBus());*/ + } + + 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/Bus/Bus/nlog.config b/Bus/Bus/nlog.config new file mode 100644 index 0000000..f16eefb --- /dev/null +++ b/Bus/Bus/nlog.config @@ -0,0 +1,15 @@ + + + + + + + + + + + + + \ No newline at end of file -- 2.25.1 From c0bbc3a118e4517528cc2bd030e8c5e6a362ec16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BC=D0=B8=D1=80=20=D0=9D=D1=83=D0=B3=D0=B0?= =?UTF-8?q?=D0=B5=D0=B2?= Date: Sat, 19 Nov 2022 13:45:52 +0400 Subject: [PATCH 3/5] =?UTF-8?q?=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=B0=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BA=D0=B0?= =?UTF-8?q?=20=D0=B2=20nlog.config?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Bus/Bus/nlog.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Bus/Bus/nlog.config b/Bus/Bus/nlog.config index f16eefb..d8f5e80 100644 --- a/Bus/Bus/nlog.config +++ b/Bus/Bus/nlog.config @@ -5,7 +5,7 @@ autoReload="true" internalLogLevel="Info"> - + -- 2.25.1 From 5327e9044f91cc7602da5fabf637ad6c34101754 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BC=D0=B8=D1=80=20=D0=9D=D1=83=D0=B3=D0=B0?= =?UTF-8?q?=D0=B5=D0=B2?= Date: Sat, 3 Dec 2022 20:08:32 +0400 Subject: [PATCH 4/5] =?UTF-8?q?=D0=B3=D0=BE=D1=82=D0=BE=D0=B2=D0=B0=D1=8F?= =?UTF-8?q?=20=D0=BB=D0=B0=D0=B1=D0=BE=D1=80=D0=B0=D1=82=D0=BE=D1=80=D0=BD?= =?UTF-8?q?=D0=B0=D1=8F=20=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 --- Bus/Bus/Bus.csproj | 11 ++++-- Bus/Bus/FormMapWithSetDoubleDeckerBus.cs | 20 ++++++---- Bus/Bus/Program.cs | 15 ++++++-- Bus/Bus/appsettings.json | 48 ++++++++++++++++++++++++ Bus/Bus/nlog.config | 15 -------- Bus/Bus/serilog.json | 20 ++++++++++ 6 files changed, 98 insertions(+), 31 deletions(-) create mode 100644 Bus/Bus/appsettings.json delete mode 100644 Bus/Bus/nlog.config create mode 100644 Bus/Bus/serilog.json diff --git a/Bus/Bus/Bus.csproj b/Bus/Bus/Bus.csproj index 38d723d..30afbe7 100644 --- a/Bus/Bus/Bus.csproj +++ b/Bus/Bus/Bus.csproj @@ -9,21 +9,24 @@ - + - + Always + - - + + + + diff --git a/Bus/Bus/FormMapWithSetDoubleDeckerBus.cs b/Bus/Bus/FormMapWithSetDoubleDeckerBus.cs index 79205ec..e425ea1 100644 --- a/Bus/Bus/FormMapWithSetDoubleDeckerBus.cs +++ b/Bus/Bus/FormMapWithSetDoubleDeckerBus.cs @@ -36,6 +36,10 @@ namespace Bus } + public FormMapWithSetDoubleDeckerBus() + { + } + private void ReloadMaps() { int index = listBoxMaps.SelectedIndex; @@ -130,24 +134,24 @@ namespace Bus int pos = Convert.ToInt32(maskedTextBoxPosition.Text); try { - if (_mapBusCollectionGeneric - pos != null) + var deletedBus = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] - pos; + if (deletedBus != null) { MessageBox.Show("Объект удален"); - pictureBox.Image = _mapBusCollectionGeneric.ShowSet(); + _logger.LogInformation("Из текущей карты удален объект {@ship}", deletedBus); + pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet(); } else { + _logger.LogInformation("Не удалось добавить объект по позиции {0} равен null", pos); MessageBox.Show("Не удалось удалить объект"); } } - catch (BusNotFoundException ex) - { - MessageBox.Show($"Ошибка удаления: {ex.Message}"); - } catch (Exception ex) { - MessageBox.Show($"Неизвестная ошибка: {ex.Message}"); - } + _logger.LogWarning("Ошибка удаления: {0}", ex.Message); + MessageBox.Show($"Ошибка удаления: {ex.Message}"); + } } private void ButtonShowStorage_Click(object sender, EventArgs e) diff --git a/Bus/Bus/Program.cs b/Bus/Bus/Program.cs index 5a1d210..6cfb254 100644 --- a/Bus/Bus/Program.cs +++ b/Bus/Bus/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 Bus { @@ -20,8 +21,8 @@ namespace Bus using (ServiceProvider serviceProvider = services.BuildServiceProvider()) { Application.Run(serviceProvider.GetRequiredService()); - } - /*Application.Run(new FormMapWithSetDoubleDeckerBus());*/ + } + } private static void ConfigureServices(ServiceCollection services) @@ -29,8 +30,14 @@ namespace Bus services.AddSingleton() .AddLogging(option => { + var configuration = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile(path: "serilog.json").Build(); + + var logger = new LoggerConfiguration() + .ReadFrom.Configuration(configuration) + .CreateLogger(); + option.SetMinimumLevel(LogLevel.Information); - option.AddNLog("nlog.config"); + option.AddSerilog(logger); }); } } diff --git a/Bus/Bus/appsettings.json b/Bus/Bus/appsettings.json new file mode 100644 index 0000000..3df4ae5 --- /dev/null +++ b/Bus/Bus/appsettings.json @@ -0,0 +1,48 @@ +{ + "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" ], + "Destructure": [ + { + "Name": "ByTransforming", + "Args": { + "returnType": "Bus.EntityBus", + "transformation": "r => new { BodyColor = r.BodyColor.Name, r.Speed, r.Weight }" + } + }, + { + "Name": "ByTransforming", + "Args": { + "returnType": "Bus.EntitySportBus", + "transformation": "r => new { BodyColor = r.BodyColor.Name, DopColor = r.DopColor.Name, r.Bodykit, r.Wing, r.Sportline, r.Speed, r.Weight }" + } + }, + { + "Name": "ToMaximumDepth", + "Args": { "maximumDestructuringDepth": 4 } + }, + { + "Name": "ToMaximumStringLength", + "Args": { "maximumStringLength": 100 } + }, + { + "Name": "ToMaximumCollectionCount", + "Args": { "maximumCollectionCount": 15 } + } + ], + "Properties": { + "Application": "Bus" + } + } +} \ No newline at end of file diff --git a/Bus/Bus/nlog.config b/Bus/Bus/nlog.config deleted file mode 100644 index d8f5e80..0000000 --- a/Bus/Bus/nlog.config +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/Bus/Bus/serilog.json b/Bus/Bus/serilog.json new file mode 100644 index 0000000..4c3cf19 --- /dev/null +++ b/Bus/Bus/serilog.json @@ -0,0 +1,20 @@ +{ + "Serilog": { + "Using": [ "Serilog.Sinks.File" ], + "MinimumLevel": "Information", + "WriteTo": [ + { + "Name": "File", + "Args": { + "path": "log_.log", + "rollingInterval": "Day", + "outputTemplate": "[{Timestamp:HH:mm:ss.fff}]{Level:u4}: {Message:lj}{NewLine}{Exception}" + } + } + ], + "Enrich": [ "FromLogContext", "WithMachineName", "WithThreadId" ], + "Properties": { + "Application": "DoubleDeckerBus" + } + } +} \ No newline at end of file -- 2.25.1 From 52eaba7622a521d562a393bc0206e476ed1562b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BC=D0=B8=D1=80=20=D0=9D=D1=83=D0=B3=D0=B0?= =?UTF-8?q?=D0=B5=D0=B2?= Date: Tue, 6 Dec 2022 13:16:46 +0400 Subject: [PATCH 5/5] fix 2 --- Bus/Bus/BusNotFoundException.cs | 4 --- Bus/Bus/SetDoubleDeckerBusGeneric.cs | 5 --- Bus/Bus/StorageOverflowException.cs | 4 --- Bus/Bus/appsettings.json | 48 ---------------------------- Bus/Bus/serilog.json | 4 --- 5 files changed, 65 deletions(-) delete mode 100644 Bus/Bus/appsettings.json diff --git a/Bus/Bus/BusNotFoundException.cs b/Bus/Bus/BusNotFoundException.cs index dd467fb..ccfdb90 100644 --- a/Bus/Bus/BusNotFoundException.cs +++ b/Bus/Bus/BusNotFoundException.cs @@ -10,13 +10,9 @@ namespace Bus internal class BusNotFoundException : ApplicationException { public BusNotFoundException(int i) : base($"Не найден объект по позиции {i}") { } - public BusNotFoundException() : base() { } - public BusNotFoundException(string message) : base(message) { } - public BusNotFoundException(string message, Exception exception) : base(message, exception) { } - protected BusNotFoundException(SerializationInfo info, StreamingContext contex) : base(info, contex) { } } } diff --git a/Bus/Bus/SetDoubleDeckerBusGeneric.cs b/Bus/Bus/SetDoubleDeckerBusGeneric.cs index e34e350..cae1e16 100644 --- a/Bus/Bus/SetDoubleDeckerBusGeneric.cs +++ b/Bus/Bus/SetDoubleDeckerBusGeneric.cs @@ -26,11 +26,6 @@ namespace Bus return Insert(bus, 0); } - private bool isCorrectPosition(int position) - { - return 0 <= position && position < _maxCount; - } - public int Insert(T bus, int position) { if (position > _maxCount && position < 0) diff --git a/Bus/Bus/StorageOverflowException.cs b/Bus/Bus/StorageOverflowException.cs index f111655..139b061 100644 --- a/Bus/Bus/StorageOverflowException.cs +++ b/Bus/Bus/StorageOverflowException.cs @@ -10,13 +10,9 @@ namespace Bus 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/Bus/Bus/appsettings.json b/Bus/Bus/appsettings.json deleted file mode 100644 index 3df4ae5..0000000 --- a/Bus/Bus/appsettings.json +++ /dev/null @@ -1,48 +0,0 @@ -{ - "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" ], - "Destructure": [ - { - "Name": "ByTransforming", - "Args": { - "returnType": "Bus.EntityBus", - "transformation": "r => new { BodyColor = r.BodyColor.Name, r.Speed, r.Weight }" - } - }, - { - "Name": "ByTransforming", - "Args": { - "returnType": "Bus.EntitySportBus", - "transformation": "r => new { BodyColor = r.BodyColor.Name, DopColor = r.DopColor.Name, r.Bodykit, r.Wing, r.Sportline, r.Speed, r.Weight }" - } - }, - { - "Name": "ToMaximumDepth", - "Args": { "maximumDestructuringDepth": 4 } - }, - { - "Name": "ToMaximumStringLength", - "Args": { "maximumStringLength": 100 } - }, - { - "Name": "ToMaximumCollectionCount", - "Args": { "maximumCollectionCount": 15 } - } - ], - "Properties": { - "Application": "Bus" - } - } -} \ No newline at end of file diff --git a/Bus/Bus/serilog.json b/Bus/Bus/serilog.json index 4c3cf19..05d3a26 100644 --- a/Bus/Bus/serilog.json +++ b/Bus/Bus/serilog.json @@ -12,9 +12,5 @@ } } ], - "Enrich": [ "FromLogContext", "WithMachineName", "WithThreadId" ], - "Properties": { - "Application": "DoubleDeckerBus" - } } } \ No newline at end of file -- 2.25.1