Ну теперь куда не шло.
This commit is contained in:
parent
e2dd2aaf7b
commit
f11c5b871a
@ -9,7 +9,7 @@ namespace TransportCompamyMongoDBImplementer
|
|||||||
{
|
{
|
||||||
public class DBMSContext
|
public class DBMSContext
|
||||||
{
|
{
|
||||||
private const string ConnectionString = "mongodb://192.168.1.135:27017";
|
private const string ConnectionString = "mongodb://127.0.0.1:27017";
|
||||||
|
|
||||||
private const string DatabaseName = "transportcompany";
|
private const string DatabaseName = "transportcompany";
|
||||||
|
|
||||||
|
@ -96,9 +96,9 @@ namespace TransportCompamyMongoDBImplementer.Implements
|
|||||||
|
|
||||||
public bool InsertFromPostgres(List<TruckingViewModel> model)
|
public bool InsertFromPostgres(List<TruckingViewModel> model)
|
||||||
{
|
{
|
||||||
var clientCollection = context.ConnectToMongo<Trucking>("client");
|
var clientCollection = context.ConnectToMongo<Client>("client");
|
||||||
var cargoCollection = context.ConnectToMongo<Trucking>("cargo");
|
var cargoCollection = context.ConnectToMongo<Cargo>("cargo");
|
||||||
var transportCollection = context.ConnectToMongo<Trucking>("transport");
|
var transportCollection = context.ConnectToMongo<Transport>("transport");
|
||||||
var truckingCollection = context.ConnectToMongo<Trucking>("trucking");
|
var truckingCollection = context.ConnectToMongo<Trucking>("trucking");
|
||||||
|
|
||||||
//список, который по итогу и будем вставлять
|
//список, который по итогу и будем вставлять
|
||||||
@ -111,9 +111,9 @@ namespace TransportCompamyMongoDBImplementer.Implements
|
|||||||
newTrucking.DateStart = element.DateStart;
|
newTrucking.DateStart = element.DateStart;
|
||||||
newTrucking.DateEnd = element.DateEnd;
|
newTrucking.DateEnd = element.DateEnd;
|
||||||
newTrucking.Price = element.Price;
|
newTrucking.Price = element.Price;
|
||||||
newTrucking.Cargo = cargoCollection.Find(x => x.Cargo.TypeCargo == element.Cargo).FirstOrDefault().Id;
|
newTrucking.Cargo = cargoCollection.Find(x => x.TypeCargo == element.Cargo).FirstOrDefault().Id;
|
||||||
newTrucking.Client = clientCollection.Find(x => x.Client.Email == element.ClientEmail).FirstOrDefault().Id;
|
newTrucking.Client = clientCollection.Find(x => x.Email == element.ClientEmail).FirstOrDefault().Id;
|
||||||
newTrucking.Transport = transportCollection.Find(x => x.Transport.TransportType == element.TransportName).FirstOrDefault().Id;
|
newTrucking.Transport = transportCollection.Find(x => x.TransportType == element.TransportName).FirstOrDefault().Id;
|
||||||
|
|
||||||
models.Add(Trucking.Create(context, newTrucking));
|
models.Add(Trucking.Create(context, newTrucking));
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,9 @@ namespace TransportCompamyMongoDBImplementer.Models
|
|||||||
ClientName = Client == null ? string.Empty : Client.Name,
|
ClientName = Client == null ? string.Empty : Client.Name,
|
||||||
ClientSurname = Client == null ? string.Empty : Client.Surname,
|
ClientSurname = Client == null ? string.Empty : Client.Surname,
|
||||||
ClientPatronymic = Client == null ? string.Empty : Client.Patronymic,
|
ClientPatronymic = Client == null ? string.Empty : Client.Patronymic,
|
||||||
|
ClientEmail = Client == null ? string.Empty : Client.Email,
|
||||||
TransportName = Transport == null ? string.Empty : Transport.TransportType,
|
TransportName = Transport == null ? string.Empty : Transport.TransportType,
|
||||||
|
TypeTransportation = Transport == null ? string.Empty : Transport.TransportationType,
|
||||||
Cargo = Cargo == null ? string.Empty : Cargo.TypeCargo
|
Cargo = Cargo == null ? string.Empty : Cargo.TypeCargo
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -6,4 +6,13 @@
|
|||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="MongoDB.Driver" Version="2.19.1" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\TransportCompanyBusinessLogic\TransportCompanyBusinessLogic.csproj" />
|
||||||
|
<ProjectReference Include="..\TransportCompanyContracts\TransportCompanyContracts.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -18,6 +18,10 @@ namespace TransportCompany
|
|||||||
{
|
{
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
|
private bool isMongo;
|
||||||
|
|
||||||
|
public bool Mongo { set { isMongo = value; } }
|
||||||
|
|
||||||
private readonly IClientLogic _logicCl;
|
private readonly IClientLogic _logicCl;
|
||||||
|
|
||||||
private readonly ITransportLogic _logicTransport;
|
private readonly ITransportLogic _logicTransport;
|
||||||
@ -82,6 +86,8 @@ namespace TransportCompany
|
|||||||
comboBoxTransports.SelectedItem = null;
|
comboBoxTransports.SelectedItem = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!isMongo)
|
||||||
|
{
|
||||||
if (viewTransportation != null)
|
if (viewTransportation != null)
|
||||||
{
|
{
|
||||||
comboBoxTypeTransportations.DisplayMember = "TransportationType";
|
comboBoxTypeTransportations.DisplayMember = "TransportationType";
|
||||||
@ -90,6 +96,11 @@ namespace TransportCompany
|
|||||||
comboBoxTypeTransportations.SelectedItem = null;
|
comboBoxTypeTransportations.SelectedItem = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
comboBoxTypeTransportations.SelectedItem = "Сейчас это недоступно";
|
||||||
|
}
|
||||||
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogError(ex, "Ошибка получения сводки по перевозке");
|
_logger.LogError(ex, "Ошибка получения сводки по перевозке");
|
||||||
@ -128,12 +139,15 @@ namespace TransportCompany
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!isMongo)
|
||||||
|
{
|
||||||
if (comboBoxTypeTransportations.SelectedValue == null)
|
if (comboBoxTypeTransportations.SelectedValue == null)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Выберите тип транспортировки", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show("Выберите тип транспортировки", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_logger.LogInformation("Создание сводки по перевозке");
|
_logger.LogInformation("Создание сводки по перевозке");
|
||||||
|
|
||||||
@ -144,7 +158,7 @@ namespace TransportCompany
|
|||||||
ClientId = Convert.ToInt32(comboBoxClients.SelectedValue),
|
ClientId = Convert.ToInt32(comboBoxClients.SelectedValue),
|
||||||
CargoId = Convert.ToInt32(comboBoxCargos.SelectedValue),
|
CargoId = Convert.ToInt32(comboBoxCargos.SelectedValue),
|
||||||
TransportId = Convert.ToInt32(comboBoxTransports.SelectedValue),
|
TransportId = Convert.ToInt32(comboBoxTransports.SelectedValue),
|
||||||
TransportationId = Convert.ToInt32(comboBoxTypeTransportations.SelectedValue),
|
TransportationId = isMongo ? 404 : Convert.ToInt32(comboBoxTypeTransportations.SelectedValue),
|
||||||
Price = Convert.ToInt32(textBoxPrice.Text),
|
Price = Convert.ToInt32(textBoxPrice.Text),
|
||||||
DateStart = dateTimePickerStart.Value,
|
DateStart = dateTimePickerStart.Value,
|
||||||
DateEnd = dateTimePickerEnd.Value
|
DateEnd = dateTimePickerEnd.Value
|
||||||
|
@ -60,7 +60,10 @@ namespace TransportCompany
|
|||||||
_truckingLogic = Program.ServiceProvider.GetService(typeof(ITruckingLogic)) as TruckingLogic;
|
_truckingLogic = Program.ServiceProvider.GetService(typeof(ITruckingLogic)) as TruckingLogic;
|
||||||
_transportLogic = Program.ServiceProvider.GetService(typeof(ITransportLogic)) as TransportLogic;
|
_transportLogic = Program.ServiceProvider.GetService(typeof(ITransportLogic)) as TransportLogic;
|
||||||
|
|
||||||
|
_cargoLogic.TransferData(cargolist);
|
||||||
|
_clientLogic.TransferData(clientlist);
|
||||||
|
_transportLogic.TransferData(transportlist);
|
||||||
|
_truckingLogic.TransferData(truckinglist);
|
||||||
|
|
||||||
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
|
||||||
|
@ -19,6 +19,10 @@ namespace TransportCompany
|
|||||||
|
|
||||||
private readonly ITransportLogic _logic;
|
private readonly ITransportLogic _logic;
|
||||||
|
|
||||||
|
private bool isMongo;
|
||||||
|
|
||||||
|
public bool SetMongo { set { isMongo = value;} }
|
||||||
|
|
||||||
public FormTransport(ILogger<FormTransport> logger, ITransportLogic logic)
|
public FormTransport(ILogger<FormTransport> logger, ITransportLogic logic)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
@ -42,9 +46,19 @@ namespace TransportCompany
|
|||||||
if (list != null)
|
if (list != null)
|
||||||
{
|
{
|
||||||
dataGridView.DataSource = list;
|
dataGridView.DataSource = list;
|
||||||
|
|
||||||
|
if (!isMongo)
|
||||||
|
{
|
||||||
|
dataGridView.Columns["Id"].Visible = true;
|
||||||
dataGridView.Columns["MongoId"].Visible = false;
|
dataGridView.Columns["MongoId"].Visible = false;
|
||||||
dataGridView.Columns["TransportationType"].Visible = false;
|
}
|
||||||
dataGridView.Columns[3].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
else
|
||||||
|
{
|
||||||
|
dataGridView.Columns["Id"].Visible = false;
|
||||||
|
dataGridView.Columns["MongoId"].Visible = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
dataGridView.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
}
|
}
|
||||||
|
|
||||||
_logger.LogInformation("Загрузка транспортных средств");
|
_logger.LogInformation("Загрузка транспортных средств");
|
||||||
|
@ -90,6 +90,8 @@ namespace TransportCompany
|
|||||||
|
|
||||||
if (service is FormCreateTrucking form)
|
if (service is FormCreateTrucking form)
|
||||||
{
|
{
|
||||||
|
form.Mongo = _mongo;
|
||||||
|
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
LoadData();
|
LoadData();
|
||||||
}
|
}
|
||||||
@ -129,6 +131,8 @@ namespace TransportCompany
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void TypeTransportationToolStripMenuItem_Click(object sender, EventArgs e)
|
private void TypeTransportationToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (!_mongo)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormTypeTransportation));
|
var service = Program.ServiceProvider?.GetService(typeof(FormTypeTransportation));
|
||||||
|
|
||||||
@ -138,6 +142,7 @@ namespace TransportCompany
|
|||||||
LoadData();
|
LoadData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void GenerationClientsToolStripMenuItem_Click(object sender, EventArgs e)
|
private void GenerationClientsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
@ -94,7 +94,6 @@ namespace TransportCompany
|
|||||||
_serviseCollection.Remove(_serviseCollection.FirstOrDefault(descriptor => descriptor.ServiceType == typeof(IClientStorage)));
|
_serviseCollection.Remove(_serviseCollection.FirstOrDefault(descriptor => descriptor.ServiceType == typeof(IClientStorage)));
|
||||||
_serviseCollection.Remove(_serviseCollection.FirstOrDefault(descriptor => descriptor.ServiceType == typeof(ITruckingStorage)));
|
_serviseCollection.Remove(_serviseCollection.FirstOrDefault(descriptor => descriptor.ServiceType == typeof(ITruckingStorage)));
|
||||||
_serviseCollection.Remove(_serviseCollection.FirstOrDefault(descriptor => descriptor.ServiceType == typeof(ITransportStorage)));
|
_serviseCollection.Remove(_serviseCollection.FirstOrDefault(descriptor => descriptor.ServiceType == typeof(ITransportStorage)));
|
||||||
_serviseCollection.Remove(_serviseCollection.FirstOrDefault(descriptor => descriptor.ServiceType == typeof(ITransportationStorage)));
|
|
||||||
|
|
||||||
_serviseCollection.AddTransient<ICargoStorage, TransportCompamyMongoDBImplementer.Implements.CargoStorage>();
|
_serviseCollection.AddTransient<ICargoStorage, TransportCompamyMongoDBImplementer.Implements.CargoStorage>();
|
||||||
_serviseCollection.AddTransient<IClientStorage, TransportCompamyMongoDBImplementer.Implements.ClientStorage>();
|
_serviseCollection.AddTransient<IClientStorage, TransportCompamyMongoDBImplementer.Implements.ClientStorage>();
|
||||||
|
@ -10,13 +10,16 @@ namespace TransportCompanyContracts.ViewModels
|
|||||||
{
|
{
|
||||||
public class TransportViewModel : ITransportModel
|
public class TransportViewModel : ITransportModel
|
||||||
{
|
{
|
||||||
|
[DisplayName("Номер")]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
[DisplayName("Номер")]
|
||||||
public string? MongoId { get; set; }
|
public string? MongoId { get; set; }
|
||||||
|
|
||||||
public string? TransportationType { get; set; }
|
|
||||||
|
|
||||||
[DisplayName("Вид транспорта")]
|
[DisplayName("Вид транспорта")]
|
||||||
public string Tranport { get; set; } = string.Empty;
|
public string Tranport { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[DisplayName("Тип перевозки")]
|
||||||
|
public string? TransportationType { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user