pibd-12 Tangatarov.I.A. LabWork06 Base #21

Closed
sqdselo wants to merge 33 commits from LabWork06 into LabWork05
5 changed files with 18 additions and 41 deletions
Showing only changes of commit ea555cc897 - Show all commits

View File

@ -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;

View File

@ -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("Создана компания");
}
/// <summary>

View File

@ -15,6 +15,10 @@
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.9" />
<PackageReference Include="Serilog" Version="3.1.1" />
<PackageReference Include="Serilog.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="Serilog.Settings.Configuration" Version="8.0.0" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
</ItemGroup>
<ItemGroup>
@ -32,10 +36,4 @@
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Update="nlog.config">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>

View File

@ -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
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[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<FormCarCollection>());
}
/// <summary>
/// Êîíôèãóðàöèÿ ñåðâèñà DI
/// </summary>
/// <param name="services"></param>
private static void ConfigureServices(ServiceCollection services)
{
services.AddSingleton<FormCarCollection>().AddLogging(option =>
// Èíèöèàëèçèðóåì Serilog
Log.Logger = new LoggerConfiguration().WriteTo.File("E:\\myLog.log").CreateLogger();
services.AddSingleton<FormCarCollection>().AddLogging(builder =>
{
option.SetMinimumLevel(LogLevel.Information);
option.AddNLog("nlog.config");
builder.AddSerilog();
});
}
}
}
}

View File

@ -1,13 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
autoReload="true" internalLogLevel="Info">
<targets>
<target xsi:type="File" name="tofile" fileName="D:\Рабочий стол\mylog.log" />
</targets>
<rules>
<logger name="*" minlevel="Debug" writeTo="tofile" />
</rules>
</nlog>
</configuration>