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