бб лаба
This commit is contained in:
parent
99cb2ed397
commit
7c0760fdba
@ -13,7 +13,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BeautySaloonBusinessLogic",
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BeautySaloonDatabaseImplement", "BeautySaloonDatabaseImplement\BeautySaloonDatabaseImplement.csproj", "{BB7AD640-FF4A-415B-A09B-BB802D64CE27}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BeautySaloonDatabaseImplement", "BeautySaloonDatabaseImplement\BeautySaloonDatabaseImplement.csproj", "{BB7AD640-FF4A-415B-A09B-BB802D64CE27}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BeautySaloonNoSQLDatabaseImplement", "BeautySaloonNoSQLDatabaseImplement\BeautySaloonNoSQLDatabaseImplement.csproj", "{153FD23E-4112-4C64-B270-914A6F17C7FE}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BeautySaloonNoSQLDatabaseImplement", "BeautySaloonNoSQLDatabaseImplement\BeautySaloonNoSQLDatabaseImplement.csproj", "{153FD23E-4112-4C64-B270-914A6F17C7FE}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
@ -28,7 +28,7 @@ namespace BeautySaloonNoSQLDatabaseImplement
|
|||||||
public string Phone { get; set; } = string.Empty;
|
public string Phone { get; set; } = string.Empty;
|
||||||
|
|
||||||
[BsonElement("position")]
|
[BsonElement("position")]
|
||||||
public string Position { get; set; } = string.Empty;
|
public string PositionName { get; set; } = string.Empty;
|
||||||
|
|
||||||
[BsonIgnore]
|
[BsonIgnore]
|
||||||
public int PositionId { get; set; }
|
public int PositionId { get; set; }
|
||||||
@ -47,7 +47,7 @@ namespace BeautySaloonNoSQLDatabaseImplement
|
|||||||
Patronymic = model.Patronymic,
|
Patronymic = model.Patronymic,
|
||||||
Phone = model.Phone,
|
Phone = model.Phone,
|
||||||
PositionId = model.PositionId,
|
PositionId = model.PositionId,
|
||||||
Position = model.PositionName
|
PositionName = model.PositionName
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,7 +62,7 @@ namespace BeautySaloonNoSQLDatabaseImplement
|
|||||||
Patronymic = model.Patronymic;
|
Patronymic = model.Patronymic;
|
||||||
Phone = model.Phone;
|
Phone = model.Phone;
|
||||||
PositionId = model.PositionId;
|
PositionId = model.PositionId;
|
||||||
Position = model.PositionName;
|
PositionName = model.PositionName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public EmployeeViewModel GetViewModel => new()
|
public EmployeeViewModel GetViewModel => new()
|
||||||
@ -73,7 +73,7 @@ namespace BeautySaloonNoSQLDatabaseImplement
|
|||||||
Patronymic = Patronymic,
|
Patronymic = Patronymic,
|
||||||
Phone = Phone,
|
Phone = Phone,
|
||||||
PositionId = PositionId,
|
PositionId = PositionId,
|
||||||
PositionName = Position,
|
PositionName = PositionName,
|
||||||
FIO = Name + ' ' + Surname + ' ' + Patronymic,
|
FIO = Name + ' ' + Surname + ' ' + Patronymic,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -9,10 +9,10 @@ namespace BeautySaloonNoSQLDatabaseImplement.Implements
|
|||||||
{
|
{
|
||||||
public class ClientStorage : IClientStorage
|
public class ClientStorage : IClientStorage
|
||||||
{
|
{
|
||||||
private readonly NewdbContext _source;
|
private readonly MongoDBContext _source;
|
||||||
public ClientStorage()
|
public ClientStorage()
|
||||||
{
|
{
|
||||||
_source = NewdbContext.GetInstance();
|
_source = MongoDBContext.GetInstance();
|
||||||
}
|
}
|
||||||
public ClientViewModel? Delete(ClientBindingModel model)
|
public ClientViewModel? Delete(ClientBindingModel model)
|
||||||
{
|
{
|
||||||
|
@ -10,10 +10,10 @@ namespace BeautySaloonNoSQLDatabaseImplement.Implements
|
|||||||
{
|
{
|
||||||
public class EmployeeStorage : IEmployeeStorage
|
public class EmployeeStorage : IEmployeeStorage
|
||||||
{
|
{
|
||||||
private readonly NewdbContext _source;
|
private readonly MongoDBContext _source;
|
||||||
public EmployeeStorage()
|
public EmployeeStorage()
|
||||||
{
|
{
|
||||||
_source = NewdbContext.GetInstance();
|
_source = MongoDBContext.GetInstance();
|
||||||
}
|
}
|
||||||
public EmployeeViewModel? Delete(EmployeeBindingModel model)
|
public EmployeeViewModel? Delete(EmployeeBindingModel model)
|
||||||
{
|
{
|
||||||
|
@ -9,10 +9,10 @@ namespace BeautySaloonNoSQLDatabaseImplement.Implements
|
|||||||
{
|
{
|
||||||
public class OrderStorage : IOrderStorage
|
public class OrderStorage : IOrderStorage
|
||||||
{
|
{
|
||||||
private readonly NewdbContext _source;
|
private readonly MongoDBContext _source;
|
||||||
public OrderStorage()
|
public OrderStorage()
|
||||||
{
|
{
|
||||||
_source = NewdbContext.GetInstance();
|
_source = MongoDBContext.GetInstance();
|
||||||
}
|
}
|
||||||
public OrderViewModel? Delete(OrderBindingModel model)
|
public OrderViewModel? Delete(OrderBindingModel model)
|
||||||
{
|
{
|
||||||
@ -57,7 +57,7 @@ namespace BeautySaloonNoSQLDatabaseImplement.Implements
|
|||||||
public List<OrderViewModel> GetFullList()
|
public List<OrderViewModel> GetFullList()
|
||||||
{
|
{
|
||||||
var filterDefinition = Builders<Order>.Filter.Empty;
|
var filterDefinition = Builders<Order>.Filter.Empty;
|
||||||
return _source.Orders.Find(filterDefinition).ToList().Select(x => x.GetViewModel).ToList();
|
return _source.Orders.Find(filterDefinition).ToList().Select(x => x.GetViewModel).ToList().OrderByDescending(x => x.Date).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public OrderViewModel? Insert(OrderBindingModel model)
|
public OrderViewModel? Insert(OrderBindingModel model)
|
||||||
|
@ -10,10 +10,10 @@ namespace BeautySaloonNoSQLDatabaseImplement.Implements
|
|||||||
{
|
{
|
||||||
public class PositionStorage : IPositionStorage
|
public class PositionStorage : IPositionStorage
|
||||||
{
|
{
|
||||||
private readonly NewdbContext _source;
|
private readonly MongoDBContext _source;
|
||||||
public PositionStorage()
|
public PositionStorage()
|
||||||
{
|
{
|
||||||
_source = NewdbContext.GetInstance();
|
_source = MongoDBContext.GetInstance();
|
||||||
}
|
}
|
||||||
public PositionViewModel? Delete(PositionBindingModel model)
|
public PositionViewModel? Delete(PositionBindingModel model)
|
||||||
{
|
{
|
||||||
|
@ -10,10 +10,10 @@ namespace BeautySaloonNoSQLDatabaseImplement.Implements
|
|||||||
{
|
{
|
||||||
public class ServiceStorage : IServiceStorage
|
public class ServiceStorage : IServiceStorage
|
||||||
{
|
{
|
||||||
private readonly NewdbContext _source;
|
private readonly MongoDBContext _source;
|
||||||
public ServiceStorage()
|
public ServiceStorage()
|
||||||
{
|
{
|
||||||
_source = NewdbContext.GetInstance();
|
_source = MongoDBContext.GetInstance();
|
||||||
}
|
}
|
||||||
public ServiceViewModel? Delete(ServiceBindingModel model)
|
public ServiceViewModel? Delete(ServiceBindingModel model)
|
||||||
{
|
{
|
||||||
@ -66,10 +66,20 @@ namespace BeautySaloonNoSQLDatabaseImplement.Implements
|
|||||||
|
|
||||||
public List<ReportViewModel> ReadMostPopular()
|
public List<ReportViewModel> ReadMostPopular()
|
||||||
{
|
{
|
||||||
/*var filterDefinition = Builders<Order>.Filter.Empty;
|
var filterDefinition = Builders<Order>.Filter.Empty;
|
||||||
_source.Orders.Find(filterDefinition).ToList().Select(x => x.ServiceOrders)
|
var result = _source.Orders
|
||||||
*/
|
.Find(filterDefinition)
|
||||||
return new();
|
.ToList()
|
||||||
|
.SelectMany(x => x.ServiceOrders)
|
||||||
|
.GroupBy(x => x.Service.Name)
|
||||||
|
.Select(x => new ReportViewModel()
|
||||||
|
{
|
||||||
|
Name = x.Key,
|
||||||
|
Sum = x.Sum(x => x.Service.Price)
|
||||||
|
})
|
||||||
|
.OrderByDescending(x => x.Sum)
|
||||||
|
.ToList();
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ServiceViewModel? Update(ServiceBindingModel model)
|
public ServiceViewModel? Update(ServiceBindingModel model)
|
||||||
|
@ -3,15 +3,15 @@ using System.Configuration;
|
|||||||
|
|
||||||
namespace BeautySaloonNoSQLDatabaseImplement
|
namespace BeautySaloonNoSQLDatabaseImplement
|
||||||
{
|
{
|
||||||
public class NewdbContext
|
public class MongoDBContext
|
||||||
{
|
{
|
||||||
private static NewdbContext? _instance;
|
private static MongoDBContext? _instance;
|
||||||
public IMongoCollection<Client> Clients { get; set; }
|
public IMongoCollection<Client> Clients { get; set; }
|
||||||
public IMongoCollection<Order> Orders { get; set; }
|
public IMongoCollection<Order> Orders { get; set; }
|
||||||
public IMongoCollection<Employee> Employees { get; set; }
|
public IMongoCollection<Employee> Employees { get; set; }
|
||||||
public IMongoCollection<Service> Services { get; set; }
|
public IMongoCollection<Service> Services { get; set; }
|
||||||
public IMongoCollection<Position> Positions { get; set; }
|
public IMongoCollection<Position> Positions { get; set; }
|
||||||
private NewdbContext()
|
private MongoDBContext()
|
||||||
{
|
{
|
||||||
var connectionString = ConfigurationManager.ConnectionStrings["DatabaseConnection"].ConnectionString;
|
var connectionString = ConfigurationManager.ConnectionStrings["DatabaseConnection"].ConnectionString;
|
||||||
var databaseName = MongoUrl.Create(connectionString).DatabaseName;
|
var databaseName = MongoUrl.Create(connectionString).DatabaseName;
|
||||||
@ -24,11 +24,11 @@ namespace BeautySaloonNoSQLDatabaseImplement
|
|||||||
Services = database.GetCollection<Service>("services");
|
Services = database.GetCollection<Service>("services");
|
||||||
Positions = database.GetCollection<Position>("positions");
|
Positions = database.GetCollection<Position>("positions");
|
||||||
}
|
}
|
||||||
public static NewdbContext GetInstance()
|
public static MongoDBContext GetInstance()
|
||||||
{
|
{
|
||||||
if (_instance == null)
|
if (_instance == null)
|
||||||
{
|
{
|
||||||
_instance = new NewdbContext();
|
_instance = new MongoDBContext();
|
||||||
}
|
}
|
||||||
return _instance;
|
return _instance;
|
||||||
}
|
}
|
@ -48,7 +48,7 @@ namespace BeautySaloonNoSQLDatabaseImplement
|
|||||||
{
|
{
|
||||||
if (_client == null)
|
if (_client == null)
|
||||||
{
|
{
|
||||||
_client = NewdbContext.GetInstance().Clients
|
_client = MongoDBContext.GetInstance().Clients
|
||||||
.Find(new BsonDocument("id", ClientId)).FirstOrDefault();
|
.Find(new BsonDocument("id", ClientId)).FirstOrDefault();
|
||||||
}
|
}
|
||||||
return _client;
|
return _client;
|
||||||
@ -61,7 +61,7 @@ namespace BeautySaloonNoSQLDatabaseImplement
|
|||||||
{
|
{
|
||||||
if (_employee == null)
|
if (_employee == null)
|
||||||
{
|
{
|
||||||
_employee = NewdbContext.GetInstance().Employees
|
_employee = MongoDBContext.GetInstance().Employees
|
||||||
.Find(new BsonDocument("id", EmployeeId)).FirstOrDefault();
|
.Find(new BsonDocument("id", EmployeeId)).FirstOrDefault();
|
||||||
}
|
}
|
||||||
return _employee;
|
return _employee;
|
||||||
@ -102,9 +102,9 @@ namespace BeautySaloonNoSQLDatabaseImplement
|
|||||||
EmployeeId = model.EmployeeId,
|
EmployeeId = model.EmployeeId,
|
||||||
ServiceOrders = model.OrderServices.Select(x => new ServiceOrder
|
ServiceOrders = model.OrderServices.Select(x => new ServiceOrder
|
||||||
{
|
{
|
||||||
Service = NewdbContext.GetInstance().Services.Find(new BsonDocument("id", x.Key)).FirstOrDefault(),
|
Service = MongoDBContext.GetInstance().Services.Find(new BsonDocument("id", x.Key)).FirstOrDefault(),
|
||||||
Date = x.Value.Item1,
|
Date = x.Value.Item1,
|
||||||
Employee = NewdbContext.GetInstance().Employees.Find(new BsonDocument("id", x.Value.Item3)).FirstOrDefault(),
|
Employee = MongoDBContext.GetInstance().Employees.Find(new BsonDocument("id", x.Value.Item3)).FirstOrDefault(),
|
||||||
}).ToList()
|
}).ToList()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using BeautySaloonContracts.BindingModels;
|
using BeautySaloonContracts.BusinessLogicsContracts;
|
||||||
using BeautySaloonContracts.BusinessLogicsContracts;
|
|
||||||
using BeautySaloonContracts.SearchModels;
|
using BeautySaloonContracts.SearchModels;
|
||||||
|
|
||||||
namespace BeautySaloonView
|
namespace BeautySaloonView
|
||||||
|
64
BeautySaloon/BeautySaloonView/FormMain.Designer.cs
generated
64
BeautySaloon/BeautySaloonView/FormMain.Designer.cs
generated
@ -35,10 +35,11 @@
|
|||||||
this.услугиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.услугиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.сотрудникиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.сотрудникиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.клиентыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.клиентыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.buttonUpdate = new System.Windows.Forms.Button();
|
|
||||||
this.buttonTest = new System.Windows.Forms.Button();
|
|
||||||
this.отчетыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.отчетыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.услугиToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
|
this.услугиToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.buttonUpdate = new System.Windows.Forms.Button();
|
||||||
|
this.buttonTest = new System.Windows.Forms.Button();
|
||||||
|
this.buttonTransfer = new System.Windows.Forms.Button();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||||
this.menuStrip1.SuspendLayout();
|
this.menuStrip1.SuspendLayout();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
@ -105,28 +106,6 @@
|
|||||||
this.клиентыToolStripMenuItem.Text = "Клиенты";
|
this.клиентыToolStripMenuItem.Text = "Клиенты";
|
||||||
this.клиентыToolStripMenuItem.Click += new System.EventHandler(this.ClientsToolStripMenuItem_Click);
|
this.клиентыToolStripMenuItem.Click += new System.EventHandler(this.ClientsToolStripMenuItem_Click);
|
||||||
//
|
//
|
||||||
// buttonUpdate
|
|
||||||
//
|
|
||||||
this.buttonUpdate.Location = new System.Drawing.Point(917, 225);
|
|
||||||
this.buttonUpdate.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.buttonUpdate.Name = "buttonUpdate";
|
|
||||||
this.buttonUpdate.Size = new System.Drawing.Size(116, 58);
|
|
||||||
this.buttonUpdate.TabIndex = 17;
|
|
||||||
this.buttonUpdate.Text = "Обновить";
|
|
||||||
this.buttonUpdate.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonUpdate.Click += new System.EventHandler(this.ButtonRef_Click);
|
|
||||||
//
|
|
||||||
// buttonTest
|
|
||||||
//
|
|
||||||
this.buttonTest.Location = new System.Drawing.Point(917, 287);
|
|
||||||
this.buttonTest.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.buttonTest.Name = "buttonTest";
|
|
||||||
this.buttonTest.Size = new System.Drawing.Size(116, 58);
|
|
||||||
this.buttonTest.TabIndex = 18;
|
|
||||||
this.buttonTest.Text = "Тесты";
|
|
||||||
this.buttonTest.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonTest.Click += new System.EventHandler(this.ButtonTest_Click);
|
|
||||||
//
|
|
||||||
// отчетыToolStripMenuItem
|
// отчетыToolStripMenuItem
|
||||||
//
|
//
|
||||||
this.отчетыToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
this.отчетыToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
@ -138,15 +117,49 @@
|
|||||||
// услугиToolStripMenuItem1
|
// услугиToolStripMenuItem1
|
||||||
//
|
//
|
||||||
this.услугиToolStripMenuItem1.Name = "услугиToolStripMenuItem1";
|
this.услугиToolStripMenuItem1.Name = "услугиToolStripMenuItem1";
|
||||||
this.услугиToolStripMenuItem1.Size = new System.Drawing.Size(180, 22);
|
this.услугиToolStripMenuItem1.Size = new System.Drawing.Size(112, 22);
|
||||||
this.услугиToolStripMenuItem1.Text = "Услуги";
|
this.услугиToolStripMenuItem1.Text = "Услуги";
|
||||||
this.услугиToolStripMenuItem1.Click += new System.EventHandler(this.ReportServicesToolStripMenuItem_Click);
|
this.услугиToolStripMenuItem1.Click += new System.EventHandler(this.ReportServicesToolStripMenuItem_Click);
|
||||||
//
|
//
|
||||||
|
// buttonUpdate
|
||||||
|
//
|
||||||
|
this.buttonUpdate.Location = new System.Drawing.Point(917, 188);
|
||||||
|
this.buttonUpdate.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||||
|
this.buttonUpdate.Name = "buttonUpdate";
|
||||||
|
this.buttonUpdate.Size = new System.Drawing.Size(116, 58);
|
||||||
|
this.buttonUpdate.TabIndex = 17;
|
||||||
|
this.buttonUpdate.Text = "Обновить";
|
||||||
|
this.buttonUpdate.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonUpdate.Click += new System.EventHandler(this.ButtonRef_Click);
|
||||||
|
//
|
||||||
|
// buttonTest
|
||||||
|
//
|
||||||
|
this.buttonTest.Location = new System.Drawing.Point(917, 250);
|
||||||
|
this.buttonTest.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||||
|
this.buttonTest.Name = "buttonTest";
|
||||||
|
this.buttonTest.Size = new System.Drawing.Size(116, 58);
|
||||||
|
this.buttonTest.TabIndex = 18;
|
||||||
|
this.buttonTest.Text = "Тесты";
|
||||||
|
this.buttonTest.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonTest.Click += new System.EventHandler(this.ButtonTest_Click);
|
||||||
|
//
|
||||||
|
// buttonTransfer
|
||||||
|
//
|
||||||
|
this.buttonTransfer.Location = new System.Drawing.Point(917, 312);
|
||||||
|
this.buttonTransfer.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||||
|
this.buttonTransfer.Name = "buttonTransfer";
|
||||||
|
this.buttonTransfer.Size = new System.Drawing.Size(116, 58);
|
||||||
|
this.buttonTransfer.TabIndex = 19;
|
||||||
|
this.buttonTransfer.Text = "PostgreSQL -> MongoDB";
|
||||||
|
this.buttonTransfer.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonTransfer.Click += new System.EventHandler(this.ButtonTransfer_Click);
|
||||||
|
//
|
||||||
// FormMain
|
// FormMain
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(1037, 539);
|
this.ClientSize = new System.Drawing.Size(1037, 539);
|
||||||
|
this.Controls.Add(this.buttonTransfer);
|
||||||
this.Controls.Add(this.buttonTest);
|
this.Controls.Add(this.buttonTest);
|
||||||
this.Controls.Add(this.buttonUpdate);
|
this.Controls.Add(this.buttonUpdate);
|
||||||
this.Controls.Add(this.dataGridView);
|
this.Controls.Add(this.dataGridView);
|
||||||
@ -177,5 +190,6 @@
|
|||||||
private Button buttonTest;
|
private Button buttonTest;
|
||||||
private ToolStripMenuItem отчетыToolStripMenuItem;
|
private ToolStripMenuItem отчетыToolStripMenuItem;
|
||||||
private ToolStripMenuItem услугиToolStripMenuItem1;
|
private ToolStripMenuItem услугиToolStripMenuItem1;
|
||||||
|
private Button buttonTransfer;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -90,5 +90,14 @@ namespace BeautySaloonView
|
|||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ButtonTransfer_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormTransfer));
|
||||||
|
if (service is FormTransfer form)
|
||||||
|
{
|
||||||
|
form.ShowDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,7 +1,6 @@
|
|||||||
using BeautySaloonContracts.BindingModels;
|
using BeautySaloonContracts.BindingModels;
|
||||||
using BeautySaloonContracts.BusinessLogicsContracts;
|
using BeautySaloonContracts.BusinessLogicsContracts;
|
||||||
using BeautySaloonContracts.SearchModels;
|
using BeautySaloonContracts.SearchModels;
|
||||||
using System.Windows.Forms;
|
|
||||||
|
|
||||||
namespace BeautySaloonView
|
namespace BeautySaloonView
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
using BeautySaloonContracts.BusinessLogicsContracts;
|
using BeautySaloonContracts.BusinessLogicsContracts;
|
||||||
using BeautySaloonContracts.SearchModels;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
|
|
||||||
namespace BeautySaloonView
|
namespace BeautySaloonView
|
||||||
{
|
{
|
||||||
|
@ -4,6 +4,7 @@ using BeautySaloonContracts.SearchModels;
|
|||||||
using BeautySaloonContracts.ViewModels;
|
using BeautySaloonContracts.ViewModels;
|
||||||
using BeautySaloonDatabaseImplement;
|
using BeautySaloonDatabaseImplement;
|
||||||
using BeautySaloonDataModels;
|
using BeautySaloonDataModels;
|
||||||
|
using BeautySaloonNoSQLDatabaseImplement;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
@ -210,7 +211,7 @@ namespace BeautySaloonView
|
|||||||
case "Сложный запрос":
|
case "Сложный запрос":
|
||||||
Stopwatch stopwatch3 = new Stopwatch();
|
Stopwatch stopwatch3 = new Stopwatch();
|
||||||
stopwatch3.Start();
|
stopwatch3.Start();
|
||||||
using (NewdbContext db = new NewdbContext())
|
/*using (NewdbContext db = new NewdbContext())
|
||||||
{
|
{
|
||||||
var users = (from o in db.Orders
|
var users = (from o in db.Orders
|
||||||
join c in db.Clients on o.ClientId equals c.Id
|
join c in db.Clients on o.ClientId equals c.Id
|
||||||
@ -227,7 +228,8 @@ namespace BeautySaloonView
|
|||||||
Date = o.Date,
|
Date = o.Date,
|
||||||
Sum = o.Sum
|
Sum = o.Sum
|
||||||
}).ToList();
|
}).ToList();
|
||||||
}
|
}*/
|
||||||
|
var result = _OLogic.ReadList(null)?.OrderByDescending(x => x.Date).OrderBy(x => x.Sum).ToList();
|
||||||
stopwatch3.Stop();
|
stopwatch3.Stop();
|
||||||
TimeSpan ts3 = stopwatch3.Elapsed;
|
TimeSpan ts3 = stopwatch3.Elapsed;
|
||||||
string elapsedTime3 = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
|
string elapsedTime3 = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
|
||||||
|
77
BeautySaloon/BeautySaloonView/FormTransfer.Designer.cs
generated
Normal file
77
BeautySaloon/BeautySaloonView/FormTransfer.Designer.cs
generated
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
namespace BeautySaloonView
|
||||||
|
{
|
||||||
|
partial class FormTransfer
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.comboBox = new System.Windows.Forms.ComboBox();
|
||||||
|
this.button = new System.Windows.Forms.Button();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// comboBox
|
||||||
|
//
|
||||||
|
this.comboBox.FormattingEnabled = true;
|
||||||
|
this.comboBox.Items.AddRange(new object[] {
|
||||||
|
"клиенты",
|
||||||
|
"сотрудники",
|
||||||
|
"услуги",
|
||||||
|
"должности",
|
||||||
|
"заказы"});
|
||||||
|
this.comboBox.Location = new System.Drawing.Point(12, 12);
|
||||||
|
this.comboBox.Name = "comboBox";
|
||||||
|
this.comboBox.Size = new System.Drawing.Size(407, 23);
|
||||||
|
this.comboBox.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// button
|
||||||
|
//
|
||||||
|
this.button.Location = new System.Drawing.Point(12, 46);
|
||||||
|
this.button.Name = "button";
|
||||||
|
this.button.Size = new System.Drawing.Size(407, 23);
|
||||||
|
this.button.TabIndex = 1;
|
||||||
|
this.button.Text = "А ну давай";
|
||||||
|
this.button.UseVisualStyleBackColor = true;
|
||||||
|
this.button.Click += new System.EventHandler(this.Button_Click);
|
||||||
|
//
|
||||||
|
// FormTransfer
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(431, 81);
|
||||||
|
this.Controls.Add(this.button);
|
||||||
|
this.Controls.Add(this.comboBox);
|
||||||
|
this.Name = "FormTransfer";
|
||||||
|
this.Text = "FormTransfer";
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private ComboBox comboBox;
|
||||||
|
private Button button;
|
||||||
|
}
|
||||||
|
}
|
170
BeautySaloon/BeautySaloonView/FormTransfer.cs
Normal file
170
BeautySaloon/BeautySaloonView/FormTransfer.cs
Normal file
@ -0,0 +1,170 @@
|
|||||||
|
using BeautySaloonContracts.BusinessLogicsContracts;
|
||||||
|
using BeautySaloonDatabaseImplement;
|
||||||
|
using BeautySaloonNoSQLDatabaseImplement;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using MongoDB.Bson;
|
||||||
|
using System.Data;
|
||||||
|
|
||||||
|
namespace BeautySaloonView
|
||||||
|
{
|
||||||
|
public partial class FormTransfer : Form
|
||||||
|
{
|
||||||
|
private readonly IOrderLogic _logic;
|
||||||
|
public FormTransfer(IOrderLogic logic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_logic = logic;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Button_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
switch (comboBox.SelectedItem)
|
||||||
|
{
|
||||||
|
case "клиенты":
|
||||||
|
TransferClients();
|
||||||
|
break;
|
||||||
|
case "сотрудники":
|
||||||
|
TransferEmployees();
|
||||||
|
break;
|
||||||
|
case "должности":
|
||||||
|
TransferPositions();
|
||||||
|
break;
|
||||||
|
case "услуги":
|
||||||
|
TransferServices();
|
||||||
|
break;
|
||||||
|
case "заказы":
|
||||||
|
TransferOrders();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void TransferClients()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var pgsqlContext = new NewdbContext();
|
||||||
|
var pgsqlClients = pgsqlContext.Clients;
|
||||||
|
var mongoClients = MongoDBContext.GetInstance().Clients;
|
||||||
|
mongoClients.DeleteMany(new BsonDocument());
|
||||||
|
mongoClients.InsertMany(pgsqlClients
|
||||||
|
.Select(model => BeautySaloonNoSQLDatabaseImplement.Client.Create(new()
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
Name = model.Name,
|
||||||
|
Surname = model.Surname,
|
||||||
|
Patronymic = model.Patronymic ?? string.Empty,
|
||||||
|
Phone = model.Phone
|
||||||
|
})));
|
||||||
|
MessageBox.Show("Трансфер прошел успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
MessageBox.Show(e.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void TransferPositions()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var pgsqlContext = new NewdbContext();
|
||||||
|
var pgsqlPositions = pgsqlContext.Positions;
|
||||||
|
var mongoPositions = MongoDBContext.GetInstance().Positions;
|
||||||
|
mongoPositions.DeleteMany(new BsonDocument());
|
||||||
|
mongoPositions.InsertMany(pgsqlPositions
|
||||||
|
.Select(model => BeautySaloonNoSQLDatabaseImplement.Position.Create(new()
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
Name = model.Name
|
||||||
|
})));
|
||||||
|
MessageBox.Show("Трансфер прошел успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
MessageBox.Show(e.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void TransferServices()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var pgsqlContext = new NewdbContext();
|
||||||
|
var pgsqlServices = pgsqlContext.Services;
|
||||||
|
var mongoServices = MongoDBContext.GetInstance().Services;
|
||||||
|
mongoServices.DeleteMany(new BsonDocument());
|
||||||
|
mongoServices.InsertMany(pgsqlServices
|
||||||
|
.Select(model => BeautySaloonNoSQLDatabaseImplement.Service.Create(new()
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
Name = model.Name,
|
||||||
|
Price = model.Price
|
||||||
|
})));
|
||||||
|
MessageBox.Show("Трансфер прошел успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
MessageBox.Show(e.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void TransferEmployees()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var pgsqlContext = new NewdbContext();
|
||||||
|
var pgsqlEmployees = pgsqlContext.Employees;
|
||||||
|
var mongoEmployees = MongoDBContext.GetInstance().Employees;
|
||||||
|
mongoEmployees.DeleteMany(new BsonDocument());
|
||||||
|
mongoEmployees.InsertMany(pgsqlEmployees
|
||||||
|
.Select(model => BeautySaloonNoSQLDatabaseImplement.Employee.Create(new()
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
Name = model.Name,
|
||||||
|
Surname = model.Surname,
|
||||||
|
Patronymic = model.Patronymic,
|
||||||
|
Phone = model.Phone,
|
||||||
|
PositionId = model.PositionId,
|
||||||
|
PositionName = model.Position.Name
|
||||||
|
})));
|
||||||
|
MessageBox.Show("Трансфер прошел успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
MessageBox.Show(e.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void TransferOrders()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var mongoOrders = MongoDBContext.GetInstance().Orders;
|
||||||
|
mongoOrders.DeleteMany(new BsonDocument());
|
||||||
|
using var context = new NewdbContext();
|
||||||
|
var orders = context.Orders
|
||||||
|
.Include(x => x.Employee)
|
||||||
|
.Include(x => x.Client)
|
||||||
|
.Include(x => x.ServiceOrders)
|
||||||
|
.ThenInclude(x => x.Service)
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
mongoOrders.InsertMany(orders
|
||||||
|
.Select(model => BeautySaloonNoSQLDatabaseImplement.Order.Create(new()
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
Date = model.Date,
|
||||||
|
Sum = model.Sum,
|
||||||
|
ClientId = model.ClientId,
|
||||||
|
EmployeeId = model.EmployeeId,
|
||||||
|
OrderServices = model.OrderServices
|
||||||
|
})));
|
||||||
|
MessageBox.Show("Трансфер прошел успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
MessageBox.Show(e.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
60
BeautySaloon/BeautySaloonView/FormTransfer.resx
Normal file
60
BeautySaloon/BeautySaloonView/FormTransfer.resx
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
<root>
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
@ -55,6 +55,7 @@ namespace BeautySaloonView
|
|||||||
services.AddTransient<FormServices>();
|
services.AddTransient<FormServices>();
|
||||||
services.AddTransient<FormTest>();
|
services.AddTransient<FormTest>();
|
||||||
services.AddTransient<FormReportServices>();
|
services.AddTransient<FormReportServices>();
|
||||||
|
services.AddTransient<FormTransfer>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
9
BeautySaloon/ConsoleTransfer/App.config
Normal file
9
BeautySaloon/ConsoleTransfer/App.config
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<configuration>
|
||||||
|
<appSettings>
|
||||||
|
<add key="connect" value="Host=192.168.56.102;Port=5432;Database=newdb;Username=username123;Password=12345"/>
|
||||||
|
</appSettings>
|
||||||
|
<connectionStrings>
|
||||||
|
<add name="DatabaseConnection" connectionString="mongodb://localhost:27017/test"/>
|
||||||
|
</connectionStrings>
|
||||||
|
</configuration>
|
15
BeautySaloon/ConsoleTransfer/ConsoleTransfer.csproj
Normal file
15
BeautySaloon/ConsoleTransfer/ConsoleTransfer.csproj
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\BeautySaloonDatabaseImplement\BeautySaloonDatabaseImplement.csproj" />
|
||||||
|
<ProjectReference Include="..\BeautySaloonNoSQLDatabaseImplement\BeautySaloonNoSQLDatabaseImplement.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
16
BeautySaloon/ConsoleTransfer/Program.cs
Normal file
16
BeautySaloon/ConsoleTransfer/Program.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
using BeautySaloonDatabaseImplement;
|
||||||
|
using BeautySaloonDataModels;
|
||||||
|
using BeautySaloonNoSQLDatabaseImplement;
|
||||||
|
using Microsoft.EntityFrameworkCore.Metadata.Internal;
|
||||||
|
using MongoDB.Bson;
|
||||||
|
using MongoDB.Driver;
|
||||||
|
|
||||||
|
namespace BeautySaloonDatabaseTransfer
|
||||||
|
{
|
||||||
|
public class Program
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user