Compare commits
2 Commits
ea555cc897
...
e4d751e638
Author | SHA1 | Date | |
---|---|---|---|
e4d751e638 | |||
|
84b3e6f21e |
@ -30,7 +30,7 @@ namespace HoistingCrane.CollectionGenericObjects
|
||||
{
|
||||
get
|
||||
{
|
||||
return (pictureWidth * pictureHeight) / (_placeSizeHeight * _placeSizeWidth)-2;
|
||||
return (pictureWidth / _placeSizeWidth) * (pictureHeight / _placeSizeHeight);
|
||||
}
|
||||
}
|
||||
public AbstractCompany(int picWidth, int picHeight, ICollectionGenericObjects<DrawningTrackedVehicle> array)
|
||||
|
@ -44,7 +44,7 @@ namespace HoistingCrane
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Не удалось добавить объект");
|
||||
logger.LogInformation("Не удалось добавить корабль {ship} в коллекцию", drawningTrackedVehicle.GetType().Name);
|
||||
logger.LogInformation("Не удалось добавить кран {crane} в коллекцию", drawningTrackedVehicle.GetType().Name);
|
||||
}
|
||||
}
|
||||
catch (CollectionOverflowException ex)
|
||||
@ -142,12 +142,12 @@ namespace HoistingCrane
|
||||
if (radioButtonMassive.Checked)
|
||||
{
|
||||
collectionType = CollectionType.Massive;
|
||||
logger.LogInformation("Создана коллекция '{nameCol}' , название: {name}", collectionType, textBoxCollectionName.Text);
|
||||
logger.LogInformation("Создана коллекция {nameCol} , название: {name}", collectionType, textBoxCollectionName.Text);
|
||||
}
|
||||
else if (radioButtonList.Checked)
|
||||
{
|
||||
collectionType = CollectionType.List;
|
||||
logger.LogInformation("Создана коллекция '{nameCol}' , название: {name}", collectionType, textBoxCollectionName.Text);
|
||||
logger.LogInformation("Создана коллекция {nameCol} , название: {name}", collectionType, textBoxCollectionName.Text);
|
||||
}
|
||||
_storageCollection.AddCollection(textBoxCollectionName.Text,collectionType);RerfreshListBoxItems();
|
||||
}
|
||||
@ -205,7 +205,7 @@ namespace HoistingCrane
|
||||
{
|
||||
_storageCollection.SaveData(saveFileDialog.FileName);
|
||||
MessageBox.Show("Сохранение прошло успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
logger.LogInformation("Сохранение в файл: {filename}", saveFileDialog.FileName);
|
||||
logger.LogInformation("Сохранение в файл: {filename}", saveFileDialog.FileName.ToString());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -229,7 +229,7 @@ namespace HoistingCrane
|
||||
_storageCollection.LoadData(openFileDialog.FileName);
|
||||
RerfreshListBoxItems();
|
||||
MessageBox.Show("Загрузка прошла успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
logger.LogInformation("Загрузка в файл: {filename}", saveFileDialog.FileName);
|
||||
logger.LogInformation("Загрузка из файла: {filename}", saveFileDialog.FileName.ToString());
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
|
@ -13,8 +13,11 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
|
||||
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.9" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.11" />
|
||||
<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" />
|
||||
|
@ -1,8 +1,7 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Serilog;
|
||||
using Serilog.Extensions.Logging;
|
||||
|
||||
namespace HoistingCrane
|
||||
{
|
||||
internal static class Program
|
||||
@ -18,11 +17,24 @@ namespace HoistingCrane
|
||||
}
|
||||
private static void ConfigureServices(ServiceCollection services)
|
||||
{
|
||||
// Èíèöèàëèçèðóåì Serilog
|
||||
Log.Logger = new LoggerConfiguration().WriteTo.File("E:\\myLog.log").CreateLogger();
|
||||
services.AddSingleton<FormCarCollection>().AddLogging(builder =>
|
||||
|
||||
string[] path = Directory.GetCurrentDirectory().Split('\\');
|
||||
string pathNeed = "";
|
||||
for (int i = 0; i < path.Length - 3; i++)
|
||||
{
|
||||
builder.AddSerilog();
|
||||
pathNeed += path[i] + "\\";
|
||||
}
|
||||
|
||||
|
||||
services.AddSingleton<FormCarCollection>()
|
||||
.AddLogging(option =>
|
||||
{
|
||||
option.SetMinimumLevel(LogLevel.Information);
|
||||
option.AddSerilog(new LoggerConfiguration()
|
||||
.ReadFrom.Configuration(new ConfigurationBuilder()
|
||||
.AddJsonFile($"{pathNeed}serilog.json")
|
||||
.Build())
|
||||
.CreateLogger());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
18
HoistingCrane/HoistingCrane/serilog.json
Normal file
18
HoistingCrane/HoistingCrane/serilog.json
Normal file
@ -0,0 +1,18 @@
|
||||
|
||||
{
|
||||
"Serilog": {
|
||||
"Using": [ "Serilog.Sinks.File" ],
|
||||
"MinimumLevel": "Debug",
|
||||
"WriteTo": [
|
||||
{
|
||||
"Name": "File",
|
||||
"Args": {
|
||||
"path": "log.log"
|
||||
}
|
||||
}
|
||||
],
|
||||
"Properties": {
|
||||
"Application": "Sample"
|
||||
}
|
||||
}
|
||||
}
|
2
ФайлДляЛабы.txt
Normal file
2
ФайлДляЛабы.txt
Normal file
@ -0,0 +1,2 @@
|
||||
CollectionsStorage
|
||||
массив|Massive|25|EntityTrackedVehicle:100:100:White;EntityTrackedVehicle:100:100:Yellow;EntityTrackedVehicle:100:100:Purple;EntityHoistingCrane:100:100:Gray:Black:True:False;EntityTrackedVehicle:100:100:White;EntityTrackedVehicle:100:100:White;EntityHoistingCrane:100:100:Green:Black:False:False;EntityTrackedVehicle:100:100:Gray;EntityTrackedVehicle:100:100:Red;EntityHoistingCrane:100:100:White:Black:False:False;EntityHoistingCrane:100:100:Green:Blue:True:False;EntityHoistingCrane:100:100:Black:Black:True:True;EntityTrackedVehicle:100:100:White;EntityTrackedVehicle:100:100:Purple;EntityTrackedVehicle:100:100:Black;EntityTrackedVehicle:100:100:Blue;EntityTrackedVehicle:100:100:Gray;EntityTrackedVehicle:100:100:Red;EntityTrackedVehicle:100:100:Purple;EntityTrackedVehicle:100:100:Green;EntityTrackedVehicle:100:100:Purple;EntityTrackedVehicle:100:100:Yellow;EntityTrackedVehicle:100:100:Blue;EntityTrackedVehicle:100:100:Gray;
|
Loading…
Reference in New Issue
Block a user