Compare commits

..

2 Commits

Author SHA1 Message Date
78bd7d56f9 FinalFix_Lab07 2024-05-22 15:22:23 +04:00
cf6968c5e3 AnotherFix_Lab07 2024-05-22 14:44:50 +04:00
7 changed files with 96 additions and 53 deletions

View File

@ -2,13 +2,25 @@
"Version": 1,
"WorkspaceRootPath": "C:\\SomeGitStuff\\ISEbd-11_Khatypov_K.R_fundamental\\ProjectLiner\\",
"Documents": [
{
"AbsoluteMoniker": "D:0:0:{7FB62E78-175F-490A-B5F2-2FF676947033}|ProjectLiner\\ProjectLiner.csproj|c:\\somegitstuff\\isebd-11_khatypov_k.r_fundamental\\projectliner\\projectliner\\serilog.json||{90A6B3A7-C1A3-4009-A288-E2FF89E96FA0}",
"RelativeMoniker": "D:0:0:{7FB62E78-175F-490A-B5F2-2FF676947033}|ProjectLiner\\ProjectLiner.csproj|solutionrelative:projectliner\\serilog.json||{90A6B3A7-C1A3-4009-A288-E2FF89E96FA0}"
},
{
"AbsoluteMoniker": "D:0:0:{7FB62E78-175F-490A-B5F2-2FF676947033}|ProjectLiner\\ProjectLiner.csproj|c:\\somegitstuff\\isebd-11_khatypov_k.r_fundamental\\projectliner\\projectliner\\program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{7FB62E78-175F-490A-B5F2-2FF676947033}|ProjectLiner\\ProjectLiner.csproj|solutionrelative:projectliner\\program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
},
{
"AbsoluteMoniker": "D:0:0:{7FB62E78-175F-490A-B5F2-2FF676947033}|ProjectLiner\\ProjectLiner.csproj|c:\\somegitstuff\\isebd-11_khatypov_k.r_fundamental\\projectliner\\projectliner\\projectliner.csproj||{FA3CD31E-987B-443A-9B81-186104E8DAC1}|",
"RelativeMoniker": "D:0:0:{7FB62E78-175F-490A-B5F2-2FF676947033}|ProjectLiner\\ProjectLiner.csproj|solutionrelative:projectliner\\projectliner.csproj||{FA3CD31E-987B-443A-9B81-186104E8DAC1}|"
},
{
"AbsoluteMoniker": "D:0:0:{7FB62E78-175F-490A-B5F2-2FF676947033}|ProjectLiner\\ProjectLiner.csproj|c:\\somegitstuff\\isebd-11_khatypov_k.r_fundamental\\projectliner\\projectliner\\formlinercollection.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{7FB62E78-175F-490A-B5F2-2FF676947033}|ProjectLiner\\ProjectLiner.csproj|solutionrelative:projectliner\\formlinercollection.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
},
{
"AbsoluteMoniker": "D:0:0:{7FB62E78-175F-490A-B5F2-2FF676947033}|ProjectLiner\\ProjectLiner.csproj|c:\\somegitstuff\\isebd-11_khatypov_k.r_fundamental\\projectliner\\projectliner\\nlog.config||{FA3CD31E-987B-443A-9B81-186104E8DAC1}",
"RelativeMoniker": "D:0:0:{7FB62E78-175F-490A-B5F2-2FF676947033}|ProjectLiner\\ProjectLiner.csproj|solutionrelative:projectliner\\nlog.config||{FA3CD31E-987B-443A-9B81-186104E8DAC1}"
"AbsoluteMoniker": "D:0:0:{7FB62E78-175F-490A-B5F2-2FF676947033}|ProjectLiner\\ProjectLiner.csproj|c:\\somegitstuff\\isebd-11_khatypov_k.r_fundamental\\projectliner\\projectliner\\collectiongenericobjects\\storagecollection.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{7FB62E78-175F-490A-B5F2-2FF676947033}|ProjectLiner\\ProjectLiner.csproj|solutionrelative:projectliner\\collectiongenericobjects\\storagecollection.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
},
{
"AbsoluteMoniker": "D:0:0:{7FB62E78-175F-490A-B5F2-2FF676947033}|ProjectLiner\\ProjectLiner.csproj|c:\\somegitstuff\\isebd-11_khatypov_k.r_fundamental\\projectliner\\projectliner\\collectiongenericobjects\\abstractcompany.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
@ -22,10 +34,6 @@
"AbsoluteMoniker": "D:0:0:{7FB62E78-175F-490A-B5F2-2FF676947033}|ProjectLiner\\ProjectLiner.csproj|c:\\somegitstuff\\isebd-11_khatypov_k.r_fundamental\\projectliner\\projectliner\\formlinerconfig.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{7FB62E78-175F-490A-B5F2-2FF676947033}|ProjectLiner\\ProjectLiner.csproj|solutionrelative:projectliner\\formlinerconfig.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
},
{
"AbsoluteMoniker": "D:0:0:{7FB62E78-175F-490A-B5F2-2FF676947033}|ProjectLiner\\ProjectLiner.csproj|c:\\somegitstuff\\isebd-11_khatypov_k.r_fundamental\\projectliner\\projectliner\\collectiongenericobjects\\storagecollection.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{7FB62E78-175F-490A-B5F2-2FF676947033}|ProjectLiner\\ProjectLiner.csproj|solutionrelative:projectliner\\collectiongenericobjects\\storagecollection.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
},
{
"AbsoluteMoniker": "D:0:0:{7FB62E78-175F-490A-B5F2-2FF676947033}|ProjectLiner\\ProjectLiner.csproj|c:\\somegitstuff\\isebd-11_khatypov_k.r_fundamental\\projectliner\\projectliner\\collectiongenericobjects\\listgenericobjects.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{7FB62E78-175F-490A-B5F2-2FF676947033}|ProjectLiner\\ProjectLiner.csproj|solutionrelative:projectliner\\collectiongenericobjects\\listgenericobjects.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
@ -55,19 +63,45 @@
{
"$type": "Document",
"DocumentIndex": 1,
"Title": "nlog.config",
"DocumentMoniker": "C:\\SomeGitStuff\\ISEbd-11_Khatypov_K.R_fundamental\\ProjectLiner\\ProjectLiner\\nlog.config",
"RelativeDocumentMoniker": "ProjectLiner\\nlog.config",
"ToolTip": "C:\\SomeGitStuff\\ISEbd-11_Khatypov_K.R_fundamental\\ProjectLiner\\ProjectLiner\\nlog.config",
"RelativeToolTip": "ProjectLiner\\nlog.config",
"ViewState": "AQIAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000601|",
"WhenOpened": "2024-05-22T09:46:17.634Z",
"Title": "Program.cs",
"DocumentMoniker": "C:\\SomeGitStuff\\ISEbd-11_Khatypov_K.R_fundamental\\ProjectLiner\\ProjectLiner\\Program.cs",
"RelativeDocumentMoniker": "ProjectLiner\\Program.cs",
"ToolTip": "C:\\SomeGitStuff\\ISEbd-11_Khatypov_K.R_fundamental\\ProjectLiner\\ProjectLiner\\Program.cs",
"RelativeToolTip": "ProjectLiner\\Program.cs",
"ViewState": "AQIAABkAAAAAAAAAAAAmwCUAAAAQAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2024-05-22T11:10:44.695Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 4,
"DocumentIndex": 2,
"Title": "ProjectLiner",
"DocumentMoniker": "C:\\SomeGitStuff\\ISEbd-11_Khatypov_K.R_fundamental\\ProjectLiner\\ProjectLiner\\ProjectLiner.csproj",
"RelativeDocumentMoniker": "ProjectLiner\\ProjectLiner.csproj",
"ToolTip": "C:\\SomeGitStuff\\ISEbd-11_Khatypov_K.R_fundamental\\ProjectLiner\\ProjectLiner\\ProjectLiner.csproj",
"RelativeToolTip": "ProjectLiner\\ProjectLiner.csproj",
"ViewState": "AQIAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000758|",
"WhenOpened": "2024-05-22T10:49:10.627Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 0,
"Title": "serilog.json",
"DocumentMoniker": "C:\\SomeGitStuff\\ISEbd-11_Khatypov_K.R_fundamental\\ProjectLiner\\ProjectLiner\\serilog.json",
"RelativeDocumentMoniker": "ProjectLiner\\serilog.json",
"ToolTip": "C:\\SomeGitStuff\\ISEbd-11_Khatypov_K.R_fundamental\\ProjectLiner\\ProjectLiner\\serilog.json",
"RelativeToolTip": "ProjectLiner\\serilog.json",
"ViewState": "AQIAAAAAAAAAAAAAAAAAAAsAAAAdAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.001642|",
"WhenOpened": "2024-05-22T10:49:21.207Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 7,
"Title": "FormLinerConfig.cs",
"DocumentMoniker": "C:\\SomeGitStuff\\ISEbd-11_Khatypov_K.R_fundamental\\ProjectLiner\\ProjectLiner\\FormLinerConfig.cs",
"RelativeDocumentMoniker": "ProjectLiner\\FormLinerConfig.cs",
@ -80,20 +114,20 @@
},
{
"$type": "Document",
"DocumentIndex": 0,
"DocumentIndex": 3,
"Title": "FormLinerCollection.cs",
"DocumentMoniker": "C:\\SomeGitStuff\\ISEbd-11_Khatypov_K.R_fundamental\\ProjectLiner\\ProjectLiner\\FormLinerCollection.cs",
"RelativeDocumentMoniker": "ProjectLiner\\FormLinerCollection.cs",
"ToolTip": "C:\\SomeGitStuff\\ISEbd-11_Khatypov_K.R_fundamental\\ProjectLiner\\ProjectLiner\\FormLinerCollection.cs",
"RelativeToolTip": "ProjectLiner\\FormLinerCollection.cs",
"ViewState": "AQIAAOYAAAAAAAAAAAAAAPYAAAAgAAAA",
"ViewState": "AQIAAN8AAAAAAAAAAAAmwPIAAABHAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2024-05-22T09:31:35.635Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 2,
"DocumentIndex": 5,
"Title": "AbstractCompany.cs",
"DocumentMoniker": "C:\\SomeGitStuff\\ISEbd-11_Khatypov_K.R_fundamental\\ProjectLiner\\ProjectLiner\\CollectionGenericObjects\\AbstractCompany.cs",
"RelativeDocumentMoniker": "ProjectLiner\\CollectionGenericObjects\\AbstractCompany.cs",
@ -106,20 +140,20 @@
},
{
"$type": "Document",
"DocumentIndex": 5,
"DocumentIndex": 4,
"Title": "StorageCollection.cs",
"DocumentMoniker": "C:\\SomeGitStuff\\ISEbd-11_Khatypov_K.R_fundamental\\ProjectLiner\\ProjectLiner\\CollectionGenericObjects\\StorageCollection.cs",
"RelativeDocumentMoniker": "ProjectLiner\\CollectionGenericObjects\\StorageCollection.cs",
"ToolTip": "C:\\SomeGitStuff\\ISEbd-11_Khatypov_K.R_fundamental\\ProjectLiner\\ProjectLiner\\CollectionGenericObjects\\StorageCollection.cs",
"RelativeToolTip": "ProjectLiner\\CollectionGenericObjects\\StorageCollection.cs",
"ViewState": "AQIAAKwAAAAAAAAAAAAYwL8AAAA1AAAA",
"ViewState": "AQIAAIEAAAAAAAAAAAAswFUAAAAFAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2024-05-22T09:26:56.734Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 7,
"DocumentIndex": 9,
"Title": "ICollectionGenericObjects.cs",
"DocumentMoniker": "C:\\SomeGitStuff\\ISEbd-11_Khatypov_K.R_fundamental\\ProjectLiner\\ProjectLiner\\CollectionGenericObjects\\ICollectionGenericObjects.cs",
"RelativeDocumentMoniker": "ProjectLiner\\CollectionGenericObjects\\ICollectionGenericObjects.cs",
@ -132,7 +166,7 @@
},
{
"$type": "Document",
"DocumentIndex": 6,
"DocumentIndex": 8,
"Title": "ListGenericObjects.cs",
"DocumentMoniker": "C:\\SomeGitStuff\\ISEbd-11_Khatypov_K.R_fundamental\\ProjectLiner\\ProjectLiner\\CollectionGenericObjects\\ListGenericObjects.cs",
"RelativeDocumentMoniker": "ProjectLiner\\CollectionGenericObjects\\ListGenericObjects.cs",
@ -145,13 +179,13 @@
},
{
"$type": "Document",
"DocumentIndex": 3,
"DocumentIndex": 6,
"Title": "MassiveGenericObjects.cs",
"DocumentMoniker": "C:\\SomeGitStuff\\ISEbd-11_Khatypov_K.R_fundamental\\ProjectLiner\\ProjectLiner\\CollectionGenericObjects\\MassiveGenericObjects.cs",
"RelativeDocumentMoniker": "ProjectLiner\\CollectionGenericObjects\\MassiveGenericObjects.cs",
"ToolTip": "C:\\SomeGitStuff\\ISEbd-11_Khatypov_K.R_fundamental\\ProjectLiner\\ProjectLiner\\CollectionGenericObjects\\MassiveGenericObjects.cs",
"RelativeToolTip": "ProjectLiner\\CollectionGenericObjects\\MassiveGenericObjects.cs",
"ViewState": "AQIAAGIAAAAAAAAAAAAmwHAAAAAIAAAA",
"ViewState": "AQIAAGIAAAAAAAAAAAAmwHAAAAARAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2024-05-22T08:45:00.199Z",
"EditorCaption": ""

View File

@ -240,7 +240,7 @@ public partial class FormLinerCollection : Form
_storageCollection.LoadData(openFileDialog.FileName);
MessageBox.Show("Загрузка прошла успешно",
"Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
_logger.LogInformation("Сохранение в файл: {filename}",
_logger.LogInformation("Загрузка из файла: {filename}",
openFileDialog.FileName);
RerfreshListBoxItems();
}

View File

@ -1,6 +1,8 @@
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using NLog.Extensions.Logging;
using Serilog;
using System.Drawing;
namespace ProjectLiner
{
@ -12,25 +14,34 @@ namespace ProjectLiner
[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<FormLinerCollection>());
using ServiceProvider servicesProvider = services.BuildServiceProvider();
Application.Run(servicesProvider.GetRequiredService<FormLinerCollection>());
}
/// <summary>
/// Êîíôèãóðàöèÿ ñåðâèñà DI
/// </summary>
/// <param name="services"></param>
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<FormLinerCollection>()
.AddLogging(option =>
{
option.SetMinimumLevel(LogLevel.Information);
option.AddNLog("nlog.config");
option.AddSerilog(new LoggerConfiguration()
.ReadFrom.Configuration(new ConfigurationBuilder()
.AddJsonFile($"{pathNeed}serilog.json")
.Build())
.CreateLogger());
});
}
}
}

View File

@ -11,6 +11,9 @@
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.11" />
<PackageReference Include="Serilog" Version="3.1.1" />
<PackageReference Include="Serilog.AspNetCore" Version="7.0.0" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
</ItemGroup>
<ItemGroup>
@ -28,10 +31,4 @@
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Update="nlog.config">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>

View File

@ -1,14 +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="carlog-
${shortdate}.log" />
</targets>
<rules>
<logger name="*" minlevel="Debug" writeTo="tofile" />
</rules>
</nlog>
</configuration>

View File

@ -0,0 +1,15 @@
{
"Serilog": {
"Using": [ "Serilog.Sinks.File" ],
"MinimumLevel": "Debug",
"WriteTo": [
{
"Name": "File",
"Args": { "path": "log.log" }
}
],
"Properties": {
"Application": "Sample"
}
}
}