From 8f85c25a622cfd3ad795aa16f3bb5dbebe9d4542 Mon Sep 17 00:00:00 2001 From: Maxim Slipenko Date: Tue, 24 May 2022 13:01:28 +0300 Subject: [PATCH] =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D1=8F?= =?UTF-8?q?=D0=B5=D1=82=20=D1=81=D0=BE=D0=BE=D0=B1=D1=89=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D1=8F=20DeleteAccount=20=D0=B8=20ChangePassword?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Globals.cs | 5 +---- Logs.cs | 12 +++++++++++- SettingsForm.cs | 2 ++ 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/Globals.cs b/Globals.cs index a953706..940c8ae 100644 --- a/Globals.cs +++ b/Globals.cs @@ -66,10 +66,7 @@ namespace AwesomeEmailExtractor command.CommandText = "CREATE TABLE IF NOT EXISTS logs_actions (id INTEGER PRIMARY KEY, name TEXT NOT NULL)"; command.ExecuteNonQuery(); - command.CommandText = "INSERT OR IGNORE INTO logs_actions (id, name) VALUES (0, 'Выполнение'), (1, 'Вход'), (2, 'Регистрация');"; - command.ExecuteNonQuery(); - - command.CommandText = "CREATE TABLE IF NOT EXISTS logs (id INTEGER PRIMARY KEY AUTOINCREMENT, user_id INTEGER NOT NULL, date TEXT NOT NULL, action INTEGER NOT NULL, message TEXT NOT NULL, FOREIGN KEY(action) REFERENCES logs_actions(id));"; + command.CommandText = "CREATE TABLE IF NOT EXISTS logs (id INTEGER PRIMARY KEY AUTOINCREMENT, user_id INTEGER NOT NULL, date TEXT NOT NULL, action INTEGER NOT NULL, message TEXT NOT NULL);"; command.ExecuteNonQuery(); command.CommandText = "ATTACH DATABASE @dbpath AS appDB"; diff --git a/Logs.cs b/Logs.cs index 79e6250..059a1b1 100644 --- a/Logs.cs +++ b/Logs.cs @@ -33,7 +33,9 @@ namespace AwesomeEmailExtractor { Execute, Login, - Registration + Registration, + DeleteAccount, + ChangePassword } public static void Log(User user, Action action, Dictionary options) @@ -151,6 +153,14 @@ namespace AwesomeEmailExtractor { return "Пользователь зарегистрировался в системе."; } + if (action == Action.DeleteAccount) + { + return "Пользователь удалил аккаунт из системы."; + } + if (action == Action.ChangePassword) + { + return "Пользователь сменил пароль."; + } return ""; } diff --git a/SettingsForm.cs b/SettingsForm.cs index 9d3aaac..287829d 100644 --- a/SettingsForm.cs +++ b/SettingsForm.cs @@ -24,6 +24,7 @@ namespace AwesomeEmailExtractor if (result == DialogResult.Yes) { Globals.currentUser.Delete(); + Logs.Log(Globals.currentUser, Logs.Action.DeleteAccount, new Dictionary()); MessageBox.Show("Аккаунт удален!"); this.Close(); @@ -42,6 +43,7 @@ namespace AwesomeEmailExtractor } Globals.currentUser.ChangePassword(entryNewPassword.Text); + Logs.Log(Globals.currentUser, Logs.Action.ChangePassword, new Dictionary()); MessageBox.Show("Пароль изменен!"); } }