Merge pull request #29 from PI20v/27-administration-form
Добавить окно с администрированием
This commit is contained in:
commit
16b0c72c5d
391
AdministrationForm.Designer.cs
generated
Normal file
391
AdministrationForm.Designer.cs
generated
Normal file
@ -0,0 +1,391 @@
|
||||
namespace AwesomeEmailExtractor
|
||||
{
|
||||
partial class AdministrationForm
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.mainTabControl = new System.Windows.Forms.TabControl();
|
||||
this.mainSettingsTabPage = new System.Windows.Forms.TabPage();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.browseButton = new System.Windows.Forms.Button();
|
||||
this.pathToJournalTextBox = new System.Windows.Forms.TextBox();
|
||||
this.usersTabPage = new System.Windows.Forms.TabPage();
|
||||
this.usersDataGridView = new System.Windows.Forms.DataGridView();
|
||||
this.journalTabPage = new System.Windows.Forms.TabPage();
|
||||
this.panel1 = new System.Windows.Forms.Panel();
|
||||
this.journalDataGridView = new System.Windows.Forms.DataGridView();
|
||||
this.editUserButton = new System.Windows.Forms.Button();
|
||||
this.panel2 = new System.Windows.Forms.Panel();
|
||||
this.deleteUserButton = new System.Windows.Forms.Button();
|
||||
this.sqliteCommand1 = new Microsoft.Data.Sqlite.SqliteCommand();
|
||||
this.panel3 = new System.Windows.Forms.Panel();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.label3 = new System.Windows.Forms.Label();
|
||||
this.label4 = new System.Windows.Forms.Label();
|
||||
this.messageRichTextBox = new System.Windows.Forms.RichTextBox();
|
||||
this.panel4 = new System.Windows.Forms.Panel();
|
||||
this.deleteJournalButton = new System.Windows.Forms.Button();
|
||||
this.dateLabel = new System.Windows.Forms.Label();
|
||||
this.userLabel = new System.Windows.Forms.Label();
|
||||
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
|
||||
this.actionLabel = new System.Windows.Forms.Label();
|
||||
this.label5 = new System.Windows.Forms.Label();
|
||||
this.mainTabControl.SuspendLayout();
|
||||
this.mainSettingsTabPage.SuspendLayout();
|
||||
this.usersTabPage.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.usersDataGridView)).BeginInit();
|
||||
this.journalTabPage.SuspendLayout();
|
||||
this.panel1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.journalDataGridView)).BeginInit();
|
||||
this.panel2.SuspendLayout();
|
||||
this.panel3.SuspendLayout();
|
||||
this.panel4.SuspendLayout();
|
||||
this.tableLayoutPanel1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// mainTabControl
|
||||
//
|
||||
this.mainTabControl.Controls.Add(this.mainSettingsTabPage);
|
||||
this.mainTabControl.Controls.Add(this.usersTabPage);
|
||||
this.mainTabControl.Controls.Add(this.journalTabPage);
|
||||
this.mainTabControl.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.mainTabControl.Location = new System.Drawing.Point(0, 0);
|
||||
this.mainTabControl.Name = "mainTabControl";
|
||||
this.mainTabControl.SelectedIndex = 0;
|
||||
this.mainTabControl.Size = new System.Drawing.Size(998, 557);
|
||||
this.mainTabControl.TabIndex = 0;
|
||||
//
|
||||
// mainSettingsTabPage
|
||||
//
|
||||
this.mainSettingsTabPage.Controls.Add(this.label1);
|
||||
this.mainSettingsTabPage.Controls.Add(this.browseButton);
|
||||
this.mainSettingsTabPage.Controls.Add(this.pathToJournalTextBox);
|
||||
this.mainSettingsTabPage.Location = new System.Drawing.Point(4, 22);
|
||||
this.mainSettingsTabPage.Name = "mainSettingsTabPage";
|
||||
this.mainSettingsTabPage.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.mainSettingsTabPage.Size = new System.Drawing.Size(990, 531);
|
||||
this.mainSettingsTabPage.TabIndex = 0;
|
||||
this.mainSettingsTabPage.Text = "Общие настройки";
|
||||
this.mainSettingsTabPage.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(8, 12);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(140, 13);
|
||||
this.label1.TabIndex = 2;
|
||||
this.label1.Text = "Путь к файлу с журналом:";
|
||||
//
|
||||
// browseButton
|
||||
//
|
||||
this.browseButton.Location = new System.Drawing.Point(678, 26);
|
||||
this.browseButton.Name = "browseButton";
|
||||
this.browseButton.Size = new System.Drawing.Size(106, 23);
|
||||
this.browseButton.TabIndex = 1;
|
||||
this.browseButton.Text = "Обзор";
|
||||
this.browseButton.UseVisualStyleBackColor = true;
|
||||
this.browseButton.Click += new System.EventHandler(this.browseButton_Click);
|
||||
//
|
||||
// pathToJournalTextBox
|
||||
//
|
||||
this.pathToJournalTextBox.Enabled = false;
|
||||
this.pathToJournalTextBox.Location = new System.Drawing.Point(8, 28);
|
||||
this.pathToJournalTextBox.Name = "pathToJournalTextBox";
|
||||
this.pathToJournalTextBox.Size = new System.Drawing.Size(664, 20);
|
||||
this.pathToJournalTextBox.TabIndex = 0;
|
||||
//
|
||||
// usersTabPage
|
||||
//
|
||||
this.usersTabPage.Controls.Add(this.usersDataGridView);
|
||||
this.usersTabPage.Controls.Add(this.panel2);
|
||||
this.usersTabPage.Location = new System.Drawing.Point(4, 22);
|
||||
this.usersTabPage.Name = "usersTabPage";
|
||||
this.usersTabPage.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.usersTabPage.Size = new System.Drawing.Size(990, 531);
|
||||
this.usersTabPage.TabIndex = 1;
|
||||
this.usersTabPage.Text = "Пользователи";
|
||||
this.usersTabPage.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// usersDataGridView
|
||||
//
|
||||
this.usersDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.usersDataGridView.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.usersDataGridView.Location = new System.Drawing.Point(3, 31);
|
||||
this.usersDataGridView.Name = "usersDataGridView";
|
||||
this.usersDataGridView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
|
||||
this.usersDataGridView.Size = new System.Drawing.Size(984, 497);
|
||||
this.usersDataGridView.TabIndex = 0;
|
||||
//
|
||||
// journalTabPage
|
||||
//
|
||||
this.journalTabPage.Controls.Add(this.panel3);
|
||||
this.journalTabPage.Controls.Add(this.panel1);
|
||||
this.journalTabPage.Location = new System.Drawing.Point(4, 22);
|
||||
this.journalTabPage.Name = "journalTabPage";
|
||||
this.journalTabPage.Size = new System.Drawing.Size(990, 531);
|
||||
this.journalTabPage.TabIndex = 2;
|
||||
this.journalTabPage.Text = "Журнал";
|
||||
this.journalTabPage.UseVisualStyleBackColor = true;
|
||||
this.journalTabPage.Click += new System.EventHandler(this.journalTabPage_Click);
|
||||
//
|
||||
// panel1
|
||||
//
|
||||
this.panel1.Controls.Add(this.tableLayoutPanel1);
|
||||
this.panel1.Dock = System.Windows.Forms.DockStyle.Right;
|
||||
this.panel1.Location = new System.Drawing.Point(536, 0);
|
||||
this.panel1.Name = "panel1";
|
||||
this.panel1.Size = new System.Drawing.Size(454, 531);
|
||||
this.panel1.TabIndex = 1;
|
||||
//
|
||||
// journalDataGridView
|
||||
//
|
||||
this.journalDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.journalDataGridView.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.journalDataGridView.Location = new System.Drawing.Point(0, 37);
|
||||
this.journalDataGridView.Name = "journalDataGridView";
|
||||
this.journalDataGridView.ReadOnly = true;
|
||||
this.journalDataGridView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
|
||||
this.journalDataGridView.Size = new System.Drawing.Size(536, 494);
|
||||
this.journalDataGridView.TabIndex = 0;
|
||||
this.journalDataGridView.SelectionChanged += new System.EventHandler(this.journalDataGridView_SelectionChanged);
|
||||
//
|
||||
// editUserButton
|
||||
//
|
||||
this.editUserButton.Location = new System.Drawing.Point(3, 3);
|
||||
this.editUserButton.Name = "editUserButton";
|
||||
this.editUserButton.Size = new System.Drawing.Size(131, 20);
|
||||
this.editUserButton.TabIndex = 1;
|
||||
this.editUserButton.Text = "Редактировать";
|
||||
this.editUserButton.UseVisualStyleBackColor = true;
|
||||
this.editUserButton.Click += new System.EventHandler(this.editUserButton_Click);
|
||||
//
|
||||
// panel2
|
||||
//
|
||||
this.panel2.Controls.Add(this.deleteUserButton);
|
||||
this.panel2.Controls.Add(this.editUserButton);
|
||||
this.panel2.Dock = System.Windows.Forms.DockStyle.Top;
|
||||
this.panel2.Location = new System.Drawing.Point(3, 3);
|
||||
this.panel2.Name = "panel2";
|
||||
this.panel2.Size = new System.Drawing.Size(984, 28);
|
||||
this.panel2.TabIndex = 2;
|
||||
//
|
||||
// deleteUserButton
|
||||
//
|
||||
this.deleteUserButton.Location = new System.Drawing.Point(140, 3);
|
||||
this.deleteUserButton.Name = "deleteUserButton";
|
||||
this.deleteUserButton.Size = new System.Drawing.Size(131, 20);
|
||||
this.deleteUserButton.TabIndex = 2;
|
||||
this.deleteUserButton.Text = "Удалить";
|
||||
this.deleteUserButton.UseVisualStyleBackColor = true;
|
||||
this.deleteUserButton.Click += new System.EventHandler(this.deleteUserButton_Click);
|
||||
//
|
||||
// sqliteCommand1
|
||||
//
|
||||
this.sqliteCommand1.CommandTimeout = 30;
|
||||
this.sqliteCommand1.Connection = null;
|
||||
this.sqliteCommand1.Transaction = null;
|
||||
this.sqliteCommand1.UpdatedRowSource = System.Data.UpdateRowSource.None;
|
||||
//
|
||||
// panel3
|
||||
//
|
||||
this.panel3.Controls.Add(this.journalDataGridView);
|
||||
this.panel3.Controls.Add(this.panel4);
|
||||
this.panel3.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.panel3.Location = new System.Drawing.Point(0, 0);
|
||||
this.panel3.Name = "panel3";
|
||||
this.panel3.Size = new System.Drawing.Size(536, 531);
|
||||
this.panel3.TabIndex = 2;
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(3, 0);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(36, 13);
|
||||
this.label2.TabIndex = 0;
|
||||
this.label2.Text = "Дата:";
|
||||
//
|
||||
// label3
|
||||
//
|
||||
this.label3.AutoSize = true;
|
||||
this.label3.Location = new System.Drawing.Point(3, 30);
|
||||
this.label3.Name = "label3";
|
||||
this.label3.Size = new System.Drawing.Size(83, 13);
|
||||
this.label3.TabIndex = 1;
|
||||
this.label3.Text = "Пользователь:";
|
||||
//
|
||||
// label4
|
||||
//
|
||||
this.label4.AutoSize = true;
|
||||
this.label4.Location = new System.Drawing.Point(3, 60);
|
||||
this.label4.Name = "label4";
|
||||
this.label4.Size = new System.Drawing.Size(54, 13);
|
||||
this.label4.TabIndex = 2;
|
||||
this.label4.Text = "Событие:";
|
||||
//
|
||||
// messageRichTextBox
|
||||
//
|
||||
this.messageRichTextBox.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.messageRichTextBox.Location = new System.Drawing.Point(103, 93);
|
||||
this.messageRichTextBox.Name = "messageRichTextBox";
|
||||
this.messageRichTextBox.Size = new System.Drawing.Size(348, 435);
|
||||
this.messageRichTextBox.TabIndex = 3;
|
||||
this.messageRichTextBox.Text = "";
|
||||
//
|
||||
// panel4
|
||||
//
|
||||
this.panel4.Controls.Add(this.deleteJournalButton);
|
||||
this.panel4.Dock = System.Windows.Forms.DockStyle.Top;
|
||||
this.panel4.Location = new System.Drawing.Point(0, 0);
|
||||
this.panel4.Name = "panel4";
|
||||
this.panel4.Size = new System.Drawing.Size(536, 37);
|
||||
this.panel4.TabIndex = 1;
|
||||
//
|
||||
// deleteJournalButton
|
||||
//
|
||||
this.deleteJournalButton.Location = new System.Drawing.Point(8, 3);
|
||||
this.deleteJournalButton.Name = "deleteJournalButton";
|
||||
this.deleteJournalButton.Size = new System.Drawing.Size(131, 20);
|
||||
this.deleteJournalButton.TabIndex = 3;
|
||||
this.deleteJournalButton.Text = "Удалить";
|
||||
this.deleteJournalButton.UseVisualStyleBackColor = true;
|
||||
this.deleteJournalButton.Click += new System.EventHandler(this.deleteJournalButton_Click);
|
||||
//
|
||||
// dateLabel
|
||||
//
|
||||
this.dateLabel.AutoSize = true;
|
||||
this.dateLabel.Location = new System.Drawing.Point(103, 0);
|
||||
this.dateLabel.Name = "dateLabel";
|
||||
this.dateLabel.Size = new System.Drawing.Size(0, 13);
|
||||
this.dateLabel.TabIndex = 4;
|
||||
//
|
||||
// userLabel
|
||||
//
|
||||
this.userLabel.AutoSize = true;
|
||||
this.userLabel.Location = new System.Drawing.Point(103, 30);
|
||||
this.userLabel.Name = "userLabel";
|
||||
this.userLabel.Size = new System.Drawing.Size(0, 13);
|
||||
this.userLabel.TabIndex = 5;
|
||||
//
|
||||
// tableLayoutPanel1
|
||||
//
|
||||
this.tableLayoutPanel1.ColumnCount = 2;
|
||||
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 100F));
|
||||
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||
this.tableLayoutPanel1.Controls.Add(this.label2, 0, 0);
|
||||
this.tableLayoutPanel1.Controls.Add(this.messageRichTextBox, 1, 3);
|
||||
this.tableLayoutPanel1.Controls.Add(this.userLabel, 1, 1);
|
||||
this.tableLayoutPanel1.Controls.Add(this.label4, 0, 2);
|
||||
this.tableLayoutPanel1.Controls.Add(this.dateLabel, 1, 0);
|
||||
this.tableLayoutPanel1.Controls.Add(this.label3, 0, 1);
|
||||
this.tableLayoutPanel1.Controls.Add(this.actionLabel, 1, 2);
|
||||
this.tableLayoutPanel1.Controls.Add(this.label5, 0, 3);
|
||||
this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0);
|
||||
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
|
||||
this.tableLayoutPanel1.RowCount = 4;
|
||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 30F));
|
||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 30F));
|
||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 30F));
|
||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||
this.tableLayoutPanel1.Size = new System.Drawing.Size(454, 531);
|
||||
this.tableLayoutPanel1.TabIndex = 6;
|
||||
//
|
||||
// actionLabel
|
||||
//
|
||||
this.actionLabel.AutoSize = true;
|
||||
this.actionLabel.Location = new System.Drawing.Point(103, 60);
|
||||
this.actionLabel.Name = "actionLabel";
|
||||
this.actionLabel.Size = new System.Drawing.Size(0, 13);
|
||||
this.actionLabel.TabIndex = 6;
|
||||
//
|
||||
// label5
|
||||
//
|
||||
this.label5.AutoSize = true;
|
||||
this.label5.Location = new System.Drawing.Point(3, 90);
|
||||
this.label5.Name = "label5";
|
||||
this.label5.Size = new System.Drawing.Size(68, 13);
|
||||
this.label5.TabIndex = 7;
|
||||
this.label5.Text = "Сообщение:";
|
||||
//
|
||||
// AdministrationForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(998, 557);
|
||||
this.Controls.Add(this.mainTabControl);
|
||||
this.Name = "AdministrationForm";
|
||||
this.Text = "Администрирование";
|
||||
this.Load += new System.EventHandler(this.AdministrationForm_Load);
|
||||
this.mainTabControl.ResumeLayout(false);
|
||||
this.mainSettingsTabPage.ResumeLayout(false);
|
||||
this.mainSettingsTabPage.PerformLayout();
|
||||
this.usersTabPage.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.usersDataGridView)).EndInit();
|
||||
this.journalTabPage.ResumeLayout(false);
|
||||
this.panel1.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.journalDataGridView)).EndInit();
|
||||
this.panel2.ResumeLayout(false);
|
||||
this.panel3.ResumeLayout(false);
|
||||
this.panel4.ResumeLayout(false);
|
||||
this.tableLayoutPanel1.ResumeLayout(false);
|
||||
this.tableLayoutPanel1.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.TabControl mainTabControl;
|
||||
private System.Windows.Forms.TabPage mainSettingsTabPage;
|
||||
private System.Windows.Forms.TabPage usersTabPage;
|
||||
private System.Windows.Forms.TabPage journalTabPage;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.Button browseButton;
|
||||
private System.Windows.Forms.TextBox pathToJournalTextBox;
|
||||
private System.Windows.Forms.DataGridView usersDataGridView;
|
||||
private System.Windows.Forms.Panel panel1;
|
||||
private System.Windows.Forms.DataGridView journalDataGridView;
|
||||
private System.Windows.Forms.Panel panel2;
|
||||
private System.Windows.Forms.Button deleteUserButton;
|
||||
private System.Windows.Forms.Button editUserButton;
|
||||
private System.Windows.Forms.Panel panel3;
|
||||
private Microsoft.Data.Sqlite.SqliteCommand sqliteCommand1;
|
||||
private System.Windows.Forms.Panel panel4;
|
||||
private System.Windows.Forms.RichTextBox messageRichTextBox;
|
||||
private System.Windows.Forms.Label label4;
|
||||
private System.Windows.Forms.Label label3;
|
||||
private System.Windows.Forms.Label label2;
|
||||
private System.Windows.Forms.Button deleteJournalButton;
|
||||
private System.Windows.Forms.Label userLabel;
|
||||
private System.Windows.Forms.Label dateLabel;
|
||||
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
|
||||
private System.Windows.Forms.Label actionLabel;
|
||||
private System.Windows.Forms.Label label5;
|
||||
}
|
||||
}
|
201
AdministrationForm.cs
Normal file
201
AdministrationForm.cs
Normal file
@ -0,0 +1,201 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using Microsoft.Data.Sqlite;
|
||||
|
||||
namespace AwesomeEmailExtractor
|
||||
{
|
||||
public partial class AdministrationForm : Form
|
||||
{
|
||||
public AdministrationForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void AdministrationForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
SqliteCommand command = new SqliteCommand();
|
||||
command.Connection = Globals.db;
|
||||
command.CommandText = "SELECT * FROM app_settings";
|
||||
|
||||
var reader = command.ExecuteReader();
|
||||
|
||||
var Row = reader.Read();
|
||||
|
||||
pathToJournalTextBox.Text = reader.GetString(0);
|
||||
|
||||
AdminUtils adminUtils = new AdminUtils(Globals.currentUser);
|
||||
|
||||
var users = adminUtils.GetAllUsers();
|
||||
usersDataGridView.DataSource = users;
|
||||
|
||||
List<string> columns = new List<string>() { "ID", "Логин", "Роль" };
|
||||
|
||||
for (int i = 0; i < usersDataGridView.Columns.Count; i++)
|
||||
{
|
||||
usersDataGridView.Columns[i].HeaderText = columns[i];
|
||||
usersDataGridView.Columns[i].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
|
||||
var logs = Logs.GetLogsList();
|
||||
journalDataGridView.DataSource = logs;
|
||||
|
||||
columns = new List<string>() { "ID", "Пользователь", "Дата", "Событие", "Сообщение" };
|
||||
|
||||
for (int i = 0; i < journalDataGridView.Columns.Count; i++)
|
||||
{
|
||||
journalDataGridView.Columns[i].HeaderText = columns[i];
|
||||
journalDataGridView.Columns[i].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
}
|
||||
|
||||
private void browseButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
FileDialog dialog = new SaveFileDialog();
|
||||
dialog.Filter = "SQLite база с журналом (*.db)|*.db";
|
||||
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
pathToJournalTextBox.Text = dialog.FileName;
|
||||
|
||||
SqliteCommand command = new SqliteCommand();
|
||||
command.Connection = Globals.db;
|
||||
command.CommandText = "UPDATE app_settings SET logs_db_path = @path";
|
||||
command.Parameters.AddWithValue("@path", pathToJournalTextBox.Text);
|
||||
command.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void journalTabPage_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void journalDataGridView_SelectionChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (journalDataGridView.SelectedRows.Count > 0)
|
||||
{
|
||||
var row = journalDataGridView.SelectedRows[0].DataBoundItem as Logs.LogData;
|
||||
|
||||
dateLabel.Text = row.Date;
|
||||
userLabel.Text = $"{row.User.Login} ({row.User.ID}) - {row.User.Role}";
|
||||
actionLabel.Text = row.Action.ToString();
|
||||
messageRichTextBox.Text = row.Message;
|
||||
}
|
||||
else
|
||||
{
|
||||
dateLabel.Text = "";
|
||||
actionLabel.Text = "";
|
||||
userLabel.Text = "";
|
||||
messageRichTextBox.Text = "";
|
||||
}
|
||||
}
|
||||
|
||||
private void editUserButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (usersDataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
var user = usersDataGridView.SelectedRows[0].DataBoundItem as User;
|
||||
|
||||
var form = new EditUserForm();
|
||||
form.User = user;
|
||||
|
||||
form.ShowDialog();
|
||||
|
||||
AdminUtils adminUtils = new AdminUtils(Globals.currentUser);
|
||||
var users = adminUtils.GetAllUsers();
|
||||
usersDataGridView.DataSource = users;
|
||||
|
||||
var logs = Logs.GetLogsList();
|
||||
journalDataGridView.DataSource = logs;
|
||||
} else
|
||||
{
|
||||
MessageBox.Show("Выберите 1 пользователя для редактирования!");
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteUserButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
bool selfDelete = false;
|
||||
|
||||
if (usersDataGridView.SelectedRows.Count > 0)
|
||||
{
|
||||
DialogResult result = MessageBox.Show("Вы уверены что хотите удалить аккаунты?", "Удаление аккаунтов", MessageBoxButtons.YesNo);
|
||||
|
||||
if (result == DialogResult.Yes)
|
||||
{
|
||||
for (int i = 0; i < usersDataGridView.SelectedRows.Count; i++)
|
||||
{
|
||||
var user = usersDataGridView.SelectedRows[i].DataBoundItem as User;
|
||||
if (user.ID != Globals.currentUser.ID)
|
||||
{
|
||||
user.Delete();
|
||||
}
|
||||
else
|
||||
{
|
||||
selfDelete = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (selfDelete)
|
||||
{
|
||||
DialogResult result2 = MessageBox.Show("Вы уверены что хотите удалить СВОЙ аккаунт?", "Удаление аккаунта", MessageBoxButtons.YesNo);
|
||||
|
||||
if (result2 == DialogResult.Yes)
|
||||
{
|
||||
Globals.currentUser.Delete();
|
||||
MessageBox.Show("Аккаунт удален!");
|
||||
|
||||
this.Close();
|
||||
|
||||
AuthorizationForm authorization = FormManager.Current.CreateForm<AuthorizationForm>();
|
||||
FormManager.Current.Navigate(this.Owner, authorization);
|
||||
}
|
||||
}
|
||||
|
||||
AdminUtils adminUtils = new AdminUtils(Globals.currentUser);
|
||||
var users = adminUtils.GetAllUsers();
|
||||
usersDataGridView.DataSource = users;
|
||||
|
||||
var logs = Logs.GetLogsList();
|
||||
journalDataGridView.DataSource = logs;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Выберите хотя бы одного пользователя для удаления!");
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteJournalButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (journalDataGridView.SelectedRows.Count > 0)
|
||||
{
|
||||
DialogResult result = MessageBox.Show("Вы уверены что хотите удалить записи в журнале?", "Удаление записей в журнале", MessageBoxButtons.YesNo);
|
||||
|
||||
if (result == DialogResult.Yes)
|
||||
{
|
||||
for (int i = 0; i < journalDataGridView.SelectedRows.Count; i++)
|
||||
{
|
||||
var logData = journalDataGridView.SelectedRows[i].DataBoundItem as Logs.LogData;
|
||||
logData.Delete();
|
||||
}
|
||||
var logs = Logs.GetLogsList();
|
||||
journalDataGridView.DataSource = logs;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Выберите хотя бы одну запись для удаления!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
126
AdministrationForm.resx
Normal file
126
AdministrationForm.resx
Normal file
@ -0,0 +1,126 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="sqliteCommand1.DesignTimeVisible" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</metadata>
|
||||
<metadata name="sqliteCommand1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
</root>
|
@ -86,7 +86,14 @@ namespace AwesomeEmailExtractor
|
||||
Login = login;
|
||||
Role = role;
|
||||
}
|
||||
|
||||
|
||||
public User(User user)
|
||||
{
|
||||
ID = user.ID;
|
||||
Login = user.Login;
|
||||
Role = user.Role;
|
||||
}
|
||||
|
||||
public void Delete()
|
||||
{
|
||||
SqliteCommand command = new SqliteCommand();
|
||||
@ -114,9 +121,9 @@ namespace AwesomeEmailExtractor
|
||||
command.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
new public string ToString()
|
||||
public override string ToString()
|
||||
{
|
||||
return this.Login;
|
||||
return Login;
|
||||
}
|
||||
}
|
||||
|
||||
@ -130,11 +137,6 @@ namespace AwesomeEmailExtractor
|
||||
}
|
||||
public void setRole(string login, UserRoles role)
|
||||
{
|
||||
if (User.Role != UserRoles.ADMIN)
|
||||
{
|
||||
throw new Exception("Недостаточно прав!");
|
||||
}
|
||||
|
||||
SqliteCommand command = new SqliteCommand();
|
||||
command.Connection = Globals.db;
|
||||
command.CommandText = "UPDATE users SET role_id = @role WHERE login = @login";
|
||||
@ -147,7 +149,6 @@ namespace AwesomeEmailExtractor
|
||||
|
||||
command.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
public void deleteUser(string login)
|
||||
{
|
||||
if (User.Role != UserRoles.ADMIN)
|
||||
@ -164,7 +165,7 @@ namespace AwesomeEmailExtractor
|
||||
|
||||
command.ExecuteNonQuery();
|
||||
}
|
||||
public List<User> getAllUsers()
|
||||
public List<User> GetAllUsers()
|
||||
{
|
||||
if (User.Role != UserRoles.ADMIN)
|
||||
{
|
||||
@ -173,7 +174,7 @@ namespace AwesomeEmailExtractor
|
||||
|
||||
SqliteCommand command = new SqliteCommand();
|
||||
command.Connection = Globals.db;
|
||||
command.CommandText = "SELECT * FROM users";
|
||||
command.CommandText = "SELECT id, login, role_id FROM users";
|
||||
|
||||
SqliteDataReader reader = command.ExecuteReader();
|
||||
|
||||
@ -186,5 +187,34 @@ namespace AwesomeEmailExtractor
|
||||
|
||||
return users;
|
||||
}
|
||||
|
||||
public void editUser(User user)
|
||||
{
|
||||
if (User.Role != UserRoles.ADMIN)
|
||||
{
|
||||
throw new Exception("Недостаточно прав!");
|
||||
}
|
||||
|
||||
SqliteCommand command = new SqliteCommand();
|
||||
command.Connection = Globals.db;
|
||||
command.CommandText = "UPDATE users SET login = @login, role_id = @role_id WHERE id = @id";
|
||||
|
||||
SqliteParameter idParam = new SqliteParameter("@id", user.ID);
|
||||
command.Parameters.Add(idParam);
|
||||
|
||||
SqliteParameter loginParam = new SqliteParameter("@login", user.Login);
|
||||
command.Parameters.Add(loginParam);
|
||||
|
||||
SqliteParameter roleParam = new SqliteParameter("@role_id", user.Role);
|
||||
command.Parameters.Add(roleParam);
|
||||
|
||||
command.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
public void editUser(User user, string password)
|
||||
{
|
||||
editUser(user);
|
||||
user.ChangePassword(password);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -76,6 +76,12 @@
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AdministrationForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="AdministrationForm.Designer.cs">
|
||||
<DependentUpon>AdministrationForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Authorization.cs" />
|
||||
<Compile Include="AuthorizationForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
@ -83,6 +89,12 @@
|
||||
<Compile Include="AuthorizationForm.Designer.cs">
|
||||
<DependentUpon>AuthorizationForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="EditUserForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="EditUserForm.Designer.cs">
|
||||
<DependentUpon>EditUserForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="ExtactEmailsAlgorithm.cs" />
|
||||
<Compile Include="FormManager.cs" />
|
||||
<Compile Include="Globals.cs" />
|
||||
@ -113,9 +125,16 @@
|
||||
<Compile Include="SettingsForm.Designer.cs">
|
||||
<DependentUpon>SettingsForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<EmbeddedResource Include="AdministrationForm.resx">
|
||||
<DependentUpon>AdministrationForm.cs</DependentUpon>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="AuthorizationForm.resx">
|
||||
<DependentUpon>AuthorizationForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="EditUserForm.resx">
|
||||
<DependentUpon>EditUserForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="JournalForm.resx">
|
||||
<DependentUpon>JournalForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
|
154
EditUserForm.Designer.cs
generated
Normal file
154
EditUserForm.Designer.cs
generated
Normal file
@ -0,0 +1,154 @@
|
||||
namespace AwesomeEmailExtractor
|
||||
{
|
||||
partial class EditUserForm
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.idTextBox = new System.Windows.Forms.TextBox();
|
||||
this.loginTextBox = new System.Windows.Forms.TextBox();
|
||||
this.passwordTextBox = new System.Windows.Forms.TextBox();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.label3 = new System.Windows.Forms.Label();
|
||||
this.submitButton = new System.Windows.Forms.Button();
|
||||
this.roleComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.label4 = new System.Windows.Forms.Label();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// idTextBox
|
||||
//
|
||||
this.idTextBox.Enabled = false;
|
||||
this.idTextBox.Location = new System.Drawing.Point(65, 8);
|
||||
this.idTextBox.Name = "idTextBox";
|
||||
this.idTextBox.Size = new System.Drawing.Size(129, 20);
|
||||
this.idTextBox.TabIndex = 0;
|
||||
//
|
||||
// loginTextBox
|
||||
//
|
||||
this.loginTextBox.Location = new System.Drawing.Point(65, 34);
|
||||
this.loginTextBox.Name = "loginTextBox";
|
||||
this.loginTextBox.Size = new System.Drawing.Size(129, 20);
|
||||
this.loginTextBox.TabIndex = 1;
|
||||
//
|
||||
// passwordTextBox
|
||||
//
|
||||
this.passwordTextBox.Location = new System.Drawing.Point(65, 60);
|
||||
this.passwordTextBox.Name = "passwordTextBox";
|
||||
this.passwordTextBox.Size = new System.Drawing.Size(129, 20);
|
||||
this.passwordTextBox.TabIndex = 2;
|
||||
this.passwordTextBox.UseSystemPasswordChar = true;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(14, 11);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(21, 13);
|
||||
this.label1.TabIndex = 3;
|
||||
this.label1.Text = "ID:";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(14, 37);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(41, 13);
|
||||
this.label2.TabIndex = 4;
|
||||
this.label2.Text = "Логин:";
|
||||
//
|
||||
// label3
|
||||
//
|
||||
this.label3.AutoSize = true;
|
||||
this.label3.Location = new System.Drawing.Point(14, 63);
|
||||
this.label3.Name = "label3";
|
||||
this.label3.Size = new System.Drawing.Size(48, 13);
|
||||
this.label3.TabIndex = 5;
|
||||
this.label3.Text = "Пароль:";
|
||||
//
|
||||
// submitButton
|
||||
//
|
||||
this.submitButton.Location = new System.Drawing.Point(17, 118);
|
||||
this.submitButton.Name = "submitButton";
|
||||
this.submitButton.Size = new System.Drawing.Size(177, 23);
|
||||
this.submitButton.TabIndex = 6;
|
||||
this.submitButton.Text = "Подтвердить";
|
||||
this.submitButton.UseVisualStyleBackColor = true;
|
||||
this.submitButton.Click += new System.EventHandler(this.submitButton_Click);
|
||||
//
|
||||
// roleComboBox
|
||||
//
|
||||
this.roleComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.roleComboBox.FormattingEnabled = true;
|
||||
this.roleComboBox.Location = new System.Drawing.Point(65, 86);
|
||||
this.roleComboBox.Name = "roleComboBox";
|
||||
this.roleComboBox.Size = new System.Drawing.Size(129, 21);
|
||||
this.roleComboBox.TabIndex = 7;
|
||||
//
|
||||
// label4
|
||||
//
|
||||
this.label4.AutoSize = true;
|
||||
this.label4.Location = new System.Drawing.Point(17, 89);
|
||||
this.label4.Name = "label4";
|
||||
this.label4.Size = new System.Drawing.Size(35, 13);
|
||||
this.label4.TabIndex = 8;
|
||||
this.label4.Text = "Роль:";
|
||||
//
|
||||
// EditUserForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(210, 153);
|
||||
this.Controls.Add(this.label4);
|
||||
this.Controls.Add(this.roleComboBox);
|
||||
this.Controls.Add(this.submitButton);
|
||||
this.Controls.Add(this.label3);
|
||||
this.Controls.Add(this.label2);
|
||||
this.Controls.Add(this.label1);
|
||||
this.Controls.Add(this.passwordTextBox);
|
||||
this.Controls.Add(this.loginTextBox);
|
||||
this.Controls.Add(this.idTextBox);
|
||||
this.Name = "EditUserForm";
|
||||
this.Text = "Редактирование";
|
||||
this.Load += new System.EventHandler(this.EditUserForm_Load);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.TextBox idTextBox;
|
||||
private System.Windows.Forms.TextBox loginTextBox;
|
||||
private System.Windows.Forms.TextBox passwordTextBox;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.Label label2;
|
||||
private System.Windows.Forms.Label label3;
|
||||
private System.Windows.Forms.Button submitButton;
|
||||
private System.Windows.Forms.ComboBox roleComboBox;
|
||||
private System.Windows.Forms.Label label4;
|
||||
}
|
||||
}
|
55
EditUserForm.cs
Normal file
55
EditUserForm.cs
Normal file
@ -0,0 +1,55 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace AwesomeEmailExtractor
|
||||
{
|
||||
public partial class EditUserForm : Form
|
||||
{
|
||||
public User User { get; set; }
|
||||
|
||||
public EditUserForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void EditUserForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
idTextBox.Text = User.ID.ToString();
|
||||
loginTextBox.Text = User.Login;
|
||||
|
||||
|
||||
roleComboBox.Items.Add(UserRoles.DEFAULT.ToString());
|
||||
roleComboBox.Items.Add(UserRoles.ADMIN.ToString());
|
||||
|
||||
roleComboBox.SelectedIndex = (int)User.Role;
|
||||
}
|
||||
|
||||
private void submitButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
AdminUtils adminUtils = new AdminUtils(Globals.currentUser);
|
||||
|
||||
User editedUser = new User(User.ID, loginTextBox.Text, (UserRoles)roleComboBox.SelectedIndex);
|
||||
|
||||
if (passwordTextBox.Text != "")
|
||||
{
|
||||
adminUtils.editUser(editedUser, passwordTextBox.Text);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
adminUtils.editUser(editedUser);
|
||||
}
|
||||
|
||||
this.Close();
|
||||
}
|
||||
}
|
||||
}
|
120
EditUserForm.resx
Normal file
120
EditUserForm.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
@ -22,17 +22,18 @@ namespace AwesomeEmailExtractor
|
||||
var logs = Logs.GetLogsList(Globals.currentUser);
|
||||
|
||||
dataGridView1.DataSource = logs;
|
||||
dataGridView1.Columns[0].Visible = false;
|
||||
dataGridView1.Columns[3].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
// dataGridView1.Columns["id"].Visible = false;
|
||||
// dataGridView1.Columns[1].Visible = false;
|
||||
dataGridView1.Columns[4].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
|
||||
private void dataGridView1_SelectionChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView1.SelectedRows.Count > 0)
|
||||
{
|
||||
dataLabel.Text = dataGridView1.SelectedRows[0].Cells[1].Value.ToString();
|
||||
actionLabel.Text = dataGridView1.SelectedRows[0].Cells[2].Value.ToString();
|
||||
richTextBox1.Text = dataGridView1.SelectedRows[0].Cells[3].Value.ToString();
|
||||
dataLabel.Text = dataGridView1.SelectedRows[0].Cells["date"].Value.ToString();
|
||||
actionLabel.Text = dataGridView1.SelectedRows[0].Cells["action"].Value.ToString();
|
||||
richTextBox1.Text = dataGridView1.SelectedRows[0].Cells["message"].Value.ToString();
|
||||
} else {
|
||||
dataLabel.Text = "";
|
||||
actionLabel.Text = "";
|
||||
|
59
Logs.cs
59
Logs.cs
@ -10,10 +10,23 @@ namespace AwesomeEmailExtractor
|
||||
public class Logs
|
||||
{
|
||||
public class LogData {
|
||||
public int ID { get; set; }
|
||||
public User User { get; set; }
|
||||
public string Date { get; set; }
|
||||
public Action Action { get; set; }
|
||||
public string Message { get; set; }
|
||||
|
||||
public void Delete()
|
||||
{
|
||||
SqliteCommand command = new SqliteCommand();
|
||||
command.Connection = Globals.logsDb;
|
||||
command.CommandText = "DELETE FROM logs WHERE id = @id;";
|
||||
|
||||
SqliteParameter idParam = new SqliteParameter("@id", ID);
|
||||
command.Parameters.Add(idParam);
|
||||
|
||||
command.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
|
||||
public enum Action
|
||||
@ -46,10 +59,11 @@ namespace AwesomeEmailExtractor
|
||||
{
|
||||
logs.Add(new LogData()
|
||||
{
|
||||
ID = Convert.ToInt32(reader["id"]),
|
||||
User = user,
|
||||
Date = reader.GetString(0),
|
||||
Action = (Action)reader.GetInt32(1),
|
||||
Message = reader.GetString(2)
|
||||
Date = Convert.ToString(reader["date"]),
|
||||
Action = (Action)Convert.ToInt32(reader["action"]),
|
||||
Message = Convert.ToString(reader["message"]),
|
||||
});
|
||||
}
|
||||
|
||||
@ -67,7 +81,7 @@ namespace AwesomeEmailExtractor
|
||||
|
||||
SqliteCommand command = new SqliteCommand();
|
||||
command.Connection = Globals.logsDb;
|
||||
command.CommandText = "SELECT date, action, message FROM logs WHERE user_id = @user_id ORDER BY date DESC";
|
||||
command.CommandText = "SELECT id, date, action, message FROM logs WHERE user_id = @user_id ORDER BY date DESC";
|
||||
command.Parameters.AddWithValue("@user_id", user.ID);
|
||||
|
||||
return command.ExecuteReader();
|
||||
@ -82,19 +96,17 @@ namespace AwesomeEmailExtractor
|
||||
|
||||
SqliteCommand command = new SqliteCommand();
|
||||
command.Connection = Globals.logsDb;
|
||||
command.CommandText = "ATTACH DATABASE @dbpath AS appDB";
|
||||
command.Parameters.AddWithValue("@dbpath", Globals.getAppDatabase());
|
||||
command.ExecuteNonQuery();
|
||||
|
||||
command.CommandText = @"
|
||||
SELECT
|
||||
SELECT
|
||||
logs.id,
|
||||
user_id,
|
||||
CASE WHEN appDB.users.login is NULL THEN 'Deleted_' || user_id ELSE appDB.users.login END AS login
|
||||
appDB.users.role,
|
||||
CASE WHEN appDB.users.login is NULL THEN 'Deleted_' || user_id ELSE appDB.users.login END AS login,
|
||||
CASE WHEN appDB.users.role_id is NULL THEN 0 ELSE appDB.users.role_id END AS role_id,
|
||||
date,
|
||||
action,
|
||||
message
|
||||
from logs LEFT JOIN appDB.users on logs.user_id = appDB.users.id ORDER BY date DESC";
|
||||
from logs LEFT JOIN appDB.users on logs.user_id = appDB.users.id ORDER BY date DESC;";
|
||||
|
||||
SqliteDataReader reader = command.ExecuteReader();
|
||||
|
||||
@ -103,10 +115,15 @@ namespace AwesomeEmailExtractor
|
||||
{
|
||||
logs.Add(new LogData()
|
||||
{
|
||||
User = new User(reader.GetInt32(0), reader.GetString(1), (UserRoles)reader.GetInt32(2)),
|
||||
Date = reader.GetString(3),
|
||||
Action = (Action)reader.GetInt32(4),
|
||||
Message = reader.GetString(5)
|
||||
ID = Convert.ToInt32(reader["id"]),
|
||||
User = new User(
|
||||
Convert.ToInt32(reader["user_id"]),
|
||||
Convert.ToString(reader["login"]),
|
||||
(UserRoles)Convert.ToInt32(reader["role_id"])
|
||||
),
|
||||
Date = Convert.ToString(reader["date"]),
|
||||
Action = (Action)Convert.ToInt32(reader["action"]),
|
||||
Message = Convert.ToString(reader["message"])
|
||||
});
|
||||
}
|
||||
|
||||
@ -137,5 +154,17 @@ namespace AwesomeEmailExtractor
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
public static void DeleteLog(LogData logData)
|
||||
{
|
||||
SqliteCommand command = new SqliteCommand();
|
||||
command.Connection = Globals.logsDb;
|
||||
|
||||
command.CommandText = "DELETE FROM logsDB WHERE id = @id";
|
||||
|
||||
command.Parameters.AddWithValue("@id", logData.ID);
|
||||
|
||||
command.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
17
MainForm.Designer.cs
generated
17
MainForm.Designer.cs
generated
@ -37,11 +37,11 @@
|
||||
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
|
||||
this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.аккаунтToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.journalToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.settingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.administrationToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.helpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.journalToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.resultStatusStrip.SuspendLayout();
|
||||
this.menuStrip1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
@ -142,6 +142,13 @@
|
||||
this.аккаунтToolStripMenuItem.Size = new System.Drawing.Size(63, 20);
|
||||
this.аккаунтToolStripMenuItem.Text = "Аккаунт";
|
||||
//
|
||||
// journalToolStripMenuItem
|
||||
//
|
||||
this.journalToolStripMenuItem.Name = "journalToolStripMenuItem";
|
||||
this.journalToolStripMenuItem.Size = new System.Drawing.Size(189, 22);
|
||||
this.journalToolStripMenuItem.Text = "Журнал";
|
||||
this.journalToolStripMenuItem.Click += new System.EventHandler(this.journalToolStripMenuItem_Click);
|
||||
//
|
||||
// settingsToolStripMenuItem
|
||||
//
|
||||
this.settingsToolStripMenuItem.Name = "settingsToolStripMenuItem";
|
||||
@ -154,6 +161,7 @@
|
||||
this.administrationToolStripMenuItem.Name = "administrationToolStripMenuItem";
|
||||
this.administrationToolStripMenuItem.Size = new System.Drawing.Size(189, 22);
|
||||
this.administrationToolStripMenuItem.Text = "Администрирование";
|
||||
this.administrationToolStripMenuItem.Click += new System.EventHandler(this.administrationToolStripMenuItem_Click);
|
||||
//
|
||||
// exitToolStripMenuItem
|
||||
//
|
||||
@ -168,13 +176,6 @@
|
||||
this.helpToolStripMenuItem.Size = new System.Drawing.Size(65, 20);
|
||||
this.helpToolStripMenuItem.Text = "Справка";
|
||||
//
|
||||
// journalToolStripMenuItem
|
||||
//
|
||||
this.journalToolStripMenuItem.Name = "journalToolStripMenuItem";
|
||||
this.journalToolStripMenuItem.Size = new System.Drawing.Size(189, 22);
|
||||
this.journalToolStripMenuItem.Text = "Журнал";
|
||||
this.journalToolStripMenuItem.Click += new System.EventHandler(this.journalToolStripMenuItem_Click);
|
||||
//
|
||||
// MainForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
|
@ -74,5 +74,11 @@ namespace AwesomeEmailExtractor
|
||||
JournalForm journalForm = FormManager.Current.CreateForm<JournalForm>();
|
||||
journalForm.ShowDialog(this);
|
||||
}
|
||||
|
||||
private void administrationToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
AdministrationForm administrationForm = FormManager.Current.CreateForm<AdministrationForm>();
|
||||
administrationForm.ShowDialog(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user