From 04c5f773195e591943236600e847e07a02ef294c Mon Sep 17 00:00:00 2001 From: Evgehil Date: Wed, 8 May 2024 17:07:14 +0400 Subject: [PATCH] =?UTF-8?q?=D0=97=D0=B0=D0=B2=D0=B5=D1=80=D1=88=D1=91?= =?UTF-8?q?=D0=BD=D0=BD=D0=B0=D1=8F=20=D0=BB=D0=B0=D0=B1=D0=BE=D1=80=D0=B0?= =?UTF-8?q?=D1=82=D0=BE=D1=80=D0=BD=D0=B0=D1=8F=20=D1=80=D0=B0=D0=B1=D0=BE?= =?UTF-8?q?=D1=82=D0=B0=20=E2=84=9607?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Project_airbus/.editorconfig | 4 + Project_airbus/Project_airbus.sln | 2 +- .../AbstractCompany.cs | 8 +- .../AirplanSharingService.cs | 5 +- .../ListGenericObjects.cs | 17 +- .../MassiveGenericObjects.cs | 18 +- .../StorageCollection.cs | 32 ++-- .../Exceptions/CollectionOverflowException.cs | 16 ++ .../Exceptions/ObjectNotFoundException.cs | 16 ++ .../PositionOutOfCollectionException.cs | 16 ++ .../Project_airbus/FormAirplanCollection.cs | 157 +++++++++++------- Project_airbus/Project_airbus/Program.cs | 31 +++- .../Project_airbus/Project_airbus.csproj | 35 +++- Project_airbus/Project_airbus/Serillog.json | 15 ++ Project_airbus/Project_airbus/Serilog.json | 16 ++ Project_airbus/Project_airbus/jsconfig.json | 15 ++ Project_airbus/Project_airbus/jsconfig1.json | 10 ++ 17 files changed, 319 insertions(+), 94 deletions(-) create mode 100644 Project_airbus/.editorconfig create mode 100644 Project_airbus/Project_airbus/Exceptions/CollectionOverflowException.cs create mode 100644 Project_airbus/Project_airbus/Exceptions/ObjectNotFoundException.cs create mode 100644 Project_airbus/Project_airbus/Exceptions/PositionOutOfCollectionException.cs create mode 100644 Project_airbus/Project_airbus/Serillog.json create mode 100644 Project_airbus/Project_airbus/Serilog.json create mode 100644 Project_airbus/Project_airbus/jsconfig.json create mode 100644 Project_airbus/Project_airbus/jsconfig1.json diff --git a/Project_airbus/.editorconfig b/Project_airbus/.editorconfig new file mode 100644 index 0000000..d7abc97 --- /dev/null +++ b/Project_airbus/.editorconfig @@ -0,0 +1,4 @@ +[*.cs] + +# IDE0022: Использовать тело блока для метода +csharp_style_expression_bodied_methods = false diff --git a/Project_airbus/Project_airbus.sln b/Project_airbus/Project_airbus.sln index 1da5fbc..b3c6d55 100644 --- a/Project_airbus/Project_airbus.sln +++ b/Project_airbus/Project_airbus.sln @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.7.34024.191 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Project_airbus", "Project_airbus\Project_airbus.csproj", "{FC3C3CBD-935E-443F-81BB-982419FEA510}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Project_airbus", "Project_airbus\Project_airbus.csproj", "{FC3C3CBD-935E-443F-81BB-982419FEA510}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/Project_airbus/Project_airbus/CollectionGenericObjects/AbstractCompany.cs b/Project_airbus/Project_airbus/CollectionGenericObjects/AbstractCompany.cs index 5fb0c76..d6325e7 100644 --- a/Project_airbus/Project_airbus/CollectionGenericObjects/AbstractCompany.cs +++ b/Project_airbus/Project_airbus/CollectionGenericObjects/AbstractCompany.cs @@ -92,8 +92,12 @@ public abstract class AbstractCompany SetObjectsPosition(); for (int i = 0; i < (_collection?.Count ?? 0); ++i) { - DrawingAirplan? obj = _collection?.Get(i); - obj?.DrawTransport(graphics); + try + { + DrawingAirplan? obj = _collection?.Get(i); + obj?.DrawTransport(graphics); + } + catch (Exception) { } } return bitmap; diff --git a/Project_airbus/Project_airbus/CollectionGenericObjects/AirplanSharingService.cs b/Project_airbus/Project_airbus/CollectionGenericObjects/AirplanSharingService.cs index 028fcf0..ad66a1b 100644 --- a/Project_airbus/Project_airbus/CollectionGenericObjects/AirplanSharingService.cs +++ b/Project_airbus/Project_airbus/CollectionGenericObjects/AirplanSharingService.cs @@ -42,11 +42,12 @@ public class AirplanSharingService : AbstractCompany for (int i = 0; i < (_collection?.Count ?? 0); i++) { - if (_collection?.Get(i) != null) + try { _collection.Get(i)?.SetPictureSize(_pictureWidth, _pictureHeight); - _collection.Get(i)?.SetPosition(_placeSizeWidth * AirplanWidth + 20, AirplanHeight * _placeSizeHeight + 20); + _collection.Get(i)?.SetPosition(_placeSizeWidth * AirplanWidth + 20, AirplanHeight * _placeSizeHeight +20); } + catch (Exception) { } if (AirplanWidth < width - 1) AirplanWidth++; diff --git a/Project_airbus/Project_airbus/CollectionGenericObjects/ListGenericObjects.cs b/Project_airbus/Project_airbus/CollectionGenericObjects/ListGenericObjects.cs index 48eec23..c052444 100644 --- a/Project_airbus/Project_airbus/CollectionGenericObjects/ListGenericObjects.cs +++ b/Project_airbus/Project_airbus/CollectionGenericObjects/ListGenericObjects.cs @@ -1,4 +1,6 @@ -namespace Project_airbus.CollectionGenericObjects; +using Project_airbus.Exceptions; + +namespace Project_airbus.CollectionGenericObjects; /// /// Параметризованный набор объектов @@ -44,30 +46,30 @@ public class ListGenericObjects : ICollectionGenericObjects _collection = new(); } - public T Get(int position) + public T? Get(int position) { - if (position >= Count || position < 0) return null; + if (position >= Count || position < 0) throw new PositionOutOfCollectionException(position); return _collection[position]; } public int Insert(T obj) { - if (Count == _maxCount) return -1; + if (Count == _maxCount) throw new CollectionOverflowException(Count); _collection.Add(obj); return Count; } public int Insert(T obj, int position) { - if (Count == _maxCount) return -1; - if (position >= Count || position < 0) return -1; + if (Count == _maxCount) throw new CollectionOverflowException(Count); + if (position >= Count || position < 0) throw new PositionOutOfCollectionException(position); _collection.Insert(position, obj); return position; } public T Remove(int position) { - if (position >= _collection.Count || position < 0) return null; + if (position >= Count || position < 0) throw new PositionOutOfCollectionException(position); T obj = _collection[position]; _collection.RemoveAt(position); return obj; @@ -80,5 +82,4 @@ public class ListGenericObjects : ICollectionGenericObjects yield return _collection[i]; } } - } diff --git a/Project_airbus/Project_airbus/CollectionGenericObjects/MassiveGenericObjects.cs b/Project_airbus/Project_airbus/CollectionGenericObjects/MassiveGenericObjects.cs index 85fa85c..0131950 100644 --- a/Project_airbus/Project_airbus/CollectionGenericObjects/MassiveGenericObjects.cs +++ b/Project_airbus/Project_airbus/CollectionGenericObjects/MassiveGenericObjects.cs @@ -1,4 +1,6 @@ -namespace Project_airbus.CollectionGenericObjects; +using Project_airbus.Exceptions; + +namespace Project_airbus.CollectionGenericObjects; /// /// Параметризованный набор объектов @@ -48,7 +50,8 @@ public class MassiveGenericObjects : ICollectionGenericObjects public T? Get(int position) { - if (position >= _collection.Length || position < 0) return null; + if (position >= _collection.Length || position < 0) throw new PositionOutOfCollectionException(position); + if (_collection[position] == null) throw new ObjectNotFoundException(position); return _collection[position]; } @@ -64,12 +67,12 @@ public class MassiveGenericObjects : ICollectionGenericObjects } index++; } - return -1; + throw new CollectionOverflowException(Count); } public int Insert(T obj, int position) { - if (position >= _collection.Length || position < 0) return -1; + if (position >= _collection.Length || position < 0) throw new PositionOutOfCollectionException(position); if (_collection[position] == null) { @@ -96,12 +99,13 @@ public class MassiveGenericObjects : ICollectionGenericObjects } index--; } - return -1; + throw new CollectionOverflowException(Count); } public T? Remove(int position) { - if (position >= _collection.Length || position < 0) return null; + if (position >= _collection.Length || position < 0) throw new PositionOutOfCollectionException(position); + if (_collection[position] == null) throw new ObjectNotFoundException(position); T? removeObj = _collection[position]; _collection[position] = null; return removeObj; @@ -114,6 +118,4 @@ public class MassiveGenericObjects : ICollectionGenericObjects yield return _collection[i]; } } - - } diff --git a/Project_airbus/Project_airbus/CollectionGenericObjects/StorageCollection.cs b/Project_airbus/Project_airbus/CollectionGenericObjects/StorageCollection.cs index fa1915b..6ce2ea4 100644 --- a/Project_airbus/Project_airbus/CollectionGenericObjects/StorageCollection.cs +++ b/Project_airbus/Project_airbus/CollectionGenericObjects/StorageCollection.cs @@ -1,4 +1,5 @@ using Project_airbus.Drawings; +using Project_airbus.Exceptions; using System.Text; namespace Project_airbus.CollectionGenericObjects; @@ -88,12 +89,11 @@ public class StorageCollection /// Сохранение информации по автомобилям в хранилище в файл /// /// Путь и имя файла - /// true - сохранение прошло успешно, false - ошибка при сохранении данных - public bool SaveData(string filename) + public void SaveData(string filename) { if (_storages.Count == 0) { - return false; + throw new Exception("В хранилище отсутствуют коллекции для сохранения"); } if (File.Exists(filename)) { @@ -131,30 +131,28 @@ public class StorageCollection } } - return true; } /// /// Загрузка информации по автомобилям в хранилище из файла /// /// Путь и имя файла - /// true - загрузка прошла успешно, false - ошибка при загрузке данных - public bool LoadData(string filename) + public void LoadData(string filename) { if (!File.Exists(filename)) { - return false; + throw new Exception("Файл не существует"); } using (StreamReader fs = File.OpenText(filename)) { string str = fs.ReadLine(); if (str == null || str.Length == 0) { - return false; + throw new Exception("В файле нет данных"); } if (!str.StartsWith(_collectionKey)) { - return false; + throw new Exception("В файле неверные данные"); } _storages.Clear(); string strs = ""; @@ -169,23 +167,29 @@ public class StorageCollection ICollectionGenericObjects? collection = StorageCollection.CreateCollection(collectionType); if (collection == null) { - return false; + throw new Exception("Не удалось определить тип коллекции:" + record[1]); } collection.MaxCount = Convert.ToInt32(record[2]); string[] set = record[3].Split(_separatorItems, StringSplitOptions.RemoveEmptyEntries); foreach (string elem in set) { - if (elem?. CreateDrawingAirplan() is T ship) + if (elem?.CreateDrawingAirplan() is T airplan) { - if (collection.Insert(ship) == -1) + try { - return false; + if (collection.Insert(airplan) == -1) + { + throw new Exception("Объект не удалось добавить в коллекцию: " + record[3]); + } + } + catch (CollectionOverflowException ex) + { + throw new Exception("Коллекция переполнена", ex); } } } _storages.Add(record[0], collection); } - return true; } } diff --git a/Project_airbus/Project_airbus/Exceptions/CollectionOverflowException.cs b/Project_airbus/Project_airbus/Exceptions/CollectionOverflowException.cs new file mode 100644 index 0000000..aff29cf --- /dev/null +++ b/Project_airbus/Project_airbus/Exceptions/CollectionOverflowException.cs @@ -0,0 +1,16 @@ +using System.Runtime.Serialization; + +namespace Project_airbus.Exceptions; + +/// +/// Класс, описывающий ошибку переполнения коллекции +/// +[Serializable] +internal class CollectionOverflowException : ApplicationException +{ + public CollectionOverflowException(int count) : base("В коллекции превышено допустимое количество: " + count) { } + public CollectionOverflowException() : base() { } + public CollectionOverflowException(string message) : base(message) { } + public CollectionOverflowException(string message, Exception exception) : base(message, exception) { } + protected CollectionOverflowException(SerializationInfo info, StreamingContext contex) : base(info, contex) { } +} \ No newline at end of file diff --git a/Project_airbus/Project_airbus/Exceptions/ObjectNotFoundException.cs b/Project_airbus/Project_airbus/Exceptions/ObjectNotFoundException.cs new file mode 100644 index 0000000..f3739c2 --- /dev/null +++ b/Project_airbus/Project_airbus/Exceptions/ObjectNotFoundException.cs @@ -0,0 +1,16 @@ +using System.Runtime.Serialization; + +namespace Project_airbus.Exceptions; + +/// +/// Класс, описывающий ошибку, что по указанной позиции нет элемента +/// +[Serializable] +internal class ObjectNotFoundException : ApplicationException +{ + public ObjectNotFoundException(int i) : base("Не найден объект по позиции " + i) { } + public ObjectNotFoundException() : base() { } + public ObjectNotFoundException(string message) : base(message) { } + public ObjectNotFoundException(string message, Exception exception) : base(message, exception) { } + protected ObjectNotFoundException(SerializationInfo info, StreamingContext contex) : base(info, contex) { } +} \ No newline at end of file diff --git a/Project_airbus/Project_airbus/Exceptions/PositionOutOfCollectionException.cs b/Project_airbus/Project_airbus/Exceptions/PositionOutOfCollectionException.cs new file mode 100644 index 0000000..d141878 --- /dev/null +++ b/Project_airbus/Project_airbus/Exceptions/PositionOutOfCollectionException.cs @@ -0,0 +1,16 @@ +using System.Runtime.Serialization; + +namespace Project_airbus.Exceptions; + +/// +/// Класс, описывающий ошибку выхода за границы коллекции +/// +[Serializable] +internal class PositionOutOfCollectionException : ApplicationException +{ + public PositionOutOfCollectionException(int i) : base("Выход за границы коллекции.Позиция " + i) { } + public PositionOutOfCollectionException() : base() { } + public PositionOutOfCollectionException(string message) : base(message) { } + public PositionOutOfCollectionException(string message, Exception exception) : base(message, exception) { } + protected PositionOutOfCollectionException(SerializationInfo info, StreamingContext contex) : base(info, contex) { } +} \ No newline at end of file diff --git a/Project_airbus/Project_airbus/FormAirplanCollection.cs b/Project_airbus/Project_airbus/FormAirplanCollection.cs index db4bf67..79dbe19 100644 --- a/Project_airbus/Project_airbus/FormAirplanCollection.cs +++ b/Project_airbus/Project_airbus/FormAirplanCollection.cs @@ -1,5 +1,7 @@ -using Project_airbus.CollectionGenericObjects; +using Microsoft.Extensions.Logging; +using Project_airbus.CollectionGenericObjects; using Project_airbus.Drawings; +using Project_airbus.Exceptions; namespace Project_airbus; @@ -18,13 +20,20 @@ public partial class FormAirplanCollection : Form /// private AbstractCompany? _company = null; + /// + /// Логер + /// + private readonly ILogger _logger; + /// /// Конструктор /// - public FormAirplanCollection() + public FormAirplanCollection(ILogger logger) { InitializeComponent(); _storageCollection = new(); + _logger = logger; + _logger.LogInformation("Форма загрузилась"); } /// @@ -51,18 +60,28 @@ public partial class FormAirplanCollection : Form private void SetAirplan(DrawingAirplan? airplan) { - if (_company == null || airplan == null) + try { - return; + if (_company == null || airplan == null) + { + return; + } + if (_company + airplan < 32) + { + MessageBox.Show("Объект добавлен"); + pictureBox.Image = _company.Show(); + _logger.LogInformation("Добавлен объект: " + airplan.GetDataForSave()); + } + else + { + MessageBox.Show("Не удалось добавить объект"); + } } - if (_company + airplan != -1) - { - MessageBox.Show("Объект добавлен"); - pictureBox.Image = _company.Show(); - } - else + catch (ObjectNotFoundException) { } + catch (CollectionOverflowException ex) { MessageBox.Show("Не удалось добавить объект"); + _logger.LogError("Ошибка: {Message}", ex.Message); } } @@ -77,21 +96,24 @@ public partial class FormAirplanCollection : Form { return; } - - if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes) + if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } - int pos = Convert.ToInt32(maskedTextBox.Text); - if (_company - pos != null) + try { - MessageBox.Show("Объект удален"); - pictureBox.Image = _company.Show(); + if (_company - pos != null) + { + MessageBox.Show("Объект удален"); + pictureBox.Image = _company.Show(); + _logger.LogInformation("Удален объект по позиции " + pos); + } } - else + catch (Exception ex) { MessageBox.Show("Не удалось удалить объект"); + _logger.LogError("Ошибка: {Message}", ex.Message); } } @@ -109,27 +131,28 @@ public partial class FormAirplanCollection : Form DrawingAirplan? airplan = null; int counter = 100; - while (airplan == null) + try { - airplan = _company.GetRandomObject(); - counter--; - if (counter <= 0) + while (airplan == null) { - break; + airplan = _company.GetRandomObject(); + counter--; + if (counter <= 0) + { + break; + } } + FormAirbus form = new() + { + SetAirplan = airplan + }; + form.ShowDialog(); } - - if (airplan == null) + catch (Exception ex) { - return; + MessageBox.Show(ex.Message, "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error); } - FormAirbus form = new() - { - SetAirplan = airplan - }; - form.ShowDialog(); - } /// @@ -173,22 +196,30 @@ public partial class FormAirplanCollection : Form { if (string.IsNullOrEmpty(textBoxCollectionName.Text) || (!radioButtonList.Checked && !radioButtonMassive.Checked)) { - MessageBox.Show("Не все данные заполнены", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show("Не все данные заполнены", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); return; } - CollectionType collectionType = CollectionType.None; - if (radioButtonMassive.Checked) + try { - collectionType = CollectionType.Massive; + CollectionType collectionType = CollectionType.None; + if (radioButtonMassive.Checked) + { + collectionType = CollectionType.Massive; + } + else if (radioButtonList.Checked) + { + collectionType = CollectionType.List; + } + _storageCollection.AddCollection(textBoxCollectionName.Text, collectionType); + RerfreshListBoxItems(); + _logger.LogInformation("Коллекция добавлена " + textBoxCollectionName.Text); } - else if (radioButtonList.Checked) + catch (Exception ex) { - collectionType = CollectionType.List; + _logger.LogError("Ошибка: {Message}", ex.Message); } - - _storageCollection.AddCollection(textBoxCollectionName.Text, collectionType); - RerfreshListBoxItems(); } /// @@ -202,12 +233,21 @@ public partial class FormAirplanCollection : Form return; } - if (MessageBox.Show("Удалить коллекцию?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) + try { - return; + if (MessageBox.Show("Удалить коллекцию?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) + { + return; + } + _storageCollection.DelCollection(listBoxCollection.SelectedItem.ToString()); + RerfreshListBoxItems(); + _logger.LogInformation("Коллекция: " + listBoxCollection.SelectedItem.ToString() + " удалена"); } - _storageCollection.DelCollection(listBoxCollection.SelectedItem.ToString()); - RerfreshListBoxItems(); + catch (Exception ex) + { + _logger.LogError("Ошибка: {Message}", ex.Message); + } + } /// @@ -222,21 +262,19 @@ public partial class FormAirplanCollection : Form MessageBox.Show("Коллекция не выбрана"); return; } - - ICollectionGenericObjects? collection = _storageCollection[listBoxCollection.SelectedItem.ToString() ?? string.Empty]; + ICollectionGenericObjects? collection = + _storageCollection[listBoxCollection.SelectedItem.ToString() ?? string.Empty]; if (collection == null) { MessageBox.Show("Коллекция не проинициализирована"); return; } - switch (comboBoxSelectorCompany.Text) { case "Хранилище": _company = new AirplanSharingService(pictureBox.Width, pictureBox.Height, collection); break; } - panelCompanyTools.Enabled = true; RerfreshListBoxItems(); } @@ -250,13 +288,16 @@ public partial class FormAirplanCollection : Form { if (saveFileDialog.ShowDialog() == DialogResult.OK) { - if (_storageCollection.SaveData(saveFileDialog.FileName)) + try { + _storageCollection.SaveData(saveFileDialog.FileName); MessageBox.Show("Сохранение прошло успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information); + _logger.LogInformation("Сохранение в файл: {filename}", saveFileDialog.FileName); } - else + catch (Exception ex) { - MessageBox.Show("Не сохранилось", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show(ex.Message, "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error); + _logger.LogError("Ошибка: {Message}", ex.Message); } } @@ -271,16 +312,18 @@ public partial class FormAirplanCollection : Form { if (openFileDialog.ShowDialog() == DialogResult.OK) { - if (_storageCollection.LoadData(openFileDialog.FileName)) + try { - MessageBox.Show("Загрузка прошла успешно", - "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information); + _storageCollection.LoadData(openFileDialog.FileName); + MessageBox.Show("Загрузка прошла успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information); RerfreshListBoxItems(); + _logger.LogInformation("Загрузка из файла: {filename}", openFileDialog.FileName); } - else + + catch (Exception ex) { - MessageBox.Show("Не сохранилось", "Результат", - MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show("Не сохранилось", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error); + _logger.LogError("Ошибка: {Message}", ex.Message); } } } diff --git a/Project_airbus/Project_airbus/Program.cs b/Project_airbus/Project_airbus/Program.cs index 436d42a..8184ec5 100644 --- a/Project_airbus/Project_airbus/Program.cs +++ b/Project_airbus/Project_airbus/Program.cs @@ -1,3 +1,8 @@ +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using Serilog; +using Microsoft.Extensions.Configuration; + namespace Project_airbus { internal static class Program @@ -11,7 +16,31 @@ namespace Project_airbus // To customize application configuration such as set high DPI settings or default font, // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); - Application.Run(new FormAirplanCollection()); + + ServiceCollection services = new(); + ConfigureServices(services); + using ServiceProvider serviceProvider = services.BuildServiceProvider(); + Application.Run(serviceProvider.GetRequiredService()); + } + private static void ConfigureServices(ServiceCollection services) + { + + string[] path = Directory.GetCurrentDirectory().Split('\\'); + string pathNeed = ""; + for (int i = 0; i < path.Length - 3; i++) + { + pathNeed += path[i] + "\\"; + } + services.AddSingleton() + .AddLogging(option => + { + option.SetMinimumLevel(LogLevel.Information); + option.AddSerilog(new LoggerConfiguration() + .ReadFrom.Configuration(new ConfigurationBuilder() + .AddJsonFile($"{pathNeed}Serillog.json") + .Build()) + .CreateLogger()); + }); } } } \ No newline at end of file diff --git a/Project_airbus/Project_airbus/Project_airbus.csproj b/Project_airbus/Project_airbus/Project_airbus.csproj index e0361e4..dfbd390 100644 --- a/Project_airbus/Project_airbus/Project_airbus.csproj +++ b/Project_airbus/Project_airbus/Project_airbus.csproj @@ -9,10 +9,43 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Always + True True diff --git a/Project_airbus/Project_airbus/Serillog.json b/Project_airbus/Project_airbus/Serillog.json new file mode 100644 index 0000000..e989f2b --- /dev/null +++ b/Project_airbus/Project_airbus/Serillog.json @@ -0,0 +1,15 @@ +{ + "Serilog": { + "Using": [ "Serilog.Sinks.File" ], + "MinimumLevel": "Debug", + "WriteTo": [ + { + "Name": "File", + "Args": { "path": "log.log" } + } + ], + "Properties": { + "Application": "Sample" + } + } +} \ No newline at end of file diff --git a/Project_airbus/Project_airbus/Serilog.json b/Project_airbus/Project_airbus/Serilog.json new file mode 100644 index 0000000..7d45dbe --- /dev/null +++ b/Project_airbus/Project_airbus/Serilog.json @@ -0,0 +1,16 @@ +{ + "Serilog": { + "Using": [ "Serilog.Sinks.File" ], + "MinimumLevel": "Debug", + "WriteTo": [ + { + "Name": "File", + "Args": { + "path": "log.txt" } + } + ], + "Properties": { + "Application": "Sample" + } + } +} \ No newline at end of file diff --git a/Project_airbus/Project_airbus/jsconfig.json b/Project_airbus/Project_airbus/jsconfig.json new file mode 100644 index 0000000..5c76266 --- /dev/null +++ b/Project_airbus/Project_airbus/jsconfig.json @@ -0,0 +1,15 @@ +{ + "jsconfig": { + "Using": [ "jsconfig.Sinks.File" ], + "MinimumLevel": "Debug", + "WriteTo": [ + { + "Name": "File", + "Args": { "path": "log.log" } + } + ], + "Properties": { + "Application": "Sample" + } + } +} \ No newline at end of file diff --git a/Project_airbus/Project_airbus/jsconfig1.json b/Project_airbus/Project_airbus/jsconfig1.json new file mode 100644 index 0000000..afb797c --- /dev/null +++ b/Project_airbus/Project_airbus/jsconfig1.json @@ -0,0 +1,10 @@ +{ + "exclude": [ + "**/bin", + "**/bower_components", + "**/jspm_packages", + "**/node_modules", + "**/obj", + "**/platforms" + ] +} \ No newline at end of file