Готовая LabWork04.
This commit is contained in:
parent
2aed31b3c5
commit
0267589a31
@ -1,95 +1,117 @@
|
|||||||
namespace TransportCompany
|
namespace TransportCompany
|
||||||
{
|
{
|
||||||
partial class FormRandomCreateClient
|
partial class FormRandomCreateClient
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Required designer variable.
|
/// Required designer variable.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private System.ComponentModel.IContainer components = null;
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Clean up any resources being used.
|
/// Clean up any resources being used.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
protected override void Dispose(bool disposing)
|
protected override void Dispose(bool disposing)
|
||||||
{
|
{
|
||||||
if (disposing && (components != null))
|
if (disposing && (components != null))
|
||||||
{
|
{
|
||||||
components.Dispose();
|
components.Dispose();
|
||||||
}
|
}
|
||||||
base.Dispose(disposing);
|
base.Dispose(disposing);
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Required method for Designer support - do not modify
|
/// Required method for Designer support - do not modify
|
||||||
/// the contents of this method with the code editor.
|
/// the contents of this method with the code editor.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
labelCount = new Label();
|
labelCount = new Label();
|
||||||
textBoxCount = new TextBox();
|
textBoxCount = new TextBox();
|
||||||
buttonStart = new Button();
|
buttonStart = new Button();
|
||||||
buttonCancel = new Button();
|
buttonCancel = new Button();
|
||||||
SuspendLayout();
|
label1 = new Label();
|
||||||
//
|
textBoxTimeWork = new TextBox();
|
||||||
// labelCount
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
labelCount.AutoSize = true;
|
// labelCount
|
||||||
labelCount.Location = new Point(21, 25);
|
//
|
||||||
labelCount.Name = "labelCount";
|
labelCount.AutoSize = true;
|
||||||
labelCount.Size = new Size(93, 20);
|
labelCount.Location = new Point(21, 25);
|
||||||
labelCount.TabIndex = 0;
|
labelCount.Name = "labelCount";
|
||||||
labelCount.Text = "Количество:";
|
labelCount.Size = new Size(93, 20);
|
||||||
//
|
labelCount.TabIndex = 0;
|
||||||
// textBoxCount
|
labelCount.Text = "Количество:";
|
||||||
//
|
//
|
||||||
textBoxCount.Location = new Point(158, 22);
|
// textBoxCount
|
||||||
textBoxCount.Name = "textBoxCount";
|
//
|
||||||
textBoxCount.Size = new Size(217, 27);
|
textBoxCount.Location = new Point(158, 22);
|
||||||
textBoxCount.TabIndex = 1;
|
textBoxCount.Name = "textBoxCount";
|
||||||
//
|
textBoxCount.Size = new Size(217, 27);
|
||||||
// buttonStart
|
textBoxCount.TabIndex = 1;
|
||||||
//
|
//
|
||||||
buttonStart.Location = new Point(147, 87);
|
// buttonStart
|
||||||
buttonStart.Name = "buttonStart";
|
//
|
||||||
buttonStart.Size = new Size(110, 29);
|
buttonStart.Location = new Point(147, 162);
|
||||||
buttonStart.TabIndex = 2;
|
buttonStart.Name = "buttonStart";
|
||||||
buttonStart.Text = "Генерация";
|
buttonStart.Size = new Size(110, 29);
|
||||||
buttonStart.UseVisualStyleBackColor = true;
|
buttonStart.TabIndex = 2;
|
||||||
buttonStart.Click += ButtonStart_Click;
|
buttonStart.Text = "Генерация";
|
||||||
//
|
buttonStart.UseVisualStyleBackColor = true;
|
||||||
// buttonCancel
|
buttonStart.Click += ButtonStart_Click;
|
||||||
//
|
//
|
||||||
buttonCancel.Location = new Point(281, 87);
|
// buttonCancel
|
||||||
buttonCancel.Name = "buttonCancel";
|
//
|
||||||
buttonCancel.Size = new Size(94, 29);
|
buttonCancel.Location = new Point(281, 162);
|
||||||
buttonCancel.TabIndex = 3;
|
buttonCancel.Name = "buttonCancel";
|
||||||
buttonCancel.Text = "Отмена";
|
buttonCancel.Size = new Size(94, 29);
|
||||||
buttonCancel.UseVisualStyleBackColor = true;
|
buttonCancel.TabIndex = 3;
|
||||||
buttonCancel.Click += ButtonCancel_Click;
|
buttonCancel.Text = "Отмена";
|
||||||
//
|
buttonCancel.UseVisualStyleBackColor = true;
|
||||||
// FormRandomCreateClient
|
buttonCancel.Click += ButtonCancel_Click;
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
// label1
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
//
|
||||||
ClientSize = new Size(429, 141);
|
label1.AutoSize = true;
|
||||||
Controls.Add(buttonCancel);
|
label1.Location = new Point(21, 101);
|
||||||
Controls.Add(buttonStart);
|
label1.Name = "label1";
|
||||||
Controls.Add(textBoxCount);
|
label1.Size = new Size(113, 20);
|
||||||
Controls.Add(labelCount);
|
label1.TabIndex = 4;
|
||||||
Name = "FormRandomCreateClient";
|
label1.Text = "Время работы:";
|
||||||
Text = "Случайная генерация клиентов";
|
//
|
||||||
ResumeLayout(false);
|
// textBoxTimeWork
|
||||||
PerformLayout();
|
//
|
||||||
}
|
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 Label labelCount;
|
||||||
private TextBox textBoxCount;
|
private TextBox textBoxCount;
|
||||||
private Button buttonStart;
|
private Button buttonStart;
|
||||||
private Button buttonCancel;
|
private Button buttonCancel;
|
||||||
}
|
private Label label1;
|
||||||
|
private TextBox textBoxTimeWork;
|
||||||
|
}
|
||||||
}
|
}
|
@ -3,6 +3,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
@ -13,65 +14,57 @@ using TransportCompanyContracts.BusinessLogicsContracts;
|
|||||||
|
|
||||||
namespace TransportCompany
|
namespace TransportCompany
|
||||||
{
|
{
|
||||||
public partial class FormRandomCreateClient : Form
|
public partial class FormRandomCreateClient : Form
|
||||||
{
|
{
|
||||||
private readonly IClientLogic _logicC;
|
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)
|
public FormRandomCreateClient(IClientLogic logicC)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
_logicC = logicC;
|
_logicC = logicC;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ButtonStart_Click(object sender, EventArgs e)
|
private void ButtonStart_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
for (int i = 0; i < Convert.ToInt32(textBoxCount.Text); i++)
|
ChangeList(_telephones);
|
||||||
{
|
|
||||||
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)],
|
|
||||||
};
|
|
||||||
|
|
||||||
var operationResult = _logicC.Create(model);
|
ChangeList(_emails);
|
||||||
|
|
||||||
if (!operationResult)
|
textBoxTimeWork.Text = _logicC.TestRandomCreate(Convert.ToInt32(textBoxCount.Text), _names, _surnames, _patronymics, _telephones, _emails);
|
||||||
{
|
}
|
||||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
catch (Exception ex)
|
||||||
}
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Close();
|
private void ButtonCancel_Click(object sender, EventArgs e)
|
||||||
}
|
{
|
||||||
}
|
DialogResult = DialogResult.Cancel;
|
||||||
catch (Exception ex)
|
Close();
|
||||||
{
|
}
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonCancel_Click(object sender, EventArgs e)
|
private void ChangeList(string[] _strings)
|
||||||
{
|
{
|
||||||
DialogResult = DialogResult.Cancel;
|
for(int i = 0; i < _strings.Length; i++)
|
||||||
Close();
|
{
|
||||||
}
|
_strings[i] = Convert.ToString(rnd.Next(0, 800000)) + _strings[i];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,95 +1,117 @@
|
|||||||
namespace TransportCompany
|
namespace TransportCompany
|
||||||
{
|
{
|
||||||
partial class FormRandomCreateTrucking
|
partial class FormRandomCreateTrucking
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Required designer variable.
|
/// Required designer variable.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private System.ComponentModel.IContainer components = null;
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Clean up any resources being used.
|
/// Clean up any resources being used.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
protected override void Dispose(bool disposing)
|
protected override void Dispose(bool disposing)
|
||||||
{
|
{
|
||||||
if (disposing && (components != null))
|
if (disposing && (components != null))
|
||||||
{
|
{
|
||||||
components.Dispose();
|
components.Dispose();
|
||||||
}
|
}
|
||||||
base.Dispose(disposing);
|
base.Dispose(disposing);
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Required method for Designer support - do not modify
|
/// Required method for Designer support - do not modify
|
||||||
/// the contents of this method with the code editor.
|
/// the contents of this method with the code editor.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
labelClient = new Label();
|
labelClient = new Label();
|
||||||
textBoxCount = new TextBox();
|
textBoxCount = new TextBox();
|
||||||
buttonCreate = new Button();
|
buttonCreate = new Button();
|
||||||
buttonCancel = new Button();
|
buttonCancel = new Button();
|
||||||
SuspendLayout();
|
label1 = new Label();
|
||||||
//
|
textBoxCheckTest = new TextBox();
|
||||||
// labelClient
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
labelClient.AutoSize = true;
|
// labelClient
|
||||||
labelClient.Location = new Point(32, 33);
|
//
|
||||||
labelClient.Name = "labelClient";
|
labelClient.AutoSize = true;
|
||||||
labelClient.Size = new Size(151, 20);
|
labelClient.Location = new Point(32, 33);
|
||||||
labelClient.TabIndex = 0;
|
labelClient.Name = "labelClient";
|
||||||
labelClient.Text = "Введите количество:";
|
labelClient.Size = new Size(151, 20);
|
||||||
//
|
labelClient.TabIndex = 0;
|
||||||
// textBoxCount
|
labelClient.Text = "Введите количество:";
|
||||||
//
|
//
|
||||||
textBoxCount.Location = new Point(221, 30);
|
// textBoxCount
|
||||||
textBoxCount.Name = "textBoxCount";
|
//
|
||||||
textBoxCount.Size = new Size(280, 27);
|
textBoxCount.Location = new Point(221, 30);
|
||||||
textBoxCount.TabIndex = 1;
|
textBoxCount.Name = "textBoxCount";
|
||||||
//
|
textBoxCount.Size = new Size(280, 27);
|
||||||
// buttonCreate
|
textBoxCount.TabIndex = 1;
|
||||||
//
|
//
|
||||||
buttonCreate.Location = new Point(237, 91);
|
// buttonCreate
|
||||||
buttonCreate.Name = "buttonCreate";
|
//
|
||||||
buttonCreate.Size = new Size(123, 29);
|
buttonCreate.Location = new Point(237, 148);
|
||||||
buttonCreate.TabIndex = 2;
|
buttonCreate.Name = "buttonCreate";
|
||||||
buttonCreate.Text = "Генерация";
|
buttonCreate.Size = new Size(123, 29);
|
||||||
buttonCreate.UseVisualStyleBackColor = true;
|
buttonCreate.TabIndex = 2;
|
||||||
buttonCreate.Click += ButtonCreate_Click;
|
buttonCreate.Text = "Генерация";
|
||||||
//
|
buttonCreate.UseVisualStyleBackColor = true;
|
||||||
// buttonCancel
|
buttonCreate.Click += ButtonCreate_Click;
|
||||||
//
|
//
|
||||||
buttonCancel.Location = new Point(382, 91);
|
// buttonCancel
|
||||||
buttonCancel.Name = "buttonCancel";
|
//
|
||||||
buttonCancel.Size = new Size(119, 29);
|
buttonCancel.Location = new Point(382, 148);
|
||||||
buttonCancel.TabIndex = 3;
|
buttonCancel.Name = "buttonCancel";
|
||||||
buttonCancel.Text = "Отмена";
|
buttonCancel.Size = new Size(119, 29);
|
||||||
buttonCancel.UseVisualStyleBackColor = true;
|
buttonCancel.TabIndex = 3;
|
||||||
buttonCancel.Click += ButtonCancel_Click;
|
buttonCancel.Text = "Отмена";
|
||||||
//
|
buttonCancel.UseVisualStyleBackColor = true;
|
||||||
// FormRandomCreateTrucking
|
buttonCancel.Click += ButtonCancel_Click;
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
// label1
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
//
|
||||||
ClientSize = new Size(548, 147);
|
label1.AutoSize = true;
|
||||||
Controls.Add(buttonCancel);
|
label1.Location = new Point(32, 99);
|
||||||
Controls.Add(buttonCreate);
|
label1.Name = "label1";
|
||||||
Controls.Add(textBoxCount);
|
label1.Size = new Size(145, 20);
|
||||||
Controls.Add(labelClient);
|
label1.TabIndex = 4;
|
||||||
Name = "FormRandomCreateTrucking";
|
label1.Text = "Время добавления:";
|
||||||
Text = "Генерация перевозок";
|
//
|
||||||
ResumeLayout(false);
|
// textBoxCheckTest
|
||||||
PerformLayout();
|
//
|
||||||
}
|
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 Label labelClient;
|
||||||
private TextBox textBoxCount;
|
private TextBox textBoxCount;
|
||||||
private Button buttonCreate;
|
private Button buttonCreate;
|
||||||
private Button buttonCancel;
|
private Button buttonCancel;
|
||||||
}
|
private Label label1;
|
||||||
|
private TextBox textBoxCheckTest;
|
||||||
|
}
|
||||||
}
|
}
|
@ -14,82 +14,51 @@ using TransportCompanyContracts.BusinessLogicsContracts;
|
|||||||
|
|
||||||
namespace TransportCompany
|
namespace TransportCompany
|
||||||
{
|
{
|
||||||
public partial class FormRandomCreateTrucking : Form
|
public partial class FormRandomCreateTrucking : Form
|
||||||
{
|
{
|
||||||
Random rnd = new Random(DateTime.Now.ToString().GetHashCode());
|
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<FormRandomCreateTrucking> 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<FormRandomCreateTrucking> logger, ITruckingLogic logic, ICargoLogic logicCargo,
|
try
|
||||||
IClientLogic logicCl, ITransportLogic logicTransport, ITransportationLogic logicTransportation)
|
{
|
||||||
{
|
textBoxCheckTest.Text = _logic.TestRandomCreate(Convert.ToInt32(textBoxCount.Text), viewClient, viewCargo, viewTransport, viewTransportation);
|
||||||
InitializeComponent();
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_logic = logic;
|
private void ButtonCancel_Click(object sender, EventArgs e)
|
||||||
_logicCargo = logicCargo;
|
{
|
||||||
_logicCl = logicCl;
|
DialogResult = DialogResult.Cancel;
|
||||||
_logicTransport = logicTransport;
|
Close();
|
||||||
_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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,13 @@ namespace TransportCompanyBusinessLogic.BusinessLogic
|
|||||||
return true;
|
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);
|
CheckModel(model);
|
||||||
|
|
||||||
@ -169,5 +175,5 @@ namespace TransportCompanyBusinessLogic.BusinessLogic
|
|||||||
throw new InvalidOperationException("Клиент с такой почтой уже есть");
|
throw new InvalidOperationException("Клиент с такой почтой уже есть");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,12 @@ namespace TransportCompanyBusinessLogic.BusinessLogic
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Update(TruckingBindingModel model)
|
public string TestRandomCreate(int count, List<ClientViewModel> clients, List<CargoViewModel> cargos, List<TransportViewModel> transports, List<TransportationViewModel> transportations)
|
||||||
|
{
|
||||||
|
return _truckingStorage.TestRandomInsert(count, clients, cargos, transports, transportations);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Update(TruckingBindingModel model)
|
||||||
{
|
{
|
||||||
CheckModel(model);
|
CheckModel(model);
|
||||||
|
|
||||||
@ -158,5 +163,5 @@ namespace TransportCompanyBusinessLogic.BusinessLogic
|
|||||||
"TransportationId:{TransportationId}. DateStart:{DateStart}. DateEnd:{DateEnd}. Id:{Id}",
|
"TransportationId:{TransportationId}. DateStart:{DateStart}. DateEnd:{DateEnd}. Id:{Id}",
|
||||||
model.ClientId, model.CargoId, model.TransportId, model.TransportationId, model.DateStart, model.DateEnd, model.Id);
|
model.ClientId, model.CargoId, model.TransportId, model.TransportationId, model.DateStart, model.DateEnd, model.Id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,9 @@ namespace TransportCompanyContracts.BusinessLogicsContracts
|
|||||||
|
|
||||||
bool Create(ClientBindingModel model);
|
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);
|
bool Delete(ClientBindingModel model);
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,9 @@ namespace TransportCompanyContracts.BusinessLogicsContracts
|
|||||||
|
|
||||||
bool Create(TruckingBindingModel model);
|
bool Create(TruckingBindingModel model);
|
||||||
|
|
||||||
bool Update(TruckingBindingModel model);
|
string TestRandomCreate(int count, List<ClientViewModel> clients, List<CargoViewModel> cargos, List<TransportViewModel> transports, List<TransportationViewModel> transportations);
|
||||||
|
|
||||||
|
bool Update(TruckingBindingModel model);
|
||||||
|
|
||||||
bool Delete(TruckingBindingModel model);
|
bool Delete(TruckingBindingModel model);
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,9 @@ namespace TransportCompanyContracts.StoragesContracts
|
|||||||
|
|
||||||
ClientViewModel? Insert(ClientBindingModel model);
|
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);
|
ClientViewModel? Delete(ClientBindingModel model);
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,9 @@ namespace TransportCompanyContracts.StoragesContracts
|
|||||||
|
|
||||||
TruckingViewModel? Insert(TruckingBindingModel model);
|
TruckingViewModel? Insert(TruckingBindingModel model);
|
||||||
|
|
||||||
TruckingViewModel? Update(TruckingBindingModel model);
|
string TestRandomInsert(int count, List<ClientViewModel> clients, List<CargoViewModel> cargos, List<TransportViewModel> transports, List<TransportationViewModel> transportations);
|
||||||
|
|
||||||
|
TruckingViewModel? Update(TruckingBindingModel model);
|
||||||
|
|
||||||
TruckingViewModel? Delete(TruckingBindingModel model);
|
TruckingViewModel? Delete(TruckingBindingModel model);
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,11 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Net;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using System.Xml.Linq;
|
||||||
using TransportCompanyContracts.BindingModels;
|
using TransportCompanyContracts.BindingModels;
|
||||||
using TransportCompanyContracts.SearchModels;
|
using TransportCompanyContracts.SearchModels;
|
||||||
using TransportCompanyContracts.StoragesContracts;
|
using TransportCompanyContracts.StoragesContracts;
|
||||||
@ -70,7 +73,45 @@ namespace TransportCompanyDatabaseImplements.Implements
|
|||||||
return newClient.GetViewModel;
|
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 context = new ElegevContext();
|
||||||
using var transaction = context.Database.BeginTransaction();
|
using var transaction = context.Database.BeginTransaction();
|
||||||
@ -114,5 +155,5 @@ namespace TransportCompanyDatabaseImplements.Implements
|
|||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@ -99,7 +100,50 @@ namespace TransportCompanyDatabaseImplements.Implements
|
|||||||
?.GetViewModel;
|
?.GetViewModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TruckingViewModel? Update(TruckingBindingModel model)
|
//метод для замера вставки большого кол-ва клиентов в бд
|
||||||
|
public string TestRandomInsert(int count, List<ClientViewModel> clients, List<CargoViewModel> cargos, List<TransportViewModel> transports, List<TransportationViewModel> 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 context = new ElegevContext();
|
||||||
using var transaction = context.Database.BeginTransaction();
|
using var transaction = context.Database.BeginTransaction();
|
||||||
|
Loading…
Reference in New Issue
Block a user