136 lines
3.5 KiB
C#
136 lines
3.5 KiB
C#
using NewsBlogAbstractions.Models;
|
|
using NewsBlogAbstractions.WorkAbstractions;
|
|
using System.Security.Policy;
|
|
|
|
namespace NewsBlogView
|
|
{
|
|
public partial class FormMain : Form
|
|
{
|
|
public FormMain()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void articleToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
var service = Program.ServiceProvider?.GetService(typeof(FormArticle));
|
|
if (service is FormArticle form)
|
|
{
|
|
form.ShowDialog();
|
|
}
|
|
}
|
|
|
|
private void authorToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
var service = Program.ServiceProvider?.GetService(typeof(FormAuthor));
|
|
if (service is FormAuthor form)
|
|
{
|
|
form.ShowDialog();
|
|
}
|
|
}
|
|
|
|
private void categoryToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
var service = Program.ServiceProvider?.GetService(typeof(FormCategory));
|
|
if (service is FormCategory form)
|
|
{
|
|
form.ShowDialog();
|
|
}
|
|
}
|
|
|
|
private void commentToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
var service = Program.ServiceProvider?.GetService(typeof(FormComment));
|
|
if (service is FormComment form)
|
|
{
|
|
form.ShowDialog();
|
|
}
|
|
}
|
|
|
|
private void tagToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
var service = Program.ServiceProvider?.GetService(typeof(FormTag));
|
|
if (service is FormTag form)
|
|
{
|
|
form.ShowDialog();
|
|
}
|
|
}
|
|
|
|
private void add1000ToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
var service = Program.ServiceProvider?.GetService(typeof(IAuthorWork));
|
|
if (service is IAuthorWork authorLogic)
|
|
{
|
|
DateTime startTime = DateTime.Now;
|
|
for (int i = 0; i < 1000; i++)
|
|
{
|
|
Author author = new()
|
|
{
|
|
Id = i + 1000,
|
|
Name = "ÔÈÎ " + i,
|
|
Description = "Îïèñàíèå " + i,
|
|
Phone = "Íîìåð " + i
|
|
};
|
|
authorLogic.CreateId(author);
|
|
}
|
|
DateTime endTime = DateTime.Now;
|
|
|
|
labelTest.Text = $"Äîáàâëåíèå 1000 ñòðîê âûïîëíåíî çà {(endTime - startTime).TotalMilliseconds} ìèëëèñåêóíä";
|
|
}
|
|
}
|
|
|
|
private void get1000ToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
var service = Program.ServiceProvider?.GetService(typeof(IAuthorWork));
|
|
if (service is IAuthorWork authorLogic)
|
|
{
|
|
DateTime startTime = DateTime.Now;
|
|
for (int i =0; i < 1000; i++)
|
|
authorLogic.Get(i + 1000);
|
|
DateTime endTime = DateTime.Now;
|
|
|
|
labelTest.Text = $"Ïîëó÷åíèå 1000 ñòðîê âûïîëíåíî çà {(endTime - startTime).TotalMilliseconds} ìèëëèñåêóíä";
|
|
}
|
|
}
|
|
|
|
private void update1000ToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
var service = Program.ServiceProvider?.GetService(typeof(IAuthorWork));
|
|
if (service is IAuthorWork authorLogic)
|
|
{
|
|
DateTime startTime = DateTime.Now;
|
|
for (int i = 0; i < 1000; i++)
|
|
{
|
|
Author author = new()
|
|
{
|
|
Id = i + 1000,
|
|
Name = "ÔÈÎ " + i + 2000,
|
|
Description = "Îïèñàíèå " + i + 2000,
|
|
Phone = "Íîìåð " + i + 2000
|
|
};
|
|
authorLogic.Update(author);
|
|
}
|
|
DateTime endTime = DateTime.Now;
|
|
|
|
labelTest.Text = $"Îáíîâëåíèå 1000 ñòðîê âûïîëíåíî çà {(endTime - startTime).TotalMilliseconds} ìèëëèñåêóíä";
|
|
}
|
|
}
|
|
|
|
private void delete1000ToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
var service = Program.ServiceProvider?.GetService(typeof(IAuthorWork));
|
|
if (service is IAuthorWork authorLogic)
|
|
{
|
|
DateTime startTime = DateTime.Now;
|
|
for (int i = 0; i < 1000; i++)
|
|
{
|
|
authorLogic.Delete(i + 1000);
|
|
}
|
|
DateTime endTime = DateTime.Now;
|
|
|
|
labelTest.Text = $"Óäàëåíèå 1000 ñòðîê âûïîëíåíî çà {(endTime - startTime).TotalMilliseconds} ìèëëèñåêóíä";
|
|
}
|
|
}
|
|
}
|
|
}
|