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("Пароль изменен!"); } }