добавил перенос данных из постгреса в монго
This commit is contained in:
parent
1758e6f5ce
commit
70a6322df4
24
SUBD_Car_rent/Forms/FormMain.Designer.cs
generated
24
SUBD_Car_rent/Forms/FormMain.Designer.cs
generated
@ -40,6 +40,7 @@
|
||||
trackBarDB = new TrackBar();
|
||||
labelPostrges = new Label();
|
||||
labelMongoDB = new Label();
|
||||
buttonTransferDataFromPostgresToMongo = new TextBox();
|
||||
menuStrip1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)trackBarDB).BeginInit();
|
||||
SuspendLayout();
|
||||
@ -97,7 +98,7 @@
|
||||
//
|
||||
// buttonTest
|
||||
//
|
||||
buttonTest.Location = new Point(75, 229);
|
||||
buttonTest.Location = new Point(75, 135);
|
||||
buttonTest.Name = "buttonTest";
|
||||
buttonTest.Size = new Size(75, 23);
|
||||
buttonTest.TabIndex = 1;
|
||||
@ -107,7 +108,7 @@
|
||||
//
|
||||
// textBoxTest
|
||||
//
|
||||
textBoxTest.Location = new Point(172, 230);
|
||||
textBoxTest.Location = new Point(172, 136);
|
||||
textBoxTest.Multiline = true;
|
||||
textBoxTest.Name = "textBoxTest";
|
||||
textBoxTest.Size = new Size(251, 75);
|
||||
@ -144,11 +145,26 @@
|
||||
labelMongoDB.TabIndex = 5;
|
||||
labelMongoDB.Text = "MongoDB";
|
||||
//
|
||||
// buttonTransferDataFromPostgresToMongo
|
||||
//
|
||||
buttonTransferDataFromPostgresToMongo.BackColor = SystemColors.ControlLight;
|
||||
buttonTransferDataFromPostgresToMongo.Cursor = Cursors.Hand;
|
||||
buttonTransferDataFromPostgresToMongo.Font = new Font("Segoe UI", 15F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
buttonTransferDataFromPostgresToMongo.Location = new Point(177, 34);
|
||||
buttonTransferDataFromPostgresToMongo.Multiline = true;
|
||||
buttonTransferDataFromPostgresToMongo.Name = "buttonTransferDataFromPostgresToMongo";
|
||||
buttonTransferDataFromPostgresToMongo.ReadOnly = true;
|
||||
buttonTransferDataFromPostgresToMongo.Size = new Size(246, 67);
|
||||
buttonTransferDataFromPostgresToMongo.TabIndex = 8;
|
||||
buttonTransferDataFromPostgresToMongo.Text = "Transfer data from PostgresSQL to MongoDB";
|
||||
buttonTransferDataFromPostgresToMongo.Click += buttonTransferDataFromPostgresToMongo_Click;
|
||||
//
|
||||
// FormMain
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(435, 317);
|
||||
ClientSize = new Size(435, 224);
|
||||
Controls.Add(buttonTransferDataFromPostgresToMongo);
|
||||
Controls.Add(labelMongoDB);
|
||||
Controls.Add(labelPostrges);
|
||||
Controls.Add(trackBarDB);
|
||||
@ -179,5 +195,7 @@
|
||||
private TrackBar trackBarDB;
|
||||
private Label labelPostrges;
|
||||
private Label labelMongoDB;
|
||||
private TextBox textBox1;
|
||||
private TextBox buttonTransferDataFromPostgresToMongo;
|
||||
}
|
||||
}
|
@ -2,85 +2,86 @@
|
||||
|
||||
namespace Forms
|
||||
{
|
||||
public partial class FormMain : Form
|
||||
{
|
||||
public partial class FormMain : Form
|
||||
{
|
||||
|
||||
public FormMain()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
public FormMain()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void carModelToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormCarModel));
|
||||
if (service is FormCarModel form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
private void carModelToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormCarModel));
|
||||
if (service is FormCarModel form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void carToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormCar));
|
||||
if (service is FormCar form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
private void carToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormCar));
|
||||
if (service is FormCar form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void branchToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormBranch));
|
||||
if (service is FormBranch form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
private void branchToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormBranch));
|
||||
if (service is FormBranch form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void clientToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormBranch));
|
||||
if (service is FormBranch form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
private void clientToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormBranch));
|
||||
if (service is FormBranch form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void rentalToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormRental));
|
||||
if (service is FormRental form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
private void rentalToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormRental));
|
||||
if (service is FormRental form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonTest_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(Abstractions));
|
||||
if (service is Abstractions bd)
|
||||
{
|
||||
var client = new Client(){
|
||||
Id = 0,
|
||||
Address = "awsedff",
|
||||
Email = "afdgaw",
|
||||
Name = "aedfrg",
|
||||
Phone = "asda",
|
||||
Surname = "dfgvsdfg",
|
||||
};
|
||||
private void buttonTest_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(Abstractions));
|
||||
if (service is Abstractions bd)
|
||||
{
|
||||
var client = new Client()
|
||||
{
|
||||
Id = 0,
|
||||
Address = "awsedff",
|
||||
Email = "afdgaw",
|
||||
Name = "aedfrg",
|
||||
Phone = "asda",
|
||||
Surname = "dfgvsdfg",
|
||||
};
|
||||
|
||||
DateTime startTime = DateTime.Now;
|
||||
bd.DeleteClient(10);
|
||||
bd.DeleteClient(11);
|
||||
bd.DeleteClient(12);
|
||||
bd.DeleteClient(13);
|
||||
bd.DeleteClient(14);
|
||||
DateTime endTime = DateTime.Now;
|
||||
DateTime startTime = DateTime.Now;
|
||||
bd.DeleteClient(10);
|
||||
bd.DeleteClient(11);
|
||||
bd.DeleteClient(12);
|
||||
bd.DeleteClient(13);
|
||||
bd.DeleteClient(14);
|
||||
DateTime endTime = DateTime.Now;
|
||||
|
||||
// Выводим время выполнения запроса в консоль
|
||||
textBoxTest.Text = $"Время выполнения запроса: {(endTime - startTime).TotalMilliseconds} миллисекунд";
|
||||
}
|
||||
}
|
||||
// Выводим время выполнения запроса в консоль
|
||||
textBoxTest.Text = $"Время выполнения запроса: {(endTime - startTime).TotalMilliseconds} миллисекунд";
|
||||
}
|
||||
}
|
||||
|
||||
private void trackBarDB_MouseUp(object sender, MouseEventArgs e)
|
||||
{
|
||||
@ -96,6 +97,44 @@ namespace Forms
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonTransferDataFromPostgresToMongo_Click(object sender, EventArgs e)
|
||||
{
|
||||
ImplementationMongoDB implementationMongoDB = new();
|
||||
|
||||
// очищаем всё
|
||||
foreach (var it in implementationMongoDB.GetBranches())
|
||||
implementationMongoDB.DeleteBranch(it.Id);
|
||||
foreach (var it in implementationMongoDB.GetClients())
|
||||
implementationMongoDB.DeleteClient(it.Id);
|
||||
foreach (var it in implementationMongoDB.GetCarModels())
|
||||
implementationMongoDB.DeleteCarModel(it.Id);
|
||||
foreach (var it in implementationMongoDB.GetCars())
|
||||
implementationMongoDB.DeleteCar(it.Id);
|
||||
foreach (var it in implementationMongoDB.GetRentals())
|
||||
implementationMongoDB.DeleteRental(it.Id);
|
||||
|
||||
ImplementationPostgres implementationPostgres = new();
|
||||
|
||||
// скачиваем из постгреса
|
||||
var listBranches = implementationPostgres.GetBranches();
|
||||
var listClients = implementationPostgres.GetClients();
|
||||
var listCarModels = implementationPostgres.GetCarModels();
|
||||
var listCars = implementationPostgres.GetCars();
|
||||
var listRentals = implementationPostgres.GetRentals();
|
||||
|
||||
// вливаем данные монго дб
|
||||
foreach (var it in listBranches)
|
||||
implementationMongoDB.AddBranch(it);
|
||||
foreach (var it in listClients)
|
||||
implementationMongoDB.AddClient(it);
|
||||
foreach (var it in listCarModels)
|
||||
implementationMongoDB.AddCarModel(it);
|
||||
foreach (var it in listCars)
|
||||
implementationMongoDB.AddCar(it);
|
||||
foreach (var it in listRentals)
|
||||
implementationMongoDB.AddRental(it);
|
||||
}
|
||||
|
||||
/*
|
||||
private Abstractions bd = new Implementation();
|
||||
private void button1_Click(object sender, EventArgs e)
|
||||
@ -122,5 +161,5 @@ namespace Forms
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user