все
This commit is contained in:
parent
19bfe37214
commit
a71a9a9cdf
@ -99,7 +99,7 @@ namespace BusinessLogic.BusinessLogic
|
||||
}
|
||||
public List<ReportHuman> GetTopDrivers()
|
||||
{
|
||||
|
||||
/*
|
||||
var list = _voyageStorage.GetFilteredList(new VoyageSM
|
||||
{
|
||||
|
||||
@ -122,12 +122,13 @@ namespace BusinessLogic.BusinessLogic
|
||||
}
|
||||
foreach (var human in humans)
|
||||
reportList.Add(new ReportHuman { Name = human.Value.Item1, Length = human.Value.Item2 });
|
||||
return reportList;
|
||||
return reportList;*/
|
||||
return _voyageStorage.ReportHuman();
|
||||
}
|
||||
|
||||
public List<ReportCompany>? GetCompanysPath()
|
||||
{
|
||||
var list = _voyageStorage.GetFullList();
|
||||
/*var list = _voyageStorage.GetFullList();
|
||||
List<ReportCompany> reportList = new List<ReportCompany>();
|
||||
Dictionary< (int? , int ?),int? > companies = new Dictionary<(int?, int?), int?>();
|
||||
foreach(var company in list)
|
||||
@ -149,7 +150,8 @@ namespace BusinessLogic.BusinessLogic
|
||||
reportList.Add(new ReportCompany { Title = _companyStorage.GetElement(new CompanySM { Id = compan.Key.Item1 }).Title, Details = _routeStorage.GetElement(new RouteSM { Id = compan.Key.Item2 }).Title, Count = compan.Value});
|
||||
}
|
||||
|
||||
return reportList;
|
||||
return reportList; */
|
||||
return _voyageStorage.ReportCompany();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ namespace Contracts.BindingModels
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public string oldName { get; set; } = string.Empty;
|
||||
public string Phone { get; set; } = string.Empty;
|
||||
|
||||
public int number { get; set; }
|
||||
public int? StatusId { get; set; }
|
||||
|
||||
public string? StatusTitle { get; set; } = string.Empty;
|
||||
|
@ -18,5 +18,7 @@ namespace Contracts.Storage
|
||||
VoyageVM? Insert(VoyageBM model);
|
||||
|
||||
VoyageVM? Delete(VoyageBM model);
|
||||
public List<ReportHuman> ReportHuman();
|
||||
public List<ReportCompany> ReportCompany();
|
||||
}
|
||||
}
|
||||
|
@ -85,6 +85,20 @@ namespace DataBase.Implements
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public List<ReportHuman> ReportHuman()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public List<ReportHuman> ReportCompany()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
List<ReportCompany> IVoyageStorage.ReportCompany()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ namespace Forms
|
||||
{
|
||||
Id = _id ?? 0,
|
||||
Model = ModelTextBox.Text,
|
||||
number = NumberBox1.Text,
|
||||
|
||||
Tonnage = Convert.ToInt32(TonnageTextBox.Text),
|
||||
StatusId = Convert.ToInt32(StatuscomboBox.SelectedValue),
|
||||
StatusTitle = StatuscomboBox.Text,
|
||||
|
14
Subd/Forms/FormCars.Designer.cs
generated
14
Subd/Forms/FormCars.Designer.cs
generated
@ -30,7 +30,6 @@
|
||||
{
|
||||
this.DataGridView = new System.Windows.Forms.DataGridView();
|
||||
this.AddButton = new System.Windows.Forms.Button();
|
||||
this.ChangeButton = new System.Windows.Forms.Button();
|
||||
this.DeleteButton = new System.Windows.Forms.Button();
|
||||
this.UpdateButton = new System.Windows.Forms.Button();
|
||||
((System.ComponentModel.ISupportInitialize)(this.DataGridView)).BeginInit();
|
||||
@ -58,17 +57,6 @@
|
||||
this.AddButton.UseVisualStyleBackColor = true;
|
||||
this.AddButton.Click += new System.EventHandler(this.AddButton_Click);
|
||||
//
|
||||
// ChangeButton
|
||||
//
|
||||
this.ChangeButton.Location = new System.Drawing.Point(669, 95);
|
||||
this.ChangeButton.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.ChangeButton.Name = "ChangeButton";
|
||||
this.ChangeButton.Size = new System.Drawing.Size(137, 55);
|
||||
this.ChangeButton.TabIndex = 2;
|
||||
this.ChangeButton.Text = "Изменить";
|
||||
this.ChangeButton.UseVisualStyleBackColor = true;
|
||||
this.ChangeButton.Click += new System.EventHandler(this.ChangeButton_Click);
|
||||
//
|
||||
// DeleteButton
|
||||
//
|
||||
this.DeleteButton.Location = new System.Drawing.Point(669, 173);
|
||||
@ -98,7 +86,6 @@
|
||||
this.ClientSize = new System.Drawing.Size(819, 669);
|
||||
this.Controls.Add(this.UpdateButton);
|
||||
this.Controls.Add(this.DeleteButton);
|
||||
this.Controls.Add(this.ChangeButton);
|
||||
this.Controls.Add(this.AddButton);
|
||||
this.Controls.Add(this.DataGridView);
|
||||
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
@ -114,7 +101,6 @@
|
||||
|
||||
private DataGridView DataGridView;
|
||||
private Button AddButton;
|
||||
private Button ChangeButton;
|
||||
private Button DeleteButton;
|
||||
private Button UpdateButton;
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ namespace Forms
|
||||
|
||||
if (service is FormCar form)
|
||||
{
|
||||
form.Id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
form.Id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Model"].Value);
|
||||
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
@ -90,14 +90,14 @@ namespace Forms
|
||||
{
|
||||
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
string id = (DataGridView.SelectedRows[0].Cells["number"].Value.ToString());
|
||||
string id = (DataGridView.SelectedRows[0].Cells["Model"].Value.ToString());
|
||||
_logger.LogInformation("Удаление изделия");
|
||||
|
||||
try
|
||||
{
|
||||
if (!_logic.Delete(new CarBM
|
||||
{
|
||||
number = id
|
||||
Model = id
|
||||
}))
|
||||
{
|
||||
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
|
||||
|
18
Subd/Forms/FormCompanies.Designer.cs
generated
18
Subd/Forms/FormCompanies.Designer.cs
generated
@ -31,7 +31,6 @@
|
||||
{
|
||||
this.DataGridView = new System.Windows.Forms.DataGridView();
|
||||
this.AddButton = new System.Windows.Forms.Button();
|
||||
this.ChangeButton = new System.Windows.Forms.Button();
|
||||
this.DeleteButton = new System.Windows.Forms.Button();
|
||||
this.UpdateButton = new System.Windows.Forms.Button();
|
||||
((System.ComponentModel.ISupportInitialize)(this.DataGridView)).BeginInit();
|
||||
@ -59,17 +58,6 @@
|
||||
this.AddButton.UseVisualStyleBackColor = true;
|
||||
this.AddButton.Click += new System.EventHandler(this.AddButton_Click);
|
||||
//
|
||||
// ChangeButton
|
||||
//
|
||||
this.ChangeButton.Location = new System.Drawing.Point(669, 95);
|
||||
this.ChangeButton.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.ChangeButton.Name = "ChangeButton";
|
||||
this.ChangeButton.Size = new System.Drawing.Size(137, 55);
|
||||
this.ChangeButton.TabIndex = 2;
|
||||
this.ChangeButton.Text = "Изменить";
|
||||
this.ChangeButton.UseVisualStyleBackColor = true;
|
||||
this.ChangeButton.Click += new System.EventHandler(this.ChangeButton_Click);
|
||||
//
|
||||
// DeleteButton
|
||||
//
|
||||
this.DeleteButton.Location = new System.Drawing.Point(669, 173);
|
||||
@ -92,18 +80,17 @@
|
||||
this.UpdateButton.UseVisualStyleBackColor = true;
|
||||
this.UpdateButton.Click += new System.EventHandler(this.UpdateButton_Click);
|
||||
//
|
||||
// FormCars
|
||||
// FormCompanies
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(819, 669);
|
||||
this.Controls.Add(this.UpdateButton);
|
||||
this.Controls.Add(this.DeleteButton);
|
||||
this.Controls.Add(this.ChangeButton);
|
||||
this.Controls.Add(this.AddButton);
|
||||
this.Controls.Add(this.DataGridView);
|
||||
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.Name = "FormCars";
|
||||
this.Name = "FormCompanies";
|
||||
this.Text = "Машины";
|
||||
this.Load += new System.EventHandler(this.FormCompanys_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.DataGridView)).EndInit();
|
||||
@ -115,7 +102,6 @@
|
||||
|
||||
private DataGridView DataGridView;
|
||||
private Button AddButton;
|
||||
private Button ChangeButton;
|
||||
private Button DeleteButton;
|
||||
private Button UpdateButton;
|
||||
}
|
||||
|
18
Subd/Forms/FormHumans.Designer.cs
generated
18
Subd/Forms/FormHumans.Designer.cs
generated
@ -30,7 +30,6 @@
|
||||
{
|
||||
this.DataGridView = new System.Windows.Forms.DataGridView();
|
||||
this.AddButton = new System.Windows.Forms.Button();
|
||||
this.ChangeButton = new System.Windows.Forms.Button();
|
||||
this.DeleteButton = new System.Windows.Forms.Button();
|
||||
this.UpdateButton = new System.Windows.Forms.Button();
|
||||
((System.ComponentModel.ISupportInitialize)(this.DataGridView)).BeginInit();
|
||||
@ -58,17 +57,6 @@
|
||||
this.AddButton.UseVisualStyleBackColor = true;
|
||||
this.AddButton.Click += new System.EventHandler(this.AddButton_Click);
|
||||
//
|
||||
// ChangeButton
|
||||
//
|
||||
this.ChangeButton.Location = new System.Drawing.Point(669, 95);
|
||||
this.ChangeButton.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.ChangeButton.Name = "ChangeButton";
|
||||
this.ChangeButton.Size = new System.Drawing.Size(137, 55);
|
||||
this.ChangeButton.TabIndex = 2;
|
||||
this.ChangeButton.Text = "Изменить";
|
||||
this.ChangeButton.UseVisualStyleBackColor = true;
|
||||
this.ChangeButton.Click += new System.EventHandler(this.ChangeButton_Click);
|
||||
//
|
||||
// DeleteButton
|
||||
//
|
||||
this.DeleteButton.Location = new System.Drawing.Point(669, 173);
|
||||
@ -91,18 +79,17 @@
|
||||
this.UpdateButton.UseVisualStyleBackColor = true;
|
||||
this.UpdateButton.Click += new System.EventHandler(this.UpdateButton_Click);
|
||||
//
|
||||
// FormCars
|
||||
// FormHumans
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(819, 669);
|
||||
this.Controls.Add(this.UpdateButton);
|
||||
this.Controls.Add(this.DeleteButton);
|
||||
this.Controls.Add(this.ChangeButton);
|
||||
this.Controls.Add(this.AddButton);
|
||||
this.Controls.Add(this.DataGridView);
|
||||
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.Name = "FormCars";
|
||||
this.Name = "FormHumans";
|
||||
this.Text = "Машины";
|
||||
this.Load += new System.EventHandler(this.FormHumans_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.DataGridView)).EndInit();
|
||||
@ -114,7 +101,6 @@
|
||||
|
||||
private DataGridView DataGridView;
|
||||
private Button AddButton;
|
||||
private Button ChangeButton;
|
||||
private Button DeleteButton;
|
||||
private Button UpdateButton;
|
||||
}
|
||||
|
18
Subd/Forms/FormPlaces.Designer.cs
generated
18
Subd/Forms/FormPlaces.Designer.cs
generated
@ -31,7 +31,6 @@
|
||||
{
|
||||
this.DataGridView = new System.Windows.Forms.DataGridView();
|
||||
this.AddButton = new System.Windows.Forms.Button();
|
||||
this.ChangeButton = new System.Windows.Forms.Button();
|
||||
this.DeleteButton = new System.Windows.Forms.Button();
|
||||
this.UpdateButton = new System.Windows.Forms.Button();
|
||||
((System.ComponentModel.ISupportInitialize)(this.DataGridView)).BeginInit();
|
||||
@ -59,17 +58,6 @@
|
||||
this.AddButton.UseVisualStyleBackColor = true;
|
||||
this.AddButton.Click += new System.EventHandler(this.AddButton_Click);
|
||||
//
|
||||
// ChangeButton
|
||||
//
|
||||
this.ChangeButton.Location = new System.Drawing.Point(669, 95);
|
||||
this.ChangeButton.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.ChangeButton.Name = "ChangeButton";
|
||||
this.ChangeButton.Size = new System.Drawing.Size(137, 55);
|
||||
this.ChangeButton.TabIndex = 2;
|
||||
this.ChangeButton.Text = "Изменить";
|
||||
this.ChangeButton.UseVisualStyleBackColor = true;
|
||||
this.ChangeButton.Click += new System.EventHandler(this.ChangeButton_Click);
|
||||
//
|
||||
// DeleteButton
|
||||
//
|
||||
this.DeleteButton.Location = new System.Drawing.Point(669, 173);
|
||||
@ -92,18 +80,17 @@
|
||||
this.UpdateButton.UseVisualStyleBackColor = true;
|
||||
this.UpdateButton.Click += new System.EventHandler(this.UpdateButton_Click);
|
||||
//
|
||||
// FormCars
|
||||
// FormPlaces
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(819, 669);
|
||||
this.Controls.Add(this.UpdateButton);
|
||||
this.Controls.Add(this.DeleteButton);
|
||||
this.Controls.Add(this.ChangeButton);
|
||||
this.Controls.Add(this.AddButton);
|
||||
this.Controls.Add(this.DataGridView);
|
||||
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.Name = "FormCars";
|
||||
this.Name = "FormPlaces";
|
||||
this.Text = "Машины";
|
||||
this.Load += new System.EventHandler(this.FormPlacees_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.DataGridView)).EndInit();
|
||||
@ -115,7 +102,6 @@
|
||||
|
||||
private DataGridView DataGridView;
|
||||
private Button AddButton;
|
||||
private Button ChangeButton;
|
||||
private Button DeleteButton;
|
||||
private Button UpdateButton;
|
||||
}
|
||||
|
18
Subd/Forms/FormStatuses.Designer.cs
generated
18
Subd/Forms/FormStatuses.Designer.cs
generated
@ -31,7 +31,6 @@
|
||||
{
|
||||
this.DataGridView = new System.Windows.Forms.DataGridView();
|
||||
this.AddButton = new System.Windows.Forms.Button();
|
||||
this.ChangeButton = new System.Windows.Forms.Button();
|
||||
this.DeleteButton = new System.Windows.Forms.Button();
|
||||
this.UpdateButton = new System.Windows.Forms.Button();
|
||||
((System.ComponentModel.ISupportInitialize)(this.DataGridView)).BeginInit();
|
||||
@ -59,17 +58,6 @@
|
||||
this.AddButton.UseVisualStyleBackColor = true;
|
||||
this.AddButton.Click += new System.EventHandler(this.AddButton_Click);
|
||||
//
|
||||
// ChangeButton
|
||||
//
|
||||
this.ChangeButton.Location = new System.Drawing.Point(669, 95);
|
||||
this.ChangeButton.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.ChangeButton.Name = "ChangeButton";
|
||||
this.ChangeButton.Size = new System.Drawing.Size(137, 55);
|
||||
this.ChangeButton.TabIndex = 2;
|
||||
this.ChangeButton.Text = "Изменить";
|
||||
this.ChangeButton.UseVisualStyleBackColor = true;
|
||||
this.ChangeButton.Click += new System.EventHandler(this.ChangeButton_Click);
|
||||
//
|
||||
// DeleteButton
|
||||
//
|
||||
this.DeleteButton.Location = new System.Drawing.Point(669, 173);
|
||||
@ -92,18 +80,17 @@
|
||||
this.UpdateButton.UseVisualStyleBackColor = true;
|
||||
this.UpdateButton.Click += new System.EventHandler(this.UpdateButton_Click);
|
||||
//
|
||||
// FormCars
|
||||
// FormStatuses
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(819, 669);
|
||||
this.Controls.Add(this.UpdateButton);
|
||||
this.Controls.Add(this.DeleteButton);
|
||||
this.Controls.Add(this.ChangeButton);
|
||||
this.Controls.Add(this.AddButton);
|
||||
this.Controls.Add(this.DataGridView);
|
||||
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.Name = "FormCars";
|
||||
this.Name = "FormStatuses";
|
||||
this.Text = "Машины";
|
||||
this.Load += new System.EventHandler(this.FormStatuses_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.DataGridView)).EndInit();
|
||||
@ -115,7 +102,6 @@
|
||||
|
||||
private DataGridView DataGridView;
|
||||
private Button AddButton;
|
||||
private Button ChangeButton;
|
||||
private Button DeleteButton;
|
||||
private Button UpdateButton;
|
||||
}
|
||||
|
@ -8,6 +8,13 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.5" />
|
||||
<PackageReference Include="MongoDB.Driver" Version="2.19.1" />
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.4" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\DataBase\DataBase.csproj" />
|
||||
<ProjectReference Include="..\MongoDB\MongoDB.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
|
@ -1,15 +1,81 @@
|
||||
// See https://aka.ms/new-console-template for more information
|
||||
using Contracts.BindingModels;
|
||||
using Contracts.SearchModel;
|
||||
using DataBase;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using MongoDB;
|
||||
using MongoDB.Driver;
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Reflection.Metadata.Ecma335;
|
||||
|
||||
MongoClient context = MongoDateBase.getInstance().client;
|
||||
foreach (var datab in context.ListDatabaseNames().ToList())
|
||||
{
|
||||
Console.WriteLine(datab);
|
||||
}
|
||||
IMongoDatabase logistic = context.GetDatabase("logistic");
|
||||
foreach(var collection in logistic.ListCollections().ToList())
|
||||
{
|
||||
Console.WriteLine(collection);
|
||||
}
|
||||
MongoDB.StatusStorage statusStorageMongo = new();
|
||||
DataBase.LogisticContext logisticContext = new();
|
||||
DataBase.Implements.StatusStorage statusStoragePost = new();
|
||||
|
||||
Console.WriteLine("start Status");
|
||||
foreach (var status in logisticContext.Statuses.ToList())
|
||||
{
|
||||
if (statusStorageMongo.GetElement(new StatusSM { Title = status.Title }) == null)
|
||||
{
|
||||
statusStorageMongo.Insert(new StatusBM { Title = status.Title });
|
||||
}
|
||||
}
|
||||
Console.WriteLine("finish Status");
|
||||
MongoDB.HumanStorage humanStorageMongo = new();
|
||||
Console.WriteLine("start human");
|
||||
foreach (var human in logisticContext.Humans.ToList())
|
||||
{
|
||||
if (humanStorageMongo.GetElement(new HumanSM { Phone = human.Phone }) == null)
|
||||
{
|
||||
humanStorageMongo.Insert(new HumanBM { Name = human.Name, StatusTitle = human.Status.Title, Phone = human.Phone , number = human.Id});
|
||||
}
|
||||
}
|
||||
Console.WriteLine("finish Human");
|
||||
MongoDB.CompanyStorage companyStorageMongo = new();
|
||||
Console.WriteLine("start Company");
|
||||
foreach (var company in logisticContext.Companies.ToList())
|
||||
{
|
||||
if (companyStorageMongo.GetElement(new CompanySM { Title = company.Title }) == null)
|
||||
{
|
||||
companyStorageMongo.Insert(new CompanyBM { Title = company.Title, StatusTitle = company.Status.Title });
|
||||
}
|
||||
}
|
||||
Console.WriteLine("finish Company");
|
||||
MongoDB.CarStorage carStorageMongo = new();
|
||||
Console.WriteLine("start car");
|
||||
foreach (var car in logisticContext.Cars.ToList())
|
||||
{
|
||||
if (carStorageMongo.GetElement(new CarSM { Model = car.Model }) == null)
|
||||
{
|
||||
carStorageMongo.Insert(new CarBM { number = car.Id.ToString(), Model = car.Model, Tonnage = car.Tonnage, StatusTitle = car.Status.Title });
|
||||
}
|
||||
}
|
||||
Console.WriteLine("finish Car");
|
||||
MongoDB.PlaceStorage placeStorageMongo = new();
|
||||
Console.WriteLine("start place");
|
||||
foreach (var place in logisticContext.Places.ToList())
|
||||
{
|
||||
if (placeStorageMongo.GetElement(new PlaceSM { Title = place.Title }) == null)
|
||||
{
|
||||
placeStorageMongo.Insert(new PlaceBM { Title = place.Title });
|
||||
}
|
||||
}
|
||||
Console.WriteLine("finish Place");
|
||||
MongoDB.RouteStorage routeStorageMongo = new();
|
||||
Console.WriteLine("start route");
|
||||
foreach (var route in logisticContext.Routes.ToList())
|
||||
{
|
||||
if (routeStorageMongo.GetElement(new RouteSM { Title = route.PlaceStartNavigation.Title + "-" + route.PlaceEndNavigation.Title }) == null)
|
||||
{
|
||||
routeStorageMongo.Insert(new RouteBM { Title = route.PlaceStartNavigation.Title + "-" + route.PlaceEndNavigation.Title, Length = route.Length, PlaceStartName = route.PlaceStartNavigation.Title, PlaceEndName = route.PlaceEndNavigation.Title });
|
||||
}
|
||||
}
|
||||
Console.WriteLine("finish Route");
|
||||
MongoDB.VoyageStorage voyageStorageMongo = new();
|
||||
Console.WriteLine("start voyage");
|
||||
foreach (var voyage in logisticContext.Voyages.ToList())
|
||||
{
|
||||
voyageStorageMongo.Insert(new VoyageBM { CarName = voyage.Car.Model, CompanyName = voyage.Company.Title, HumanName = voyage.Human.Name, RouteName = voyage.Route.Title, DateStart = voyage.DateStart, DateEnd = voyage.DateEnd });
|
||||
}
|
||||
Console.WriteLine("finish Voyage");
|
||||
|
@ -23,13 +23,13 @@ namespace MongoDB
|
||||
{
|
||||
IMongoDatabase db = contex.GetDatabase("logistic");
|
||||
var collection = db.GetCollection<BsonDocument>("Car");
|
||||
var res = collection.FindOneAndDelete(new BsonDocument("number", model.number));
|
||||
var res = collection.FindOneAndDelete(new BsonDocument("model", model.Model));
|
||||
if (res == null)
|
||||
return null;
|
||||
return new CarVM
|
||||
{
|
||||
Model = res["model"].ToString(),
|
||||
number = res["number"].ToString(),
|
||||
|
||||
StatusTitle = res["Status"].ToString(),
|
||||
|
||||
};
|
||||
@ -39,13 +39,12 @@ namespace MongoDB
|
||||
{
|
||||
IMongoDatabase db = contex.GetDatabase("logistic");
|
||||
var collection = db.GetCollection<BsonDocument>("Car");
|
||||
BsonDocument car = collection.Find(new BsonDocument("number", model.Id)).FirstOrDefault();
|
||||
BsonDocument car = collection.Find(new BsonDocument{ {"model",model.Model } }).FirstOrDefault();
|
||||
if (car == null)
|
||||
return null;
|
||||
return new CarVM
|
||||
{
|
||||
Model = car["name"].ToString(),
|
||||
number = car["phone"].ToString(),
|
||||
|
||||
Tonnage = car["tonnage"].ToInt32(),
|
||||
StatusTitle = car["Status"].ToString()
|
||||
};
|
||||
@ -81,7 +80,7 @@ namespace MongoDB
|
||||
res.Add(new CarVM
|
||||
{
|
||||
Model = car["model"].ToString(),
|
||||
number = car["number"].ToString(),
|
||||
|
||||
Tonnage = car["tonnage"].ToInt32(),
|
||||
StatusTitle = car["Status"].ToString()
|
||||
});
|
||||
@ -93,11 +92,11 @@ namespace MongoDB
|
||||
{
|
||||
IMongoDatabase db = contex.GetDatabase("logistic");
|
||||
var collection = db.GetCollection<BsonDocument>("Car");
|
||||
BsonDocument car = new BsonDocument { { "number", model.number }, { "model", model.Model }, { "Status", model.StatusTitle }, { "tonnage", model.Tonnage } };
|
||||
BsonDocument car = new BsonDocument { { "model", model.Model }, { "Status", model.StatusTitle }, { "tonnage", model.Tonnage } };
|
||||
collection.InsertOne(car);
|
||||
return new CarVM {
|
||||
Model = car["model"].ToString(),
|
||||
number = car["number"].ToString(),
|
||||
|
||||
Tonnage = car["tonnage"].ToInt32(),
|
||||
StatusTitle = car["Status"].ToString()
|
||||
};
|
||||
@ -115,7 +114,7 @@ namespace MongoDB
|
||||
Model = model.Model,
|
||||
StatusTitle = model.StatusTitle,
|
||||
Tonnage = model.Tonnage,
|
||||
number = model.number
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ namespace MongoDB
|
||||
{
|
||||
IMongoDatabase db = contex.GetDatabase("logistic");
|
||||
var collection = db.GetCollection<BsonDocument>("Human");
|
||||
BsonDocument human = collection.Find(new BsonDocument("number", model.Id)).FirstOrDefault();
|
||||
BsonDocument human = collection.Find(new BsonDocument("phine", model.Phone)).FirstOrDefault();
|
||||
if (human == null)
|
||||
return null;
|
||||
return new HumanVM
|
||||
@ -90,7 +90,7 @@ namespace MongoDB
|
||||
{
|
||||
IMongoDatabase db = contex.GetDatabase("logistic");
|
||||
var collection = db.GetCollection<BsonDocument>("Human");
|
||||
BsonDocument human = new BsonDocument { {"number", model.Id }, { "name", model.Name }, { "Status", model.StatusTitle }, { "phone" , model.Phone} };
|
||||
BsonDocument human = new BsonDocument { { "name", model.Name }, { "Status", model.StatusTitle }, { "phone" , model.Phone} };
|
||||
collection.InsertOne(human);
|
||||
return new HumanVM { Name = model.Name, StatusTitle = model.StatusTitle,Phone = model.Phone };
|
||||
}
|
||||
|
@ -72,6 +72,55 @@ namespace MongoDB
|
||||
};
|
||||
}
|
||||
|
||||
public List<ReportCompany> ReportCompany()
|
||||
{
|
||||
IMongoDatabase db = contex.GetDatabase("logistic");
|
||||
var collection = db.GetCollection<BsonDocument>("Voyage");
|
||||
var builder = Builders<BsonDocument>.Filter;
|
||||
DateTime date = DateTime.Now;
|
||||
var filter = builder.Gt("date_From", date.AddYears(-1));
|
||||
var res = collection.Aggregate().Match(filter).Group(
|
||||
new BsonDocument {
|
||||
{ "_id", new BsonDocument{{"company" , "$company"},{"route" , "$route" } } },
|
||||
{ "total_count", new BsonDocument("$count", new BsonDocument{}) } }).ToList();
|
||||
List<ReportCompany> list = new List<ReportCompany>();
|
||||
foreach (var el in res)
|
||||
{
|
||||
var mid = el.GetValue("_id");
|
||||
list.Add(new ReportCompany
|
||||
{
|
||||
Title = mid["company"].ToString(),
|
||||
Details = mid["route"].ToString(),
|
||||
Count = el["total_count"].ToInt32()
|
||||
}); ;
|
||||
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<ReportHuman> ReportHuman()
|
||||
{
|
||||
IMongoDatabase db = contex.GetDatabase("logistic");
|
||||
var collection = db.GetCollection<BsonDocument>("Voyage");
|
||||
var builder = Builders<BsonDocument>.Filter;
|
||||
DateTime date = DateTime.Now;
|
||||
var filter = builder.Gt("date_From", date.AddMonths(-1));
|
||||
var res = collection.Aggregate().Match(filter).Lookup("Route", "route", "name", "RouteObj").Unwind("RouteObj").Group(
|
||||
new BsonDocument {
|
||||
{ "_id", "$human" },
|
||||
{ "total_length", new BsonDocument("$sum", "$RouteObj.length") } }).ToList();
|
||||
List<ReportHuman> list = new List<ReportHuman>();
|
||||
foreach(var el in res)
|
||||
{
|
||||
|
||||
list.Add(new ReportHuman
|
||||
{
|
||||
Name = el["_id"].ToString(),
|
||||
Length = el["total_length"].ToInt32()
|
||||
});
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user