Добавлено логирование необходимых действий пользователя
This commit is contained in:
parent
6d3098d62b
commit
911543fd43
@ -99,6 +99,7 @@ namespace ProjectStormtrooper
|
||||
_logger.LogInformation($"Удален набор: {name}");
|
||||
ReloadObjects();
|
||||
}
|
||||
_logger.LogWarning("Отмена удаления набора");
|
||||
}
|
||||
/// <summary>
|
||||
/// Добавление объекта в набор
|
||||
@ -129,6 +130,7 @@ namespace ProjectStormtrooper
|
||||
if (obj + plane > -1)
|
||||
{
|
||||
MessageBox.Show("Объект добавлен");
|
||||
_logger.LogInformation($"Добавлен объект {plane}");
|
||||
pictureBoxCollection.Image = obj.ShowPlanes();
|
||||
}
|
||||
else
|
||||
@ -165,9 +167,11 @@ namespace ProjectStormtrooper
|
||||
int pos = Convert.ToInt32(maskedTextBoxNumber.Text);
|
||||
try
|
||||
{
|
||||
if (obj - pos != null)
|
||||
var removedObj = obj - pos;
|
||||
if (removedObj != null)
|
||||
{
|
||||
MessageBox.Show("Объект удален");
|
||||
_logger.LogInformation($"Удален объект {removedObj} с позиции {pos}");
|
||||
pictureBoxCollection.Image = obj.ShowPlanes();
|
||||
}
|
||||
else
|
||||
@ -211,10 +215,12 @@ namespace ProjectStormtrooper
|
||||
{
|
||||
_storage.SaveData(saveFileDialog.FileName);
|
||||
MessageBox.Show("Сохранение прошло успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
_logger.LogInformation($"Данные сохранены в файл {saveFileDialog.FileName}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show($"Не сохранилось: {ex.Message}", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
_logger.LogWarning($"Не удалось сохранить информацию в файл: {ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -229,10 +235,12 @@ namespace ProjectStormtrooper
|
||||
ReloadObjects();
|
||||
RefreshCollection();
|
||||
MessageBox.Show("Загрузка прошло успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
_logger.LogInformation($"Данные загружены из файла {openFileDialog.FileName}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show($"Не загрузилось: {ex.Message}", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
_logger.LogWarning($"Не удалось загрузить информацию из файла: {ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -117,18 +117,18 @@ namespace ProjectStormtrooper
|
||||
{
|
||||
if (!File.Exists(filename))
|
||||
{
|
||||
throw new Exception("Ошибка открытия файла");
|
||||
throw new FileNotFoundException("Ошибка открытия файла");
|
||||
}
|
||||
using (StreamReader sr = new StreamReader(filename))
|
||||
{
|
||||
string? currentLine = sr.ReadLine();
|
||||
if (currentLine == null)
|
||||
{
|
||||
throw new Exception("Нет данных для загрузки");
|
||||
throw new IOException("Нет данных для загрузки");
|
||||
}
|
||||
if (!currentLine.Contains("PlaneStorage"))
|
||||
{
|
||||
throw new Exception("Неверный формат данных");
|
||||
throw new FileFormatException("Неверный формат данных");
|
||||
}
|
||||
_planeStorages.Clear();
|
||||
currentLine = sr.ReadLine();
|
||||
|
Loading…
Reference in New Issue
Block a user