diff --git a/TransportCompany/TransportCompany/FormRandomCreateClient.Designer.cs b/TransportCompany/TransportCompany/FormRandomCreateClient.Designer.cs
index 38c5260..9065a97 100644
--- a/TransportCompany/TransportCompany/FormRandomCreateClient.Designer.cs
+++ b/TransportCompany/TransportCompany/FormRandomCreateClient.Designer.cs
@@ -1,95 +1,117 @@
namespace TransportCompany
{
- partial class FormRandomCreateClient
- {
- ///
- /// Required designer variable.
- ///
- private System.ComponentModel.IContainer components = null;
+ partial class FormRandomCreateClient
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
- ///
- /// Clean up any resources being used.
- ///
- /// true if managed resources should be disposed; otherwise, false.
- protected override void Dispose(bool disposing)
- {
- if (disposing && (components != null))
- {
- components.Dispose();
- }
- base.Dispose(disposing);
- }
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
- #region Windows Form Designer generated code
+ #region Windows Form Designer generated code
- ///
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- ///
- private void InitializeComponent()
- {
- labelCount = new Label();
- textBoxCount = new TextBox();
- buttonStart = new Button();
- buttonCancel = new Button();
- SuspendLayout();
- //
- // labelCount
- //
- labelCount.AutoSize = true;
- labelCount.Location = new Point(21, 25);
- labelCount.Name = "labelCount";
- labelCount.Size = new Size(93, 20);
- labelCount.TabIndex = 0;
- labelCount.Text = "Количество:";
- //
- // textBoxCount
- //
- textBoxCount.Location = new Point(158, 22);
- textBoxCount.Name = "textBoxCount";
- textBoxCount.Size = new Size(217, 27);
- textBoxCount.TabIndex = 1;
- //
- // buttonStart
- //
- buttonStart.Location = new Point(147, 87);
- buttonStart.Name = "buttonStart";
- buttonStart.Size = new Size(110, 29);
- buttonStart.TabIndex = 2;
- buttonStart.Text = "Генерация";
- buttonStart.UseVisualStyleBackColor = true;
- buttonStart.Click += ButtonStart_Click;
- //
- // buttonCancel
- //
- buttonCancel.Location = new Point(281, 87);
- buttonCancel.Name = "buttonCancel";
- buttonCancel.Size = new Size(94, 29);
- buttonCancel.TabIndex = 3;
- buttonCancel.Text = "Отмена";
- buttonCancel.UseVisualStyleBackColor = true;
- buttonCancel.Click += ButtonCancel_Click;
- //
- // FormRandomCreateClient
- //
- AutoScaleDimensions = new SizeF(8F, 20F);
- AutoScaleMode = AutoScaleMode.Font;
- ClientSize = new Size(429, 141);
- Controls.Add(buttonCancel);
- Controls.Add(buttonStart);
- Controls.Add(textBoxCount);
- Controls.Add(labelCount);
- Name = "FormRandomCreateClient";
- Text = "Случайная генерация клиентов";
- ResumeLayout(false);
- PerformLayout();
- }
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ labelCount = new Label();
+ textBoxCount = new TextBox();
+ buttonStart = new Button();
+ buttonCancel = new Button();
+ label1 = new Label();
+ textBoxTimeWork = new TextBox();
+ SuspendLayout();
+ //
+ // labelCount
+ //
+ labelCount.AutoSize = true;
+ labelCount.Location = new Point(21, 25);
+ labelCount.Name = "labelCount";
+ labelCount.Size = new Size(93, 20);
+ labelCount.TabIndex = 0;
+ labelCount.Text = "Количество:";
+ //
+ // textBoxCount
+ //
+ textBoxCount.Location = new Point(158, 22);
+ textBoxCount.Name = "textBoxCount";
+ textBoxCount.Size = new Size(217, 27);
+ textBoxCount.TabIndex = 1;
+ //
+ // buttonStart
+ //
+ buttonStart.Location = new Point(147, 162);
+ buttonStart.Name = "buttonStart";
+ buttonStart.Size = new Size(110, 29);
+ buttonStart.TabIndex = 2;
+ buttonStart.Text = "Генерация";
+ buttonStart.UseVisualStyleBackColor = true;
+ buttonStart.Click += ButtonStart_Click;
+ //
+ // buttonCancel
+ //
+ buttonCancel.Location = new Point(281, 162);
+ buttonCancel.Name = "buttonCancel";
+ buttonCancel.Size = new Size(94, 29);
+ buttonCancel.TabIndex = 3;
+ buttonCancel.Text = "Отмена";
+ buttonCancel.UseVisualStyleBackColor = true;
+ buttonCancel.Click += ButtonCancel_Click;
+ //
+ // label1
+ //
+ label1.AutoSize = true;
+ label1.Location = new Point(21, 101);
+ label1.Name = "label1";
+ label1.Size = new Size(113, 20);
+ label1.TabIndex = 4;
+ label1.Text = "Время работы:";
+ //
+ // textBoxTimeWork
+ //
+ textBoxTimeWork.Location = new Point(158, 98);
+ textBoxTimeWork.Name = "textBoxTimeWork";
+ textBoxTimeWork.Size = new Size(217, 27);
+ textBoxTimeWork.TabIndex = 5;
+ //
+ // FormRandomCreateClient
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(412, 220);
+ Controls.Add(textBoxTimeWork);
+ Controls.Add(label1);
+ Controls.Add(buttonCancel);
+ Controls.Add(buttonStart);
+ Controls.Add(textBoxCount);
+ Controls.Add(labelCount);
+ Name = "FormRandomCreateClient";
+ Text = "Случайная генерация клиентов";
+ ResumeLayout(false);
+ PerformLayout();
+ }
- #endregion
+ #endregion
- private Label labelCount;
- private TextBox textBoxCount;
- private Button buttonStart;
- private Button buttonCancel;
- }
+ private Label labelCount;
+ private TextBox textBoxCount;
+ private Button buttonStart;
+ private Button buttonCancel;
+ private Label label1;
+ private TextBox textBoxTimeWork;
+ }
}
\ No newline at end of file
diff --git a/TransportCompany/TransportCompany/FormRandomCreateClient.cs b/TransportCompany/TransportCompany/FormRandomCreateClient.cs
index fbb0a41..1b3efd3 100644
--- a/TransportCompany/TransportCompany/FormRandomCreateClient.cs
+++ b/TransportCompany/TransportCompany/FormRandomCreateClient.cs
@@ -3,6 +3,7 @@ using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
+using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Text;
@@ -13,65 +14,57 @@ using TransportCompanyContracts.BusinessLogicsContracts;
namespace TransportCompany
{
- public partial class FormRandomCreateClient : Form
- {
- private readonly IClientLogic _logicC;
+ public partial class FormRandomCreateClient : Form
+ {
+ private readonly IClientLogic _logicC;
- Random rnd = new Random(DateTime.Now.ToString().GetHashCode());
+ Random rnd = new Random(DateTime.Now.ToString().GetHashCode());
- private string[] _names = { "Иван", "Егор", "Роман", "Денис", "Игнат", "Ренат", "Никита", "Павел", "Данил", "Максим", "Николай", "Дмитрий", "Владислав", "Марк", "Булат", "Марсель", "Назар", "Багир", "Кирилл", "Всеволод", "Ярослав", "Юрий", "Виталий" };
+ private string[] _names = { "Иван", "Егор", "Роман", "Денис", "Игнат", "Ренат", "Никита", "Павел", "Данил", "Максим", "Николай", "Дмитрий", "Владислав", "Марк", "Булат", "Марсель", "Назар", "Багир", "Кирилл", "Всеволод", "Ярослав", "Юрий", "Виталий" };
- private string[] _surnames = { "Иванов", "Елисеев", "Марков", "Негин", "Мусоев", "Сегреев", "Распаев", "Минаров", "Захарченко", "Пятаков", "Юдаков", "Карташев", "Селин", "Марков", "Захаров", "Никитин", "Распаев", "Алексанян", "Скалкин", "Строев", "Горшков", "Каримов", "Кочкадаев", "Ершов", "Алиакберов", "Закуанов", "Пахомов" };
+ private string[] _surnames = { "Иванов", "Елисеев", "Марков", "Негин", "Мусоев", "Сегреев", "Распаев", "Минаров", "Захарченко", "Пятаков", "Юдаков", "Карташев", "Селин", "Марков", "Захаров", "Никитин", "Распаев", "Алексанян", "Скалкин", "Строев", "Горшков", "Каримов", "Кочкадаев", "Ершов", "Алиакберов", "Закуанов", "Пахомов" };
- private string[] _patronymics = { "Иванович", "Евгеньевич", "Егорович", "Николаевич", "Дмитриевич", "Владиславович", "Юрьевич", "Кириллович", "Артемиевич", "Павлович", "Максимович", "Назарович", "Багирович", "Булатович", "Всеволодович", "Витальевич", "Евгеньевич", "Романович", "Ярославович", "Данилович", "Зульфия", "Марсельевич", "Маркович", };
+ private string[] _patronymics = { "Иванович", "Евгеньевич", "Егорович", "Николаевич", "Дмитриевич", "Владиславович", "Юрьевич", "Кириллович", "Артемиевич", "Павлович", "Максимович", "Назарович", "Багирович", "Булатович", "Всеволодович", "Витальевич", "Евгеньевич", "Романович", "Ярославович", "Данилович", "Зульфия", "Марсельевич", "Маркович", };
- private string[] _telephones = { "89529876316", "88804293534", "84508874804", "82035754008", "80926246994", "83316923921", "88497436387", "82372606638", "81582656294", "83605675249", "87978864427", "81882538381", "83432311066", "80220603131", "82166498710", "80271945648", "83581821702", "84911615179", "89993116947", "80830482909", "89463846784", "84817550460", "81785373218", "80654035595", "81304432863", "85601863128" };
+ private string[] _telephones = { "89529876316", "88804293534", "84508874804", "82035754008", "80926246994", "83316923921", "88497436387", "82372606638", "81582656294", "83605675249", "87978864427", "81882538381", "83432311066", "80220603131", "82166498710", "80271945648", "83581821702", "84911615179", "89993116947", "80830482909", "89463846784", "84817550460", "81785373218", "80654035595", "81304432863", "85601863128" };
- private string[] _emails = { "deffabuttiprei-5025@yopmail.com", "quiquoucrobrilla-7902@yopmail.com", "tucoffokexoi-9537@yopmail.com", "nebroijulleinne-7231@yopmail.com", "xedeujezoilli-1668@yopmail.com", "foikoussoidouhau-5112@yopmail.com", "pruddougoddeda-2757@yopmail.com", "keidevoillaga-5758@yopmail.com", "palemeinnacra-4165@yopmail.com", "capribukoippa-8523@yopmail.com", "truwauheineita-8708@yopmail.com", "mudebralanu-3594@yopmail.com", "nuxauttisoibri-7020@yopmail.com", "dufenosatte-4543@yopmail.com", "xullusaquilou-9479@yopmail.com", "broixifrommelle-3859@yopmail.com", "yimozofreixeu-4046@yopmail.com", "wetrouddemoro-9168@yopmail.com", "crepropretaji-6969@yopmail.com", "pahoufforutre-6805@yopmail.com", "gretreidineuba-8655@yopmail.com", "koullinnorulli-5851@yopmail.com", "bougreigewetto-3164@yopmail.com", "brocoffanauba-5102@yopmail.com", "kaddasumetre-7742@yopmail.com", "heussouprogromu-7061@yopmail.com", "teresitruffe-8881@yopmail.com", "kejicrouzazei-9377@yopmail.com", "zoicaquaugrili-2744@yopmail.com", "quepifrucragrou-8404@yopmail.com", "graditilladdi-7217@yopmail.com", "doboijifammeu-4816@yopmail.com", "tobrograusessoi-6295@yopmail.com", "xeifeuffiyoka-8243@yopmail.com", "greuquekucaju-9438@yopmail.com", "prisseproittunne-3785@yopmail.com", "vuppeiyatrare-8690@yopmail.com", "pennibexewa-9132@yopmail.com", "gayufeppaucu-4744@yopmail.com", "boicegreisussa-1695@yopmail.com" };
+ private string[] _emails = { "deffabuttiprei-5025@yopmail.com", "quiquoucrobrilla-7902@yopmail.com", "tucoffokexoi-9537@yopmail.com", "nebroijulleinne-7231@yopmail.com", "xedeujezoilli-1668@yopmail.com", "foikoussoidouhau-5112@yopmail.com", "pruddougoddeda-2757@yopmail.com", "keidevoillaga-5758@yopmail.com", "palemeinnacra-4165@yopmail.com", "capribukoippa-8523@yopmail.com", "truwauheineita-8708@yopmail.com", "mudebralanu-3594@yopmail.com", "nuxauttisoibri-7020@yopmail.com", "dufenosatte-4543@yopmail.com", "xullusaquilou-9479@yopmail.com", "broixifrommelle-3859@yopmail.com", "yimozofreixeu-4046@yopmail.com", "wetrouddemoro-9168@yopmail.com", "crepropretaji-6969@yopmail.com", "pahoufforutre-6805@yopmail.com", "gretreidineuba-8655@yopmail.com", "koullinnorulli-5851@yopmail.com", "bougreigewetto-3164@yopmail.com", "brocoffanauba-5102@yopmail.com", "kaddasumetre-7742@yopmail.com", "heussouprogromu-7061@yopmail.com", "teresitruffe-8881@yopmail.com", "kejicrouzazei-9377@yopmail.com", "zoicaquaugrili-2744@yopmail.com", "quepifrucragrou-8404@yopmail.com", "graditilladdi-7217@yopmail.com", "doboijifammeu-4816@yopmail.com", "tobrograusessoi-6295@yopmail.com", "xeifeuffiyoka-8243@yopmail.com", "greuquekucaju-9438@yopmail.com", "prisseproittunne-3785@yopmail.com", "vuppeiyatrare-8690@yopmail.com", "pennibexewa-9132@yopmail.com", "gayufeppaucu-4744@yopmail.com", "boicegreisussa-1695@yopmail.com" };
- public FormRandomCreateClient(IClientLogic logicC)
- {
- InitializeComponent();
+ public FormRandomCreateClient(IClientLogic logicC)
+ {
+ InitializeComponent();
- _logicC = logicC;
- }
+ _logicC = logicC;
+ }
- private void ButtonStart_Click(object sender, EventArgs e)
- {
- try
- {
- for (int i = 0; i < Convert.ToInt32(textBoxCount.Text); i++)
- {
- var model = new ClientBindingModel
- {
- Id = 0,
- Name = _names[rnd.Next(0, _names.Length)],
- Surname = _surnames[rnd.Next(0, _surnames.Length)],
- Patronymic = _patronymics[rnd.Next(0, _patronymics.Length)],
- Telephone = _telephones[rnd.Next(0, _telephones.Length)] + Convert.ToString(rnd.Next(0, 800000)),
- Email = Convert.ToString(rnd.Next(0, 800000)) + _emails[rnd.Next(0, _emails.Length)],
- };
+ private void ButtonStart_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ ChangeList(_telephones);
- var operationResult = _logicC.Create(model);
+ ChangeList(_emails);
- if (!operationResult)
- {
- throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
- }
+ textBoxTimeWork.Text = _logicC.TestRandomCreate(Convert.ToInt32(textBoxCount.Text), _names, _surnames, _patronymics, _telephones, _emails);
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
- Close();
- }
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- }
+ private void ButtonCancel_Click(object sender, EventArgs e)
+ {
+ DialogResult = DialogResult.Cancel;
+ Close();
+ }
- private void ButtonCancel_Click(object sender, EventArgs e)
- {
- DialogResult = DialogResult.Cancel;
- Close();
- }
- }
+ private void ChangeList(string[] _strings)
+ {
+ for(int i = 0; i < _strings.Length; i++)
+ {
+ _strings[i] = Convert.ToString(rnd.Next(0, 800000)) + _strings[i];
+ }
+ }
+ }
}
diff --git a/TransportCompany/TransportCompany/FormRandomCreateTrucking.Designer.cs b/TransportCompany/TransportCompany/FormRandomCreateTrucking.Designer.cs
index 6e9dfd3..837f181 100644
--- a/TransportCompany/TransportCompany/FormRandomCreateTrucking.Designer.cs
+++ b/TransportCompany/TransportCompany/FormRandomCreateTrucking.Designer.cs
@@ -1,95 +1,117 @@
namespace TransportCompany
{
- partial class FormRandomCreateTrucking
- {
- ///
- /// Required designer variable.
- ///
- private System.ComponentModel.IContainer components = null;
+ partial class FormRandomCreateTrucking
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
- ///
- /// Clean up any resources being used.
- ///
- /// true if managed resources should be disposed; otherwise, false.
- protected override void Dispose(bool disposing)
- {
- if (disposing && (components != null))
- {
- components.Dispose();
- }
- base.Dispose(disposing);
- }
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
- #region Windows Form Designer generated code
+ #region Windows Form Designer generated code
- ///
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- ///
- private void InitializeComponent()
- {
- labelClient = new Label();
- textBoxCount = new TextBox();
- buttonCreate = new Button();
- buttonCancel = new Button();
- SuspendLayout();
- //
- // labelClient
- //
- labelClient.AutoSize = true;
- labelClient.Location = new Point(32, 33);
- labelClient.Name = "labelClient";
- labelClient.Size = new Size(151, 20);
- labelClient.TabIndex = 0;
- labelClient.Text = "Введите количество:";
- //
- // textBoxCount
- //
- textBoxCount.Location = new Point(221, 30);
- textBoxCount.Name = "textBoxCount";
- textBoxCount.Size = new Size(280, 27);
- textBoxCount.TabIndex = 1;
- //
- // buttonCreate
- //
- buttonCreate.Location = new Point(237, 91);
- buttonCreate.Name = "buttonCreate";
- buttonCreate.Size = new Size(123, 29);
- buttonCreate.TabIndex = 2;
- buttonCreate.Text = "Генерация";
- buttonCreate.UseVisualStyleBackColor = true;
- buttonCreate.Click += ButtonCreate_Click;
- //
- // buttonCancel
- //
- buttonCancel.Location = new Point(382, 91);
- buttonCancel.Name = "buttonCancel";
- buttonCancel.Size = new Size(119, 29);
- buttonCancel.TabIndex = 3;
- buttonCancel.Text = "Отмена";
- buttonCancel.UseVisualStyleBackColor = true;
- buttonCancel.Click += ButtonCancel_Click;
- //
- // FormRandomCreateTrucking
- //
- AutoScaleDimensions = new SizeF(8F, 20F);
- AutoScaleMode = AutoScaleMode.Font;
- ClientSize = new Size(548, 147);
- Controls.Add(buttonCancel);
- Controls.Add(buttonCreate);
- Controls.Add(textBoxCount);
- Controls.Add(labelClient);
- Name = "FormRandomCreateTrucking";
- Text = "Генерация перевозок";
- ResumeLayout(false);
- PerformLayout();
- }
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ labelClient = new Label();
+ textBoxCount = new TextBox();
+ buttonCreate = new Button();
+ buttonCancel = new Button();
+ label1 = new Label();
+ textBoxCheckTest = new TextBox();
+ SuspendLayout();
+ //
+ // labelClient
+ //
+ labelClient.AutoSize = true;
+ labelClient.Location = new Point(32, 33);
+ labelClient.Name = "labelClient";
+ labelClient.Size = new Size(151, 20);
+ labelClient.TabIndex = 0;
+ labelClient.Text = "Введите количество:";
+ //
+ // textBoxCount
+ //
+ textBoxCount.Location = new Point(221, 30);
+ textBoxCount.Name = "textBoxCount";
+ textBoxCount.Size = new Size(280, 27);
+ textBoxCount.TabIndex = 1;
+ //
+ // buttonCreate
+ //
+ buttonCreate.Location = new Point(237, 148);
+ buttonCreate.Name = "buttonCreate";
+ buttonCreate.Size = new Size(123, 29);
+ buttonCreate.TabIndex = 2;
+ buttonCreate.Text = "Генерация";
+ buttonCreate.UseVisualStyleBackColor = true;
+ buttonCreate.Click += ButtonCreate_Click;
+ //
+ // buttonCancel
+ //
+ buttonCancel.Location = new Point(382, 148);
+ buttonCancel.Name = "buttonCancel";
+ buttonCancel.Size = new Size(119, 29);
+ buttonCancel.TabIndex = 3;
+ buttonCancel.Text = "Отмена";
+ buttonCancel.UseVisualStyleBackColor = true;
+ buttonCancel.Click += ButtonCancel_Click;
+ //
+ // label1
+ //
+ label1.AutoSize = true;
+ label1.Location = new Point(32, 99);
+ label1.Name = "label1";
+ label1.Size = new Size(145, 20);
+ label1.TabIndex = 4;
+ label1.Text = "Время добавления:";
+ //
+ // textBoxCheckTest
+ //
+ textBoxCheckTest.Location = new Point(221, 96);
+ textBoxCheckTest.Name = "textBoxCheckTest";
+ textBoxCheckTest.Size = new Size(280, 27);
+ textBoxCheckTest.TabIndex = 5;
+ //
+ // FormRandomCreateTrucking
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(548, 215);
+ Controls.Add(textBoxCheckTest);
+ Controls.Add(label1);
+ Controls.Add(buttonCancel);
+ Controls.Add(buttonCreate);
+ Controls.Add(textBoxCount);
+ Controls.Add(labelClient);
+ Name = "FormRandomCreateTrucking";
+ Text = "Генерация перевозок";
+ ResumeLayout(false);
+ PerformLayout();
+ }
- #endregion
+ #endregion
- private Label labelClient;
- private TextBox textBoxCount;
- private Button buttonCreate;
- private Button buttonCancel;
- }
+ private Label labelClient;
+ private TextBox textBoxCount;
+ private Button buttonCreate;
+ private Button buttonCancel;
+ private Label label1;
+ private TextBox textBoxCheckTest;
+ }
}
\ No newline at end of file
diff --git a/TransportCompany/TransportCompany/FormRandomCreateTrucking.cs b/TransportCompany/TransportCompany/FormRandomCreateTrucking.cs
index dc74974..9f98ea9 100644
--- a/TransportCompany/TransportCompany/FormRandomCreateTrucking.cs
+++ b/TransportCompany/TransportCompany/FormRandomCreateTrucking.cs
@@ -14,82 +14,51 @@ using TransportCompanyContracts.BusinessLogicsContracts;
namespace TransportCompany
{
- public partial class FormRandomCreateTrucking : Form
- {
- Random rnd = new Random(DateTime.Now.ToString().GetHashCode());
+ public partial class FormRandomCreateTrucking : Form
+ {
+ private readonly IClientLogic _logicCl;
- private readonly IClientLogic _logicCl;
+ private readonly ITransportLogic _logicTransport;
- private readonly ITransportLogic _logicTransport;
+ private readonly ITransportationLogic _logicTransportation;
- private readonly ITransportationLogic _logicTransportation;
+ private readonly ICargoLogic _logicCargo;
- private readonly ICargoLogic _logicCargo;
+ private readonly ITruckingLogic _logic;
- private readonly ITruckingLogic _logic;
+ public FormRandomCreateTrucking(ILogger logger, ITruckingLogic logic, ICargoLogic logicCargo,
+ IClientLogic logicCl, ITransportLogic logicTransport, ITransportationLogic logicTransportation)
+ {
+ InitializeComponent();
- private int? _id;
+ _logic = logic;
+ _logicCargo = logicCargo;
+ _logicCl = logicCl;
+ _logicTransport = logicTransport;
+ _logicTransportation = logicTransportation;
+ }
- public int Id { set { _id = value; } }
+ private void ButtonCreate_Click(object sender, EventArgs e)
+ {
+ var viewClient = _logicCl.ReadList(null);
+ var viewCargo = _logicCargo.ReadList(null);
+ var viewTransport = _logicTransport.ReadList(null);
+ var viewTransportation = _logicTransportation.ReadList(null);
- public FormRandomCreateTrucking(ILogger logger, ITruckingLogic logic, ICargoLogic logicCargo,
- IClientLogic logicCl, ITransportLogic logicTransport, ITransportationLogic logicTransportation)
- {
- InitializeComponent();
+ try
+ {
+ textBoxCheckTest.Text = _logic.TestRandomCreate(Convert.ToInt32(textBoxCount.Text), viewClient, viewCargo, viewTransport, viewTransportation);
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
- _logic = logic;
- _logicCargo = logicCargo;
- _logicCl = logicCl;
- _logicTransport = logicTransport;
- _logicTransportation = logicTransportation;
- }
-
- private void ButtonCreate_Click(object sender, EventArgs e)
- {
- var viewClient = _logicCl.ReadList(null);
- var viewCargo = _logicCargo.ReadList(null);
- var viewTransport = _logicTransport.ReadList(null);
- var viewTransportation = _logicTransportation.ReadList(null);
-
- try
- {
- for (int i = 0; i < Convert.ToInt32(textBoxCount.Text); i++)
- {
- DateTime dateStart = new DateTime(rnd.Next(1991, 2023), rnd.Next(1, 12), rnd.Next(1, 28));
- DateTime dateEnd = dateStart.AddDays(20);
-
- var model = new TruckingBindingModel
- {
- Id = 0,
- ClientId = viewClient[rnd.Next(0, viewClient.Count)].Id,
- CargoId = viewCargo[rnd.Next(0, viewCargo.Count)].Id,
- TransportId = viewTransport[rnd.Next(0, viewTransport.Count)].Id,
- TransportationId = viewTransportation[rnd.Next(0, viewTransportation.Count)].Id,
- DateStart = dateStart,
- DateEnd = dateEnd,
- Price = viewClient.Count * rnd.Next(100, 5000)
- };
-
- var operationResult = _logic.Create(model);
-
- if (!operationResult)
- {
- throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
- }
-
- Close();
- }
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- }
-
- private void ButtonCancel_Click(object sender, EventArgs e)
- {
- DialogResult = DialogResult.Cancel;
- Close();
- }
- }
+ private void ButtonCancel_Click(object sender, EventArgs e)
+ {
+ DialogResult = DialogResult.Cancel;
+ Close();
+ }
+ }
}
diff --git a/TransportCompany/TransportCompanyBusinessLogic/BusinessLogic/ClientLogic.cs b/TransportCompany/TransportCompanyBusinessLogic/BusinessLogic/ClientLogic.cs
index 2564c73..6e97b4d 100644
--- a/TransportCompany/TransportCompanyBusinessLogic/BusinessLogic/ClientLogic.cs
+++ b/TransportCompany/TransportCompanyBusinessLogic/BusinessLogic/ClientLogic.cs
@@ -80,7 +80,13 @@ namespace TransportCompanyBusinessLogic.BusinessLogic
return true;
}
- public bool Update(ClientBindingModel model)
+
+ public string TestRandomCreate(int count, string[] _name, string[] _surname, string[] _patronymic, string[] _telephone, string[] _email)
+ {
+ return _clientStorage.TestRandomInsert(count, _name, _surname, _patronymic, _telephone, _email);
+ }
+
+ public bool Update(ClientBindingModel model)
{
CheckModel(model);
@@ -169,5 +175,5 @@ namespace TransportCompanyBusinessLogic.BusinessLogic
throw new InvalidOperationException("Клиент с такой почтой уже есть");
}
}
- }
+ }
}
diff --git a/TransportCompany/TransportCompanyBusinessLogic/BusinessLogic/TruckingLogic.cs b/TransportCompany/TransportCompanyBusinessLogic/BusinessLogic/TruckingLogic.cs
index 7c08d4d..f048151 100644
--- a/TransportCompany/TransportCompanyBusinessLogic/BusinessLogic/TruckingLogic.cs
+++ b/TransportCompany/TransportCompanyBusinessLogic/BusinessLogic/TruckingLogic.cs
@@ -81,7 +81,12 @@ namespace TransportCompanyBusinessLogic.BusinessLogic
return true;
}
- public bool Update(TruckingBindingModel model)
+ public string TestRandomCreate(int count, List clients, List cargos, List transports, List transportations)
+ {
+ return _truckingStorage.TestRandomInsert(count, clients, cargos, transports, transportations);
+ }
+
+ public bool Update(TruckingBindingModel model)
{
CheckModel(model);
@@ -158,5 +163,5 @@ namespace TransportCompanyBusinessLogic.BusinessLogic
"TransportationId:{TransportationId}. DateStart:{DateStart}. DateEnd:{DateEnd}. Id:{Id}",
model.ClientId, model.CargoId, model.TransportId, model.TransportationId, model.DateStart, model.DateEnd, model.Id);
}
- }
+ }
}
diff --git a/TransportCompany/TransportCompanyContracts/BusinessLogicsContracts/IClientLogic.cs b/TransportCompany/TransportCompanyContracts/BusinessLogicsContracts/IClientLogic.cs
index 615d83d..95dfb66 100644
--- a/TransportCompany/TransportCompanyContracts/BusinessLogicsContracts/IClientLogic.cs
+++ b/TransportCompany/TransportCompanyContracts/BusinessLogicsContracts/IClientLogic.cs
@@ -17,7 +17,9 @@ namespace TransportCompanyContracts.BusinessLogicsContracts
bool Create(ClientBindingModel model);
- bool Update(ClientBindingModel model);
+ string TestRandomCreate(int count, string[] _name, string[] _surname, string[] _patronymic, string[] _telephone, string[] _email);
+
+ bool Update(ClientBindingModel model);
bool Delete(ClientBindingModel model);
}
diff --git a/TransportCompany/TransportCompanyContracts/BusinessLogicsContracts/ITruckingLogic.cs b/TransportCompany/TransportCompanyContracts/BusinessLogicsContracts/ITruckingLogic.cs
index 1d22c31..dca9436 100644
--- a/TransportCompany/TransportCompanyContracts/BusinessLogicsContracts/ITruckingLogic.cs
+++ b/TransportCompany/TransportCompanyContracts/BusinessLogicsContracts/ITruckingLogic.cs
@@ -17,7 +17,9 @@ namespace TransportCompanyContracts.BusinessLogicsContracts
bool Create(TruckingBindingModel model);
- bool Update(TruckingBindingModel model);
+ string TestRandomCreate(int count, List clients, List cargos, List transports, List transportations);
+
+ bool Update(TruckingBindingModel model);
bool Delete(TruckingBindingModel model);
}
diff --git a/TransportCompany/TransportCompanyContracts/StoragesContracts/IClientStorage.cs b/TransportCompany/TransportCompanyContracts/StoragesContracts/IClientStorage.cs
index e147c46..46bc3b4 100644
--- a/TransportCompany/TransportCompanyContracts/StoragesContracts/IClientStorage.cs
+++ b/TransportCompany/TransportCompanyContracts/StoragesContracts/IClientStorage.cs
@@ -19,7 +19,9 @@ namespace TransportCompanyContracts.StoragesContracts
ClientViewModel? Insert(ClientBindingModel model);
- ClientViewModel? Update(ClientBindingModel model);
+ string TestRandomInsert(int count, string[] _name, string[] _surname, string[] _patronymic, string[] _telephone, string[] _email);
+
+ ClientViewModel? Update(ClientBindingModel model);
ClientViewModel? Delete(ClientBindingModel model);
}
diff --git a/TransportCompany/TransportCompanyContracts/StoragesContracts/ITruckingStorage.cs b/TransportCompany/TransportCompanyContracts/StoragesContracts/ITruckingStorage.cs
index 37afb54..0ca3d8a 100644
--- a/TransportCompany/TransportCompanyContracts/StoragesContracts/ITruckingStorage.cs
+++ b/TransportCompany/TransportCompanyContracts/StoragesContracts/ITruckingStorage.cs
@@ -19,7 +19,9 @@ namespace TransportCompanyContracts.StoragesContracts
TruckingViewModel? Insert(TruckingBindingModel model);
- TruckingViewModel? Update(TruckingBindingModel model);
+ string TestRandomInsert(int count, List clients, List cargos, List transports, List transportations);
+
+ TruckingViewModel? Update(TruckingBindingModel model);
TruckingViewModel? Delete(TruckingBindingModel model);
}
diff --git a/TransportCompany/TransportCompanyDatabaseImplements/Implements/ClientStorage.cs b/TransportCompany/TransportCompanyDatabaseImplements/Implements/ClientStorage.cs
index 46bbc8e..73837fa 100644
--- a/TransportCompany/TransportCompanyDatabaseImplements/Implements/ClientStorage.cs
+++ b/TransportCompany/TransportCompanyDatabaseImplements/Implements/ClientStorage.cs
@@ -1,8 +1,11 @@
using System;
using System.Collections.Generic;
+using System.Diagnostics;
using System.Linq;
+using System.Net;
using System.Text;
using System.Threading.Tasks;
+using System.Xml.Linq;
using TransportCompanyContracts.BindingModels;
using TransportCompanyContracts.SearchModels;
using TransportCompanyContracts.StoragesContracts;
@@ -70,7 +73,45 @@ namespace TransportCompanyDatabaseImplements.Implements
return newClient.GetViewModel;
}
- public ClientViewModel? Update(ClientBindingModel model)
+ //метод для замера вставки большого кол-ва клиентов в бд
+ public string TestRandomInsert(int count, string[] _name, string[] _surname, string[] _patronymic, string[] _telephone, string[] _email)
+ {
+ using var context = new ElegevContext();
+
+ Random rnd = new Random(DateTime.Now.ToString().GetHashCode());
+
+ int lastId = context.Clients.Count() > 0 ? context.Clients.Max(x => x.Id) + 1 : 1;
+
+ for (int i = 0; i < count; i++)
+ {
+ var model = new Client
+ {
+ Id = lastId,
+ Name = _name[rnd.Next(0, _name.Length)],
+ Surname = _surname[rnd.Next(0, _surname.Length)],
+ Patronymic = _patronymic[rnd.Next(0, _patronymic.Length)],
+ Telephone = _telephone[rnd.Next(0, _telephone.Length)],
+ Email = _email[rnd.Next(0, _email.Length)],
+ };
+
+ lastId++;
+
+ context.Clients.Add(model);
+ }
+
+ //старт замера времени добавления в бд
+ Stopwatch stopwatch = new();
+
+ stopwatch.Start();
+
+ context.SaveChanges();
+
+ stopwatch.Stop();
+
+ return stopwatch.ElapsedMilliseconds.ToString();
+ }
+
+ public ClientViewModel? Update(ClientBindingModel model)
{
using var context = new ElegevContext();
using var transaction = context.Database.BeginTransaction();
@@ -114,5 +155,5 @@ namespace TransportCompanyDatabaseImplements.Implements
return null;
}
- }
+ }
}
diff --git a/TransportCompany/TransportCompanyDatabaseImplements/Implements/TruckingStorage.cs b/TransportCompany/TransportCompanyDatabaseImplements/Implements/TruckingStorage.cs
index 1cb4303..32090c5 100644
--- a/TransportCompany/TransportCompanyDatabaseImplements/Implements/TruckingStorage.cs
+++ b/TransportCompany/TransportCompanyDatabaseImplements/Implements/TruckingStorage.cs
@@ -1,6 +1,7 @@
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
+using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -99,7 +100,50 @@ namespace TransportCompanyDatabaseImplements.Implements
?.GetViewModel;
}
- public TruckingViewModel? Update(TruckingBindingModel model)
+ //метод для замера вставки большого кол-ва клиентов в бд
+ public string TestRandomInsert(int count, List clients, List cargos, List transports, List transportations)
+ {
+ using var context = new ElegevContext();
+
+ Random rnd = new Random(DateTime.Now.ToString().GetHashCode());
+
+ int lastId = context.Truckings.Count() > 0 ? context.Truckings.Max(x => x.Id) + 1 : 1;
+
+ for (int i = 0; i < count; i++)
+ {
+ DateTime dateStart = new(rnd.Next(1991, 2023), rnd.Next(1, 12), rnd.Next(1, 28));
+ DateTime dateEnd = dateStart.AddDays(20);
+
+ var model = new Trucking
+ {
+ Id = lastId,
+ ClientId = clients[rnd.Next(0, clients.Count)].Id,
+ CargoId = cargos[rnd.Next(0, cargos.Count)].Id,
+ TransportId = transports[rnd.Next(0, transports.Count)].Id,
+ TransportationId = transportations[rnd.Next(0, transportations.Count)].Id,
+ DateStart = dateStart,
+ DateEnd = dateEnd,
+ Price = clients.Count * rnd.Next(100, 5000)
+ };
+
+ lastId++;
+
+ context.Truckings.Add(model);
+ }
+
+ //старт замера времени добавления в бд
+ Stopwatch stopwatch = new();
+
+ stopwatch.Start();
+
+ context.SaveChanges();
+
+ stopwatch.Stop();
+
+ return stopwatch.ElapsedMilliseconds.ToString();
+ }
+
+ public TruckingViewModel? Update(TruckingBindingModel model)
{
using var context = new ElegevContext();
using var transaction = context.Database.BeginTransaction();