From ea555cc89719b619e6234fee39543348883c3344 Mon Sep 17 00:00:00 2001 From: sqdselo <147947144+sqdselo@users.noreply.github.com> Date: Mon, 6 May 2024 23:02:05 +0400 Subject: [PATCH] =?UTF-8?q?=D0=93=D0=BE=D1=82=D0=BE=D0=B2=D0=B0=D1=8F=20?= =?UTF-8?q?=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 --- .../AbstractCompany.cs | 1 - .../HoistingCrane/FormCarCollection.cs | 13 ++++++----- .../HoistingCrane/HoistingCrane.csproj | 10 ++++----- HoistingCrane/HoistingCrane/Program.cs | 22 ++++++------------- HoistingCrane/HoistingCrane/nlog.config | 13 ----------- 5 files changed, 18 insertions(+), 41 deletions(-) delete mode 100644 HoistingCrane/HoistingCrane/nlog.config diff --git a/HoistingCrane/HoistingCrane/CollectionGenericObjects/AbstractCompany.cs b/HoistingCrane/HoistingCrane/CollectionGenericObjects/AbstractCompany.cs index e56d990..fb26d02 100644 --- a/HoistingCrane/HoistingCrane/CollectionGenericObjects/AbstractCompany.cs +++ b/HoistingCrane/HoistingCrane/CollectionGenericObjects/AbstractCompany.cs @@ -40,7 +40,6 @@ namespace HoistingCrane.CollectionGenericObjects arr = array; arr.MaxCount = GetMaxCount; } - public static int operator +(AbstractCompany company, DrawningTrackedVehicle car) { return company.arr?.Insert(car) ?? -1; diff --git a/HoistingCrane/HoistingCrane/FormCarCollection.cs b/HoistingCrane/HoistingCrane/FormCarCollection.cs index 623ad8f..318a373 100644 --- a/HoistingCrane/HoistingCrane/FormCarCollection.cs +++ b/HoistingCrane/HoistingCrane/FormCarCollection.cs @@ -129,7 +129,6 @@ namespace HoistingCrane listBoxCollection.Items.Add(colName); } } - logger.LogInformation("Коллекция успешно обновлена"); } private void buttonCollectionAdd_Click(object sender, EventArgs e) { @@ -143,12 +142,12 @@ namespace HoistingCrane if (radioButtonMassive.Checked) { collectionType = CollectionType.Massive; - logger.LogInformation("Создана коллекция типа: {name}, название: {name}", collectionType, textBoxCollectionName.Text); + logger.LogInformation("Создана коллекция '{nameCol}' , название: {name}", collectionType, textBoxCollectionName.Text); } else if (radioButtonList.Checked) { collectionType = CollectionType.List; - logger.LogInformation("Создана коллекция типа: {name}, название: {name}", collectionType, textBoxCollectionName.Text); + logger.LogInformation("Создана коллекция '{nameCol}' , название: {name}", collectionType, textBoxCollectionName.Text); } _storageCollection.AddCollection(textBoxCollectionName.Text,collectionType);RerfreshListBoxItems(); } @@ -161,9 +160,13 @@ namespace HoistingCrane } if (MessageBox.Show("Удалить коллекцию?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) return; + if (listBoxCollection.SelectedItem != null) + { + logger.LogInformation("Коллекция '{name}' успешно удалена", listBoxCollection.SelectedItem.ToString()); + } _storageCollection.DelCollection(listBoxCollection.SelectedItem.ToString()); RerfreshListBoxItems(); - logger.LogInformation("Коллекция {name} успешно удалена", listBoxCollection.SelectedItem.ToString()); + } private void buttonCreateCompany_Click(object sender, EventArgs e) { @@ -187,8 +190,6 @@ namespace HoistingCrane } panelCompanyTool.Enabled = true; RerfreshListBoxItems(); - logger.LogInformation("Создана компания"); - } /// diff --git a/HoistingCrane/HoistingCrane/HoistingCrane.csproj b/HoistingCrane/HoistingCrane/HoistingCrane.csproj index 5f40a60..9b3b27e 100644 --- a/HoistingCrane/HoistingCrane/HoistingCrane.csproj +++ b/HoistingCrane/HoistingCrane/HoistingCrane.csproj @@ -15,6 +15,10 @@ + + + + @@ -32,10 +36,4 @@ - - - Always - - - \ No newline at end of file diff --git a/HoistingCrane/HoistingCrane/Program.cs b/HoistingCrane/HoistingCrane/Program.cs index c5abf19..562ee2d 100644 --- a/HoistingCrane/HoistingCrane/Program.cs +++ b/HoistingCrane/HoistingCrane/Program.cs @@ -1,37 +1,29 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; -using NLog.Extensions.Logging; +using Serilog; +using Serilog.Extensions.Logging; namespace HoistingCrane { internal static class Program { - /// - /// The main entry point for the application. - /// [STAThread] static void Main() { - // To customize application configuration such as set high DPI settings or default font, - // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); ServiceCollection services = new(); ConfigureServices(services); using ServiceProvider serviceProvider = services.BuildServiceProvider(); Application.Run(serviceProvider.GetRequiredService()); - } - /// - /// DI - /// - /// private static void ConfigureServices(ServiceCollection services) { - services.AddSingleton().AddLogging(option => + // Serilog + Log.Logger = new LoggerConfiguration().WriteTo.File("E:\\myLog.log").CreateLogger(); + services.AddSingleton().AddLogging(builder => { - option.SetMinimumLevel(LogLevel.Information); - option.AddNLog("nlog.config"); + builder.AddSerilog(); }); } } -} \ No newline at end of file +} diff --git a/HoistingCrane/HoistingCrane/nlog.config b/HoistingCrane/HoistingCrane/nlog.config deleted file mode 100644 index 0c93951..0000000 --- a/HoistingCrane/HoistingCrane/nlog.config +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - \ No newline at end of file