2022-05-14 09:53:01 +03:00
|
|
|
|
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
|
|
|
|
|
{
|
2022-05-14 10:11:05 +03:00
|
|
|
|
public partial class MainForm : Form
|
2022-05-14 09:53:01 +03:00
|
|
|
|
{
|
2022-05-14 10:11:05 +03:00
|
|
|
|
public MainForm()
|
2022-05-14 09:53:01 +03:00
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
2022-05-22 11:18:49 +03:00
|
|
|
|
|
|
|
|
|
administrationToolStripMenuItem.Enabled = Globals.currentUser.Role == UserRoles.ADMIN;
|
2022-05-14 09:53:01 +03:00
|
|
|
|
}
|
2022-05-22 01:19:10 +03:00
|
|
|
|
|
2022-05-16 15:42:58 +03:00
|
|
|
|
private void executeButton_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2022-05-22 01:19:10 +03:00
|
|
|
|
// Получаем исходный текст из sourceRichTextBox
|
|
|
|
|
string sourceText = sourceRichTextBox.Text;
|
|
|
|
|
|
|
|
|
|
if (sourceText.Length == 0)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("Введите текст в поле исходного текста", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-16 15:54:54 +03:00
|
|
|
|
// Чистим предыдущий результат
|
|
|
|
|
toolStripStatusLabel.Text = "";
|
|
|
|
|
resultCountLabel.Text = "";
|
|
|
|
|
uniqueListBox.DataSource = null;
|
|
|
|
|
|
2022-05-16 15:50:40 +03:00
|
|
|
|
// Объявляем список уникальных e-mail-ов
|
|
|
|
|
List<string> uniqueEmails = new List<string>();
|
|
|
|
|
|
|
|
|
|
// Вызываем метод для извлечения e-mail-ов
|
|
|
|
|
int count = ExtactEmailsAlgorithm.Extract(sourceText, out uniqueEmails);
|
|
|
|
|
|
|
|
|
|
// Выводим результат
|
|
|
|
|
toolStripStatusLabel.Text = "Успех!";
|
2022-05-16 15:54:54 +03:00
|
|
|
|
resultCountLabel.Text = $"Количество e-mail-ов в тексте: {count}";
|
2022-05-16 15:50:40 +03:00
|
|
|
|
uniqueListBox.DataSource = uniqueEmails;
|
2022-05-22 01:19:10 +03:00
|
|
|
|
|
|
|
|
|
Logs.Log(
|
2022-05-22 10:00:00 +03:00
|
|
|
|
Globals.currentUser,
|
2022-05-22 01:19:10 +03:00
|
|
|
|
Logs.Action.Execute,
|
|
|
|
|
new Dictionary<string, object>() {
|
|
|
|
|
{ "sourceText", sourceText },
|
|
|
|
|
{ "count", count },
|
|
|
|
|
{ "uniqueEmails", uniqueEmails }
|
|
|
|
|
});
|
2022-05-16 15:42:58 +03:00
|
|
|
|
}
|
2022-05-22 10:56:32 +03:00
|
|
|
|
|
|
|
|
|
private void settingsToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
SettingsForm settingsForm = FormManager.Current.CreateForm<SettingsForm>();
|
|
|
|
|
settingsForm.ShowDialog(this);
|
|
|
|
|
}
|
2022-05-22 11:12:41 +03:00
|
|
|
|
|
|
|
|
|
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Globals.currentUser = null;
|
|
|
|
|
AuthorizationForm authorization = FormManager.Current.CreateForm<AuthorizationForm>();
|
|
|
|
|
FormManager.Current.Navigate(this, authorization);
|
|
|
|
|
}
|
2022-05-23 21:08:30 +03:00
|
|
|
|
|
|
|
|
|
private void journalToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
JournalForm journalForm = FormManager.Current.CreateForm<JournalForm>();
|
|
|
|
|
journalForm.ShowDialog(this);
|
|
|
|
|
}
|
2022-05-14 09:53:01 +03:00
|
|
|
|
}
|
|
|
|
|
}
|