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