Compare commits
52 Commits
Author | SHA1 | Date | |
---|---|---|---|
6fdb00527c | |||
6442b02b27 | |||
9d0c1ccf59 | |||
46cc1d3463 | |||
227f8a46bc | |||
fe4e192538 | |||
cc449216a4 | |||
caaf57b46e | |||
fbb645930c | |||
736f677c4e | |||
209a551daa | |||
0b969c28b5 | |||
c1c87bd76d | |||
29259daa0c | |||
6b1ae5fa20 | |||
a18bfb6e52 | |||
97da2e21f6 | |||
69a998fe9b | |||
a35c382c4b | |||
e9b6d20eb4 | |||
7d71bfeb46 | |||
c25a92b271 | |||
8f85c25a62 | |||
16b0c72c5d | |||
51b75c35c5 | |||
0f6d88a4ad | |||
4527f07c89 | |||
d386e8338a | |||
c5abaad465 | |||
51a2bb4ee9 | |||
94c54bc727 | |||
59b5b18baf | |||
5f3aa8fcd0 | |||
a8ea3fe279 | |||
5e5aff5f7d | |||
121abac88e | |||
c412738640 | |||
f2928f71be | |||
c8bb88a734 | |||
ff9e5827b7 | |||
8b1d8d93b4 | |||
8453920585 | |||
d47b3ee319 | |||
8e69fa569d | |||
347551cf92 | |||
1fe2728aff | |||
613315a988 | |||
7f9ca4200e | |||
a38dfe2308 | |||
dfff6faacc | |||
43f9cc859e | |||
1124eb01af |
.vs/AwesomeEmailExtractor
AdministrationForm.Designer.csAdministrationForm.csAdministrationForm.resxAuthorization.csAuthorizationForm.Designer.csAuthorizationForm.csAuthorizationForm.resxAwesomeEmailExtractor.csprojEditUserForm.Designer.csEditUserForm.csEditUserForm.resxExtactEmailsAlgorithm.csFormManager.csGlobals.csHelpForm.Designer.csHelpForm.csHelpForm.resxJournalForm.Designer.csJournalForm.csJournalForm.resxLogs.csMainForm.Designer.csMainForm.csProgram.csREADME.mdRegistrationForm.Designer.csRegistrationForm.csRegistrationForm.resxSettingsForm.Designer.csSettingsForm.csSettingsForm.resxpackages.config
11
.vs/AwesomeEmailExtractor/project-colors.json
Normal file
11
.vs/AwesomeEmailExtractor/project-colors.json
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"Version": 1,
|
||||
"ProjectMap": {
|
||||
"fe70a2f9-d831-462e-8705-b14623544f1c": {
|
||||
"ProjectGuid": "fe70a2f9-d831-462e-8705-b14623544f1c",
|
||||
"DisplayName": "AwesomeEmailExtractor",
|
||||
"ColorIndex": 0
|
||||
}
|
||||
},
|
||||
"NextColorIndex": 1
|
||||
}
|
392
AdministrationForm.Designer.cs
generated
Normal file
392
AdministrationForm.Designer.cs
generated
Normal file
@ -0,0 +1,392 @@
|
||||
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.panel2 = new System.Windows.Forms.Panel();
|
||||
this.deleteUserButton = new System.Windows.Forms.Button();
|
||||
this.editUserButton = new System.Windows.Forms.Button();
|
||||
this.journalTabPage = new System.Windows.Forms.TabPage();
|
||||
this.panel3 = new System.Windows.Forms.Panel();
|
||||
this.journalDataGridView = new System.Windows.Forms.DataGridView();
|
||||
this.panel4 = new System.Windows.Forms.Panel();
|
||||
this.deleteJournalButton = new System.Windows.Forms.Button();
|
||||
this.panel1 = new System.Windows.Forms.Panel();
|
||||
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.messageRichTextBox = new System.Windows.Forms.RichTextBox();
|
||||
this.userLabel = new System.Windows.Forms.Label();
|
||||
this.label4 = new System.Windows.Forms.Label();
|
||||
this.dateLabel = new System.Windows.Forms.Label();
|
||||
this.label3 = new System.Windows.Forms.Label();
|
||||
this.actionLabel = new System.Windows.Forms.Label();
|
||||
this.label5 = new System.Windows.Forms.Label();
|
||||
this.sqliteCommand1 = new Microsoft.Data.Sqlite.SqliteCommand();
|
||||
this.mainTabControl.SuspendLayout();
|
||||
this.mainSettingsTabPage.SuspendLayout();
|
||||
this.usersTabPage.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.usersDataGridView)).BeginInit();
|
||||
this.panel2.SuspendLayout();
|
||||
this.journalTabPage.SuspendLayout();
|
||||
this.panel3.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.journalDataGridView)).BeginInit();
|
||||
this.panel4.SuspendLayout();
|
||||
this.panel1.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;
|
||||
//
|
||||
// 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);
|
||||
//
|
||||
// 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);
|
||||
//
|
||||
// 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);
|
||||
//
|
||||
// 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;
|
||||
//
|
||||
// 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);
|
||||
//
|
||||
// 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);
|
||||
//
|
||||
// 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;
|
||||
//
|
||||
// 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;
|
||||
//
|
||||
// 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 = "Дата:";
|
||||
//
|
||||
// messageRichTextBox
|
||||
//
|
||||
this.messageRichTextBox.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.messageRichTextBox.Location = new System.Drawing.Point(103, 93);
|
||||
this.messageRichTextBox.Name = "messageRichTextBox";
|
||||
this.messageRichTextBox.ReadOnly = true;
|
||||
this.messageRichTextBox.Size = new System.Drawing.Size(348, 435);
|
||||
this.messageRichTextBox.TabIndex = 3;
|
||||
this.messageRichTextBox.Text = "";
|
||||
//
|
||||
// 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;
|
||||
//
|
||||
// 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 = "Событие:";
|
||||
//
|
||||
// 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;
|
||||
//
|
||||
// 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 = "Пользователь:";
|
||||
//
|
||||
// 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 = "Сообщение:";
|
||||
//
|
||||
// sqliteCommand1
|
||||
//
|
||||
this.sqliteCommand1.CommandTimeout = 30;
|
||||
this.sqliteCommand1.Connection = null;
|
||||
this.sqliteCommand1.Transaction = null;
|
||||
this.sqliteCommand1.UpdatedRowSource = System.Data.UpdateRowSource.None;
|
||||
//
|
||||
// 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.panel2.ResumeLayout(false);
|
||||
this.journalTabPage.ResumeLayout(false);
|
||||
this.panel3.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.journalDataGridView)).EndInit();
|
||||
this.panel4.ResumeLayout(false);
|
||||
this.panel1.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, MessageBoxIcon.Warning);
|
||||
|
||||
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, MessageBoxIcon.Warning);
|
||||
|
||||
if (result2 == DialogResult.Yes)
|
||||
{
|
||||
Globals.currentUser.Delete();
|
||||
MessageBox.Show("Аккаунт удален!", "Аккаунт удален", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
|
||||
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("Выберите хотя бы одного пользователя для удаления!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteJournalButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (journalDataGridView.SelectedRows.Count > 0)
|
||||
{
|
||||
DialogResult result = MessageBox.Show("Вы уверены что хотите удалить записи в журнале?", "Удаление записей в журнале", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
|
||||
|
||||
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("Выберите хотя бы одну запись для удаления!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
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>
|
220
Authorization.cs
Normal file
220
Authorization.cs
Normal file
@ -0,0 +1,220 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using System.Security.Cryptography;
|
||||
using Microsoft.Data.Sqlite;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AwesomeEmailExtractor
|
||||
{
|
||||
public class Authorization
|
||||
{
|
||||
public static User Login(string login, string password)
|
||||
{
|
||||
SqliteCommand command = new SqliteCommand();
|
||||
command.Connection = Globals.db;
|
||||
command.CommandText = "SELECT id, login, role_id FROM users WHERE login = @login AND password = @password";
|
||||
|
||||
SqliteParameter loginParam = new SqliteParameter("@login", login);
|
||||
command.Parameters.Add(loginParam);
|
||||
|
||||
SqliteParameter passwordParam = new SqliteParameter("@password", EncryptPassword(password));
|
||||
command.Parameters.Add(passwordParam);
|
||||
|
||||
SqliteDataReader reader = command.ExecuteReader();
|
||||
|
||||
while (reader.Read())
|
||||
{
|
||||
return new User(reader.GetInt32(0), reader.GetString(1), (UserRoles)reader.GetInt32(2));
|
||||
}
|
||||
|
||||
throw new Exception("Неверные данные для входа!");
|
||||
}
|
||||
|
||||
public static User Register(string login, string password)
|
||||
{
|
||||
SqliteCommand command = new SqliteCommand();
|
||||
command.Connection = Globals.db;
|
||||
command.CommandText = "INSERT INTO users (login, password, role_id) VALUES (@login, @password, 0);";
|
||||
|
||||
SqliteParameter loginParam = new SqliteParameter("@login", login);
|
||||
command.Parameters.Add(loginParam);
|
||||
|
||||
SqliteParameter passwordParam = new SqliteParameter("@password", EncryptPassword(password));
|
||||
command.Parameters.Add(passwordParam);
|
||||
|
||||
try
|
||||
{
|
||||
command.ExecuteNonQuery();
|
||||
} catch (SqliteException e)
|
||||
{
|
||||
if (e.SqliteErrorCode == 19) {
|
||||
throw new Exception("Имя пользователя занятно!");
|
||||
}
|
||||
|
||||
throw new Exception($"Ошибка: {e.Message}");
|
||||
};
|
||||
|
||||
return Login(login, password);
|
||||
}
|
||||
|
||||
public static string EncryptPassword(string password)
|
||||
{
|
||||
using (MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider())
|
||||
{
|
||||
UTF8Encoding utf8 = new UTF8Encoding();
|
||||
byte[] data = md5.ComputeHash(utf8.GetBytes(password));
|
||||
return Convert.ToBase64String(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum UserRoles
|
||||
{
|
||||
DEFAULT,
|
||||
ADMIN
|
||||
}
|
||||
public class User
|
||||
{
|
||||
public int ID { get; }
|
||||
public string Login { get; }
|
||||
public UserRoles Role { get; }
|
||||
|
||||
public User(int id, string login, UserRoles role)
|
||||
{
|
||||
ID = id;
|
||||
Login = login;
|
||||
Role = role;
|
||||
}
|
||||
|
||||
public User(User user)
|
||||
{
|
||||
ID = user.ID;
|
||||
Login = user.Login;
|
||||
Role = user.Role;
|
||||
}
|
||||
|
||||
public void Delete()
|
||||
{
|
||||
SqliteCommand command = new SqliteCommand();
|
||||
command.Connection = Globals.db;
|
||||
command.CommandText = "DELETE FROM users WHERE id = @id;";
|
||||
|
||||
SqliteParameter idParam = new SqliteParameter("@id", ID);
|
||||
command.Parameters.Add(idParam);
|
||||
|
||||
command.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
public void ChangePassword(string password)
|
||||
{
|
||||
SqliteCommand command = new SqliteCommand();
|
||||
command.Connection = Globals.db;
|
||||
command.CommandText = "UPDATE users SET password = @password WHERE id = @id;";
|
||||
|
||||
SqliteParameter idParam = new SqliteParameter("@id", ID);
|
||||
command.Parameters.Add(idParam);
|
||||
|
||||
SqliteParameter passwordParam = new SqliteParameter("@password", Authorization.EncryptPassword(password));
|
||||
command.Parameters.Add(passwordParam);
|
||||
|
||||
command.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Login;
|
||||
}
|
||||
}
|
||||
|
||||
public class AdminUtils
|
||||
{
|
||||
public User User { get; set; }
|
||||
|
||||
public AdminUtils(User user)
|
||||
{
|
||||
User = user;
|
||||
}
|
||||
public void setRole(string login, UserRoles role)
|
||||
{
|
||||
SqliteCommand command = new SqliteCommand();
|
||||
command.Connection = Globals.db;
|
||||
command.CommandText = "UPDATE users SET role_id = @role WHERE login = @login";
|
||||
|
||||
SqliteParameter roleParam = new SqliteParameter("@role", (int)role);
|
||||
command.Parameters.Add(roleParam);
|
||||
|
||||
SqliteParameter loginParam = new SqliteParameter("@login", login);
|
||||
command.Parameters.Add(loginParam);
|
||||
|
||||
command.ExecuteNonQuery();
|
||||
}
|
||||
public void deleteUser(string login)
|
||||
{
|
||||
if (User.Role != UserRoles.ADMIN)
|
||||
{
|
||||
throw new Exception("Недостаточно прав!");
|
||||
}
|
||||
|
||||
SqliteCommand command = new SqliteCommand();
|
||||
command.Connection = Globals.db;
|
||||
command.CommandText = "DELETE FROM users WHERE login = @login";
|
||||
|
||||
SqliteParameter loginParam = new SqliteParameter("@login", login);
|
||||
command.Parameters.Add(loginParam);
|
||||
|
||||
command.ExecuteNonQuery();
|
||||
}
|
||||
public List<User> GetAllUsers()
|
||||
{
|
||||
if (User.Role != UserRoles.ADMIN)
|
||||
{
|
||||
throw new Exception("Недостаточно прав!");
|
||||
}
|
||||
|
||||
SqliteCommand command = new SqliteCommand();
|
||||
command.Connection = Globals.db;
|
||||
command.CommandText = "SELECT id, login, role_id FROM users";
|
||||
|
||||
SqliteDataReader reader = command.ExecuteReader();
|
||||
|
||||
List<User> users = new List<User>();
|
||||
|
||||
while (reader.Read())
|
||||
{
|
||||
users.Add(new User(reader.GetInt32(0), reader.GetString(1), (UserRoles)reader.GetInt32(2)));
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
125
AuthorizationForm.Designer.cs
generated
Normal file
125
AuthorizationForm.Designer.cs
generated
Normal file
@ -0,0 +1,125 @@
|
||||
namespace AwesomeEmailExtractor
|
||||
{
|
||||
partial class AuthorizationForm
|
||||
{
|
||||
/// <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.loginButton = new System.Windows.Forms.Button();
|
||||
this.registerButton = new System.Windows.Forms.Button();
|
||||
this.entryLogin = new System.Windows.Forms.TextBox();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.entryPassword = new System.Windows.Forms.TextBox();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// loginButton
|
||||
//
|
||||
this.loginButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
|
||||
this.loginButton.Location = new System.Drawing.Point(12, 127);
|
||||
this.loginButton.Name = "loginButton";
|
||||
this.loginButton.Size = new System.Drawing.Size(293, 23);
|
||||
this.loginButton.TabIndex = 0;
|
||||
this.loginButton.Text = "Авторизоваться";
|
||||
this.loginButton.UseVisualStyleBackColor = true;
|
||||
this.loginButton.Click += new System.EventHandler(this.loginButton_Click);
|
||||
//
|
||||
// registerButton
|
||||
//
|
||||
this.registerButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
|
||||
this.registerButton.Location = new System.Drawing.Point(12, 156);
|
||||
this.registerButton.Name = "registerButton";
|
||||
this.registerButton.Size = new System.Drawing.Size(293, 23);
|
||||
this.registerButton.TabIndex = 1;
|
||||
this.registerButton.Text = "Зарегистрироваться";
|
||||
this.registerButton.UseVisualStyleBackColor = true;
|
||||
this.registerButton.Click += new System.EventHandler(this.registerButton_Click);
|
||||
//
|
||||
// entryLogin
|
||||
//
|
||||
this.entryLogin.Location = new System.Drawing.Point(110, 32);
|
||||
this.entryLogin.Name = "entryLogin";
|
||||
this.entryLogin.Size = new System.Drawing.Size(195, 20);
|
||||
this.entryLogin.TabIndex = 2;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
|
||||
this.label1.Location = new System.Drawing.Point(12, 30);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(77, 25);
|
||||
this.label1.TabIndex = 3;
|
||||
this.label1.Text = "Логин:";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
|
||||
this.label2.Location = new System.Drawing.Point(12, 77);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(92, 25);
|
||||
this.label2.TabIndex = 5;
|
||||
this.label2.Text = "Пароль:";
|
||||
//
|
||||
// entryPassword
|
||||
//
|
||||
this.entryPassword.Location = new System.Drawing.Point(110, 79);
|
||||
this.entryPassword.Name = "entryPassword";
|
||||
this.entryPassword.Size = new System.Drawing.Size(195, 20);
|
||||
this.entryPassword.TabIndex = 4;
|
||||
this.entryPassword.UseSystemPasswordChar = true;
|
||||
//
|
||||
// AuthorizationForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(317, 191);
|
||||
this.Controls.Add(this.label2);
|
||||
this.Controls.Add(this.entryPassword);
|
||||
this.Controls.Add(this.label1);
|
||||
this.Controls.Add(this.entryLogin);
|
||||
this.Controls.Add(this.registerButton);
|
||||
this.Controls.Add(this.loginButton);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
||||
this.MaximizeBox = false;
|
||||
this.Name = "AuthorizationForm";
|
||||
this.Text = "Авторизоваться";
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Button loginButton;
|
||||
private System.Windows.Forms.Button registerButton;
|
||||
private System.Windows.Forms.TextBox entryLogin;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.Label label2;
|
||||
private System.Windows.Forms.TextBox entryPassword;
|
||||
}
|
||||
}
|
48
AuthorizationForm.cs
Normal file
48
AuthorizationForm.cs
Normal file
@ -0,0 +1,48 @@
|
||||
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 AuthorizationForm : Form
|
||||
{
|
||||
public AuthorizationForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void loginButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrEmpty(entryLogin.Text) || string.IsNullOrEmpty(entryPassword.Text))
|
||||
{
|
||||
MessageBox.Show("Введите логин и пароль", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
Globals.currentUser = Authorization.Login(entryLogin.Text, entryPassword.Text);
|
||||
Logs.Log(Globals.currentUser, Logs.Action.Login, new Dictionary<string, object>());
|
||||
|
||||
var mainForm = FormManager.Current.CreateForm<MainForm>();
|
||||
FormManager.Current.Navigate(this, mainForm);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void registerButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
var form = FormManager.Current.CreateForm<RegistrationForm>();
|
||||
FormManager.Current.Navigate(this, form);
|
||||
}
|
||||
}
|
||||
}
|
120
AuthorizationForm.resx
Normal file
120
AuthorizationForm.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>
|
@ -12,6 +12,8 @@
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<Deterministic>true</Deterministic>
|
||||
<NuGetPackageImportStamp>
|
||||
</NuGetPackageImportStamp>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
@ -33,8 +35,36 @@
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.Data.Sqlite, Version=5.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Microsoft.Data.Sqlite.Core.5.0.3\lib\netstandard2.0\Microsoft.Data.Sqlite.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="SQLitePCLRaw.batteries_v2, Version=2.0.4.976, Culture=neutral, PublicKeyToken=8226ea5df37bcae9, processorArchitecture=MSIL">
|
||||
<HintPath>packages\SQLitePCLRaw.bundle_e_sqlite3.2.0.4\lib\net461\SQLitePCLRaw.batteries_v2.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="SQLitePCLRaw.core, Version=2.0.4.976, Culture=neutral, PublicKeyToken=1488e028ca7ab535, processorArchitecture=MSIL">
|
||||
<HintPath>packages\SQLitePCLRaw.core.2.0.4\lib\netstandard2.0\SQLitePCLRaw.core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="SQLitePCLRaw.nativelibrary, Version=2.0.4.976, Culture=neutral, PublicKeyToken=502ed628492ab262, processorArchitecture=MSIL">
|
||||
<HintPath>packages\SQLitePCLRaw.bundle_e_sqlite3.2.0.4\lib\net461\SQLitePCLRaw.nativelibrary.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="SQLitePCLRaw.provider.dynamic_cdecl, Version=2.0.4.976, Culture=neutral, PublicKeyToken=b68184102cba0b3b, processorArchitecture=MSIL">
|
||||
<HintPath>packages\SQLitePCLRaw.provider.dynamic_cdecl.2.0.4\lib\netstandard2.0\SQLitePCLRaw.provider.dynamic_cdecl.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Buffers, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>packages\System.Buffers.4.4.0\lib\netstandard2.0\System.Buffers.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>packages\System.Memory.4.5.3\lib\netstandard2.0\System.Memory.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Numerics" />
|
||||
<Reference Include="System.Numerics.Vectors, Version=4.1.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>packages\System.Numerics.Vectors.4.4.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>packages\System.Runtime.CompilerServices.Unsafe.4.5.2\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
@ -46,7 +76,41 @@
|
||||
<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>
|
||||
</Compile>
|
||||
<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" />
|
||||
<Compile Include="HelpForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="HelpForm.Designer.cs">
|
||||
<DependentUpon>HelpForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="JournalForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="JournalForm.Designer.cs">
|
||||
<DependentUpon>JournalForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Logs.cs" />
|
||||
<Compile Include="MainForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
@ -55,6 +119,34 @@
|
||||
</Compile>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="RegistrationForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="RegistrationForm.Designer.cs">
|
||||
<DependentUpon>RegistrationForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="SettingsForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<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="HelpForm.resx">
|
||||
<DependentUpon>HelpForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="JournalForm.resx">
|
||||
<DependentUpon>JournalForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="MainForm.resx">
|
||||
<DependentUpon>MainForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
@ -67,6 +159,13 @@
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<EmbeddedResource Include="SettingsForm.resx">
|
||||
<DependentUpon>SettingsForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<None Include="packages.config" />
|
||||
<EmbeddedResource Include="RegistrationForm.resx">
|
||||
<DependentUpon>RegistrationForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
@ -81,4 +180,11 @@
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="packages\SQLitePCLRaw.lib.e_sqlite3.2.0.4\build\net461\SQLitePCLRaw.lib.e_sqlite3.targets" Condition="Exists('packages\SQLitePCLRaw.lib.e_sqlite3.2.0.4\build\net461\SQLitePCLRaw.lib.e_sqlite3.targets')" />
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
<ErrorText>Данный проект ссылается на пакеты NuGet, отсутствующие на этом компьютере. Используйте восстановление пакетов NuGet, чтобы скачать их. Дополнительную информацию см. по адресу: http://go.microsoft.com/fwlink/?LinkID=322105. Отсутствует следующий файл: {0}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('packages\SQLitePCLRaw.lib.e_sqlite3.2.0.4\build\net461\SQLitePCLRaw.lib.e_sqlite3.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\SQLitePCLRaw.lib.e_sqlite3.2.0.4\build\net461\SQLitePCLRaw.lib.e_sqlite3.targets'))" />
|
||||
</Target>
|
||||
</Project>
|
155
EditUserForm.Designer.cs
generated
Normal file
155
EditUserForm.Designer.cs
generated
Normal file
@ -0,0 +1,155 @@
|
||||
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.MaximizeBox = false;
|
||||
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;
|
||||
}
|
||||
}
|
69
EditUserForm.cs
Normal file
69
EditUserForm.cs
Normal file
@ -0,0 +1,69 @@
|
||||
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)
|
||||
{
|
||||
if (loginTextBox.Text.Length == 0)
|
||||
{
|
||||
MessageBox.Show("Логин не может быть пустым!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
AdminUtils adminUtils = new AdminUtils(Globals.currentUser);
|
||||
|
||||
User editedUser = new User(User.ID, loginTextBox.Text, (UserRoles)roleComboBox.SelectedIndex);
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
if (passwordTextBox.Text != "")
|
||||
{
|
||||
adminUtils.editUser(editedUser, passwordTextBox.Text);
|
||||
}
|
||||
else
|
||||
{
|
||||
adminUtils.editUser(editedUser);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
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>
|
@ -12,7 +12,7 @@ namespace AwesomeEmailExtractor
|
||||
public static int Extract(string inputText, out List<string> uniqueEmails)
|
||||
{
|
||||
// Регулярное выражение для поиска почтовых адресов
|
||||
string pattern = @"\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b";
|
||||
string pattern = "(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|\"(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21\\x23-\\x5b\\x5d-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])*\")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21-\\x5a\\x53-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])+)\\])";
|
||||
|
||||
// Находим каждый почтовый адрес в тексте
|
||||
var matches = Regex.Matches(inputText, pattern, RegexOptions.IgnoreCase);
|
||||
|
46
FormManager.cs
Normal file
46
FormManager.cs
Normal file
@ -0,0 +1,46 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace AwesomeEmailExtractor
|
||||
{
|
||||
public class FormManager : ApplicationContext
|
||||
{
|
||||
private void onFormClosed(object sender, EventArgs e)
|
||||
{
|
||||
if (Application.OpenForms.Count == 0)
|
||||
{
|
||||
if (((Form)sender).Name == currentForm)
|
||||
ExitThread();
|
||||
}
|
||||
}
|
||||
|
||||
public T CreateForm<T>() where T : Form, new()
|
||||
{
|
||||
var ret = new T();
|
||||
ret.FormClosed += onFormClosed;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public void Navigate(Form from, Form to)
|
||||
{
|
||||
currentForm = to.Name;
|
||||
from.Close();
|
||||
to.Show();
|
||||
}
|
||||
|
||||
public string currentForm = "AuthorizationForm";
|
||||
|
||||
private static Lazy<FormManager> _current = new Lazy<FormManager>();
|
||||
public static FormManager Current => _current.Value;
|
||||
|
||||
public FormManager()
|
||||
{
|
||||
var authorization = CreateForm<AuthorizationForm>();
|
||||
authorization.Show();
|
||||
}
|
||||
}
|
||||
}
|
124
Globals.cs
Normal file
124
Globals.cs
Normal file
@ -0,0 +1,124 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.IO;
|
||||
using Microsoft.Data.Sqlite;
|
||||
|
||||
|
||||
namespace AwesomeEmailExtractor
|
||||
{
|
||||
internal class Globals
|
||||
{
|
||||
// Getter and setter for SQLite database connection
|
||||
public static SqliteConnection db { get; set; }
|
||||
public static SqliteConnection logsDb { get; set; }
|
||||
|
||||
public static User currentUser { get; set; }
|
||||
|
||||
public static string getAppDirectory()
|
||||
{
|
||||
return Path.Combine(
|
||||
Environment.GetFolderPath(
|
||||
Environment.SpecialFolder.ApplicationData
|
||||
),
|
||||
"AwesomeEmailExtractor"
|
||||
);
|
||||
}
|
||||
|
||||
public static string getAppDatabase()
|
||||
{
|
||||
return Path.Combine(
|
||||
getAppDirectory(),
|
||||
"database.db"
|
||||
);
|
||||
}
|
||||
|
||||
public static string getDefaultPathAppLogs()
|
||||
{
|
||||
return Path.Combine(
|
||||
getAppDirectory(),
|
||||
"logs.db"
|
||||
);
|
||||
}
|
||||
|
||||
public static string getPathAppLogs()
|
||||
{
|
||||
SqliteCommand command = new SqliteCommand();
|
||||
command.Connection = db;
|
||||
command.CommandText = "SELECT logs_db_path FROM app_settings LIMIT 1";
|
||||
|
||||
SqliteDataReader reader = command.ExecuteReader();
|
||||
while (reader.Read())
|
||||
{
|
||||
return reader["logs_db_path"].ToString();
|
||||
}
|
||||
|
||||
return getDefaultPathAppLogs();
|
||||
}
|
||||
|
||||
public static void CreateLogsTable()
|
||||
{
|
||||
SqliteCommand command = new SqliteCommand();
|
||||
command.Connection = logsDb;
|
||||
|
||||
command.CommandText = "CREATE TABLE IF NOT EXISTS logs_actions (id INTEGER PRIMARY KEY, name TEXT NOT NULL)";
|
||||
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);";
|
||||
command.ExecuteNonQuery();
|
||||
|
||||
command.CommandText = "ATTACH DATABASE @dbpath AS appDB";
|
||||
command.Parameters.AddWithValue("@dbpath", Globals.getAppDatabase());
|
||||
command.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
public static void CreateTables()
|
||||
{
|
||||
SqliteCommand command = new SqliteCommand();
|
||||
command.Connection = db;
|
||||
|
||||
// Создать таблицу для хранения ролей
|
||||
command.CommandText = "CREATE TABLE IF NOT EXISTS roles (id INTEGER PRIMARY KEY, name TEXT NOT NULL);";
|
||||
command.ExecuteNonQuery();
|
||||
|
||||
// Добавить роли
|
||||
command.CommandText = "INSERT OR IGNORE INTO roles (id, name) VALUES (0, 'Обычный'), (1, 'Администратор');";
|
||||
command.ExecuteNonQuery();
|
||||
|
||||
// Создать таблицу для хранения настроек (знаю, так плохо, но сойдет)
|
||||
command.CommandText = "CREATE TABLE IF NOT EXISTS app_settings (logs_db_path TEXT);";
|
||||
command.ExecuteNonQuery();
|
||||
|
||||
// Создать таблицу для хранения пользователей
|
||||
command.CommandText = "CREATE TABLE IF NOT EXISTS users (id INTEGER PRIMARY KEY AUTOINCREMENT, login TEXT NOT NULL UNIQUE, password TEXT NOT NULL, role_id INTEGER NOT NULL, FOREIGN KEY(role_id) REFERENCES roles(id));";
|
||||
command.ExecuteNonQuery();
|
||||
|
||||
// Если таблица пуста - добавить пользователя по умолчанию
|
||||
command.CommandText = "SELECT COUNT(*) FROM users";
|
||||
|
||||
if (Convert.ToInt32(command.ExecuteScalar()) == 0)
|
||||
{
|
||||
command.CommandText = "INSERT INTO users (login, password, role_id) VALUES ('admin', @password, 1);";
|
||||
|
||||
SqliteParameter passwordParam = new SqliteParameter("@password", Authorization.EncryptPassword("admin"));
|
||||
command.Parameters.Add(passwordParam);
|
||||
command.ExecuteNonQuery();
|
||||
command.Parameters.Clear();
|
||||
}
|
||||
|
||||
command.CommandText = "SELECT COUNT(*) FROM app_settings";
|
||||
|
||||
if (Convert.ToInt32(command.ExecuteScalar()) == 0)
|
||||
{
|
||||
command.CommandText = "INSERT INTO app_settings (logs_db_path) VALUES (@logs_db_path);";
|
||||
|
||||
SqliteParameter logsDbPathParam = new SqliteParameter("@logs_db_path", getDefaultPathAppLogs());
|
||||
command.Parameters.Add(logsDbPathParam);
|
||||
command.ExecuteNonQuery();
|
||||
command.Parameters.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
76
HelpForm.Designer.cs
generated
Normal file
76
HelpForm.Designer.cs
generated
Normal file
@ -0,0 +1,76 @@
|
||||
namespace AwesomeEmailExtractor
|
||||
{
|
||||
partial class HelpForm
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(HelpForm));
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.panel1 = new System.Windows.Forms.Panel();
|
||||
this.panel1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
|
||||
this.label1.Location = new System.Drawing.Point(3, 9);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Padding = new System.Windows.Forms.Padding(5);
|
||||
this.label1.Size = new System.Drawing.Size(649, 358);
|
||||
this.label1.TabIndex = 0;
|
||||
this.label1.Text = resources.GetString("label1.Text");
|
||||
//
|
||||
// panel1
|
||||
//
|
||||
this.panel1.Controls.Add(this.label1);
|
||||
this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.panel1.Location = new System.Drawing.Point(0, 0);
|
||||
this.panel1.Name = "panel1";
|
||||
this.panel1.Size = new System.Drawing.Size(652, 393);
|
||||
this.panel1.TabIndex = 1;
|
||||
//
|
||||
// HelpForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(652, 393);
|
||||
this.Controls.Add(this.panel1);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
||||
this.MaximizeBox = false;
|
||||
this.Name = "HelpForm";
|
||||
this.Text = "Справка";
|
||||
this.panel1.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.Panel panel1;
|
||||
}
|
||||
}
|
20
HelpForm.cs
Normal file
20
HelpForm.cs
Normal file
@ -0,0 +1,20 @@
|
||||
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 HelpForm : Form
|
||||
{
|
||||
public HelpForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
128
HelpForm.resx
Normal file
128
HelpForm.resx
Normal file
@ -0,0 +1,128 @@
|
||||
<?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>
|
||||
<data name="label1.Text" xml:space="preserve">
|
||||
<value>Программный продукт AwesomeEmailExtractor будет востребован в тех случаях, когда необходимо из текста получить список уникальных e-mail-ов.
|
||||
Для того чтобы получить список, необходимо ввести исходный текст и нажать кнопку "Выполнить". После этого, в правой части окна появится список из уникальных e-mail-ов.
|
||||
При необходимости можно экспортировать результат выполнения программы с помощью меню "Файл" > "Экспортировать результат".
|
||||
Во время своей работы программа ведет журнал активности пользователя. Это может быть полезно, чтобы узнать, какие до этого были результаты выполнения. "Аккаунт" -> "Журнал".
|
||||
Для смены пароля или удаления аккаунта необходимо выбрать в меню "Аккаунт" -> "Настройки".
|
||||
Для администраторов доступны некоторые особые возможности, их можно найти в меню "Аккаунт" -> "Администрирование".</value>
|
||||
</data>
|
||||
</root>
|
175
JournalForm.Designer.cs
generated
Normal file
175
JournalForm.Designer.cs
generated
Normal file
@ -0,0 +1,175 @@
|
||||
namespace AwesomeEmailExtractor
|
||||
{
|
||||
partial class JournalForm
|
||||
{
|
||||
/// <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.dataGridView1 = new System.Windows.Forms.DataGridView();
|
||||
this.panel1 = new System.Windows.Forms.Panel();
|
||||
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.label3 = new System.Windows.Forms.Label();
|
||||
this.richTextBox1 = new System.Windows.Forms.RichTextBox();
|
||||
this.dataLabel = new System.Windows.Forms.Label();
|
||||
this.actionLabel = new System.Windows.Forms.Label();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
|
||||
this.panel1.SuspendLayout();
|
||||
this.tableLayoutPanel1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// dataGridView1
|
||||
//
|
||||
this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.dataGridView1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.dataGridView1.Location = new System.Drawing.Point(10, 10);
|
||||
this.dataGridView1.MultiSelect = false;
|
||||
this.dataGridView1.Name = "dataGridView1";
|
||||
this.dataGridView1.ReadOnly = true;
|
||||
this.dataGridView1.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
|
||||
this.dataGridView1.Size = new System.Drawing.Size(414, 451);
|
||||
this.dataGridView1.TabIndex = 0;
|
||||
this.dataGridView1.SelectionChanged += new System.EventHandler(this.dataGridView1_SelectionChanged);
|
||||
//
|
||||
// panel1
|
||||
//
|
||||
this.panel1.Controls.Add(this.tableLayoutPanel1);
|
||||
this.panel1.Dock = System.Windows.Forms.DockStyle.Right;
|
||||
this.panel1.Location = new System.Drawing.Point(424, 10);
|
||||
this.panel1.Name = "panel1";
|
||||
this.panel1.Size = new System.Drawing.Size(458, 451);
|
||||
this.panel1.TabIndex = 1;
|
||||
//
|
||||
// tableLayoutPanel1
|
||||
//
|
||||
this.tableLayoutPanel1.ColumnCount = 2;
|
||||
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 29.2876F));
|
||||
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 70.7124F));
|
||||
this.tableLayoutPanel1.Controls.Add(this.label1, 0, 0);
|
||||
this.tableLayoutPanel1.Controls.Add(this.label3, 0, 2);
|
||||
this.tableLayoutPanel1.Controls.Add(this.richTextBox1, 1, 2);
|
||||
this.tableLayoutPanel1.Controls.Add(this.dataLabel, 1, 0);
|
||||
this.tableLayoutPanel1.Controls.Add(this.actionLabel, 1, 1);
|
||||
this.tableLayoutPanel1.Controls.Add(this.label2, 0, 1);
|
||||
this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0);
|
||||
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
|
||||
this.tableLayoutPanel1.Padding = new System.Windows.Forms.Padding(10);
|
||||
this.tableLayoutPanel1.RowCount = 3;
|
||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
|
||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
|
||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||
this.tableLayoutPanel1.Size = new System.Drawing.Size(458, 451);
|
||||
this.tableLayoutPanel1.TabIndex = 8;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(13, 10);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(36, 13);
|
||||
this.label1.TabIndex = 2;
|
||||
this.label1.Text = "Дата:";
|
||||
//
|
||||
// label3
|
||||
//
|
||||
this.label3.AutoSize = true;
|
||||
this.label3.Location = new System.Drawing.Point(13, 50);
|
||||
this.label3.Name = "label3";
|
||||
this.label3.Size = new System.Drawing.Size(68, 13);
|
||||
this.label3.TabIndex = 4;
|
||||
this.label3.Text = "Сообщение:";
|
||||
//
|
||||
// richTextBox1
|
||||
//
|
||||
this.richTextBox1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.richTextBox1.Location = new System.Drawing.Point(141, 53);
|
||||
this.richTextBox1.Name = "richTextBox1";
|
||||
this.richTextBox1.ReadOnly = true;
|
||||
this.richTextBox1.Size = new System.Drawing.Size(304, 385);
|
||||
this.richTextBox1.TabIndex = 7;
|
||||
this.richTextBox1.Text = "";
|
||||
//
|
||||
// dataLabel
|
||||
//
|
||||
this.dataLabel.AutoSize = true;
|
||||
this.dataLabel.Location = new System.Drawing.Point(141, 10);
|
||||
this.dataLabel.Name = "dataLabel";
|
||||
this.dataLabel.Size = new System.Drawing.Size(54, 13);
|
||||
this.dataLabel.TabIndex = 5;
|
||||
this.dataLabel.Text = "dataLabel";
|
||||
//
|
||||
// actionLabel
|
||||
//
|
||||
this.actionLabel.AutoSize = true;
|
||||
this.actionLabel.Location = new System.Drawing.Point(141, 30);
|
||||
this.actionLabel.Name = "actionLabel";
|
||||
this.actionLabel.Size = new System.Drawing.Size(62, 13);
|
||||
this.actionLabel.TabIndex = 6;
|
||||
this.actionLabel.Text = "actionLabel";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(13, 30);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(54, 13);
|
||||
this.label2.TabIndex = 3;
|
||||
this.label2.Text = "Событие:";
|
||||
//
|
||||
// JournalForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(892, 471);
|
||||
this.Controls.Add(this.dataGridView1);
|
||||
this.Controls.Add(this.panel1);
|
||||
this.Name = "JournalForm";
|
||||
this.Padding = new System.Windows.Forms.Padding(10);
|
||||
this.Text = "Журнал";
|
||||
this.Load += new System.EventHandler(this.JournalForm_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
|
||||
this.panel1.ResumeLayout(false);
|
||||
this.tableLayoutPanel1.ResumeLayout(false);
|
||||
this.tableLayoutPanel1.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.DataGridView dataGridView1;
|
||||
private System.Windows.Forms.Panel panel1;
|
||||
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.Label label3;
|
||||
private System.Windows.Forms.RichTextBox richTextBox1;
|
||||
private System.Windows.Forms.Label dataLabel;
|
||||
private System.Windows.Forms.Label actionLabel;
|
||||
private System.Windows.Forms.Label label2;
|
||||
}
|
||||
}
|
53
JournalForm.cs
Normal file
53
JournalForm.cs
Normal file
@ -0,0 +1,53 @@
|
||||
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 JournalForm : Form
|
||||
{
|
||||
public JournalForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void JournalForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
var logs = Logs.GetLogsList(Globals.currentUser);
|
||||
|
||||
dataGridView1.DataSource = logs;
|
||||
|
||||
List<string> columns = new List<string>() { "Дата", "Событие", "Сообщение" };
|
||||
|
||||
dataGridView1.Columns["id"].Visible = false;
|
||||
dataGridView1.Columns["user"].Visible = false;
|
||||
|
||||
for (int i = 0; i < columns.Count; i++)
|
||||
{
|
||||
dataGridView1.Columns[i + 2].HeaderText = columns[i];
|
||||
};
|
||||
|
||||
dataGridView1.Columns["message"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
|
||||
private void dataGridView1_SelectionChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView1.SelectedRows.Count > 0)
|
||||
{
|
||||
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 = "";
|
||||
richTextBox1.Text = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
120
JournalForm.resx
Normal file
120
JournalForm.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>
|
180
Logs.cs
Normal file
180
Logs.cs
Normal file
@ -0,0 +1,180 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Data.Sqlite;
|
||||
|
||||
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
|
||||
{
|
||||
Execute,
|
||||
Login,
|
||||
Registration,
|
||||
DeleteAccount,
|
||||
ChangePassword
|
||||
}
|
||||
|
||||
public static void Log(User user, Action action, Dictionary<string, object> options)
|
||||
{
|
||||
SqliteCommand command = new SqliteCommand();
|
||||
command.Connection = Globals.logsDb;
|
||||
|
||||
command.CommandText = "INSERT INTO logs (user_id, date, action, message) VALUES (@user_id, strftime('%Y-%m-%d %H:%M:%S', datetime('now')), @action, @message)";
|
||||
|
||||
command.Parameters.AddWithValue("@user_id", user.ID);
|
||||
command.Parameters.AddWithValue("@action", action);
|
||||
command.Parameters.AddWithValue("@message", GetLogMessage(action, options));
|
||||
|
||||
command.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
public static List<LogData> GetLogsList(User user)
|
||||
{
|
||||
SqliteDataReader reader = GetLogsDataReader(user);
|
||||
|
||||
List<LogData> logs = new List<LogData>();
|
||||
while (reader.Read())
|
||||
{
|
||||
logs.Add(new LogData()
|
||||
{
|
||||
ID = Convert.ToInt32(reader["id"]),
|
||||
User = user,
|
||||
Date = Convert.ToString(reader["date"]),
|
||||
Action = (Action)Convert.ToInt32(reader["action"]),
|
||||
Message = Convert.ToString(reader["message"]),
|
||||
});
|
||||
}
|
||||
|
||||
reader.Close();
|
||||
|
||||
return logs;
|
||||
}
|
||||
|
||||
private static SqliteDataReader GetLogsDataReader(User user)
|
||||
{
|
||||
if (Globals.currentUser.ID != user.ID && Globals.currentUser.Role != UserRoles.ADMIN)
|
||||
{
|
||||
throw new Exception("У вас нет прав на просмотр логов");
|
||||
}
|
||||
|
||||
SqliteCommand command = new SqliteCommand();
|
||||
command.Connection = Globals.logsDb;
|
||||
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();
|
||||
}
|
||||
|
||||
public static List<LogData> GetLogsList()
|
||||
{
|
||||
if (Globals.currentUser.Role != UserRoles.ADMIN)
|
||||
{
|
||||
throw new Exception("У вас нет прав на просмотр логов");
|
||||
}
|
||||
|
||||
SqliteCommand command = new SqliteCommand();
|
||||
command.Connection = Globals.logsDb;
|
||||
|
||||
command.CommandText = @"
|
||||
SELECT
|
||||
logs.id,
|
||||
user_id,
|
||||
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;";
|
||||
|
||||
SqliteDataReader reader = command.ExecuteReader();
|
||||
|
||||
List<LogData> logs = new List<LogData>();
|
||||
while (reader.Read())
|
||||
{
|
||||
logs.Add(new LogData()
|
||||
{
|
||||
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"])
|
||||
});
|
||||
}
|
||||
|
||||
return logs;
|
||||
}
|
||||
|
||||
public static string GetLogMessage(Action action, Dictionary<string, object> options)
|
||||
{
|
||||
if (action == Action.Execute)
|
||||
{
|
||||
string sourceText = (string)options["sourceText"];
|
||||
int count = (int)options["count"];
|
||||
List<string> uniqueEmails = options["uniqueEmails"] as List<string>;
|
||||
|
||||
|
||||
return $"Пользователь выполнил поиск email-ов c таким исходным текстом: [ {sourceText}. ]\n" +
|
||||
$"Найдено {count} email-ов.\n" +
|
||||
$"Список уникальных: {String.Join(", ", uniqueEmails)}.";
|
||||
}
|
||||
if (action == Action.Login)
|
||||
{
|
||||
return "Пользователь вошел в систему.";
|
||||
}
|
||||
if (action == Action.Registration)
|
||||
{
|
||||
return "Пользователь зарегистрировался в системе.";
|
||||
}
|
||||
if (action == Action.DeleteAccount)
|
||||
{
|
||||
return "Пользователь удалил аккаунт из системы.";
|
||||
}
|
||||
if (action == Action.ChangePassword)
|
||||
{
|
||||
return "Пользователь сменил пароль.";
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
89
MainForm.Designer.cs
generated
89
MainForm.Designer.cs
generated
@ -36,7 +36,14 @@
|
||||
this.toolStripStatusLabel = new System.Windows.Forms.ToolStripStatusLabel();
|
||||
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
|
||||
this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.exportResultToolStripMenuItem = 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.importToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.resultStatusStrip.SuspendLayout();
|
||||
this.menuStrip1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
@ -48,12 +55,9 @@
|
||||
this.uniqueListBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
|
||||
this.uniqueListBox.FormattingEnabled = true;
|
||||
this.uniqueListBox.ItemHeight = 20;
|
||||
this.uniqueListBox.Items.AddRange(new object[] {
|
||||
"alice@example.com",
|
||||
"bob@example.com"});
|
||||
this.uniqueListBox.Location = new System.Drawing.Point(424, 32);
|
||||
this.uniqueListBox.Name = "uniqueListBox";
|
||||
this.uniqueListBox.Size = new System.Drawing.Size(225, 304);
|
||||
this.uniqueListBox.Size = new System.Drawing.Size(225, 324);
|
||||
this.uniqueListBox.TabIndex = 0;
|
||||
//
|
||||
// sourceRichTextBox
|
||||
@ -66,8 +70,7 @@
|
||||
this.sourceRichTextBox.Name = "sourceRichTextBox";
|
||||
this.sourceRichTextBox.Size = new System.Drawing.Size(406, 288);
|
||||
this.sourceRichTextBox.TabIndex = 1;
|
||||
this.sourceRichTextBox.Text = "Алиса (alice@example.com) послылает Бобу (bob@example.com) сообщение.\nАдрес bob@e" +
|
||||
"xample.com Алиса нашла на сайте example.com";
|
||||
this.sourceRichTextBox.Text = "";
|
||||
//
|
||||
// executeButton
|
||||
//
|
||||
@ -89,9 +92,9 @@
|
||||
this.resultCountLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
|
||||
this.resultCountLabel.Location = new System.Drawing.Point(12, 323);
|
||||
this.resultCountLabel.Name = "resultCountLabel";
|
||||
this.resultCountLabel.Size = new System.Drawing.Size(303, 24);
|
||||
this.resultCountLabel.Size = new System.Drawing.Size(363, 24);
|
||||
this.resultCountLabel.TabIndex = 3;
|
||||
this.resultCountLabel.Text = "Количество e-mail-ов в тексте: 3";
|
||||
this.resultCountLabel.Text = "Введите текст и нажмите \"Выполнить\"";
|
||||
//
|
||||
// resultStatusStrip
|
||||
//
|
||||
@ -105,13 +108,13 @@
|
||||
// toolStripStatusLabel
|
||||
//
|
||||
this.toolStripStatusLabel.Name = "toolStripStatusLabel";
|
||||
this.toolStripStatusLabel.Size = new System.Drawing.Size(42, 17);
|
||||
this.toolStripStatusLabel.Text = "Успех!";
|
||||
this.toolStripStatusLabel.Size = new System.Drawing.Size(0, 17);
|
||||
//
|
||||
// menuStrip1
|
||||
//
|
||||
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.fileToolStripMenuItem,
|
||||
this.аккаунтToolStripMenuItem,
|
||||
this.helpToolStripMenuItem});
|
||||
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
|
||||
this.menuStrip1.Name = "menuStrip1";
|
||||
@ -121,15 +124,72 @@
|
||||
//
|
||||
// fileToolStripMenuItem
|
||||
//
|
||||
this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.exportResultToolStripMenuItem,
|
||||
this.importToolStripMenuItem});
|
||||
this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
|
||||
this.fileToolStripMenuItem.Size = new System.Drawing.Size(48, 20);
|
||||
this.fileToolStripMenuItem.Text = "Файл";
|
||||
//
|
||||
// exportResultToolStripMenuItem
|
||||
//
|
||||
this.exportResultToolStripMenuItem.Name = "exportResultToolStripMenuItem";
|
||||
this.exportResultToolStripMenuItem.Size = new System.Drawing.Size(219, 22);
|
||||
this.exportResultToolStripMenuItem.Text = "Экспортировать результат";
|
||||
this.exportResultToolStripMenuItem.Click += new System.EventHandler(this.exportResultToolStripMenuItem_Click);
|
||||
//
|
||||
// аккаунтToolStripMenuItem
|
||||
//
|
||||
this.аккаунтToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.journalToolStripMenuItem,
|
||||
this.settingsToolStripMenuItem,
|
||||
this.administrationToolStripMenuItem,
|
||||
this.exitToolStripMenuItem});
|
||||
this.аккаунтToolStripMenuItem.Name = "аккаунтToolStripMenuItem";
|
||||
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";
|
||||
this.settingsToolStripMenuItem.Size = new System.Drawing.Size(189, 22);
|
||||
this.settingsToolStripMenuItem.Text = "Настройки";
|
||||
this.settingsToolStripMenuItem.Click += new System.EventHandler(this.settingsToolStripMenuItem_Click);
|
||||
//
|
||||
// administrationToolStripMenuItem
|
||||
//
|
||||
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
|
||||
//
|
||||
this.exitToolStripMenuItem.Name = "exitToolStripMenuItem";
|
||||
this.exitToolStripMenuItem.Size = new System.Drawing.Size(189, 22);
|
||||
this.exitToolStripMenuItem.Text = "Выход";
|
||||
this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click);
|
||||
//
|
||||
// helpToolStripMenuItem
|
||||
//
|
||||
this.helpToolStripMenuItem.Name = "helpToolStripMenuItem";
|
||||
this.helpToolStripMenuItem.Size = new System.Drawing.Size(65, 20);
|
||||
this.helpToolStripMenuItem.Text = "Справка";
|
||||
this.helpToolStripMenuItem.Click += new System.EventHandler(this.helpToolStripMenuItem_Click);
|
||||
//
|
||||
// importToolStripMenuItem
|
||||
//
|
||||
this.importToolStripMenuItem.Name = "importToolStripMenuItem";
|
||||
this.importToolStripMenuItem.Size = new System.Drawing.Size(219, 22);
|
||||
this.importToolStripMenuItem.Text = "Импортировать файл";
|
||||
this.importToolStripMenuItem.Click += new System.EventHandler(this.importToolStripMenuItem_Click);
|
||||
//
|
||||
// MainForm
|
||||
//
|
||||
@ -145,7 +205,7 @@
|
||||
this.MainMenuStrip = this.menuStrip1;
|
||||
this.MinimumSize = new System.Drawing.Size(642, 438);
|
||||
this.Name = "MainForm";
|
||||
this.Text = "Main Form";
|
||||
this.Text = "Главное окно";
|
||||
this.resultStatusStrip.ResumeLayout(false);
|
||||
this.resultStatusStrip.PerformLayout();
|
||||
this.menuStrip1.ResumeLayout(false);
|
||||
@ -166,6 +226,13 @@
|
||||
private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem helpToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel;
|
||||
private System.Windows.Forms.ToolStripMenuItem аккаунтToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem settingsToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem administrationToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem journalToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem exportResultToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem importToolStripMenuItem;
|
||||
}
|
||||
}
|
||||
|
||||
|
104
MainForm.cs
104
MainForm.cs
@ -12,31 +12,123 @@ namespace AwesomeEmailExtractor
|
||||
{
|
||||
public partial class MainForm : Form
|
||||
{
|
||||
public int count;
|
||||
public List<string> uniqueEmails;
|
||||
|
||||
public MainForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
administrationToolStripMenuItem.Enabled = Globals.currentUser.Role == UserRoles.ADMIN;
|
||||
}
|
||||
|
||||
private void executeButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
// Получаем исходный текст из sourceRichTextBox
|
||||
string sourceText = sourceRichTextBox.Text;
|
||||
|
||||
if (sourceText.Length == 0)
|
||||
{
|
||||
MessageBox.Show("Введите текст в поле исходного текста", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
// Чистим предыдущий результат
|
||||
toolStripStatusLabel.Text = "";
|
||||
resultCountLabel.Text = "";
|
||||
uniqueListBox.DataSource = null;
|
||||
|
||||
// Объявляем список уникальных e-mail-ов
|
||||
List<string> uniqueEmails = new List<string>();
|
||||
|
||||
// Получаем исходный текст из sourceRichTextBox
|
||||
string sourceText = sourceRichTextBox.Text;
|
||||
uniqueEmails = new List<string>();
|
||||
|
||||
// Вызываем метод для извлечения e-mail-ов
|
||||
int count = ExtactEmailsAlgorithm.Extract(sourceText, out uniqueEmails);
|
||||
count = ExtactEmailsAlgorithm.Extract(sourceText, out uniqueEmails);
|
||||
|
||||
// Выводим результат
|
||||
toolStripStatusLabel.Text = "Успех!";
|
||||
resultCountLabel.Text = $"Количество e-mail-ов в тексте: {count}";
|
||||
uniqueListBox.DataSource = uniqueEmails;
|
||||
|
||||
Logs.Log(
|
||||
Globals.currentUser,
|
||||
Logs.Action.Execute,
|
||||
new Dictionary<string, object>() {
|
||||
{ "sourceText", sourceText },
|
||||
{ "count", count },
|
||||
{ "uniqueEmails", uniqueEmails }
|
||||
});
|
||||
}
|
||||
|
||||
private void settingsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
SettingsForm settingsForm = FormManager.Current.CreateForm<SettingsForm>();
|
||||
settingsForm.ShowDialog(this);
|
||||
}
|
||||
|
||||
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
Globals.currentUser = null;
|
||||
AuthorizationForm authorization = FormManager.Current.CreateForm<AuthorizationForm>();
|
||||
FormManager.Current.Navigate(this, authorization);
|
||||
}
|
||||
|
||||
private void journalToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
private void exportResultToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
// Показать окно с выбором файла
|
||||
SaveFileDialog saveFileDialog = new SaveFileDialog();
|
||||
saveFileDialog.Filter = "Текстовый файл (*.txt)|*.txt";
|
||||
saveFileDialog.FileName = "Результат.txt";
|
||||
|
||||
var res = saveFileDialog.ShowDialog();
|
||||
|
||||
|
||||
// Сохранить результат в файл
|
||||
if (res == DialogResult.OK)
|
||||
{
|
||||
string fileName = saveFileDialog.FileName;
|
||||
string resultText = $"Количество e-mail-ов в тексте: {count}\nСписок уникальных e-mail-ов:\n{string.Join("\n", uniqueEmails)}";
|
||||
|
||||
System.IO.File.WriteAllText(fileName, resultText);
|
||||
|
||||
MessageBox.Show("E-mail-ы успешно сохранены в файл", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
|
||||
private void helpToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
HelpForm helpForm = FormManager.Current.CreateForm<HelpForm>();
|
||||
helpForm.ShowDialog(this);
|
||||
}
|
||||
|
||||
private void importToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
// Показать окно с выбором файла
|
||||
OpenFileDialog openFileDialog = new OpenFileDialog();
|
||||
openFileDialog.Filter = "Текстовый файл (*.txt)|*.txt";
|
||||
|
||||
var res = openFileDialog.ShowDialog();
|
||||
|
||||
// Загрузить текст из файла
|
||||
if (res == DialogResult.OK)
|
||||
{
|
||||
string fileName = openFileDialog.FileName;
|
||||
string sourceText = System.IO.File.ReadAllText(fileName);
|
||||
|
||||
sourceRichTextBox.Text = sourceText;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
31
Program.cs
31
Program.cs
@ -3,6 +3,8 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using System.IO;
|
||||
using Microsoft.Data.Sqlite;
|
||||
|
||||
namespace AwesomeEmailExtractor
|
||||
{
|
||||
@ -14,9 +16,36 @@ namespace AwesomeEmailExtractor
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
preMain();
|
||||
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Application.Run(new MainForm());
|
||||
Application.Run(FormManager.Current);
|
||||
|
||||
postMain();
|
||||
}
|
||||
|
||||
static void preMain()
|
||||
{
|
||||
if (!Directory.Exists(Globals.getAppDirectory()))
|
||||
{
|
||||
Directory.CreateDirectory(Globals.getAppDirectory());
|
||||
}
|
||||
|
||||
Globals.db = new SqliteConnection("Data Source=" + Globals.getAppDatabase());
|
||||
Globals.db.Open();
|
||||
|
||||
Globals.CreateTables();
|
||||
|
||||
Globals.logsDb = new SqliteConnection("Data Source=" + Globals.getPathAppLogs());
|
||||
Globals.logsDb.Open();
|
||||
|
||||
Globals.CreateLogsTable();
|
||||
}
|
||||
|
||||
static void postMain()
|
||||
{
|
||||
Globals.db.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
25
README.md
25
README.md
@ -1 +1,24 @@
|
||||
# awesome-email-extractor
|
||||
# Awesome Email Extractor
|
||||
|
||||
## О программе
|
||||
|
||||
Смотри на [wiki](https://github.com/PI20v/awesome-email-extractor/wiki/%D0%9E-%D0%BF%D1%80%D0%BE%D0%B3%D1%80%D0%B0%D0%BC%D0%BC%D0%B5).
|
||||
|
||||
## Как скачать и запустить
|
||||
|
||||
### Для пользователей
|
||||
|
||||
1. Скачать архив с нужной версией из раздела [Releases](https://github.com/PI20v/awesome-email-extractor/releases);
|
||||
2. Распаковать в удобном месте;
|
||||
3. Запустить `AwesomeEmailExtractor.exe`.
|
||||
|
||||
> Аккаунт администратора по умолчанию - `admin:admin`
|
||||
|
||||
### Для разработчиков
|
||||
|
||||
1. Скачать репозиторий;
|
||||
2. Открыть `AwesomeEmailExtractor.sln` в Visual Studio 2022.
|
||||
|
||||
## Лицензия
|
||||
|
||||
Распростроняется под MIT License. Дополнительную информацию см. в `LICENSE.txt`.
|
||||
|
163
RegistrationForm.Designer.cs
generated
Normal file
163
RegistrationForm.Designer.cs
generated
Normal file
@ -0,0 +1,163 @@
|
||||
namespace AwesomeEmailExtractor
|
||||
{
|
||||
partial class RegistrationForm
|
||||
{
|
||||
/// <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.label2 = new System.Windows.Forms.Label();
|
||||
this.entryPassword = new System.Windows.Forms.TextBox();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.entryLogin = new System.Windows.Forms.TextBox();
|
||||
this.registerButton = new System.Windows.Forms.Button();
|
||||
this.loginButton = new System.Windows.Forms.Button();
|
||||
this.label3 = new System.Windows.Forms.Label();
|
||||
this.entryRePassword = new System.Windows.Forms.TextBox();
|
||||
this.label4 = new System.Windows.Forms.Label();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
|
||||
this.label2.Location = new System.Drawing.Point(9, 52);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(92, 25);
|
||||
this.label2.TabIndex = 11;
|
||||
this.label2.Text = "Пароль:";
|
||||
//
|
||||
// entryPassword
|
||||
//
|
||||
this.entryPassword.Location = new System.Drawing.Point(183, 52);
|
||||
this.entryPassword.Name = "entryPassword";
|
||||
this.entryPassword.Size = new System.Drawing.Size(195, 20);
|
||||
this.entryPassword.TabIndex = 10;
|
||||
this.entryPassword.UseSystemPasswordChar = true;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
|
||||
this.label1.Location = new System.Drawing.Point(9, 10);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(77, 25);
|
||||
this.label1.TabIndex = 9;
|
||||
this.label1.Text = "Логин:";
|
||||
//
|
||||
// entryLogin
|
||||
//
|
||||
this.entryLogin.Location = new System.Drawing.Point(183, 10);
|
||||
this.entryLogin.Name = "entryLogin";
|
||||
this.entryLogin.Size = new System.Drawing.Size(195, 20);
|
||||
this.entryLogin.TabIndex = 8;
|
||||
//
|
||||
// registerButton
|
||||
//
|
||||
this.registerButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
|
||||
this.registerButton.Location = new System.Drawing.Point(14, 135);
|
||||
this.registerButton.Name = "registerButton";
|
||||
this.registerButton.Size = new System.Drawing.Size(364, 23);
|
||||
this.registerButton.TabIndex = 6;
|
||||
this.registerButton.Text = "Зарегистрироваться";
|
||||
this.registerButton.UseVisualStyleBackColor = true;
|
||||
this.registerButton.Click += new System.EventHandler(this.registerButton_Click);
|
||||
//
|
||||
// loginButton
|
||||
//
|
||||
this.loginButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
|
||||
this.loginButton.Location = new System.Drawing.Point(14, 187);
|
||||
this.loginButton.Name = "loginButton";
|
||||
this.loginButton.Size = new System.Drawing.Size(364, 23);
|
||||
this.loginButton.TabIndex = 7;
|
||||
this.loginButton.Text = "Авторизоваться";
|
||||
this.loginButton.UseVisualStyleBackColor = true;
|
||||
this.loginButton.Click += new System.EventHandler(this.loginButton_Click);
|
||||
//
|
||||
// label3
|
||||
//
|
||||
this.label3.AutoSize = true;
|
||||
this.label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
|
||||
this.label3.Location = new System.Drawing.Point(9, 94);
|
||||
this.label3.Name = "label3";
|
||||
this.label3.Size = new System.Drawing.Size(167, 25);
|
||||
this.label3.TabIndex = 13;
|
||||
this.label3.Text = "Повтор пароля:";
|
||||
//
|
||||
// entryRePassword
|
||||
//
|
||||
this.entryRePassword.Location = new System.Drawing.Point(183, 94);
|
||||
this.entryRePassword.Name = "entryRePassword";
|
||||
this.entryRePassword.Size = new System.Drawing.Size(195, 20);
|
||||
this.entryRePassword.TabIndex = 12;
|
||||
this.entryRePassword.UseSystemPasswordChar = true;
|
||||
//
|
||||
// label4
|
||||
//
|
||||
this.label4.AutoSize = true;
|
||||
this.label4.Font = new System.Drawing.Font("Microsoft Sans Serif", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
|
||||
this.label4.Location = new System.Drawing.Point(12, 166);
|
||||
this.label4.Name = "label4";
|
||||
this.label4.Size = new System.Drawing.Size(178, 18);
|
||||
this.label4.TabIndex = 14;
|
||||
this.label4.Text = "Уже зарегистрированы?";
|
||||
//
|
||||
// RegistrationForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(391, 222);
|
||||
this.Controls.Add(this.label4);
|
||||
this.Controls.Add(this.label3);
|
||||
this.Controls.Add(this.entryRePassword);
|
||||
this.Controls.Add(this.label2);
|
||||
this.Controls.Add(this.entryPassword);
|
||||
this.Controls.Add(this.label1);
|
||||
this.Controls.Add(this.entryLogin);
|
||||
this.Controls.Add(this.registerButton);
|
||||
this.Controls.Add(this.loginButton);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
||||
this.MaximizeBox = false;
|
||||
this.Name = "RegistrationForm";
|
||||
this.Text = "Зарегистрироваться";
|
||||
this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.RegistrationForm_FormClosed);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Label label2;
|
||||
private System.Windows.Forms.TextBox entryPassword;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.TextBox entryLogin;
|
||||
private System.Windows.Forms.Button registerButton;
|
||||
private System.Windows.Forms.Button loginButton;
|
||||
private System.Windows.Forms.Label label3;
|
||||
private System.Windows.Forms.TextBox entryRePassword;
|
||||
private System.Windows.Forms.Label label4;
|
||||
}
|
||||
}
|
59
RegistrationForm.cs
Normal file
59
RegistrationForm.cs
Normal file
@ -0,0 +1,59 @@
|
||||
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 RegistrationForm : Form
|
||||
{
|
||||
public RegistrationForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void registerButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(entryLogin.Text) || string.IsNullOrEmpty(entryPassword.Text))
|
||||
{
|
||||
MessageBox.Show("Введите логин и пароль!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!string.Equals(entryPassword.Text, entryRePassword.Text))
|
||||
{
|
||||
MessageBox.Show("Пароли не совпадают!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Globals.currentUser = Authorization.Register(entryLogin.Text, entryPassword.Text);
|
||||
Logs.Log(Globals.currentUser, Logs.Action.Registration, new Dictionary<string, object>());
|
||||
|
||||
var form = FormManager.Current.CreateForm<MainForm>();
|
||||
FormManager.Current.Navigate(this, form);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void loginButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
AuthorizationForm form = FormManager.Current.CreateForm<AuthorizationForm>();
|
||||
FormManager.Current.Navigate(this, form);
|
||||
}
|
||||
|
||||
private void RegistrationForm_FormClosed(object sender, FormClosedEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
120
RegistrationForm.resx
Normal file
120
RegistrationForm.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>
|
124
SettingsForm.Designer.cs
generated
Normal file
124
SettingsForm.Designer.cs
generated
Normal file
@ -0,0 +1,124 @@
|
||||
namespace AwesomeEmailExtractor
|
||||
{
|
||||
partial class SettingsForm
|
||||
{
|
||||
/// <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.changePasswordButton = new System.Windows.Forms.Button();
|
||||
this.entryNewPassword = new System.Windows.Forms.TextBox();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.label3 = new System.Windows.Forms.Label();
|
||||
this.entryRePassword = new System.Windows.Forms.TextBox();
|
||||
this.deleteAccountButton = new System.Windows.Forms.Button();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// changePasswordButton
|
||||
//
|
||||
this.changePasswordButton.Location = new System.Drawing.Point(34, 96);
|
||||
this.changePasswordButton.Name = "changePasswordButton";
|
||||
this.changePasswordButton.Size = new System.Drawing.Size(275, 26);
|
||||
this.changePasswordButton.TabIndex = 0;
|
||||
this.changePasswordButton.Text = "Изменить пароль";
|
||||
this.changePasswordButton.UseVisualStyleBackColor = true;
|
||||
this.changePasswordButton.Click += new System.EventHandler(this.changePasswordButton_Click);
|
||||
//
|
||||
// entryNewPassword
|
||||
//
|
||||
this.entryNewPassword.Location = new System.Drawing.Point(158, 12);
|
||||
this.entryNewPassword.Name = "entryNewPassword";
|
||||
this.entryNewPassword.Size = new System.Drawing.Size(151, 20);
|
||||
this.entryNewPassword.TabIndex = 2;
|
||||
this.entryNewPassword.UseSystemPasswordChar = true;
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
|
||||
this.label2.Location = new System.Drawing.Point(30, 12);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(118, 20);
|
||||
this.label2.TabIndex = 4;
|
||||
this.label2.Text = "Новый пароль";
|
||||
//
|
||||
// label3
|
||||
//
|
||||
this.label3.AutoSize = true;
|
||||
this.label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
|
||||
this.label3.Location = new System.Drawing.Point(30, 53);
|
||||
this.label3.Name = "label3";
|
||||
this.label3.Size = new System.Drawing.Size(125, 20);
|
||||
this.label3.TabIndex = 5;
|
||||
this.label3.Text = "Повтор пароля";
|
||||
//
|
||||
// entryRePassword
|
||||
//
|
||||
this.entryRePassword.Location = new System.Drawing.Point(158, 53);
|
||||
this.entryRePassword.Name = "entryRePassword";
|
||||
this.entryRePassword.Size = new System.Drawing.Size(151, 20);
|
||||
this.entryRePassword.TabIndex = 6;
|
||||
this.entryRePassword.UseSystemPasswordChar = true;
|
||||
//
|
||||
// deleteAccountButton
|
||||
//
|
||||
this.deleteAccountButton.Location = new System.Drawing.Point(34, 137);
|
||||
this.deleteAccountButton.Name = "deleteAccountButton";
|
||||
this.deleteAccountButton.Size = new System.Drawing.Size(275, 26);
|
||||
this.deleteAccountButton.TabIndex = 7;
|
||||
this.deleteAccountButton.Text = "Удалить аккаунт";
|
||||
this.deleteAccountButton.UseVisualStyleBackColor = true;
|
||||
this.deleteAccountButton.Click += new System.EventHandler(this.deleteAccountButton_Click);
|
||||
//
|
||||
// SettingsForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(338, 184);
|
||||
this.Controls.Add(this.deleteAccountButton);
|
||||
this.Controls.Add(this.entryRePassword);
|
||||
this.Controls.Add(this.label3);
|
||||
this.Controls.Add(this.label2);
|
||||
this.Controls.Add(this.entryNewPassword);
|
||||
this.Controls.Add(this.changePasswordButton);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
||||
this.MaximizeBox = false;
|
||||
this.Name = "SettingsForm";
|
||||
this.Text = "Настройки";
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Button changePasswordButton;
|
||||
private System.Windows.Forms.TextBox entryNewPassword;
|
||||
private System.Windows.Forms.Label label2;
|
||||
private System.Windows.Forms.Label label3;
|
||||
private System.Windows.Forms.TextBox entryRePassword;
|
||||
private System.Windows.Forms.Button deleteAccountButton;
|
||||
}
|
||||
}
|
56
SettingsForm.cs
Normal file
56
SettingsForm.cs
Normal file
@ -0,0 +1,56 @@
|
||||
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 SettingsForm : Form
|
||||
{
|
||||
public SettingsForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void deleteAccountButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult result = MessageBox.Show("Вы уверены что хотите удалить аккаунт?", "Удаление аккаунта", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
|
||||
|
||||
if (result == DialogResult.Yes)
|
||||
{
|
||||
Globals.currentUser.Delete();
|
||||
Logs.Log(Globals.currentUser, Logs.Action.DeleteAccount, new Dictionary<string, object>());
|
||||
MessageBox.Show("Аккаунт удален!", "Аккаунт удален", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
|
||||
this.Close();
|
||||
|
||||
AuthorizationForm authorization = FormManager.Current.CreateForm<AuthorizationForm>();
|
||||
FormManager.Current.Navigate(this.Owner, authorization);
|
||||
}
|
||||
}
|
||||
|
||||
private void changePasswordButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(entryNewPassword.Text))
|
||||
{
|
||||
MessageBox.Show("Введите пароль!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!string.Equals(entryNewPassword.Text, entryRePassword.Text))
|
||||
{
|
||||
MessageBox.Show("Пароли не совпадают!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
Globals.currentUser.ChangePassword(entryNewPassword.Text);
|
||||
Logs.Log(Globals.currentUser, Logs.Action.ChangePassword, new Dictionary<string, object>());
|
||||
MessageBox.Show("Пароль изменен!", "Пароль изменен", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
}
|
120
SettingsForm.resx
Normal file
120
SettingsForm.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>
|
13
packages.config
Normal file
13
packages.config
Normal file
@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Microsoft.Data.Sqlite" version="5.0.3" targetFramework="net472" />
|
||||
<package id="Microsoft.Data.Sqlite.Core" version="5.0.3" targetFramework="net472" />
|
||||
<package id="SQLitePCLRaw.bundle_e_sqlite3" version="2.0.4" targetFramework="net472" />
|
||||
<package id="SQLitePCLRaw.core" version="2.0.4" targetFramework="net472" />
|
||||
<package id="SQLitePCLRaw.lib.e_sqlite3" version="2.0.4" targetFramework="net472" />
|
||||
<package id="SQLitePCLRaw.provider.dynamic_cdecl" version="2.0.4" targetFramework="net472" />
|
||||
<package id="System.Buffers" version="4.4.0" targetFramework="net472" />
|
||||
<package id="System.Memory" version="4.5.3" targetFramework="net472" />
|
||||
<package id="System.Numerics.Vectors" version="4.4.0" targetFramework="net472" />
|
||||
<package id="System.Runtime.CompilerServices.Unsafe" version="4.5.2" targetFramework="net472" />
|
||||
</packages>
|
Reference in New Issue
Block a user