Compare commits
No commits in common. "SecondStage" and "main" have entirely different histories.
SecondStag
...
main
@ -1,24 +0,0 @@
|
||||
using MongoDB.Driver;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TransportCompamyMongoDBImplementer
|
||||
{
|
||||
public class DBMSContext
|
||||
{
|
||||
private const string ConnectionString = "mongodb://127.0.0.1:27017";
|
||||
|
||||
private const string DatabaseName = "transportcompany";
|
||||
|
||||
public IMongoCollection<T> ConnectToMongo<T>(in string collection)
|
||||
{
|
||||
var client = new MongoClient(ConnectionString);
|
||||
var db = client.GetDatabase(DatabaseName);
|
||||
|
||||
return db.GetCollection<T>(collection);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,123 +0,0 @@
|
||||
using MongoDB.Driver;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.ConstrainedExecution;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TransportCompamyMongoDBImplementer.Models;
|
||||
using TransportCompanyContracts.BindingModels;
|
||||
using TransportCompanyContracts.SearchModels;
|
||||
using TransportCompanyContracts.StoragesContracts;
|
||||
using TransportCompanyContracts.ViewModels;
|
||||
|
||||
namespace TransportCompamyMongoDBImplementer.Implements
|
||||
{
|
||||
public class CargoStorage : ICargoStorage
|
||||
{
|
||||
private DBMSContext context = new();
|
||||
|
||||
public CargoViewModel? Delete(CargoBindingModel model)
|
||||
{
|
||||
var cargoCollection = context.ConnectToMongo<Cargo>("cargo");
|
||||
|
||||
var element = cargoCollection.Find(rec => rec.Id == model.MongoId).FirstOrDefault();
|
||||
|
||||
if (element != null)
|
||||
{
|
||||
cargoCollection.DeleteOne(x => x.Id == model.MongoId);
|
||||
|
||||
return element.GetViewModel;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public CargoViewModel? GetElement(CargoSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.TypeCargo) && string.IsNullOrEmpty(model.MongoId))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var cargoCollection = context.ConnectToMongo<Cargo>("cargo");
|
||||
|
||||
return cargoCollection.Find(x => (!string.IsNullOrEmpty(model.TypeCargo) && x.TypeCargo == model.TypeCargo) ||
|
||||
(!string.IsNullOrEmpty(model.MongoId) && x.Id == model.MongoId))
|
||||
.FirstOrDefault()
|
||||
?.GetViewModel;
|
||||
}
|
||||
|
||||
public List<CargoViewModel> GetFilteredList(CargoSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.MongoId))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
|
||||
var cargoCollection = context.ConnectToMongo<Cargo>("cargo");
|
||||
|
||||
return cargoCollection.Find(x => x.TypeCargo.Contains(model.TypeCargo))
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<CargoViewModel> GetFullList()
|
||||
{
|
||||
var cargoCollection = context.ConnectToMongo<Cargo>("cargo");
|
||||
|
||||
return cargoCollection.Find(_ => true)
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public CargoViewModel? Insert(CargoBindingModel model)
|
||||
{
|
||||
var cargoCollection = context.ConnectToMongo<Cargo>("cargo");
|
||||
|
||||
var newCargo = Cargo.Create(model);
|
||||
|
||||
if (newCargo == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
cargoCollection.InsertOne(newCargo);
|
||||
|
||||
return newCargo.GetViewModel;
|
||||
}
|
||||
|
||||
//добавление экземпляров сущности из Postgresql
|
||||
public bool InsertFromPostgres(List<CargoViewModel> model)
|
||||
{
|
||||
var cargoCollection = context.ConnectToMongo<Cargo>("cargo");
|
||||
|
||||
List<Cargo> models = model.Select(x => Cargo.Create(new() { TypeCargo = x.TypeCargo })).ToList();
|
||||
|
||||
cargoCollection.InsertMany(models);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public CargoViewModel? Update(CargoBindingModel model)
|
||||
{
|
||||
var cargoCollection = context.ConnectToMongo<Cargo>("cargo");
|
||||
|
||||
var cargo = cargoCollection.Find(x => x.Id == model.MongoId).FirstOrDefault();
|
||||
|
||||
if (cargo == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
cargo.Update(model);
|
||||
|
||||
var filter = Builders<Cargo>.Filter.Eq("Id", model.MongoId);
|
||||
cargoCollection.ReplaceOne(filter, cargo, new ReplaceOptions { IsUpsert = true });
|
||||
|
||||
return cargo.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,193 +0,0 @@
|
||||
using MongoDB.Driver;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TransportCompamyMongoDBImplementer.Models;
|
||||
using TransportCompanyContracts.BindingModels;
|
||||
using TransportCompanyContracts.SearchModels;
|
||||
using TransportCompanyContracts.StoragesContracts;
|
||||
using TransportCompanyContracts.ViewModels;
|
||||
|
||||
namespace TransportCompamyMongoDBImplementer.Implements
|
||||
{
|
||||
public class ClientStorage : IClientStorage
|
||||
{
|
||||
private DBMSContext context = new();
|
||||
|
||||
public List<ClientViewModel> GetFullList()
|
||||
{
|
||||
var clientCollection = context.ConnectToMongo<Client>("client");
|
||||
|
||||
return clientCollection.Find(_ => true)
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<ClientViewModel> GetFilteredList(ClientSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.MongoId))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
|
||||
var clientCollection = context.ConnectToMongo<Client>("client");
|
||||
|
||||
return clientCollection.Find(x => x.Id.Contains(model.MongoId))
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public ClientViewModel? GetElement(ClientSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.Name) && string.IsNullOrEmpty(model.MongoId))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var clientCollection = context.ConnectToMongo<Client>("client");
|
||||
|
||||
return clientCollection.Find(x => (!string.IsNullOrEmpty(model.MongoId) && x.Id == model.MongoId))
|
||||
.FirstOrDefault()
|
||||
?.GetViewModel;
|
||||
}
|
||||
|
||||
public ClientViewModel? Insert(ClientBindingModel model)
|
||||
{
|
||||
var clientCollection = context.ConnectToMongo<Client>("client");
|
||||
|
||||
var newClient = Client.Create(model);
|
||||
|
||||
if (newClient == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
clientCollection.InsertOne(newClient);
|
||||
|
||||
return newClient.GetViewModel;
|
||||
}
|
||||
|
||||
//метод для замера вставки большого кол-ва клиентов в бд
|
||||
public string TestRandomInsert(int count, string[] _name, string[] _surname, string[] _patronymic, string[] _telephone, string[] _email)
|
||||
{
|
||||
var clientCollection = context.ConnectToMongo<Client>("client");
|
||||
|
||||
Random rnd = new Random(DateTime.Now.ToString().GetHashCode());
|
||||
|
||||
//старт замера времени добавления в бд
|
||||
Stopwatch stopwatch = new();
|
||||
|
||||
stopwatch.Start();
|
||||
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
var model = new Client
|
||||
{
|
||||
Name = _name[rnd.Next(0, _name.Length)],
|
||||
Surname = _surname[rnd.Next(0, _surname.Length)],
|
||||
Patronymic = _patronymic[rnd.Next(0, _patronymic.Length)],
|
||||
Telephone = _telephone[rnd.Next(0, _telephone.Length)],
|
||||
Email = _email[rnd.Next(0, _email.Length)],
|
||||
};
|
||||
|
||||
clientCollection.InsertOne(model);
|
||||
}
|
||||
|
||||
stopwatch.Stop();
|
||||
|
||||
return stopwatch.ElapsedMilliseconds.ToString();
|
||||
}
|
||||
|
||||
|
||||
public string SecondJoin()
|
||||
{
|
||||
var clientCollection = context.ConnectToMongo<Client>("client");
|
||||
var truckingCollection = context.ConnectToMongo<Trucking>("trucking");
|
||||
|
||||
Random rnd = new Random(DateTime.Now.ToString().GetHashCode());
|
||||
|
||||
//старт замера времени добавления в бд
|
||||
Stopwatch stopwatch = new();
|
||||
|
||||
stopwatch.Start();
|
||||
|
||||
var secondJoin = from t in truckingCollection.Find(_ => true).ToList()
|
||||
from c in clientCollection.Find(c => c.Id == t.Client.Id).ToList()
|
||||
select new { c, t };
|
||||
|
||||
//ВСЁ ГОТОВО ДЛЯ СЛЕДУЮЩЕГО ЗАМЕРА
|
||||
|
||||
foreach (var element in secondJoin)
|
||||
{
|
||||
var trucking = truckingCollection.Find(x => x.Id == element.t.Id).FirstOrDefault();
|
||||
|
||||
trucking.Update(new TruckingBindingModel
|
||||
{
|
||||
Price = element.t.Price,
|
||||
DateStart = element.t.DateStart.AddDays(10),
|
||||
DateEnd = element.t.DateEnd.AddDays(10)
|
||||
});
|
||||
|
||||
var filter = Builders<Trucking>.Filter.Eq("Id", element.t.Id);
|
||||
truckingCollection.ReplaceOne(filter, trucking, new ReplaceOptions { IsUpsert = true });
|
||||
}
|
||||
|
||||
stopwatch.Stop();
|
||||
|
||||
return stopwatch.ElapsedMilliseconds.ToString();
|
||||
}
|
||||
|
||||
public ClientViewModel? Update(ClientBindingModel model)
|
||||
{
|
||||
var clientCollection = context.ConnectToMongo<Client>("client");
|
||||
|
||||
var client = clientCollection.Find(x => x.Id == model.MongoId).FirstOrDefault();
|
||||
|
||||
if (client == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
client.Update(model);
|
||||
|
||||
var filter = Builders<Client>.Filter.Eq("Id", model.MongoId);
|
||||
clientCollection.ReplaceOne(filter, client, new ReplaceOptions { IsUpsert = true });
|
||||
|
||||
return client.GetViewModel;
|
||||
}
|
||||
|
||||
public ClientViewModel? Delete(ClientBindingModel model)
|
||||
{
|
||||
var clientCollection = context.ConnectToMongo<Client>("client");
|
||||
|
||||
var element = clientCollection.Find(rec => rec.Id == model.MongoId).FirstOrDefault();
|
||||
|
||||
if (element != null)
|
||||
{
|
||||
clientCollection.DeleteOne(x => x.Id == model.MongoId);
|
||||
|
||||
return element.GetViewModel;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
//добавление экземпляров сущности из Postgresql
|
||||
public bool InsertFromPostgres(List<ClientViewModel> model)
|
||||
{
|
||||
var clientCollection = context.ConnectToMongo<Client>("client");
|
||||
|
||||
List<Client> models = model.Select(x => Client.Create(new() { Name = x.Name, Surname = x.Surname,
|
||||
Patronymic = x.Patronymic, Email = x.Email, Telephone = x.Telephone })).ToList();
|
||||
|
||||
clientCollection.InsertMany(models);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,164 +0,0 @@
|
||||
using MongoDB.Driver;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TransportCompamyMongoDBImplementer.Models;
|
||||
using TransportCompanyContracts.BindingModels;
|
||||
using TransportCompanyContracts.SearchModels;
|
||||
using TransportCompanyContracts.StoragesContracts;
|
||||
using TransportCompanyContracts.ViewModels;
|
||||
|
||||
namespace TransportCompamyMongoDBImplementer.Implements
|
||||
{
|
||||
public class TransportStorage : ITransportStorage
|
||||
{
|
||||
private DBMSContext context = new();
|
||||
|
||||
public TransportViewModel? Delete(TransportBindingModel model)
|
||||
{
|
||||
var transportCollection = context.ConnectToMongo<Transport>("transport");
|
||||
|
||||
var element = transportCollection.Find(rec => rec.Id == model.MongoId).FirstOrDefault();
|
||||
|
||||
if (element != null)
|
||||
{
|
||||
transportCollection.DeleteOne(x => x.Id == model.MongoId);
|
||||
|
||||
return element.GetViewModel;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public TransportViewModel? GetElement(TransportSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.Tranport) && string.IsNullOrEmpty(model.MongoId))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var transportCollection = context.ConnectToMongo<Transport>("transport");
|
||||
|
||||
return transportCollection.Find(x => (!string.IsNullOrEmpty(model.MongoId) && x.Id == model.MongoId)
|
||||
&& x.TransportType == model.Tranport || (!string.IsNullOrEmpty(model.MongoId) && x.Id == model.MongoId))
|
||||
.FirstOrDefault()
|
||||
?.GetViewModel;
|
||||
}
|
||||
|
||||
public List<TransportViewModel> GetFilteredList(TransportSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
|
||||
var transportCollection = context.ConnectToMongo<Transport>("transport");
|
||||
|
||||
return transportCollection.Find(x => x.Id == model.MongoId)
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<TransportViewModel> GetFullList()
|
||||
{
|
||||
var transportCollection = context.ConnectToMongo<Transport>("transport");
|
||||
|
||||
return transportCollection.Find(_ => true)
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public TransportViewModel? Insert(TransportBindingModel model)
|
||||
{
|
||||
var transportCollection = context.ConnectToMongo<Transport>("transport");
|
||||
|
||||
var newTransport = Transport.Create(model);
|
||||
|
||||
if (newTransport == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
transportCollection.InsertOne(newTransport);
|
||||
|
||||
return newTransport.GetViewModel;
|
||||
}
|
||||
|
||||
//добавление экземпляров сущности из Postgresql
|
||||
public bool InsertFromPostgres(List<TransportViewModel> model)
|
||||
{
|
||||
var transportCollection = context.ConnectToMongo<Transport>("transport");
|
||||
|
||||
List<Transport> models = model.Select(x => Transport.Create(new()
|
||||
{
|
||||
Tranport = x.Tranport
|
||||
})).ToList();
|
||||
|
||||
//цикл для перезаписи типа грузоперевозки
|
||||
foreach (var transport in models)
|
||||
{
|
||||
if (transport.TransportType.Equals("Баржа"))
|
||||
{
|
||||
transport.TransportationType = "Грузовая";
|
||||
}
|
||||
|
||||
if (transport.TransportType.Equals("Вертолёт"))
|
||||
{
|
||||
transport.TransportationType = "Пассажирская";
|
||||
}
|
||||
|
||||
if (transport.TransportType.Equals("Самолёт"))
|
||||
{
|
||||
transport.TransportationType = "Пассажирская";
|
||||
}
|
||||
|
||||
if (transport.TransportType.Equals("Легковой автомобиль"))
|
||||
{
|
||||
transport.TransportationType = "Пассажирская";
|
||||
}
|
||||
|
||||
if (transport.TransportType.Equals("Фура"))
|
||||
{
|
||||
transport.TransportationType = "Грузовая";
|
||||
}
|
||||
|
||||
if (transport.TransportType.Equals("Минивен"))
|
||||
{
|
||||
transport.TransportationType = "Грузовая";
|
||||
}
|
||||
|
||||
if (transport.TransportType.Equals("Открытый грузовик"))
|
||||
{
|
||||
transport.TransportationType = "Перевозка животных";
|
||||
}
|
||||
}
|
||||
|
||||
transportCollection.InsertMany(models);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public TransportViewModel? Update(TransportBindingModel model)
|
||||
{
|
||||
var transportCollection = context.ConnectToMongo<Transport>("transport");
|
||||
|
||||
var transport = transportCollection.Find(x => x.Id == model.MongoId).FirstOrDefault();
|
||||
|
||||
if (transport == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
transport.Update(model);
|
||||
|
||||
var filter = Builders<Transport>.Filter.Eq("Id", model.MongoId);
|
||||
transportCollection.ReplaceOne(filter, transport, new ReplaceOptions { IsUpsert = true });
|
||||
|
||||
return transport.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,240 +0,0 @@
|
||||
using MongoDB.Driver;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TransportCompamyMongoDBImplementer.Models;
|
||||
using TransportCompanyContracts.BindingModels;
|
||||
using TransportCompanyContracts.SearchModels;
|
||||
using TransportCompanyContracts.StoragesContracts;
|
||||
using TransportCompanyContracts.ViewModels;
|
||||
|
||||
namespace TransportCompamyMongoDBImplementer.Implements
|
||||
{
|
||||
public class TruckingStorage : ITruckingStorage
|
||||
{
|
||||
private DBMSContext context = new();
|
||||
|
||||
public TruckingViewModel? Delete(TruckingBindingModel model)
|
||||
{
|
||||
var truckingCollection = context.ConnectToMongo<Trucking>("trucking");
|
||||
|
||||
var element = truckingCollection.Find(rec => rec.Id == model.MongoId).FirstOrDefault();
|
||||
|
||||
if (element != null)
|
||||
{
|
||||
truckingCollection.DeleteOne(x => x.Id == model.MongoId);
|
||||
|
||||
return element.GetViewModel;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public string FirstJoin()
|
||||
{
|
||||
var truckingCollection = context.ConnectToMongo<Trucking>("trucking");
|
||||
var clientCollection = context.ConnectToMongo<Client>("client");
|
||||
|
||||
Random rnd = new Random(DateTime.Now.ToString().GetHashCode());
|
||||
|
||||
//старт замера времени добавления в бд
|
||||
Stopwatch stopwatch = new();
|
||||
|
||||
stopwatch.Start();
|
||||
|
||||
var firstJoin = from t in truckingCollection.Find(t => t.Price == 999999.0).ToList()
|
||||
from c in clientCollection.Find(c => c.Id == t.Client.Id).ToList()
|
||||
select new { t, c };
|
||||
|
||||
//ВСЁ ГОТОВО ДЛЯ СЛЕДУЮЩЕГО ЗАМЕРА
|
||||
// 999999.0
|
||||
|
||||
foreach (var element in firstJoin)
|
||||
{
|
||||
var trucking = truckingCollection.Find(x => x.Id == element.t.Id).FirstOrDefault();
|
||||
|
||||
trucking.Update(new TruckingBindingModel
|
||||
{
|
||||
Price = 1200000.0,
|
||||
DateStart = element.t.DateStart,
|
||||
DateEnd = element.t.DateEnd,
|
||||
});
|
||||
|
||||
var filter = Builders<Trucking>.Filter.Eq("Id", element.t.Id);
|
||||
truckingCollection.ReplaceOne(filter, trucking, new ReplaceOptions { IsUpsert = true });
|
||||
}
|
||||
|
||||
stopwatch.Stop();
|
||||
|
||||
return stopwatch.ElapsedMilliseconds.ToString();
|
||||
}
|
||||
|
||||
public TruckingViewModel? GetElement(TruckingSearchModel model)
|
||||
{
|
||||
|
||||
if (!model.Id.HasValue || !model.ClientId.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var truckingCollection = context.ConnectToMongo<Trucking>("trucking");
|
||||
|
||||
return truckingCollection.Find(x => !string.IsNullOrEmpty(model.MongoId) && x.Id == model.MongoId)
|
||||
.FirstOrDefault()
|
||||
?.GetViewModel;
|
||||
}
|
||||
|
||||
public List<TruckingViewModel> GetFilteredList(TruckingSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.MongoId))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
|
||||
var truckingCollection = context.ConnectToMongo<Trucking>("trucking");
|
||||
|
||||
//не забудь, что тут сделал исправление для поиска по id клиента в MongoDB
|
||||
return truckingCollection.Find(x => x.Client.Id == model.MongoId)
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<TruckingViewModel> GetFullList()
|
||||
{
|
||||
var truckingCollection = context.ConnectToMongo<Trucking>("trucking");
|
||||
|
||||
return truckingCollection.Find(_ => true)
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public TruckingViewModel? Insert(TruckingBindingModel model)
|
||||
{
|
||||
var truckingCollection = context.ConnectToMongo<Trucking>("trucking");
|
||||
|
||||
var newTrucking = Trucking.Create(context, model);
|
||||
|
||||
if (newTrucking == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
truckingCollection.InsertOne(newTrucking);
|
||||
|
||||
return newTrucking.GetViewModel;
|
||||
}
|
||||
|
||||
public bool InsertFromPostgres(List<TruckingViewModel> model)
|
||||
{
|
||||
var clientCollection = context.ConnectToMongo<Client>("client");
|
||||
var cargoCollection = context.ConnectToMongo<Cargo>("cargo");
|
||||
var transportCollection = context.ConnectToMongo<Transport>("transport");
|
||||
var truckingCollection = context.ConnectToMongo<Trucking>("trucking");
|
||||
|
||||
//список, который по итогу и будем вставлять
|
||||
List<Trucking> models = new();
|
||||
|
||||
foreach(var element in model)
|
||||
{
|
||||
var newTrucking = new TruckingBindingModel();
|
||||
|
||||
newTrucking.DateStart = element.DateStart;
|
||||
newTrucking.DateEnd = element.DateEnd;
|
||||
newTrucking.Price = element.Price;
|
||||
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));
|
||||
}
|
||||
|
||||
truckingCollection.InsertMany(models);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public string TestGetFullList()
|
||||
{
|
||||
var truckingCollection = context.ConnectToMongo<Trucking>("trucking");
|
||||
|
||||
string result = null;
|
||||
|
||||
//для замера времени считывания из бд
|
||||
Stopwatch stopwatch = new();
|
||||
|
||||
stopwatch.Start();
|
||||
|
||||
List<TruckingViewModel> list = truckingCollection.Find(_ => true)
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
|
||||
stopwatch.Stop();
|
||||
|
||||
result = list.Count.ToString();
|
||||
|
||||
list.Clear();
|
||||
|
||||
return result + " " + stopwatch.ElapsedMilliseconds.ToString();
|
||||
}
|
||||
|
||||
public string TestRandomInsert(int count, List<ClientViewModel> clients, List<CargoViewModel> cargos, List<TransportViewModel> transports, List<TransportationViewModel> transportations)
|
||||
{
|
||||
var truckingCollection = context.ConnectToMongo<Trucking>("trucking");
|
||||
|
||||
Random rnd = new Random(DateTime.Now.ToString().GetHashCode());
|
||||
|
||||
//старт замера времени добавления в бд
|
||||
Stopwatch stopwatch = new();
|
||||
|
||||
stopwatch.Start();
|
||||
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
DateTime dateStart = new(rnd.Next(1991, 2023), rnd.Next(1, 12), rnd.Next(1, 28));
|
||||
DateTime dateEnd = dateStart.AddDays(20);
|
||||
|
||||
var model = Trucking.Create(context, new()
|
||||
{
|
||||
Client = clients[rnd.Next(0, clients.Count)].MongoId,
|
||||
Cargo = cargos[rnd.Next(0, cargos.Count)].MongoId,
|
||||
Transport = transports[rnd.Next(0, transports.Count)].MongoId,
|
||||
DateStart = dateStart,
|
||||
DateEnd = dateEnd,
|
||||
Price = clients.Count * rnd.Next(100, 5000)
|
||||
});
|
||||
|
||||
truckingCollection.InsertOne(model);
|
||||
}
|
||||
|
||||
stopwatch.Stop();
|
||||
|
||||
return stopwatch.ElapsedMilliseconds.ToString();
|
||||
}
|
||||
|
||||
public TruckingViewModel? Update(TruckingBindingModel model)
|
||||
{
|
||||
var truckingCollection = context.ConnectToMongo<Trucking>("trucking");
|
||||
|
||||
var trucking = truckingCollection.Find(x => x.Id == model.MongoId).FirstOrDefault();
|
||||
|
||||
if (trucking == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
trucking.Update(model);
|
||||
|
||||
var filter = Builders<Trucking>.Filter.Eq("Id", model.MongoId);
|
||||
truckingCollection.ReplaceOne(filter, trucking, new ReplaceOptions { IsUpsert = true });
|
||||
|
||||
return trucking.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,43 +0,0 @@
|
||||
using MongoDB.Bson.Serialization.Attributes;
|
||||
using MongoDB.Bson;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TransportCompanyContracts.BindingModels;
|
||||
using TransportCompanyContracts.ViewModels;
|
||||
|
||||
namespace TransportCompamyMongoDBImplementer.Models
|
||||
{
|
||||
public class Cargo
|
||||
{
|
||||
[BsonId]
|
||||
[BsonRepresentation(BsonType.ObjectId)]
|
||||
public string Id { get; set; }
|
||||
|
||||
public string TypeCargo { get; set; } = null!;
|
||||
|
||||
//public virtual ICollection<Trucking> Truckings { get; set; } = new List<Trucking>();
|
||||
|
||||
public static Cargo Create(CargoBindingModel model)
|
||||
{
|
||||
return new Cargo()
|
||||
{
|
||||
Id = model.MongoId,
|
||||
TypeCargo = model.TypeCargo
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(CargoBindingModel model)
|
||||
{
|
||||
TypeCargo = model.TypeCargo;
|
||||
}
|
||||
|
||||
public CargoViewModel GetViewModel => new()
|
||||
{
|
||||
MongoId = Id,
|
||||
TypeCargo = TypeCargo
|
||||
};
|
||||
}
|
||||
}
|
@ -1,63 +0,0 @@
|
||||
using MongoDB.Bson.Serialization.Attributes;
|
||||
using MongoDB.Bson;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TransportCompanyContracts.BindingModels;
|
||||
using TransportCompanyContracts.ViewModels;
|
||||
|
||||
namespace TransportCompamyMongoDBImplementer.Models
|
||||
{
|
||||
public class Client
|
||||
{
|
||||
[BsonId]
|
||||
[BsonRepresentation(BsonType.ObjectId)]
|
||||
public string Id { get; set; }
|
||||
|
||||
public string Name { get; set; } = null!;
|
||||
|
||||
public string Surname { get; set; } = null!;
|
||||
|
||||
public string Patronymic { get; set; } = null!;
|
||||
|
||||
public string Telephone { get; set; } = null!;
|
||||
|
||||
public string Email { get; set; } = null!;
|
||||
|
||||
//public virtual ICollection<Trucking> Truckings { get; set; } = new List<Trucking>();
|
||||
|
||||
public static Client Create(ClientBindingModel model)
|
||||
{
|
||||
return new Client()
|
||||
{
|
||||
Id = model.MongoId,
|
||||
Name = model.Name,
|
||||
Surname = model.Surname,
|
||||
Patronymic = model.Patronymic,
|
||||
Telephone = model.Telephone,
|
||||
Email = model.Email,
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(ClientBindingModel model)
|
||||
{
|
||||
Name = model.Name;
|
||||
Surname = model.Surname;
|
||||
Patronymic = model.Patronymic;
|
||||
Telephone = model.Telephone;
|
||||
Email = model.Email;
|
||||
}
|
||||
|
||||
public ClientViewModel GetViewModel => new()
|
||||
{
|
||||
MongoId = Id,
|
||||
Name = Name,
|
||||
Surname = Surname,
|
||||
Patronymic = Patronymic,
|
||||
Telephone = Telephone,
|
||||
Email = Email
|
||||
};
|
||||
}
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
using MongoDB.Bson.Serialization.Attributes;
|
||||
using MongoDB.Bson;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TransportCompanyContracts.BindingModels;
|
||||
using TransportCompanyContracts.ViewModels;
|
||||
|
||||
namespace TransportCompamyMongoDBImplementer.Models
|
||||
{
|
||||
public class Transport
|
||||
{
|
||||
|
||||
[BsonId]
|
||||
[BsonRepresentation(BsonType.ObjectId)]
|
||||
public string Id { get; set; }
|
||||
|
||||
public string TransportType { get; set; } = null!;
|
||||
|
||||
public string TransportationType { get; set; } = null!;
|
||||
|
||||
//public virtual ICollection<Trucking> Truckings { get; set; } = new List<Trucking>();
|
||||
|
||||
public static Transport Create(TransportBindingModel model)
|
||||
{
|
||||
return new Transport()
|
||||
{
|
||||
Id = model.MongoId,
|
||||
TransportType = model.Tranport,
|
||||
TransportationType = model.TransportationType
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(TransportBindingModel model)
|
||||
{
|
||||
Id = model.MongoId;
|
||||
TransportType = model.Tranport;
|
||||
TransportationType = model.TransportationType;
|
||||
}
|
||||
|
||||
public TransportViewModel GetViewModel => new()
|
||||
{
|
||||
MongoId = Id,
|
||||
Tranport = TransportType,
|
||||
TransportationType = TransportationType
|
||||
};
|
||||
}
|
||||
}
|
@ -1,78 +0,0 @@
|
||||
using MongoDB.Bson.Serialization.Attributes;
|
||||
using MongoDB.Bson;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TransportCompanyContracts.BindingModels;
|
||||
using TransportCompanyContracts.ViewModels;
|
||||
using MongoDB.Driver;
|
||||
|
||||
namespace TransportCompamyMongoDBImplementer.Models
|
||||
{
|
||||
public class Trucking
|
||||
{
|
||||
[BsonId]
|
||||
[BsonRepresentation(BsonType.ObjectId)]
|
||||
public string Id { get; set; }
|
||||
|
||||
public double Price { get; set; }
|
||||
|
||||
public DateTime DateStart { get; set; }
|
||||
|
||||
public DateTime DateEnd { get; set; }
|
||||
|
||||
public Cargo Cargo { get; set; }
|
||||
|
||||
public Client Client { get; set; }
|
||||
|
||||
public Transport Transport { get; set; }
|
||||
|
||||
public static Trucking? Create( DBMSContext context, TruckingBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new Trucking()
|
||||
{
|
||||
Id = model.MongoId,
|
||||
Price = model.Price,
|
||||
DateStart = model.DateStart,
|
||||
DateEnd = model.DateEnd,
|
||||
Cargo = context.ConnectToMongo<Cargo>("cargo").Find(x => x.Id == model.Cargo).FirstOrDefault(),
|
||||
Client = context.ConnectToMongo<Client>("client").Find(x => x.Id == model.Client).FirstOrDefault(),
|
||||
Transport = context.ConnectToMongo<Transport>("transport").Find(x => x.Id == model.Transport).FirstOrDefault()
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(TruckingBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Price = model.Price;
|
||||
DateStart = model.DateStart;
|
||||
DateEnd = model.DateEnd;
|
||||
}
|
||||
|
||||
public TruckingViewModel GetViewModel => new()
|
||||
{
|
||||
MongoId = Id,
|
||||
Price = Price,
|
||||
DateStart = DateStart,
|
||||
DateEnd = DateEnd,
|
||||
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
|
||||
};
|
||||
}
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<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>
|
@ -1,55 +0,0 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.5.33516.290
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TransportCompany", "TransportCompany\TransportCompany.csproj", "{0512F64B-00F5-49BA-9613-7A396C075C0C}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TransportCompanyDataModels", "TransportCompanyDataModels\TransportCompanyDataModels.csproj", "{C57B4449-A725-4804-833D-7CE33965F001}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TransportCompanyContracts", "TransportCompanyContracts\TransportCompanyContracts.csproj", "{8707D719-D7B3-4F64-8BBE-DE9C7014DD13}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TransportCompanyBusinessLogic", "TransportCompanyBusinessLogic\TransportCompanyBusinessLogic.csproj", "{5FD7F1C8-0B2C-4AD4-91FD-A4475274FD3A}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TransportCompanyDatabaseImplements", "TransportCompanyDatabaseImplements\TransportCompanyDatabaseImplements.csproj", "{E421890B-5501-4A4D-931A-1B8139FDDB24}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TransportCompamyMongoDBImplementer", "TransportCompamyMongoDBImplementer\TransportCompamyMongoDBImplementer.csproj", "{5315CD03-FC5D-4ECB-9973-38989C1B02EE}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{0512F64B-00F5-49BA-9613-7A396C075C0C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{0512F64B-00F5-49BA-9613-7A396C075C0C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{0512F64B-00F5-49BA-9613-7A396C075C0C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{0512F64B-00F5-49BA-9613-7A396C075C0C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{C57B4449-A725-4804-833D-7CE33965F001}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{C57B4449-A725-4804-833D-7CE33965F001}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{C57B4449-A725-4804-833D-7CE33965F001}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{C57B4449-A725-4804-833D-7CE33965F001}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{8707D719-D7B3-4F64-8BBE-DE9C7014DD13}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{8707D719-D7B3-4F64-8BBE-DE9C7014DD13}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{8707D719-D7B3-4F64-8BBE-DE9C7014DD13}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{8707D719-D7B3-4F64-8BBE-DE9C7014DD13}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{5FD7F1C8-0B2C-4AD4-91FD-A4475274FD3A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{5FD7F1C8-0B2C-4AD4-91FD-A4475274FD3A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{5FD7F1C8-0B2C-4AD4-91FD-A4475274FD3A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{5FD7F1C8-0B2C-4AD4-91FD-A4475274FD3A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{E421890B-5501-4A4D-931A-1B8139FDDB24}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{E421890B-5501-4A4D-931A-1B8139FDDB24}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{E421890B-5501-4A4D-931A-1B8139FDDB24}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{E421890B-5501-4A4D-931A-1B8139FDDB24}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{5315CD03-FC5D-4ECB-9973-38989C1B02EE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{5315CD03-FC5D-4ECB-9973-38989C1B02EE}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{5315CD03-FC5D-4ECB-9973-38989C1B02EE}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{5315CD03-FC5D-4ECB-9973-38989C1B02EE}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {AAEBEE78-0520-4BC3-A684-3326238BD705}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
@ -1,7 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<appSettings>
|
||||
<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>
|
114
TransportCompany/TransportCompany/FormCargo.Designer.cs
generated
114
TransportCompany/TransportCompany/FormCargo.Designer.cs
generated
@ -1,114 +0,0 @@
|
||||
namespace TransportCompany
|
||||
{
|
||||
partial class FormCargo
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
dataGridView = new DataGridView();
|
||||
buttonCreate = new Button();
|
||||
buttonUpdate = new Button();
|
||||
buttonDelete = new Button();
|
||||
buttonReload = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView.Location = new Point(12, 12);
|
||||
dataGridView.Name = "dataGridView";
|
||||
dataGridView.RowHeadersWidth = 51;
|
||||
dataGridView.RowTemplate.Height = 29;
|
||||
dataGridView.Size = new Size(523, 426);
|
||||
dataGridView.TabIndex = 0;
|
||||
//
|
||||
// buttonCreate
|
||||
//
|
||||
buttonCreate.Location = new Point(590, 33);
|
||||
buttonCreate.Name = "buttonCreate";
|
||||
buttonCreate.Size = new Size(129, 29);
|
||||
buttonCreate.TabIndex = 1;
|
||||
buttonCreate.Text = "Создать";
|
||||
buttonCreate.UseVisualStyleBackColor = true;
|
||||
buttonCreate.Click += ButtonCreate_Click;
|
||||
//
|
||||
// buttonUpdate
|
||||
//
|
||||
buttonUpdate.Location = new Point(590, 108);
|
||||
buttonUpdate.Name = "buttonUpdate";
|
||||
buttonUpdate.Size = new Size(129, 29);
|
||||
buttonUpdate.TabIndex = 2;
|
||||
buttonUpdate.Text = "Изменить";
|
||||
buttonUpdate.UseVisualStyleBackColor = true;
|
||||
buttonUpdate.Click += ButtonUpdate_Click;
|
||||
//
|
||||
// buttonDelete
|
||||
//
|
||||
buttonDelete.Location = new Point(590, 179);
|
||||
buttonDelete.Name = "buttonDelete";
|
||||
buttonDelete.Size = new Size(129, 29);
|
||||
buttonDelete.TabIndex = 3;
|
||||
buttonDelete.Text = "Удалить";
|
||||
buttonDelete.UseVisualStyleBackColor = true;
|
||||
buttonDelete.Click += ButtonDelete_Click;
|
||||
//
|
||||
// buttonReload
|
||||
//
|
||||
buttonReload.Location = new Point(590, 251);
|
||||
buttonReload.Name = "buttonReload";
|
||||
buttonReload.Size = new Size(129, 29);
|
||||
buttonReload.TabIndex = 4;
|
||||
buttonReload.Text = "Обновить";
|
||||
buttonReload.UseVisualStyleBackColor = true;
|
||||
buttonReload.Click += ButtonReload_Click;
|
||||
//
|
||||
// FormCargo
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(766, 450);
|
||||
Controls.Add(buttonReload);
|
||||
Controls.Add(buttonDelete);
|
||||
Controls.Add(buttonUpdate);
|
||||
Controls.Add(buttonCreate);
|
||||
Controls.Add(dataGridView);
|
||||
Name = "FormCargo";
|
||||
Text = "FormCargo";
|
||||
Load += FormCargo_Load;
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DataGridView dataGridView;
|
||||
private Button buttonCreate;
|
||||
private Button buttonUpdate;
|
||||
private Button buttonDelete;
|
||||
private Button buttonReload;
|
||||
}
|
||||
}
|
@ -1,132 +0,0 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using TransportCompanyContracts.BindingModels;
|
||||
using TransportCompanyContracts.BusinessLogicsContracts;
|
||||
|
||||
namespace TransportCompany
|
||||
{
|
||||
public partial class FormCargo : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private readonly ICargoLogic _logicC;
|
||||
|
||||
public FormCargo(ILogger<FormCargo> logger, ICargoLogic logicC)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_logger = logger;
|
||||
_logicC = logicC;
|
||||
}
|
||||
|
||||
private void FormCargo_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
try
|
||||
{
|
||||
var list = _logicC.ReadList(null);
|
||||
|
||||
if (list != null)
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["Id"].Visible = false;
|
||||
dataGridView.Columns["MongoId"].Visible = false;
|
||||
dataGridView.Columns[2].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
|
||||
_logger.LogInformation("Загрузка типов грузов");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки типов грузов");
|
||||
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonCreate_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormCreateCargo));
|
||||
|
||||
if (service is FormCreateCargo form)
|
||||
{
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonUpdate_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormCreateCargo));
|
||||
|
||||
if (service is FormCreateCargo form)
|
||||
{
|
||||
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
|
||||
form.MongoId = Convert.ToString(dataGridView.SelectedRows[0].Cells["MongoId"].Value);
|
||||
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonDelete_Click(object sender, EventArgs e)
|
||||
{
|
||||
//проверяем наличие выделенной строки
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
|
||||
string _mongoId = Convert.ToString(dataGridView.SelectedRows[0].Cells["MongoId"].Value);
|
||||
|
||||
_logger.LogInformation("Удаление типа груза");
|
||||
|
||||
try
|
||||
{
|
||||
if (!_logicC.Delete(new CargoBindingModel
|
||||
{
|
||||
Id = id,
|
||||
MongoId = _mongoId
|
||||
}))
|
||||
{
|
||||
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
|
||||
}
|
||||
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка удаления типа груза");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonReload_Click(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,60 +0,0 @@
|
||||
<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>
|
@ -1,135 +0,0 @@
|
||||
namespace TransportCompany
|
||||
{
|
||||
partial class FormCheckTimeJoin
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
textBoxFirstCheck = new TextBox();
|
||||
groupBoxFirst = new GroupBox();
|
||||
buttonCheckFirstJoin = new Button();
|
||||
groupBoxSecond = new GroupBox();
|
||||
textBoxSecondCheck = new TextBox();
|
||||
buttonCheckSecondJoin = new Button();
|
||||
buttonCancel = new Button();
|
||||
groupBoxFirst.SuspendLayout();
|
||||
groupBoxSecond.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// textBoxFirstCheck
|
||||
//
|
||||
textBoxFirstCheck.Location = new Point(312, 42);
|
||||
textBoxFirstCheck.Name = "textBoxFirstCheck";
|
||||
textBoxFirstCheck.Size = new Size(228, 27);
|
||||
textBoxFirstCheck.TabIndex = 0;
|
||||
//
|
||||
// groupBoxFirst
|
||||
//
|
||||
groupBoxFirst.Controls.Add(buttonCheckFirstJoin);
|
||||
groupBoxFirst.Controls.Add(textBoxFirstCheck);
|
||||
groupBoxFirst.Location = new Point(12, 12);
|
||||
groupBoxFirst.Name = "groupBoxFirst";
|
||||
groupBoxFirst.Size = new Size(580, 91);
|
||||
groupBoxFirst.TabIndex = 1;
|
||||
groupBoxFirst.TabStop = false;
|
||||
groupBoxFirst.Text = "Для первого запроса";
|
||||
//
|
||||
// buttonCheckFirstJoin
|
||||
//
|
||||
buttonCheckFirstJoin.Location = new Point(65, 42);
|
||||
buttonCheckFirstJoin.Name = "buttonCheckFirstJoin";
|
||||
buttonCheckFirstJoin.Size = new Size(195, 29);
|
||||
buttonCheckFirstJoin.TabIndex = 1;
|
||||
buttonCheckFirstJoin.Text = "Произвести замер";
|
||||
buttonCheckFirstJoin.UseVisualStyleBackColor = true;
|
||||
buttonCheckFirstJoin.Click += ButtonCheckFirstJoin_Click;
|
||||
//
|
||||
// groupBoxSecond
|
||||
//
|
||||
groupBoxSecond.Controls.Add(textBoxSecondCheck);
|
||||
groupBoxSecond.Controls.Add(buttonCheckSecondJoin);
|
||||
groupBoxSecond.Location = new Point(12, 109);
|
||||
groupBoxSecond.Name = "groupBoxSecond";
|
||||
groupBoxSecond.Size = new Size(580, 95);
|
||||
groupBoxSecond.TabIndex = 2;
|
||||
groupBoxSecond.TabStop = false;
|
||||
groupBoxSecond.Text = "Для второго запроса";
|
||||
//
|
||||
// textBoxSecondCheck
|
||||
//
|
||||
textBoxSecondCheck.Location = new Point(312, 41);
|
||||
textBoxSecondCheck.Name = "textBoxSecondCheck";
|
||||
textBoxSecondCheck.Size = new Size(228, 27);
|
||||
textBoxSecondCheck.TabIndex = 1;
|
||||
//
|
||||
// buttonCheckSecondJoin
|
||||
//
|
||||
buttonCheckSecondJoin.Location = new Point(65, 41);
|
||||
buttonCheckSecondJoin.Name = "buttonCheckSecondJoin";
|
||||
buttonCheckSecondJoin.Size = new Size(195, 29);
|
||||
buttonCheckSecondJoin.TabIndex = 0;
|
||||
buttonCheckSecondJoin.Text = "Произвести замер";
|
||||
buttonCheckSecondJoin.UseVisualStyleBackColor = true;
|
||||
buttonCheckSecondJoin.Click += ButtonCheckSecondJoin_Click;
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(452, 220);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(140, 29);
|
||||
buttonCancel.TabIndex = 3;
|
||||
buttonCancel.Text = "Закрыть";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
buttonCancel.Click += ButtonCancel_Click;
|
||||
//
|
||||
// FormCheckTimeJoin
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(604, 259);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(groupBoxSecond);
|
||||
Controls.Add(groupBoxFirst);
|
||||
Name = "FormCheckTimeJoin";
|
||||
Text = "Замер времени сложных запросов";
|
||||
groupBoxFirst.ResumeLayout(false);
|
||||
groupBoxFirst.PerformLayout();
|
||||
groupBoxSecond.ResumeLayout(false);
|
||||
groupBoxSecond.PerformLayout();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private TextBox textBoxFirstCheck;
|
||||
private GroupBox groupBoxFirst;
|
||||
private Button buttonCheckFirstJoin;
|
||||
private GroupBox groupBoxSecond;
|
||||
private TextBox textBoxSecondCheck;
|
||||
private Button buttonCheckSecondJoin;
|
||||
private Button buttonCancel;
|
||||
}
|
||||
}
|
@ -1,58 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using TransportCompanyContracts.BusinessLogicsContracts;
|
||||
|
||||
namespace TransportCompany
|
||||
{
|
||||
public partial class FormCheckTimeJoin : Form
|
||||
{
|
||||
private readonly ITruckingLogic _truckingLogic;
|
||||
|
||||
private readonly IClientLogic _clientLogic;
|
||||
|
||||
public FormCheckTimeJoin(ITruckingLogic truckingLogic, IClientLogic clientLogic)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_truckingLogic = truckingLogic;
|
||||
_clientLogic = clientLogic;
|
||||
}
|
||||
|
||||
private void ButtonCheckFirstJoin_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
textBoxFirstCheck.Text = _truckingLogic.TestFirstJoin();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonCheckSecondJoin_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
textBoxSecondCheck.Text = _clientLogic.TestSecondJoin();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,60 +0,0 @@
|
||||
<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>
|
@ -1,114 +0,0 @@
|
||||
namespace TransportCompany
|
||||
{
|
||||
partial class FormClients
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
dataGridView = new DataGridView();
|
||||
buttonCreate = new Button();
|
||||
buttonUpdate = new Button();
|
||||
buttonDelete = new Button();
|
||||
buttonReload = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView.Location = new Point(12, 12);
|
||||
dataGridView.Name = "dataGridView";
|
||||
dataGridView.RowHeadersWidth = 51;
|
||||
dataGridView.RowTemplate.Height = 29;
|
||||
dataGridView.Size = new Size(1024, 426);
|
||||
dataGridView.TabIndex = 0;
|
||||
//
|
||||
// buttonCreate
|
||||
//
|
||||
buttonCreate.Location = new Point(1081, 36);
|
||||
buttonCreate.Name = "buttonCreate";
|
||||
buttonCreate.Size = new Size(150, 29);
|
||||
buttonCreate.TabIndex = 1;
|
||||
buttonCreate.Text = "Создать";
|
||||
buttonCreate.UseVisualStyleBackColor = true;
|
||||
buttonCreate.Click += ButtonCreate_Click;
|
||||
//
|
||||
// buttonUpdate
|
||||
//
|
||||
buttonUpdate.Location = new Point(1081, 110);
|
||||
buttonUpdate.Name = "buttonUpdate";
|
||||
buttonUpdate.Size = new Size(150, 29);
|
||||
buttonUpdate.TabIndex = 2;
|
||||
buttonUpdate.Text = "Изменить";
|
||||
buttonUpdate.UseVisualStyleBackColor = true;
|
||||
buttonUpdate.Click += ButtonUpdate_Click;
|
||||
//
|
||||
// buttonDelete
|
||||
//
|
||||
buttonDelete.Location = new Point(1081, 182);
|
||||
buttonDelete.Name = "buttonDelete";
|
||||
buttonDelete.Size = new Size(150, 29);
|
||||
buttonDelete.TabIndex = 3;
|
||||
buttonDelete.Text = "Удалить";
|
||||
buttonDelete.UseVisualStyleBackColor = true;
|
||||
buttonDelete.Click += ButtonDelete_Click;
|
||||
//
|
||||
// buttonReload
|
||||
//
|
||||
buttonReload.Location = new Point(1081, 251);
|
||||
buttonReload.Name = "buttonReload";
|
||||
buttonReload.Size = new Size(150, 29);
|
||||
buttonReload.TabIndex = 4;
|
||||
buttonReload.Text = "Обновить";
|
||||
buttonReload.UseVisualStyleBackColor = true;
|
||||
buttonReload.Click += ButtonReload_Click;
|
||||
//
|
||||
// FormClients
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(1271, 450);
|
||||
Controls.Add(buttonReload);
|
||||
Controls.Add(buttonDelete);
|
||||
Controls.Add(buttonUpdate);
|
||||
Controls.Add(buttonCreate);
|
||||
Controls.Add(dataGridView);
|
||||
Name = "FormClients";
|
||||
Text = "Клиенты";
|
||||
Load += FormClients_Load;
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DataGridView dataGridView;
|
||||
private Button buttonCreate;
|
||||
private Button buttonUpdate;
|
||||
private Button buttonDelete;
|
||||
private Button buttonReload;
|
||||
}
|
||||
}
|
@ -1,135 +0,0 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Serilog.Core;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using TransportCompanyContracts.BindingModels;
|
||||
using TransportCompanyContracts.BusinessLogicsContracts;
|
||||
|
||||
namespace TransportCompany
|
||||
{
|
||||
public partial class FormClients : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private readonly IClientLogic _logicC;
|
||||
|
||||
public FormClients(ILogger<FormClients> logger, IClientLogic logicC)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_logger = logger;
|
||||
_logicC = logicC;
|
||||
}
|
||||
|
||||
private void FormClients_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
try
|
||||
{
|
||||
var list = _logicC.ReadList(null);
|
||||
|
||||
//растягиваем колонку Название на всю ширину, колонку Id скрываем
|
||||
if (list != null)
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["Id"].Visible = false;
|
||||
dataGridView.Columns["MongoId"].Visible = false;
|
||||
dataGridView.Columns[5].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
dataGridView.Columns[6].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
|
||||
_logger.LogInformation("Загрузка клиентов");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки заготовок");
|
||||
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonCreate_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormCreateClient));
|
||||
|
||||
if (service is FormCreateClient form)
|
||||
{
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonUpdate_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormCreateClient));
|
||||
|
||||
if (service is FormCreateClient form)
|
||||
{
|
||||
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
|
||||
form.MongoId = Convert.ToString(dataGridView.SelectedRows[0].Cells["MongoId"].Value);
|
||||
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonDelete_Click(object sender, EventArgs e)
|
||||
{
|
||||
//проверяем наличие выделенной строки
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
|
||||
string mongoId = Convert.ToString(dataGridView.SelectedRows[0].Cells["MongoId"].Value);
|
||||
|
||||
_logger.LogInformation("Удаление клиента");
|
||||
|
||||
try
|
||||
{
|
||||
if (!_logicC.Delete(new ClientBindingModel
|
||||
{
|
||||
Id = id,
|
||||
MongoId = mongoId
|
||||
}))
|
||||
{
|
||||
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
|
||||
}
|
||||
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка удаления компонента");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonReload_Click(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,60 +0,0 @@
|
||||
<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>
|
@ -1,96 +0,0 @@
|
||||
namespace TransportCompany
|
||||
{
|
||||
partial class FormCreateCargo
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
label1 = new Label();
|
||||
textBoxCargo = new TextBox();
|
||||
buttonCreate = new Button();
|
||||
buttonCancel = new Button();
|
||||
SuspendLayout();
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(33, 28);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(137, 20);
|
||||
label1.TabIndex = 0;
|
||||
label1.Text = "Введите тип груза:";
|
||||
//
|
||||
// textBoxCargo
|
||||
//
|
||||
textBoxCargo.Location = new Point(198, 25);
|
||||
textBoxCargo.Name = "textBoxCargo";
|
||||
textBoxCargo.Size = new Size(313, 27);
|
||||
textBoxCargo.TabIndex = 1;
|
||||
//
|
||||
// buttonCreate
|
||||
//
|
||||
buttonCreate.Location = new Point(305, 73);
|
||||
buttonCreate.Name = "buttonCreate";
|
||||
buttonCreate.Size = new Size(94, 29);
|
||||
buttonCreate.TabIndex = 2;
|
||||
buttonCreate.Text = "Создать";
|
||||
buttonCreate.UseVisualStyleBackColor = true;
|
||||
buttonCreate.Click += ButtonCreate_Click;
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(417, 73);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(94, 29);
|
||||
buttonCancel.TabIndex = 3;
|
||||
buttonCancel.Text = "Отмена";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
buttonCancel.Click += ButtonCancel_Click;
|
||||
//
|
||||
// FormCreateCargo
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(571, 118);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonCreate);
|
||||
Controls.Add(textBoxCargo);
|
||||
Controls.Add(label1);
|
||||
Name = "FormCreateCargo";
|
||||
Text = "Создание груза";
|
||||
Load += FormCreateCargo_Load;
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label label1;
|
||||
private TextBox textBoxCargo;
|
||||
private Button buttonCreate;
|
||||
private Button buttonCancel;
|
||||
}
|
||||
}
|
@ -1,129 +0,0 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using TransportCompanyContracts.BindingModels;
|
||||
using TransportCompanyContracts.BusinessLogicsContracts;
|
||||
using TransportCompanyContracts.SearchModels;
|
||||
|
||||
namespace TransportCompany
|
||||
{
|
||||
public partial class FormCreateCargo : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private readonly ICargoLogic _logicCg;
|
||||
|
||||
private int? _id;
|
||||
|
||||
private string? _mongoId;
|
||||
|
||||
public int Id { set { _id = value; } }
|
||||
|
||||
public string MongoId { set { _mongoId = value; } }
|
||||
|
||||
public FormCreateCargo(ILogger<FormCreateCargo> logger, ICargoLogic logicCg)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_logger = logger;
|
||||
_logicCg = logicCg;
|
||||
}
|
||||
|
||||
private void FormCreateCargo_Load(object sender, EventArgs e)
|
||||
{
|
||||
//проверка на заполнение поля id. Если оно заполнено, то пробуем получить запись и выести её на экран
|
||||
if (!string.IsNullOrEmpty(_mongoId))
|
||||
{
|
||||
try
|
||||
{
|
||||
_logger.LogInformation("Получение типа груза");
|
||||
|
||||
var view = _logicCg.ReadElement(new CargoSearchModel { MongoId = _mongoId });
|
||||
|
||||
if (view != null)
|
||||
{
|
||||
textBoxCargo.Text = view.TypeCargo;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения типа груза");
|
||||
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
else if (_id.HasValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logger.LogInformation("Получение типа груза");
|
||||
|
||||
var view = _logicCg.ReadElement(new CargoSearchModel { Id = _id.Value });
|
||||
|
||||
if (view != null)
|
||||
{
|
||||
textBoxCargo.Text = view.TypeCargo;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения типа груза");
|
||||
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonCreate_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(textBoxCargo.Text))
|
||||
{
|
||||
MessageBox.Show("Введите тип груза", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
_logger.LogInformation("Добавление груза");
|
||||
|
||||
try
|
||||
{
|
||||
var model = new CargoBindingModel
|
||||
{
|
||||
Id = _id ?? 0,
|
||||
MongoId = _mongoId,
|
||||
TypeCargo = textBoxCargo.Text
|
||||
};
|
||||
|
||||
var operationResult = _id.HasValue ? _logicCg.Update(model) : _logicCg.Create(model);
|
||||
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||
}
|
||||
|
||||
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
DialogResult = DialogResult.OK;
|
||||
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка сохранения клиента");
|
||||
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,60 +0,0 @@
|
||||
<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>
|
@ -1,184 +0,0 @@
|
||||
namespace TransportCompany
|
||||
{
|
||||
partial class FormCreateClient
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
labelName = new Label();
|
||||
labelSurname = new Label();
|
||||
labelPatronymic = new Label();
|
||||
labelTelephone = new Label();
|
||||
labelEmail = new Label();
|
||||
textBoxName = new TextBox();
|
||||
textBoxSurname = new TextBox();
|
||||
textBoxPatronymic = new TextBox();
|
||||
textBoxTelephone = new TextBox();
|
||||
textBoxEmail = new TextBox();
|
||||
buttonCreate = new Button();
|
||||
buttonCancel = new Button();
|
||||
SuspendLayout();
|
||||
//
|
||||
// labelName
|
||||
//
|
||||
labelName.AutoSize = true;
|
||||
labelName.Location = new Point(36, 51);
|
||||
labelName.Name = "labelName";
|
||||
labelName.Size = new Size(42, 20);
|
||||
labelName.TabIndex = 0;
|
||||
labelName.Text = "Имя:";
|
||||
//
|
||||
// labelSurname
|
||||
//
|
||||
labelSurname.AutoSize = true;
|
||||
labelSurname.Location = new Point(36, 100);
|
||||
labelSurname.Name = "labelSurname";
|
||||
labelSurname.Size = new Size(76, 20);
|
||||
labelSurname.TabIndex = 1;
|
||||
labelSurname.Text = "Фамилия:";
|
||||
//
|
||||
// labelPatronymic
|
||||
//
|
||||
labelPatronymic.AutoSize = true;
|
||||
labelPatronymic.Location = new Point(36, 152);
|
||||
labelPatronymic.Name = "labelPatronymic";
|
||||
labelPatronymic.Size = new Size(75, 20);
|
||||
labelPatronymic.TabIndex = 2;
|
||||
labelPatronymic.Text = "Отчество:";
|
||||
//
|
||||
// labelTelephone
|
||||
//
|
||||
labelTelephone.AutoSize = true;
|
||||
labelTelephone.Location = new Point(36, 206);
|
||||
labelTelephone.Name = "labelTelephone";
|
||||
labelTelephone.Size = new Size(138, 20);
|
||||
labelTelephone.TabIndex = 3;
|
||||
labelTelephone.Text = "Номера телефона:";
|
||||
//
|
||||
// labelEmail
|
||||
//
|
||||
labelEmail.AutoSize = true;
|
||||
labelEmail.Location = new Point(36, 260);
|
||||
labelEmail.Name = "labelEmail";
|
||||
labelEmail.Size = new Size(54, 20);
|
||||
labelEmail.TabIndex = 4;
|
||||
labelEmail.Text = "Почта:";
|
||||
//
|
||||
// textBoxName
|
||||
//
|
||||
textBoxName.Location = new Point(195, 48);
|
||||
textBoxName.Name = "textBoxName";
|
||||
textBoxName.Size = new Size(394, 27);
|
||||
textBoxName.TabIndex = 5;
|
||||
//
|
||||
// textBoxSurname
|
||||
//
|
||||
textBoxSurname.Location = new Point(195, 97);
|
||||
textBoxSurname.Name = "textBoxSurname";
|
||||
textBoxSurname.Size = new Size(394, 27);
|
||||
textBoxSurname.TabIndex = 6;
|
||||
//
|
||||
// textBoxPatronymic
|
||||
//
|
||||
textBoxPatronymic.Location = new Point(195, 149);
|
||||
textBoxPatronymic.Name = "textBoxPatronymic";
|
||||
textBoxPatronymic.Size = new Size(394, 27);
|
||||
textBoxPatronymic.TabIndex = 7;
|
||||
//
|
||||
// textBoxTelephone
|
||||
//
|
||||
textBoxTelephone.Location = new Point(195, 203);
|
||||
textBoxTelephone.Name = "textBoxTelephone";
|
||||
textBoxTelephone.Size = new Size(394, 27);
|
||||
textBoxTelephone.TabIndex = 8;
|
||||
//
|
||||
// textBoxEmail
|
||||
//
|
||||
textBoxEmail.Location = new Point(195, 257);
|
||||
textBoxEmail.Name = "textBoxEmail";
|
||||
textBoxEmail.Size = new Size(394, 27);
|
||||
textBoxEmail.TabIndex = 9;
|
||||
//
|
||||
// buttonCreate
|
||||
//
|
||||
buttonCreate.Location = new Point(309, 318);
|
||||
buttonCreate.Name = "buttonCreate";
|
||||
buttonCreate.Size = new Size(131, 29);
|
||||
buttonCreate.TabIndex = 10;
|
||||
buttonCreate.Text = "Создать";
|
||||
buttonCreate.UseVisualStyleBackColor = true;
|
||||
buttonCreate.Click += ButtonCreate_Click;
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(458, 318);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(131, 29);
|
||||
buttonCancel.TabIndex = 11;
|
||||
buttonCancel.Text = "Отмена";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
buttonCancel.Click += ButtonCancel_Click;
|
||||
//
|
||||
// FormCreateClient
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(623, 372);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonCreate);
|
||||
Controls.Add(textBoxEmail);
|
||||
Controls.Add(textBoxTelephone);
|
||||
Controls.Add(textBoxPatronymic);
|
||||
Controls.Add(textBoxSurname);
|
||||
Controls.Add(textBoxName);
|
||||
Controls.Add(labelEmail);
|
||||
Controls.Add(labelTelephone);
|
||||
Controls.Add(labelPatronymic);
|
||||
Controls.Add(labelSurname);
|
||||
Controls.Add(labelName);
|
||||
Name = "FormCreateClient";
|
||||
Text = "Клиент";
|
||||
Load += FormCreateClient_Load;
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label labelName;
|
||||
private Label labelSurname;
|
||||
private Label labelPatronymic;
|
||||
private Label labelTelephone;
|
||||
private Label labelEmail;
|
||||
private TextBox textBoxName;
|
||||
private TextBox textBoxSurname;
|
||||
private TextBox textBoxPatronymic;
|
||||
private TextBox textBoxTelephone;
|
||||
private TextBox textBoxEmail;
|
||||
private Button buttonCreate;
|
||||
private Button buttonCancel;
|
||||
}
|
||||
}
|
@ -1,166 +0,0 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using TransportCompanyContracts.BindingModels;
|
||||
using TransportCompanyContracts.BusinessLogicsContracts;
|
||||
using TransportCompanyContracts.SearchModels;
|
||||
|
||||
namespace TransportCompany
|
||||
{
|
||||
public partial class FormCreateClient : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private readonly IClientLogic _logicC;
|
||||
|
||||
private int? _id;
|
||||
|
||||
private string? _mongoId;
|
||||
|
||||
public int Id { set { _id = value; } }
|
||||
|
||||
public string MongoId { set { _mongoId = value; } }
|
||||
|
||||
public FormCreateClient(ILogger<FormCreateClient> logger, IClientLogic logicC)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_logger = logger;
|
||||
_logicC = logicC;
|
||||
}
|
||||
|
||||
//для загрузки данных при редактировании
|
||||
private void FormCreateClient_Load(object sender, EventArgs e)
|
||||
{
|
||||
//проверка на заполнение поля id. Если оно заполнено, то пробуем получить запись и выести её на экран
|
||||
if (!string.IsNullOrEmpty(_mongoId))
|
||||
{
|
||||
try
|
||||
{
|
||||
_logger.LogInformation("Получение клиента");
|
||||
|
||||
var view = _logicC.ReadElement(new ClientSearchModel { MongoId = _mongoId });
|
||||
|
||||
if (view != null)
|
||||
{
|
||||
textBoxName.Text = view.Name;
|
||||
textBoxSurname.Text = view.Surname;
|
||||
textBoxPatronymic.Text = view.Patronymic;
|
||||
textBoxTelephone.Text = view.Telephone;
|
||||
textBoxEmail.Text = view.Email;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения компонента");
|
||||
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
else if (_id.HasValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logger.LogInformation("Получение клиента");
|
||||
|
||||
var view = _logicC.ReadElement(new ClientSearchModel { Id = _id.Value });
|
||||
|
||||
if (view != null)
|
||||
{
|
||||
textBoxName.Text = view.Name;
|
||||
textBoxSurname.Text = view.Surname;
|
||||
textBoxPatronymic.Text = view.Patronymic;
|
||||
textBoxTelephone.Text = view.Telephone;
|
||||
textBoxEmail.Text = view.Email;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения компонента");
|
||||
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonCreate_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(textBoxName.Text))
|
||||
{
|
||||
MessageBox.Show("Введите своё имя", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(textBoxSurname.Text))
|
||||
{
|
||||
MessageBox.Show("Введите свою фамилию", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(textBoxPatronymic.Text))
|
||||
{
|
||||
MessageBox.Show("Введите своё отчество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(textBoxTelephone.Text))
|
||||
{
|
||||
MessageBox.Show("Введите свой телефон", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(textBoxEmail.Text))
|
||||
{
|
||||
MessageBox.Show("Введите свою почту", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
_logger.LogInformation("Добавление клиента");
|
||||
|
||||
try
|
||||
{
|
||||
var model = new ClientBindingModel
|
||||
{
|
||||
Id = 0,
|
||||
MongoId = _mongoId,
|
||||
Name = textBoxName.Text,
|
||||
Surname = textBoxSurname.Text,
|
||||
Patronymic = textBoxPatronymic.Text,
|
||||
Telephone = textBoxTelephone.Text,
|
||||
Email = textBoxEmail.Text
|
||||
};
|
||||
|
||||
var operationResult = _id.HasValue ? _logicC.Update(model) : _logicC.Create(model);
|
||||
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранеии. Дополнительная информация в логах.");
|
||||
}
|
||||
|
||||
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
DialogResult = DialogResult.OK;
|
||||
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка сохранения клиента");
|
||||
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,60 +0,0 @@
|
||||
<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>
|
@ -1,118 +0,0 @@
|
||||
namespace TransportCompany
|
||||
{
|
||||
partial class FormCreateTransport
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
label1 = new Label();
|
||||
textBoxTransport = new TextBox();
|
||||
buttonCreate = new Button();
|
||||
buttonCancel = new Button();
|
||||
label2 = new Label();
|
||||
textBoxTypeTransportation = new TextBox();
|
||||
SuspendLayout();
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(36, 43);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(122, 20);
|
||||
label1.TabIndex = 0;
|
||||
label1.Text = "Тип транспорта:";
|
||||
//
|
||||
// textBoxTransport
|
||||
//
|
||||
textBoxTransport.Location = new Point(215, 40);
|
||||
textBoxTransport.Name = "textBoxTransport";
|
||||
textBoxTransport.Size = new Size(254, 27);
|
||||
textBoxTransport.TabIndex = 1;
|
||||
//
|
||||
// buttonCreate
|
||||
//
|
||||
buttonCreate.Location = new Point(262, 164);
|
||||
buttonCreate.Name = "buttonCreate";
|
||||
buttonCreate.Size = new Size(94, 29);
|
||||
buttonCreate.TabIndex = 2;
|
||||
buttonCreate.Text = "Создать";
|
||||
buttonCreate.UseVisualStyleBackColor = true;
|
||||
buttonCreate.Click += ButtonCreate_Click;
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(375, 164);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(94, 29);
|
||||
buttonCancel.TabIndex = 3;
|
||||
buttonCancel.Text = "Отмена";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
buttonCancel.Click += ButtonCancel_Click;
|
||||
//
|
||||
// label2
|
||||
//
|
||||
label2.AutoSize = true;
|
||||
label2.Location = new Point(36, 112);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new Size(116, 20);
|
||||
label2.TabIndex = 4;
|
||||
label2.Text = "Тип перевозки:";
|
||||
//
|
||||
// textBoxTypeTransportation
|
||||
//
|
||||
textBoxTypeTransportation.Location = new Point(215, 109);
|
||||
textBoxTypeTransportation.Name = "textBoxTypeTransportation";
|
||||
textBoxTypeTransportation.Size = new Size(254, 27);
|
||||
textBoxTypeTransportation.TabIndex = 5;
|
||||
//
|
||||
// FormCreateTransport
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(527, 215);
|
||||
Controls.Add(textBoxTypeTransportation);
|
||||
Controls.Add(label2);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonCreate);
|
||||
Controls.Add(textBoxTransport);
|
||||
Controls.Add(label1);
|
||||
Name = "FormCreateTransport";
|
||||
Text = "Транспорт";
|
||||
Load += FormCreateTransport_Load;
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label label1;
|
||||
private TextBox textBoxTransport;
|
||||
private Button buttonCreate;
|
||||
private Button buttonCancel;
|
||||
private Label label2;
|
||||
private TextBox textBoxTypeTransportation;
|
||||
}
|
||||
}
|
@ -1,137 +0,0 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using TransportCompanyContracts.BindingModels;
|
||||
using TransportCompanyContracts.BusinessLogicsContracts;
|
||||
using TransportCompanyContracts.SearchModels;
|
||||
|
||||
namespace TransportCompany
|
||||
{
|
||||
public partial class FormCreateTransport : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private readonly ITransportLogic _logicT;
|
||||
|
||||
private int? _id;
|
||||
|
||||
private string? _mongoId;
|
||||
|
||||
public int Id { set { _id = value; } }
|
||||
|
||||
public string MongoId { set { _mongoId = value; } }
|
||||
|
||||
public FormCreateTransport(ILogger<FormCreateTransport> logger, ITransportLogic logicT)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_logger = logger;
|
||||
_logicT = logicT;
|
||||
}
|
||||
|
||||
private void FormCreateTransport_Load(object sender, EventArgs e)
|
||||
{
|
||||
//проверка на заполнение поля id. Если оно заполнено, то пробуем получить запись и выести её на экран
|
||||
if (!string.IsNullOrEmpty(_mongoId))
|
||||
{
|
||||
try
|
||||
{
|
||||
_logger.LogInformation("Получение транспорта");
|
||||
|
||||
var view = _logicT.ReadElement(new TransportSearchModel { MongoId = _mongoId });
|
||||
|
||||
if (view != null)
|
||||
{
|
||||
textBoxTransport.Text = view.Tranport;
|
||||
textBoxTypeTransportation.Text = view.TransportationType;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения транспорта");
|
||||
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
else if (_id.HasValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logger.LogInformation("Получение транспорта");
|
||||
|
||||
var view = _logicT.ReadElement(new TransportSearchModel { Id = _id.Value });
|
||||
|
||||
if (view != null)
|
||||
{
|
||||
textBoxTransport.Text = view.Tranport;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения транспорта");
|
||||
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonCreate_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(textBoxTransport.Text))
|
||||
{
|
||||
MessageBox.Show("Введите тип транспорта", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
/*if (string.IsNullOrEmpty(textBoxTypeTransportation.Text))
|
||||
{
|
||||
MessageBox.Show("Введите тип транспортировки", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}*/
|
||||
|
||||
_logger.LogInformation("Добавление транспорта");
|
||||
|
||||
try
|
||||
{
|
||||
var model = new TransportBindingModel
|
||||
{
|
||||
Id = _id ?? 0,
|
||||
MongoId = _mongoId,
|
||||
Tranport = textBoxTransport.Text,
|
||||
TransportationType = textBoxTypeTransportation.Text
|
||||
};
|
||||
|
||||
var operationResult = _id.HasValue ? _logicT.Update(model) : _logicT.Create(model);
|
||||
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранеии. Дополнительная информация в логах.");
|
||||
}
|
||||
|
||||
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
DialogResult = DialogResult.OK;
|
||||
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка сохранения транспорта");
|
||||
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,60 +0,0 @@
|
||||
<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>
|
@ -1,232 +0,0 @@
|
||||
namespace TransportCompany
|
||||
{
|
||||
partial class FormCreateTrucking
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
labelCLient = new Label();
|
||||
label1 = new Label();
|
||||
label2 = new Label();
|
||||
label3 = new Label();
|
||||
label4 = new Label();
|
||||
label5 = new Label();
|
||||
comboBoxClients = new ComboBox();
|
||||
comboBoxCargos = new ComboBox();
|
||||
comboBoxTransports = new ComboBox();
|
||||
comboBoxTypeTransportations = new ComboBox();
|
||||
dateTimePickerStart = new DateTimePicker();
|
||||
dateTimePickerEnd = new DateTimePicker();
|
||||
buttonCreate = new Button();
|
||||
buttonCancel = new Button();
|
||||
label6 = new Label();
|
||||
textBoxPrice = new TextBox();
|
||||
SuspendLayout();
|
||||
//
|
||||
// labelCLient
|
||||
//
|
||||
labelCLient.AutoSize = true;
|
||||
labelCLient.Location = new Point(37, 30);
|
||||
labelCLient.Name = "labelCLient";
|
||||
labelCLient.Size = new Size(140, 20);
|
||||
labelCLient.TabIndex = 0;
|
||||
labelCLient.Text = "Выберите клиента:";
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(37, 81);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(150, 20);
|
||||
label1.TabIndex = 1;
|
||||
label1.Text = "Выберите тип груза:";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
label2.AutoSize = true;
|
||||
label2.Location = new Point(37, 135);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new Size(157, 20);
|
||||
label2.TabIndex = 2;
|
||||
label2.Text = "Выберите транспорт:";
|
||||
//
|
||||
// label3
|
||||
//
|
||||
label3.AutoSize = true;
|
||||
label3.Location = new Point(37, 237);
|
||||
label3.Name = "label3";
|
||||
label3.Size = new Size(224, 20);
|
||||
label3.TabIndex = 3;
|
||||
label3.Text = "Дата начала транспортировки:";
|
||||
//
|
||||
// label4
|
||||
//
|
||||
label4.AutoSize = true;
|
||||
label4.Location = new Point(37, 288);
|
||||
label4.Name = "label4";
|
||||
label4.Size = new Size(217, 20);
|
||||
label4.TabIndex = 4;
|
||||
label4.Text = "Дата конца транспортировки:";
|
||||
//
|
||||
// label5
|
||||
//
|
||||
label5.AutoSize = true;
|
||||
label5.Location = new Point(37, 187);
|
||||
label5.Name = "label5";
|
||||
label5.Size = new Size(236, 20);
|
||||
label5.TabIndex = 5;
|
||||
label5.Text = "Выберите тип транспортировки:";
|
||||
//
|
||||
// comboBoxClients
|
||||
//
|
||||
comboBoxClients.FormattingEnabled = true;
|
||||
comboBoxClients.Location = new Point(307, 27);
|
||||
comboBoxClients.Name = "comboBoxClients";
|
||||
comboBoxClients.Size = new Size(319, 28);
|
||||
comboBoxClients.TabIndex = 6;
|
||||
//
|
||||
// comboBoxCargos
|
||||
//
|
||||
comboBoxCargos.FormattingEnabled = true;
|
||||
comboBoxCargos.Location = new Point(307, 78);
|
||||
comboBoxCargos.Name = "comboBoxCargos";
|
||||
comboBoxCargos.Size = new Size(319, 28);
|
||||
comboBoxCargos.TabIndex = 7;
|
||||
//
|
||||
// comboBoxTransports
|
||||
//
|
||||
comboBoxTransports.FormattingEnabled = true;
|
||||
comboBoxTransports.Location = new Point(307, 127);
|
||||
comboBoxTransports.Name = "comboBoxTransports";
|
||||
comboBoxTransports.Size = new Size(319, 28);
|
||||
comboBoxTransports.TabIndex = 8;
|
||||
//
|
||||
// comboBoxTypeTransportations
|
||||
//
|
||||
comboBoxTypeTransportations.FormattingEnabled = true;
|
||||
comboBoxTypeTransportations.Location = new Point(307, 184);
|
||||
comboBoxTypeTransportations.Name = "comboBoxTypeTransportations";
|
||||
comboBoxTypeTransportations.Size = new Size(319, 28);
|
||||
comboBoxTypeTransportations.TabIndex = 9;
|
||||
//
|
||||
// dateTimePickerStart
|
||||
//
|
||||
dateTimePickerStart.Location = new Point(307, 237);
|
||||
dateTimePickerStart.Name = "dateTimePickerStart";
|
||||
dateTimePickerStart.Size = new Size(319, 27);
|
||||
dateTimePickerStart.TabIndex = 10;
|
||||
//
|
||||
// dateTimePickerEnd
|
||||
//
|
||||
dateTimePickerEnd.Location = new Point(307, 283);
|
||||
dateTimePickerEnd.Name = "dateTimePickerEnd";
|
||||
dateTimePickerEnd.Size = new Size(319, 27);
|
||||
dateTimePickerEnd.TabIndex = 11;
|
||||
//
|
||||
// buttonCreate
|
||||
//
|
||||
buttonCreate.Location = new Point(373, 392);
|
||||
buttonCreate.Name = "buttonCreate";
|
||||
buttonCreate.Size = new Size(120, 29);
|
||||
buttonCreate.TabIndex = 12;
|
||||
buttonCreate.Text = "Создать";
|
||||
buttonCreate.UseVisualStyleBackColor = true;
|
||||
buttonCreate.Click += ButtonCreate_Click;
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(513, 392);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(113, 29);
|
||||
buttonCancel.TabIndex = 13;
|
||||
buttonCancel.Text = "Отмена";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
buttonCancel.Click += ButtonCancel_Click;
|
||||
//
|
||||
// label6
|
||||
//
|
||||
label6.AutoSize = true;
|
||||
label6.Location = new Point(37, 346);
|
||||
label6.Name = "label6";
|
||||
label6.Size = new Size(86, 20);
|
||||
label6.TabIndex = 14;
|
||||
label6.Text = "Стоимость:";
|
||||
//
|
||||
// textBoxPrice
|
||||
//
|
||||
textBoxPrice.Location = new Point(307, 343);
|
||||
textBoxPrice.Name = "textBoxPrice";
|
||||
textBoxPrice.Size = new Size(319, 27);
|
||||
textBoxPrice.TabIndex = 15;
|
||||
//
|
||||
// FormCreateTrucking
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(666, 438);
|
||||
Controls.Add(textBoxPrice);
|
||||
Controls.Add(label6);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonCreate);
|
||||
Controls.Add(dateTimePickerEnd);
|
||||
Controls.Add(dateTimePickerStart);
|
||||
Controls.Add(comboBoxTypeTransportations);
|
||||
Controls.Add(comboBoxTransports);
|
||||
Controls.Add(comboBoxCargos);
|
||||
Controls.Add(comboBoxClients);
|
||||
Controls.Add(label5);
|
||||
Controls.Add(label4);
|
||||
Controls.Add(label3);
|
||||
Controls.Add(label2);
|
||||
Controls.Add(label1);
|
||||
Controls.Add(labelCLient);
|
||||
Name = "FormCreateTrucking";
|
||||
Text = "Перевозка";
|
||||
Load += FormCreateTrucking_Load;
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label labelCLient;
|
||||
private Label label1;
|
||||
private Label label2;
|
||||
private Label label3;
|
||||
private Label label4;
|
||||
private Label label5;
|
||||
private ComboBox comboBoxClients;
|
||||
private ComboBox comboBoxCargos;
|
||||
private ComboBox comboBoxTransports;
|
||||
private ComboBox comboBoxTypeTransportations;
|
||||
private DateTimePicker dateTimePickerStart;
|
||||
private DateTimePicker dateTimePickerEnd;
|
||||
private Button buttonCreate;
|
||||
private Button buttonCancel;
|
||||
private Label label6;
|
||||
private TextBox textBoxPrice;
|
||||
}
|
||||
}
|
@ -1,239 +0,0 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.Eventing.Reader;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using TransportCompanyContracts.BindingModels;
|
||||
using TransportCompanyContracts.BusinessLogicsContracts;
|
||||
using TransportCompanyContracts.SearchModels;
|
||||
|
||||
namespace TransportCompany
|
||||
{
|
||||
public partial class FormCreateTrucking : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private bool isMongo;
|
||||
|
||||
public bool Mongo { set { isMongo = value; } }
|
||||
|
||||
private readonly IClientLogic _logicCl;
|
||||
|
||||
private readonly ITransportLogic _logicTransport;
|
||||
|
||||
private readonly ITransportationLogic _logicTransportation;
|
||||
|
||||
private readonly ICargoLogic _logicCargo;
|
||||
|
||||
private readonly ITruckingLogic _logic;
|
||||
|
||||
private int? _id;
|
||||
|
||||
public int Id { set { _id = value; } }
|
||||
|
||||
public FormCreateTrucking(ILogger<FormCreateTrucking> logger, ITruckingLogic logic, ICargoLogic logicCargo,
|
||||
IClientLogic logicCl, ITransportLogic logicTransport, ITransportationLogic logicTransportation)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
_logicCargo = logicCargo;
|
||||
_logicCl = logicCl;
|
||||
_logicTransport = logicTransport;
|
||||
_logicTransportation = logicTransportation;
|
||||
}
|
||||
|
||||
private void FormCreateTrucking_Load(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logger.LogInformation("Получение сводки по перевозке");
|
||||
|
||||
var viewClient = _logicCl.ReadList(null);
|
||||
var viewCargo = _logicCargo.ReadList(null);
|
||||
var viewTransport = _logicTransport.ReadList(null);
|
||||
var viewTransportation = _logicTransportation.ReadList(null);
|
||||
|
||||
//var view = _logic.ReadElement(new TruckingSearchModel { Id = _id.Value });
|
||||
|
||||
if (viewClient != null)
|
||||
{
|
||||
comboBoxClients.DisplayMember = "Email";
|
||||
|
||||
if (isMongo)
|
||||
{
|
||||
comboBoxClients.ValueMember = "MongoId";
|
||||
}
|
||||
else
|
||||
{
|
||||
comboBoxClients.ValueMember = "Id";
|
||||
}
|
||||
|
||||
comboBoxClients.DataSource = viewClient;
|
||||
comboBoxClients.SelectedItem = null;
|
||||
}
|
||||
|
||||
if (viewCargo != null)
|
||||
{
|
||||
comboBoxCargos.DisplayMember = "TypeCargo";
|
||||
|
||||
if (isMongo)
|
||||
{
|
||||
comboBoxClients.ValueMember = "MongoId";
|
||||
}
|
||||
else
|
||||
{
|
||||
comboBoxClients.ValueMember = "Id";
|
||||
}
|
||||
|
||||
comboBoxCargos.DataSource = viewCargo;
|
||||
comboBoxCargos.SelectedItem = null;
|
||||
}
|
||||
|
||||
if (viewTransport != null)
|
||||
{
|
||||
comboBoxTransports.DisplayMember = "Tranport";
|
||||
|
||||
if (isMongo)
|
||||
{
|
||||
comboBoxClients.ValueMember = "MongoId";
|
||||
}
|
||||
else
|
||||
{
|
||||
comboBoxClients.ValueMember = "Id";
|
||||
}
|
||||
|
||||
comboBoxTransports.DataSource = viewTransport;
|
||||
comboBoxTransports.SelectedItem = null;
|
||||
}
|
||||
|
||||
if (!isMongo)
|
||||
{
|
||||
if (viewTransportation != null)
|
||||
{
|
||||
comboBoxTypeTransportations.DisplayMember = "TransportationType";
|
||||
comboBoxTypeTransportations.ValueMember = "Id";
|
||||
comboBoxTypeTransportations.DataSource = viewTransportation;
|
||||
comboBoxTypeTransportations.SelectedItem = null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
comboBoxTypeTransportations.Text = "Сейчас это недоступно";
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения сводки по перевозке");
|
||||
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonCreate_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dateTimePickerStart.Value > dateTimePickerEnd.Value)
|
||||
{
|
||||
MessageBox.Show("Дата начала транспортировки не может быть позже её конца", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (comboBoxClients.SelectedValue == null)
|
||||
{
|
||||
MessageBox.Show("Выберите клиента", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (comboBoxCargos.SelectedValue == null)
|
||||
{
|
||||
MessageBox.Show("Выберите груз", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (comboBoxTransports.SelectedValue == null)
|
||||
{
|
||||
MessageBox.Show("Выберите транспорт", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isMongo)
|
||||
{
|
||||
if (comboBoxTypeTransportations.SelectedValue == null)
|
||||
{
|
||||
MessageBox.Show("Выберите тип транспортировки", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
_logger.LogInformation("Создание сводки по перевозке");
|
||||
|
||||
try
|
||||
{
|
||||
if (isMongo)
|
||||
{
|
||||
var operationResult = _logic.Create(new TruckingBindingModel
|
||||
{
|
||||
Client = comboBoxClients.SelectedValue.ToString(),
|
||||
Cargo = comboBoxCargos.SelectedValue.ToString(),
|
||||
Transport = comboBoxTransports.SelectedValue.ToString(),
|
||||
Price = Convert.ToInt32(textBoxPrice.Text),
|
||||
DateStart = dateTimePickerStart.Value,
|
||||
DateEnd = dateTimePickerEnd.Value
|
||||
});
|
||||
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при создании сводки по перевозке. Дополнительная информация в логах.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var operationResult = _logic.Create(new TruckingBindingModel
|
||||
{
|
||||
ClientId = Convert.ToInt32(comboBoxClients.SelectedValue),
|
||||
CargoId = Convert.ToInt32(comboBoxCargos.SelectedValue),
|
||||
TransportId = Convert.ToInt32(comboBoxTransports.SelectedValue),
|
||||
TransportationId = Convert.ToInt32(comboBoxTypeTransportations.SelectedValue),
|
||||
Price = Convert.ToInt32(textBoxPrice.Text),
|
||||
DateStart = dateTimePickerStart.Value,
|
||||
DateEnd = dateTimePickerEnd.Value
|
||||
});
|
||||
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при создании сводки по перевозке. Дополнительная информация в логах.");
|
||||
}
|
||||
}
|
||||
|
||||
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
DialogResult = DialogResult.OK;
|
||||
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка создания сводки по перевозке");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,60 +0,0 @@
|
||||
<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>
|
@ -1,96 +0,0 @@
|
||||
namespace TransportCompany
|
||||
{
|
||||
partial class FormCreateTypeTransportation
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
label1 = new Label();
|
||||
textBoxTypeTransportation = new TextBox();
|
||||
buttonCreate = new Button();
|
||||
buttonCancel = new Button();
|
||||
SuspendLayout();
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(24, 36);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(165, 20);
|
||||
label1.TabIndex = 0;
|
||||
label1.Text = "Тип транспортировки:";
|
||||
//
|
||||
// textBoxTypeTransportation
|
||||
//
|
||||
textBoxTypeTransportation.Location = new Point(232, 33);
|
||||
textBoxTypeTransportation.Name = "textBoxTypeTransportation";
|
||||
textBoxTypeTransportation.Size = new Size(330, 27);
|
||||
textBoxTypeTransportation.TabIndex = 1;
|
||||
//
|
||||
// buttonCreate
|
||||
//
|
||||
buttonCreate.Location = new Point(355, 83);
|
||||
buttonCreate.Name = "buttonCreate";
|
||||
buttonCreate.Size = new Size(94, 29);
|
||||
buttonCreate.TabIndex = 2;
|
||||
buttonCreate.Text = "Создать";
|
||||
buttonCreate.UseVisualStyleBackColor = true;
|
||||
buttonCreate.Click += ButtonCreate_Click;
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(468, 83);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(94, 29);
|
||||
buttonCancel.TabIndex = 3;
|
||||
buttonCancel.Text = "Отмена";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
buttonCancel.Click += ButtonCancel_Click;
|
||||
//
|
||||
// FormCreateTypeTransportation
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(617, 138);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonCreate);
|
||||
Controls.Add(textBoxTypeTransportation);
|
||||
Controls.Add(label1);
|
||||
Name = "FormCreateTypeTransportation";
|
||||
Text = "FormCreateTypeTransportation";
|
||||
Load += FormCreateTypeTransportation_Load;
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label label1;
|
||||
private TextBox textBoxTypeTransportation;
|
||||
private Button buttonCreate;
|
||||
private Button buttonCancel;
|
||||
}
|
||||
}
|
@ -1,104 +0,0 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using TransportCompanyContracts.BindingModels;
|
||||
using TransportCompanyContracts.BusinessLogicsContracts;
|
||||
using TransportCompanyContracts.SearchModels;
|
||||
|
||||
namespace TransportCompany
|
||||
{
|
||||
public partial class FormCreateTypeTransportation : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private readonly ITransportationLogic _logic;
|
||||
|
||||
private int? _id;
|
||||
|
||||
public int Id { set { _id = value; } }
|
||||
|
||||
public FormCreateTypeTransportation(ILogger<FormCreateTypeTransportation> logger, ITransportationLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
}
|
||||
|
||||
private void FormCreateTypeTransportation_Load(object sender, EventArgs e)
|
||||
{
|
||||
//проверка на заполнение поля id. Если оно заполнено, то пробуем получить запись и выести её на экран
|
||||
if (_id.HasValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logger.LogInformation("Получение типа транспортировки");
|
||||
|
||||
var view = _logic.ReadElement(new TransportationSearchModel { Id = _id.Value });
|
||||
|
||||
if (view != null)
|
||||
{
|
||||
textBoxTypeTransportation.Text = view.TransportationType;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения типа транспортировки");
|
||||
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonCreate_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(textBoxTypeTransportation.Text))
|
||||
{
|
||||
MessageBox.Show("Введите тип транспортировки", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
_logger.LogInformation("Добавление типа транспортировки");
|
||||
|
||||
try
|
||||
{
|
||||
var model = new TransportationBindingModel
|
||||
{
|
||||
Id = 0,
|
||||
TransportationType = textBoxTypeTransportation.Text
|
||||
};
|
||||
|
||||
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
|
||||
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранеии. Дополнительная информация в логах.");
|
||||
}
|
||||
|
||||
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
DialogResult = DialogResult.OK;
|
||||
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка сохранения типа транспортировки");
|
||||
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,60 +0,0 @@
|
||||
<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>
|
@ -1,117 +0,0 @@
|
||||
namespace TransportCompany
|
||||
{
|
||||
partial class FormRandomCreateClient
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
labelCount = new Label();
|
||||
textBoxCount = new TextBox();
|
||||
buttonStart = new Button();
|
||||
buttonCancel = new Button();
|
||||
label1 = new Label();
|
||||
textBoxTimeWork = new TextBox();
|
||||
SuspendLayout();
|
||||
//
|
||||
// labelCount
|
||||
//
|
||||
labelCount.AutoSize = true;
|
||||
labelCount.Location = new Point(21, 25);
|
||||
labelCount.Name = "labelCount";
|
||||
labelCount.Size = new Size(93, 20);
|
||||
labelCount.TabIndex = 0;
|
||||
labelCount.Text = "Количество:";
|
||||
//
|
||||
// textBoxCount
|
||||
//
|
||||
textBoxCount.Location = new Point(158, 22);
|
||||
textBoxCount.Name = "textBoxCount";
|
||||
textBoxCount.Size = new Size(217, 27);
|
||||
textBoxCount.TabIndex = 1;
|
||||
//
|
||||
// buttonStart
|
||||
//
|
||||
buttonStart.Location = new Point(147, 162);
|
||||
buttonStart.Name = "buttonStart";
|
||||
buttonStart.Size = new Size(110, 29);
|
||||
buttonStart.TabIndex = 2;
|
||||
buttonStart.Text = "Генерация";
|
||||
buttonStart.UseVisualStyleBackColor = true;
|
||||
buttonStart.Click += ButtonStart_Click;
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(281, 162);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(94, 29);
|
||||
buttonCancel.TabIndex = 3;
|
||||
buttonCancel.Text = "Отмена";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
buttonCancel.Click += ButtonCancel_Click;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(21, 101);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(113, 20);
|
||||
label1.TabIndex = 4;
|
||||
label1.Text = "Время работы:";
|
||||
//
|
||||
// textBoxTimeWork
|
||||
//
|
||||
textBoxTimeWork.Location = new Point(158, 98);
|
||||
textBoxTimeWork.Name = "textBoxTimeWork";
|
||||
textBoxTimeWork.Size = new Size(217, 27);
|
||||
textBoxTimeWork.TabIndex = 5;
|
||||
//
|
||||
// FormRandomCreateClient
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(412, 220);
|
||||
Controls.Add(textBoxTimeWork);
|
||||
Controls.Add(label1);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonStart);
|
||||
Controls.Add(textBoxCount);
|
||||
Controls.Add(labelCount);
|
||||
Name = "FormRandomCreateClient";
|
||||
Text = "Случайная генерация клиентов";
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label labelCount;
|
||||
private TextBox textBoxCount;
|
||||
private Button buttonStart;
|
||||
private Button buttonCancel;
|
||||
private Label label1;
|
||||
private TextBox textBoxTimeWork;
|
||||
}
|
||||
}
|
@ -1,70 +0,0 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using TransportCompanyContracts.BindingModels;
|
||||
using TransportCompanyContracts.BusinessLogicsContracts;
|
||||
|
||||
namespace TransportCompany
|
||||
{
|
||||
public partial class FormRandomCreateClient : Form
|
||||
{
|
||||
private readonly IClientLogic _logicC;
|
||||
|
||||
Random rnd = new Random(DateTime.Now.ToString().GetHashCode());
|
||||
|
||||
private string[] _names = { "Иван", "Егор", "Роман", "Денис", "Игнат", "Ренат", "Никита", "Павел", "Данил", "Максим", "Николай", "Дмитрий", "Владислав", "Марк", "Булат", "Марсель", "Назар", "Багир", "Кирилл", "Всеволод", "Ярослав", "Юрий", "Виталий" };
|
||||
|
||||
private string[] _surnames = { "Иванов", "Елисеев", "Марков", "Негин", "Мусоев", "Сегреев", "Распаев", "Минаров", "Захарченко", "Пятаков", "Юдаков", "Карташев", "Селин", "Марков", "Захаров", "Никитин", "Распаев", "Алексанян", "Скалкин", "Строев", "Горшков", "Каримов", "Кочкадаев", "Ершов", "Алиакберов", "Закуанов", "Пахомов" };
|
||||
|
||||
private string[] _patronymics = { "Иванович", "Евгеньевич", "Егорович", "Николаевич", "Дмитриевич", "Владиславович", "Юрьевич", "Кириллович", "Артемиевич", "Павлович", "Максимович", "Назарович", "Багирович", "Булатович", "Всеволодович", "Витальевич", "Евгеньевич", "Романович", "Ярославович", "Данилович", "Зульфия", "Марсельевич", "Маркович", };
|
||||
|
||||
private string[] _telephones = { "89529876316", "88804293534", "84508874804", "82035754008", "80926246994", "83316923921", "88497436387", "82372606638", "81582656294", "83605675249", "87978864427", "81882538381", "83432311066", "80220603131", "82166498710", "80271945648", "83581821702", "84911615179", "89993116947", "80830482909", "89463846784", "84817550460", "81785373218", "80654035595", "81304432863", "85601863128" };
|
||||
|
||||
private string[] _emails = { "deffabuttiprei-5025@yopmail.com", "quiquoucrobrilla-7902@yopmail.com", "tucoffokexoi-9537@yopmail.com", "nebroijulleinne-7231@yopmail.com", "xedeujezoilli-1668@yopmail.com", "foikoussoidouhau-5112@yopmail.com", "pruddougoddeda-2757@yopmail.com", "keidevoillaga-5758@yopmail.com", "palemeinnacra-4165@yopmail.com", "capribukoippa-8523@yopmail.com", "truwauheineita-8708@yopmail.com", "mudebralanu-3594@yopmail.com", "nuxauttisoibri-7020@yopmail.com", "dufenosatte-4543@yopmail.com", "xullusaquilou-9479@yopmail.com", "broixifrommelle-3859@yopmail.com", "yimozofreixeu-4046@yopmail.com", "wetrouddemoro-9168@yopmail.com", "crepropretaji-6969@yopmail.com", "pahoufforutre-6805@yopmail.com", "gretreidineuba-8655@yopmail.com", "koullinnorulli-5851@yopmail.com", "bougreigewetto-3164@yopmail.com", "brocoffanauba-5102@yopmail.com", "kaddasumetre-7742@yopmail.com", "heussouprogromu-7061@yopmail.com", "teresitruffe-8881@yopmail.com", "kejicrouzazei-9377@yopmail.com", "zoicaquaugrili-2744@yopmail.com", "quepifrucragrou-8404@yopmail.com", "graditilladdi-7217@yopmail.com", "doboijifammeu-4816@yopmail.com", "tobrograusessoi-6295@yopmail.com", "xeifeuffiyoka-8243@yopmail.com", "greuquekucaju-9438@yopmail.com", "prisseproittunne-3785@yopmail.com", "vuppeiyatrare-8690@yopmail.com", "pennibexewa-9132@yopmail.com", "gayufeppaucu-4744@yopmail.com", "boicegreisussa-1695@yopmail.com" };
|
||||
|
||||
public FormRandomCreateClient(IClientLogic logicC)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_logicC = logicC;
|
||||
}
|
||||
|
||||
private void ButtonStart_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
ChangeList(_telephones);
|
||||
|
||||
ChangeList(_emails);
|
||||
|
||||
textBoxTimeWork.Text = _logicC.TestRandomCreate(Convert.ToInt32(textBoxCount.Text), _names, _surnames, _patronymics, _telephones, _emails);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void ChangeList(string[] _strings)
|
||||
{
|
||||
for(int i = 0; i < _strings.Length; i++)
|
||||
{
|
||||
_strings[i] = Convert.ToString(rnd.Next(0, 800000)) + _strings[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,60 +0,0 @@
|
||||
<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>
|
@ -1,117 +0,0 @@
|
||||
namespace TransportCompany
|
||||
{
|
||||
partial class FormRandomCreateTrucking
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
labelClient = new Label();
|
||||
textBoxCount = new TextBox();
|
||||
buttonCreate = new Button();
|
||||
buttonCancel = new Button();
|
||||
label1 = new Label();
|
||||
textBoxCheckTest = new TextBox();
|
||||
SuspendLayout();
|
||||
//
|
||||
// labelClient
|
||||
//
|
||||
labelClient.AutoSize = true;
|
||||
labelClient.Location = new Point(32, 33);
|
||||
labelClient.Name = "labelClient";
|
||||
labelClient.Size = new Size(151, 20);
|
||||
labelClient.TabIndex = 0;
|
||||
labelClient.Text = "Введите количество:";
|
||||
//
|
||||
// textBoxCount
|
||||
//
|
||||
textBoxCount.Location = new Point(221, 30);
|
||||
textBoxCount.Name = "textBoxCount";
|
||||
textBoxCount.Size = new Size(280, 27);
|
||||
textBoxCount.TabIndex = 1;
|
||||
//
|
||||
// buttonCreate
|
||||
//
|
||||
buttonCreate.Location = new Point(237, 148);
|
||||
buttonCreate.Name = "buttonCreate";
|
||||
buttonCreate.Size = new Size(123, 29);
|
||||
buttonCreate.TabIndex = 2;
|
||||
buttonCreate.Text = "Генерация";
|
||||
buttonCreate.UseVisualStyleBackColor = true;
|
||||
buttonCreate.Click += ButtonCreate_Click;
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(382, 148);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(119, 29);
|
||||
buttonCancel.TabIndex = 3;
|
||||
buttonCancel.Text = "Отмена";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
buttonCancel.Click += ButtonCancel_Click;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(32, 99);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(145, 20);
|
||||
label1.TabIndex = 4;
|
||||
label1.Text = "Время добавления:";
|
||||
//
|
||||
// textBoxCheckTest
|
||||
//
|
||||
textBoxCheckTest.Location = new Point(221, 96);
|
||||
textBoxCheckTest.Name = "textBoxCheckTest";
|
||||
textBoxCheckTest.Size = new Size(280, 27);
|
||||
textBoxCheckTest.TabIndex = 5;
|
||||
//
|
||||
// FormRandomCreateTrucking
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(548, 215);
|
||||
Controls.Add(textBoxCheckTest);
|
||||
Controls.Add(label1);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonCreate);
|
||||
Controls.Add(textBoxCount);
|
||||
Controls.Add(labelClient);
|
||||
Name = "FormRandomCreateTrucking";
|
||||
Text = "Генерация перевозок";
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label labelClient;
|
||||
private TextBox textBoxCount;
|
||||
private Button buttonCreate;
|
||||
private Button buttonCancel;
|
||||
private Label label1;
|
||||
private TextBox textBoxCheckTest;
|
||||
}
|
||||
}
|
@ -1,64 +0,0 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using System.Xml.Linq;
|
||||
using TransportCompanyContracts.BindingModels;
|
||||
using TransportCompanyContracts.BusinessLogicsContracts;
|
||||
|
||||
namespace TransportCompany
|
||||
{
|
||||
public partial class FormRandomCreateTrucking : Form
|
||||
{
|
||||
private readonly IClientLogic _logicCl;
|
||||
|
||||
private readonly ITransportLogic _logicTransport;
|
||||
|
||||
private readonly ITransportationLogic _logicTransportation;
|
||||
|
||||
private readonly ICargoLogic _logicCargo;
|
||||
|
||||
private readonly ITruckingLogic _logic;
|
||||
|
||||
public FormRandomCreateTrucking(ILogger<FormRandomCreateTrucking> logger, ITruckingLogic logic, ICargoLogic logicCargo,
|
||||
IClientLogic logicCl, ITransportLogic logicTransport, ITransportationLogic logicTransportation)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_logic = logic;
|
||||
_logicCargo = logicCargo;
|
||||
_logicCl = logicCl;
|
||||
_logicTransport = logicTransport;
|
||||
_logicTransportation = logicTransportation;
|
||||
}
|
||||
|
||||
private void ButtonCreate_Click(object sender, EventArgs e)
|
||||
{
|
||||
var viewClient = _logicCl.ReadList(null);
|
||||
var viewCargo = _logicCargo.ReadList(null);
|
||||
var viewTransport = _logicTransport.ReadList(null);
|
||||
var viewTransportation = _logicTransportation.ReadList(null);
|
||||
|
||||
try
|
||||
{
|
||||
textBoxCheckTest.Text = _logic.TestRandomCreate(Convert.ToInt32(textBoxCount.Text), viewClient, viewCargo, viewTransport, viewTransportation);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,60 +0,0 @@
|
||||
<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>
|
@ -1,117 +0,0 @@
|
||||
namespace TransportCompany
|
||||
{
|
||||
partial class FormTimeCheck
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
buttonStartTest = new Button();
|
||||
buttonCancel = new Button();
|
||||
label1 = new Label();
|
||||
textBoxCount = new TextBox();
|
||||
label2 = new Label();
|
||||
textBoxTimeWork = new TextBox();
|
||||
SuspendLayout();
|
||||
//
|
||||
// buttonStartTest
|
||||
//
|
||||
buttonStartTest.Location = new Point(123, 22);
|
||||
buttonStartTest.Name = "buttonStartTest";
|
||||
buttonStartTest.Size = new Size(257, 75);
|
||||
buttonStartTest.TabIndex = 0;
|
||||
buttonStartTest.Text = "Запуск теста";
|
||||
buttonStartTest.UseVisualStyleBackColor = true;
|
||||
buttonStartTest.Click += ButtonStartTest_Click;
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(361, 241);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(94, 30);
|
||||
buttonCancel.TabIndex = 1;
|
||||
buttonCancel.Text = "Закрыть";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
buttonCancel.Click += ButtonCancel_Click;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(25, 131);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(230, 20);
|
||||
label1.TabIndex = 2;
|
||||
label1.Text = "Кол-во считываемых значений:";
|
||||
//
|
||||
// textBoxCount
|
||||
//
|
||||
textBoxCount.Location = new Point(284, 128);
|
||||
textBoxCount.Name = "textBoxCount";
|
||||
textBoxCount.Size = new Size(171, 27);
|
||||
textBoxCount.TabIndex = 3;
|
||||
//
|
||||
// label2
|
||||
//
|
||||
label2.AutoSize = true;
|
||||
label2.Location = new Point(25, 186);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new Size(113, 20);
|
||||
label2.TabIndex = 4;
|
||||
label2.Text = "Время работы:";
|
||||
//
|
||||
// textBoxTimeWork
|
||||
//
|
||||
textBoxTimeWork.Location = new Point(284, 183);
|
||||
textBoxTimeWork.Name = "textBoxTimeWork";
|
||||
textBoxTimeWork.Size = new Size(171, 27);
|
||||
textBoxTimeWork.TabIndex = 5;
|
||||
//
|
||||
// FormTimeCheck
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(480, 285);
|
||||
Controls.Add(textBoxTimeWork);
|
||||
Controls.Add(label2);
|
||||
Controls.Add(textBoxCount);
|
||||
Controls.Add(label1);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonStartTest);
|
||||
Name = "FormTimeCheck";
|
||||
Text = "Тест скорости чтения записей перевозок";
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Button buttonStartTest;
|
||||
private Button buttonCancel;
|
||||
private Label label1;
|
||||
private TextBox textBoxCount;
|
||||
private Label label2;
|
||||
private TextBox textBoxTimeWork;
|
||||
}
|
||||
}
|
@ -1,51 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using TransportCompanyBusinessLogic.BusinessLogic;
|
||||
using TransportCompanyContracts.BusinessLogicsContracts;
|
||||
|
||||
namespace TransportCompany
|
||||
{
|
||||
//форма за измерения времени считывания значений
|
||||
public partial class FormTimeCheck : Form
|
||||
{
|
||||
private readonly ITruckingLogic _truckingLogic;
|
||||
|
||||
public FormTimeCheck(ITruckingLogic truckingLogic)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_truckingLogic = truckingLogic;
|
||||
}
|
||||
|
||||
private void ButtonStartTest_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = _truckingLogic.TestReadList();
|
||||
|
||||
string[] parameters = result.Split(' ');
|
||||
|
||||
textBoxCount.Text = parameters[0];
|
||||
|
||||
textBoxTimeWork.Text = parameters[1];
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,60 +0,0 @@
|
||||
<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>
|
@ -1,62 +0,0 @@
|
||||
namespace TransportCompany
|
||||
{
|
||||
partial class FormTransferData
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
buttonStartTransfer = new Button();
|
||||
SuspendLayout();
|
||||
//
|
||||
// buttonStartTransfer
|
||||
//
|
||||
buttonStartTransfer.BackColor = Color.Red;
|
||||
buttonStartTransfer.BackgroundImageLayout = ImageLayout.Zoom;
|
||||
buttonStartTransfer.Font = new Font("Snap ITC", 9F, FontStyle.Bold, GraphicsUnit.Point);
|
||||
buttonStartTransfer.Location = new Point(102, 12);
|
||||
buttonStartTransfer.Name = "buttonStartTransfer";
|
||||
buttonStartTransfer.Size = new Size(213, 36);
|
||||
buttonStartTransfer.TabIndex = 0;
|
||||
buttonStartTransfer.Text = "НУ ЧЁ, ПОГНАЛИ";
|
||||
buttonStartTransfer.UseVisualStyleBackColor = false;
|
||||
buttonStartTransfer.Click += ButtonStartTransfer_Click;
|
||||
//
|
||||
// FormTransferData
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(415, 60);
|
||||
Controls.Add(buttonStartTransfer);
|
||||
Name = "FormTransferData";
|
||||
Text = "Передача данных";
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Button buttonStartTransfer;
|
||||
}
|
||||
}
|
@ -1,72 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Media;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using TransportCompanyBusinessLogic.BusinessLogic;
|
||||
using TransportCompanyContracts.BusinessLogicsContracts;
|
||||
|
||||
namespace TransportCompany
|
||||
{
|
||||
//форма для перегона данных в MongoDB
|
||||
public partial class FormTransferData : Form
|
||||
{
|
||||
private ICargoLogic _cargoLogic;
|
||||
|
||||
private ITruckingLogic _truckingLogic;
|
||||
|
||||
private ITransportLogic _transportLogic;
|
||||
|
||||
private IClientLogic _clientLogic;
|
||||
|
||||
public FormTransferData(ICargoLogic cargoLogic, ITruckingLogic truckingLogic, IClientLogic clientLogic, ITransportLogic transportLogic)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_cargoLogic = cargoLogic;
|
||||
_truckingLogic = truckingLogic;
|
||||
_clientLogic = clientLogic;
|
||||
_transportLogic = transportLogic;
|
||||
}
|
||||
|
||||
private void ButtonStartTransfer_Click(object sender, EventArgs e)
|
||||
{
|
||||
var soundPlayer = new SoundPlayer(@"C:\Users\Programmist73\Desktop\Практика\2-й курс\4-й семестр\СУБД\Лаб. раб. №8\led-tronulsya.wav");
|
||||
|
||||
soundPlayer.PlaySync(); // can also use soundPlayer.PlaySync()
|
||||
|
||||
Program.ConnectPostgres();
|
||||
|
||||
_cargoLogic = Program.ServiceProvider.GetService(typeof(ICargoLogic)) as CargoLogic;
|
||||
_clientLogic = Program.ServiceProvider.GetService(typeof(IClientLogic)) as ClientLogic;
|
||||
_truckingLogic = Program.ServiceProvider.GetService(typeof(ITruckingLogic)) as TruckingLogic;
|
||||
_transportLogic = Program.ServiceProvider.GetService(typeof(ITransportLogic)) as TransportLogic;
|
||||
|
||||
var cargolist = _cargoLogic.ReadList(null);
|
||||
var clientlist = _clientLogic.ReadList(null);
|
||||
var truckinglist = _truckingLogic.ReadList(null);
|
||||
var transportlist = _transportLogic.ReadList(null);
|
||||
|
||||
Program.ConnectMongo();
|
||||
|
||||
_cargoLogic = Program.ServiceProvider.GetService(typeof(ICargoLogic)) as CargoLogic;
|
||||
_clientLogic = Program.ServiceProvider.GetService(typeof(IClientLogic)) as ClientLogic;
|
||||
_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);
|
||||
|
||||
Program.ConnectPostgres();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,60 +0,0 @@
|
||||
<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>
|
@ -1,114 +0,0 @@
|
||||
namespace TransportCompany
|
||||
{
|
||||
partial class FormTransport
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
dataGridView = new DataGridView();
|
||||
buttonCreate = new Button();
|
||||
buttonUpdate = new Button();
|
||||
buttonReload = new Button();
|
||||
buttonDelete = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView.Location = new Point(12, 12);
|
||||
dataGridView.Name = "dataGridView";
|
||||
dataGridView.RowHeadersWidth = 51;
|
||||
dataGridView.RowTemplate.Height = 29;
|
||||
dataGridView.Size = new Size(455, 426);
|
||||
dataGridView.TabIndex = 0;
|
||||
//
|
||||
// buttonCreate
|
||||
//
|
||||
buttonCreate.Location = new Point(521, 39);
|
||||
buttonCreate.Name = "buttonCreate";
|
||||
buttonCreate.Size = new Size(138, 29);
|
||||
buttonCreate.TabIndex = 1;
|
||||
buttonCreate.Text = "Создать";
|
||||
buttonCreate.UseVisualStyleBackColor = true;
|
||||
buttonCreate.Click += ButtonCreate_Click;
|
||||
//
|
||||
// buttonUpdate
|
||||
//
|
||||
buttonUpdate.Location = new Point(521, 112);
|
||||
buttonUpdate.Name = "buttonUpdate";
|
||||
buttonUpdate.Size = new Size(138, 29);
|
||||
buttonUpdate.TabIndex = 2;
|
||||
buttonUpdate.Text = "Изменить";
|
||||
buttonUpdate.UseVisualStyleBackColor = true;
|
||||
buttonUpdate.Click += ButtonUpdate_Click;
|
||||
//
|
||||
// buttonReload
|
||||
//
|
||||
buttonReload.Location = new Point(521, 258);
|
||||
buttonReload.Name = "buttonReload";
|
||||
buttonReload.Size = new Size(138, 29);
|
||||
buttonReload.TabIndex = 4;
|
||||
buttonReload.Text = "Обновить";
|
||||
buttonReload.UseVisualStyleBackColor = true;
|
||||
buttonReload.Click += ButtonReload_Click;
|
||||
//
|
||||
// buttonDelete
|
||||
//
|
||||
buttonDelete.Location = new Point(521, 184);
|
||||
buttonDelete.Name = "buttonDelete";
|
||||
buttonDelete.Size = new Size(138, 29);
|
||||
buttonDelete.TabIndex = 5;
|
||||
buttonDelete.Text = "Удалить";
|
||||
buttonDelete.UseVisualStyleBackColor = true;
|
||||
buttonDelete.Click += ButtonDelete_Click;
|
||||
//
|
||||
// FormTransport
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(703, 450);
|
||||
Controls.Add(buttonDelete);
|
||||
Controls.Add(buttonReload);
|
||||
Controls.Add(buttonUpdate);
|
||||
Controls.Add(buttonCreate);
|
||||
Controls.Add(dataGridView);
|
||||
Name = "FormTransport";
|
||||
Text = "FormTransports";
|
||||
Load += FormTransport_Load;
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DataGridView dataGridView;
|
||||
private Button buttonCreate;
|
||||
private Button buttonUpdate;
|
||||
private Button buttonReload;
|
||||
private Button buttonDelete;
|
||||
}
|
||||
}
|
@ -1,153 +0,0 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using TransportCompanyContracts.BindingModels;
|
||||
using TransportCompanyContracts.BusinessLogicsContracts;
|
||||
|
||||
namespace TransportCompany
|
||||
{
|
||||
public partial class FormTransport : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private readonly ITransportLogic _logic;
|
||||
|
||||
private bool isMongo;
|
||||
|
||||
public bool SetMongo { set { isMongo = value;} }
|
||||
|
||||
public FormTransport(ILogger<FormTransport> logger, ITransportLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
}
|
||||
|
||||
private void FormClients_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
try
|
||||
{
|
||||
var list = _logic.ReadList(null);
|
||||
|
||||
//растягиваем колонку Название на всю ширину, колонку Id скрываем
|
||||
if (list != null)
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
|
||||
if (!isMongo)
|
||||
{
|
||||
dataGridView.Columns["Id"].Visible = true;
|
||||
dataGridView.Columns["MongoId"].Visible = false;
|
||||
dataGridView.Columns["TransportationType"].Visible = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
dataGridView.Columns["Id"].Visible = false;
|
||||
dataGridView.Columns["MongoId"].Visible = true;
|
||||
}
|
||||
|
||||
dataGridView.Columns[2].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
|
||||
_logger.LogInformation("Загрузка транспортных средств");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки транспортных средств");
|
||||
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void FormTransport_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void ButtonCreate_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormCreateTransport));
|
||||
|
||||
if (service is FormCreateTransport form)
|
||||
{
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonUpdate_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormCreateTransport));
|
||||
|
||||
if (service is FormCreateTransport form)
|
||||
{
|
||||
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
|
||||
form.MongoId = Convert.ToString(dataGridView.SelectedRows[0].Cells["MongoId"].Value);
|
||||
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonDelete_Click(object sender, EventArgs e)
|
||||
{
|
||||
//проверяем наличие выделенной строки
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
|
||||
string mongoId = Convert.ToString(dataGridView.SelectedRows[0].Cells["MongoId"].Value);
|
||||
|
||||
_logger.LogInformation("Удаление транспорта");
|
||||
|
||||
try
|
||||
{
|
||||
if (!_logic.Delete(new TransportBindingModel
|
||||
{
|
||||
Id = id,
|
||||
MongoId = mongoId
|
||||
}))
|
||||
{
|
||||
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
|
||||
}
|
||||
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка удаления транспорта");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonReload_Click(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,60 +0,0 @@
|
||||
<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>
|
@ -1,297 +0,0 @@
|
||||
namespace TransportCompany
|
||||
{
|
||||
partial class FormTrucking
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
dataGridView = new DataGridView();
|
||||
buttonCreateTrucking = new Button();
|
||||
menuStrip = new MenuStrip();
|
||||
toolStripMenuItem = new ToolStripMenuItem();
|
||||
transportToolStripMenuItem = new ToolStripMenuItem();
|
||||
typeTransportationToolStripMenuItem = new ToolStripMenuItem();
|
||||
cargoToolStripMenuItem = new ToolStripMenuItem();
|
||||
clientToolStripMenuItem = new ToolStripMenuItem();
|
||||
rndGenerationToolStripMenuItem = new ToolStripMenuItem();
|
||||
generationClientsToolStripMenuItem = new ToolStripMenuItem();
|
||||
generationTruckingsToolStripMenuItem = new ToolStripMenuItem();
|
||||
testTimeGetDataToolStripMenuItem = new ToolStripMenuItem();
|
||||
testComplexQueriesToolStripMenuItem = new ToolStripMenuItem();
|
||||
buttonUpdate = new Button();
|
||||
comboBoxEmails = new ComboBox();
|
||||
label1 = new Label();
|
||||
checkBoxSorted = new CheckBox();
|
||||
checkBoxForFilterMode = new CheckBox();
|
||||
chooiceDBToolStripMenuItem = new ToolStripMenuItem();
|
||||
transferDataToolStripMenuItem = new ToolStripMenuItem();
|
||||
startPostgresqlToolStripMenuItem = new ToolStripMenuItem();
|
||||
startMongoDBToolStripMenuItem = new ToolStripMenuItem();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
menuStrip.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView.Location = new Point(11, 67);
|
||||
dataGridView.Name = "dataGridView";
|
||||
dataGridView.RowHeadersWidth = 51;
|
||||
dataGridView.RowTemplate.Height = 29;
|
||||
dataGridView.Size = new Size(937, 417);
|
||||
dataGridView.TabIndex = 0;
|
||||
//
|
||||
// buttonCreateTrucking
|
||||
//
|
||||
buttonCreateTrucking.Location = new Point(1014, 67);
|
||||
buttonCreateTrucking.Name = "buttonCreateTrucking";
|
||||
buttonCreateTrucking.Size = new Size(235, 29);
|
||||
buttonCreateTrucking.TabIndex = 1;
|
||||
buttonCreateTrucking.Text = "Создать перевозку";
|
||||
buttonCreateTrucking.UseVisualStyleBackColor = true;
|
||||
buttonCreateTrucking.Click += ButtonCreateTrucking_Click;
|
||||
//
|
||||
// menuStrip
|
||||
//
|
||||
menuStrip.ImageScalingSize = new Size(20, 20);
|
||||
menuStrip.Items.AddRange(new ToolStripItem[] { toolStripMenuItem, rndGenerationToolStripMenuItem, testTimeGetDataToolStripMenuItem, testComplexQueriesToolStripMenuItem, chooiceDBToolStripMenuItem });
|
||||
menuStrip.Location = new Point(0, 0);
|
||||
menuStrip.Name = "menuStrip";
|
||||
menuStrip.Padding = new Padding(6, 3, 0, 3);
|
||||
menuStrip.Size = new Size(1297, 30);
|
||||
menuStrip.TabIndex = 6;
|
||||
menuStrip.Text = "menuStrip1";
|
||||
//
|
||||
// toolStripMenuItem
|
||||
//
|
||||
toolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { transportToolStripMenuItem, typeTransportationToolStripMenuItem, cargoToolStripMenuItem, clientToolStripMenuItem });
|
||||
toolStripMenuItem.Name = "toolStripMenuItem";
|
||||
toolStripMenuItem.Size = new Size(117, 24);
|
||||
toolStripMenuItem.Text = "Справочники";
|
||||
//
|
||||
// transportToolStripMenuItem
|
||||
//
|
||||
transportToolStripMenuItem.Name = "transportToolStripMenuItem";
|
||||
transportToolStripMenuItem.Size = new Size(245, 26);
|
||||
transportToolStripMenuItem.Text = "Транспорт";
|
||||
transportToolStripMenuItem.Click += TransportToolStripMenuItem_Click;
|
||||
//
|
||||
// typeTransportationToolStripMenuItem
|
||||
//
|
||||
typeTransportationToolStripMenuItem.Name = "typeTransportationToolStripMenuItem";
|
||||
typeTransportationToolStripMenuItem.Size = new Size(245, 26);
|
||||
typeTransportationToolStripMenuItem.Text = "Тип транспортировки";
|
||||
typeTransportationToolStripMenuItem.Click += TypeTransportationToolStripMenuItem_Click;
|
||||
//
|
||||
// cargoToolStripMenuItem
|
||||
//
|
||||
cargoToolStripMenuItem.Name = "cargoToolStripMenuItem";
|
||||
cargoToolStripMenuItem.Size = new Size(245, 26);
|
||||
cargoToolStripMenuItem.Text = "Груз";
|
||||
cargoToolStripMenuItem.Click += CargoToolStripMenuItem_Click;
|
||||
//
|
||||
// clientToolStripMenuItem
|
||||
//
|
||||
clientToolStripMenuItem.Name = "clientToolStripMenuItem";
|
||||
clientToolStripMenuItem.Size = new Size(245, 26);
|
||||
clientToolStripMenuItem.Text = "Клиенты";
|
||||
clientToolStripMenuItem.Click += ClientToolStripMenuItem_Click;
|
||||
//
|
||||
// rndGenerationToolStripMenuItem
|
||||
//
|
||||
rndGenerationToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { generationClientsToolStripMenuItem, generationTruckingsToolStripMenuItem });
|
||||
rndGenerationToolStripMenuItem.Name = "rndGenerationToolStripMenuItem";
|
||||
rndGenerationToolStripMenuItem.Size = new Size(179, 24);
|
||||
rndGenerationToolStripMenuItem.Text = "Рандомная генерация";
|
||||
//
|
||||
// generationClientsToolStripMenuItem
|
||||
//
|
||||
generationClientsToolStripMenuItem.Name = "generationClientsToolStripMenuItem";
|
||||
generationClientsToolStripMenuItem.Size = new Size(245, 26);
|
||||
generationClientsToolStripMenuItem.Text = "Генерация клиентов";
|
||||
generationClientsToolStripMenuItem.Click += GenerationClientsToolStripMenuItem_Click;
|
||||
//
|
||||
// generationTruckingsToolStripMenuItem
|
||||
//
|
||||
generationTruckingsToolStripMenuItem.Name = "generationTruckingsToolStripMenuItem";
|
||||
generationTruckingsToolStripMenuItem.Size = new Size(245, 26);
|
||||
generationTruckingsToolStripMenuItem.Text = "Генерация перевозок";
|
||||
generationTruckingsToolStripMenuItem.Click += GenerationTruckingsToolStripMenuItem_Click;
|
||||
//
|
||||
// testTimeGetDataToolStripMenuItem
|
||||
//
|
||||
testTimeGetDataToolStripMenuItem.Name = "testTimeGetDataToolStripMenuItem";
|
||||
testTimeGetDataToolStripMenuItem.Size = new Size(227, 24);
|
||||
testTimeGetDataToolStripMenuItem.Text = "Тест скорости чтения данных";
|
||||
testTimeGetDataToolStripMenuItem.Click += TestTimeGetDataToolStripMenuItem_Click;
|
||||
//
|
||||
// testComplexQueriesToolStripMenuItem
|
||||
//
|
||||
testComplexQueriesToolStripMenuItem.Name = "testComplexQueriesToolStripMenuItem";
|
||||
testComplexQueriesToolStripMenuItem.Size = new Size(188, 24);
|
||||
testComplexQueriesToolStripMenuItem.Text = "Тест сложных запросов";
|
||||
testComplexQueriesToolStripMenuItem.Click += TestComplexQueriesToolStripMenuItem_Click;
|
||||
//
|
||||
// buttonUpdate
|
||||
//
|
||||
buttonUpdate.Location = new Point(1014, 138);
|
||||
buttonUpdate.Name = "buttonUpdate";
|
||||
buttonUpdate.Size = new Size(235, 29);
|
||||
buttonUpdate.TabIndex = 7;
|
||||
buttonUpdate.Text = "Обновить";
|
||||
buttonUpdate.UseVisualStyleBackColor = true;
|
||||
buttonUpdate.Click += ButtonUpdate_Click;
|
||||
//
|
||||
// comboBoxEmails
|
||||
//
|
||||
comboBoxEmails.FormattingEnabled = true;
|
||||
comboBoxEmails.Location = new Point(142, 33);
|
||||
comboBoxEmails.Name = "comboBoxEmails";
|
||||
comboBoxEmails.Size = new Size(208, 28);
|
||||
comboBoxEmails.TabIndex = 8;
|
||||
comboBoxEmails.SelectedIndexChanged += ComboBoxEmails_SelectedIndexChanged;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(12, 36);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(124, 20);
|
||||
label1.TabIndex = 9;
|
||||
label1.Text = "Выберите почту:";
|
||||
//
|
||||
// checkBoxSorted
|
||||
//
|
||||
checkBoxSorted.AutoSize = true;
|
||||
checkBoxSorted.Location = new Point(632, 35);
|
||||
checkBoxSorted.Name = "checkBoxSorted";
|
||||
checkBoxSorted.Size = new Size(316, 24);
|
||||
checkBoxSorted.TabIndex = 10;
|
||||
checkBoxSorted.Text = "Сортировать по возрастанию стоимости";
|
||||
checkBoxSorted.UseVisualStyleBackColor = true;
|
||||
checkBoxSorted.CheckedChanged += CheckBoxSorted_CheckedChanged;
|
||||
//
|
||||
// checkBoxForFilterMode
|
||||
//
|
||||
checkBoxForFilterMode.AutoSize = true;
|
||||
checkBoxForFilterMode.Location = new Point(370, 35);
|
||||
checkBoxForFilterMode.Name = "checkBoxForFilterMode";
|
||||
checkBoxForFilterMode.Size = new Size(212, 24);
|
||||
checkBoxForFilterMode.TabIndex = 11;
|
||||
checkBoxForFilterMode.Text = "Включить режим фильтра";
|
||||
checkBoxForFilterMode.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// chooiceDBToolStripMenuItem
|
||||
//
|
||||
chooiceDBToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { transferDataToolStripMenuItem, startPostgresqlToolStripMenuItem, startMongoDBToolStripMenuItem });
|
||||
chooiceDBToolStripMenuItem.Name = "chooiceDBToolStripMenuItem";
|
||||
chooiceDBToolStripMenuItem.Size = new Size(93, 24);
|
||||
chooiceDBToolStripMenuItem.Text = "Выбор БД";
|
||||
//
|
||||
// transferDataToolStripMenuItem
|
||||
//
|
||||
transferDataToolStripMenuItem.Name = "transferDataToolStripMenuItem";
|
||||
transferDataToolStripMenuItem.Size = new Size(224, 26);
|
||||
transferDataToolStripMenuItem.Text = "Передача данных";
|
||||
transferDataToolStripMenuItem.Click += TransferDataToolStripMenuItem_Click;
|
||||
//
|
||||
// startPostgresqlToolStripMenuItem
|
||||
//
|
||||
startPostgresqlToolStripMenuItem.Name = "startPostgresqlToolStripMenuItem";
|
||||
startPostgresqlToolStripMenuItem.Size = new Size(224, 26);
|
||||
startPostgresqlToolStripMenuItem.Text = "Запуск Postgresql";
|
||||
startPostgresqlToolStripMenuItem.Click += StartPostgresqlToolStripMenuItem_Click;
|
||||
//
|
||||
// startMongoDBToolStripMenuItem
|
||||
//
|
||||
startMongoDBToolStripMenuItem.Name = "startMongoDBToolStripMenuItem";
|
||||
startMongoDBToolStripMenuItem.Size = new Size(224, 26);
|
||||
startMongoDBToolStripMenuItem.Text = "Запуск MongoDB";
|
||||
startMongoDBToolStripMenuItem.Click += StartMongoDBToolStripMenuItem_Click;
|
||||
//
|
||||
// FormTrucking
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(1297, 496);
|
||||
Controls.Add(checkBoxForFilterMode);
|
||||
Controls.Add(checkBoxSorted);
|
||||
Controls.Add(label1);
|
||||
Controls.Add(comboBoxEmails);
|
||||
Controls.Add(buttonUpdate);
|
||||
Controls.Add(buttonCreateTrucking);
|
||||
Controls.Add(dataGridView);
|
||||
Controls.Add(menuStrip);
|
||||
MainMenuStrip = menuStrip;
|
||||
Name = "FormTrucking";
|
||||
Text = "Перевозки";
|
||||
Load += FormMain_Load;
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
menuStrip.ResumeLayout(false);
|
||||
menuStrip.PerformLayout();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DataGridView dataGridView;
|
||||
private Button buttonCreateTrucking;
|
||||
private Button buttonTakeOrderInWork;
|
||||
private Button buttonOrderReady;
|
||||
private Button buttonIssuedOrder;
|
||||
private Button buttonRef;
|
||||
private MenuStrip menuStrip;
|
||||
private ToolStripMenuItem toolStripMenuItem;
|
||||
private ToolStripMenuItem transportToolStripMenuItem;
|
||||
private ToolStripMenuItem workPieceToolStripMenuItem;
|
||||
private ToolStripMenuItem typeTransportationToolStripMenuItem;
|
||||
private ToolStripMenuItem cargoToolStripMenuItem;
|
||||
private ToolStripMenuItem clientToolStripMenuItem;
|
||||
private ToolStripMenuItem shopToolStripMenuItem;
|
||||
private ToolStripMenuItem addManufactureToolStripMenuItem;
|
||||
private Button buttonSellManufacture;
|
||||
private ToolStripMenuItem reportToolStripMenuItem;
|
||||
private ToolStripMenuItem groupedOrdersReportToolStripMenuItem;
|
||||
private ToolStripMenuItem ordersReportToolStripMenuItem;
|
||||
private ToolStripMenuItem manufactureWorkPiecesReportToolStripMenuItem;
|
||||
private ToolStripMenuItem shopsReportToolStripMenuItem;
|
||||
private ToolStripMenuItem rndGenerationToolStripMenuItem;
|
||||
private ToolStripMenuItem generationClientsToolStripMenuItem;
|
||||
private ToolStripMenuItem generationTruckingsToolStripMenuItem;
|
||||
private Button buttonUpdate;
|
||||
private ComboBox comboBoxEmails;
|
||||
private Label label1;
|
||||
private CheckBox checkBoxSorted;
|
||||
private CheckBox checkBoxForFilterMode;
|
||||
private ToolStripMenuItem testTimeGetDataToolStripMenuItem;
|
||||
private ToolStripMenuItem testComplexQueriesToolStripMenuItem;
|
||||
private ToolStripMenuItem chooiceDBToolStripMenuItem;
|
||||
private ToolStripMenuItem transferDataToolStripMenuItem;
|
||||
private ToolStripMenuItem startPostgresqlToolStripMenuItem;
|
||||
private ToolStripMenuItem startMongoDBToolStripMenuItem;
|
||||
}
|
||||
}
|
@ -1,298 +0,0 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.ComponentModel;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Windows.Forms;
|
||||
using TransportCompanyBusinessLogic.BusinessLogic;
|
||||
using TransportCompanyContracts.BusinessLogicsContracts;
|
||||
using TransportCompanyContracts.SearchModels;
|
||||
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
||||
|
||||
namespace TransportCompany
|
||||
{
|
||||
public partial class FormTrucking : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private bool _mongo;
|
||||
|
||||
private ITruckingLogic _truckingLogic;
|
||||
|
||||
private IClientLogic _clientLogic;
|
||||
|
||||
public FormTrucking(ILogger<FormTrucking> logger, ITruckingLogic truckingLogic, IClientLogic clientLogic,
|
||||
ICargoLogic cargoLogic, ITransportLogic transportLogic, ITransportationLogic transportationLogic)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_logger = logger;
|
||||
_truckingLogic = truckingLogic;
|
||||
_clientLogic = clientLogic;
|
||||
_mongo = false;
|
||||
}
|
||||
|
||||
private void FormMain_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
_logger.LogInformation("Çàãðóçêà ïåðåâîçîê");
|
||||
|
||||
try
|
||||
{
|
||||
var list = _truckingLogic.ReadList(null);
|
||||
|
||||
var listClients = _clientLogic.ReadList(null);
|
||||
|
||||
if (list != null)
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
|
||||
if (list.Any(x => !string.IsNullOrEmpty(x.MongoId)))
|
||||
{
|
||||
dataGridView.Columns["Id"].Visible = false;
|
||||
dataGridView.Columns["MongoId"].Visible = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
dataGridView.Columns["Id"].Visible = true;
|
||||
dataGridView.Columns["MongoId"].Visible = false;
|
||||
}
|
||||
|
||||
dataGridView.Columns["ClientId"].Visible = false;
|
||||
dataGridView.Columns["CargoId"].Visible = false;
|
||||
dataGridView.Columns["TransportId"].Visible = false;
|
||||
dataGridView.Columns["TransportationId"].Visible = false;
|
||||
}
|
||||
|
||||
if (listClients != null)
|
||||
{
|
||||
comboBoxEmails.DisplayMember = "Email";
|
||||
|
||||
if (_mongo)
|
||||
{
|
||||
comboBoxEmails.ValueMember = "MongoId";
|
||||
}
|
||||
else
|
||||
{
|
||||
comboBoxEmails.ValueMember = "Id";
|
||||
}
|
||||
|
||||
comboBoxEmails.DataSource = listClients;
|
||||
comboBoxEmails.SelectedItem = null;
|
||||
}
|
||||
|
||||
_logger.LogInformation("Çàãðóçêà ïåðåâîçîê");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Îøèáêà çàãðóçêè ïåðåâîçîê");
|
||||
MessageBox.Show(ex.Message, "Îøèáêà", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonCreateTrucking_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormCreateTrucking));
|
||||
|
||||
if (service is FormCreateTrucking form)
|
||||
{
|
||||
form.Mongo = _mongo;
|
||||
|
||||
form.ShowDialog();
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
|
||||
private void TransportToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormTransport));
|
||||
|
||||
if (service is FormTransport form)
|
||||
{
|
||||
form.SetMongo = _mongo;
|
||||
|
||||
form.ShowDialog();
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
|
||||
private void CargoToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormCargo));
|
||||
|
||||
if (service is FormCargo form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
|
||||
private void ClientToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormClients));
|
||||
|
||||
if (service is FormClients form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
|
||||
private void TypeTransportationToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (!_mongo)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormTypeTransportation));
|
||||
|
||||
if (service is FormTypeTransportation form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void GenerationClientsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormRandomCreateClient));
|
||||
|
||||
if (service is FormRandomCreateClient form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
|
||||
private void GenerationTruckingsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormRandomCreateTrucking));
|
||||
|
||||
if (service is FormRandomCreateTrucking form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonUpdate_Click(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void ComboBoxEmails_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (!checkBoxForFilterMode.Checked)
|
||||
{
|
||||
//dataGridView.DataSource = _truckingLogic.ReadList(null);
|
||||
LoadData();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_mongo)
|
||||
{
|
||||
dataGridView.DataSource = _truckingLogic.ReadList(new TruckingSearchModel { MongoId = comboBoxEmails.SelectedValue.ToString() });
|
||||
}
|
||||
else
|
||||
{
|
||||
dataGridView.DataSource = _truckingLogic.ReadList(null).Where(x => x.ClientId == comboBoxEmails.SelectedIndex).ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void CheckBoxSorted_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
dataGridView.DataSource = _truckingLogic.ReadList(null).OrderByDescending(x => x.Price).ToList();
|
||||
}
|
||||
|
||||
private void TestTimeGetDataToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormTimeCheck));
|
||||
|
||||
if (service is FormTimeCheck form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
|
||||
private void TestComplexQueriesToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormCheckTimeJoin));
|
||||
|
||||
if (service is FormCheckTimeJoin form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
|
||||
/*private void CreateJsonFilesToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var listTrucking = _truckingLogic.ReadList(null);
|
||||
var listClients = _clientLogic.ReadList(null);
|
||||
var listCargos = _cargoLogic.ReadList(null);
|
||||
var listTransport = _transportLogic.ReadList(null);
|
||||
var listTransportation = _transportationLogic.ReadList(null);
|
||||
|
||||
string jsonList = JsonSerializer.Serialize(listClients).ToString();
|
||||
|
||||
string path = @"C:\Users\Programmist73\Desktop\JSON\"; // ïóòü ê ôàéëó
|
||||
|
||||
string realPath;
|
||||
|
||||
for (int i = 0; i < listClients.Count; i++)
|
||||
{
|
||||
realPath = path + "json" + i.ToString() + ".json";
|
||||
|
||||
File.Create(realPath).Close();
|
||||
|
||||
StreamWriter writetext = new StreamWriter(realPath);
|
||||
|
||||
writetext.WriteLine("{\n\t" + "\"client\" : " + "{\n\t" + "\t\"Name\" : " + "\"" + listClients[i].Name + "\"" + "\n\t}\n}");
|
||||
|
||||
writetext.Close();
|
||||
}
|
||||
}*/
|
||||
|
||||
//ïåðåäà÷à äàííûõ èç Postgresql â MongoDB
|
||||
private void TransferDataToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormTransferData));
|
||||
|
||||
if (service is FormTransferData form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
//ðàáîòà ñ Postgresql
|
||||
private void StartPostgresqlToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
_mongo = false;
|
||||
|
||||
Program.ConnectPostgres();
|
||||
|
||||
_truckingLogic = Program.ServiceProvider.GetService(typeof(ITruckingLogic)) as TruckingLogic;
|
||||
_clientLogic = Program.ServiceProvider.GetService(typeof(IClientLogic)) as ClientLogic;
|
||||
|
||||
LoadData();
|
||||
}
|
||||
|
||||
//ðàáîòà ñ MongoBD
|
||||
private void StartMongoDBToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
_mongo = true;
|
||||
|
||||
Program.ConnectMongo();
|
||||
|
||||
_truckingLogic = Program.ServiceProvider.GetService(typeof(ITruckingLogic)) as TruckingLogic;
|
||||
_clientLogic = Program.ServiceProvider.GetService(typeof(IClientLogic)) as ClientLogic;
|
||||
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,63 +0,0 @@
|
||||
<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>
|
||||
<metadata name="menuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
</root>
|
@ -1,114 +0,0 @@
|
||||
namespace TransportCompany
|
||||
{
|
||||
partial class FormTypeTransportation
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
dataGridView = new DataGridView();
|
||||
buttonCreate = new Button();
|
||||
buttonUpdate = new Button();
|
||||
buttonDelete = new Button();
|
||||
buttonReload = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView.Location = new Point(12, 12);
|
||||
dataGridView.Name = "dataGridView";
|
||||
dataGridView.RowHeadersWidth = 51;
|
||||
dataGridView.RowTemplate.Height = 29;
|
||||
dataGridView.Size = new Size(450, 426);
|
||||
dataGridView.TabIndex = 0;
|
||||
//
|
||||
// buttonCreate
|
||||
//
|
||||
buttonCreate.Location = new Point(512, 27);
|
||||
buttonCreate.Name = "buttonCreate";
|
||||
buttonCreate.Size = new Size(145, 29);
|
||||
buttonCreate.TabIndex = 1;
|
||||
buttonCreate.Text = "Создать";
|
||||
buttonCreate.UseVisualStyleBackColor = true;
|
||||
buttonCreate.Click += ButtonCreate_Click;
|
||||
//
|
||||
// buttonUpdate
|
||||
//
|
||||
buttonUpdate.Location = new Point(512, 93);
|
||||
buttonUpdate.Name = "buttonUpdate";
|
||||
buttonUpdate.Size = new Size(145, 29);
|
||||
buttonUpdate.TabIndex = 2;
|
||||
buttonUpdate.Text = "Обновить";
|
||||
buttonUpdate.UseVisualStyleBackColor = true;
|
||||
buttonUpdate.Click += ButtonUpdate_Click;
|
||||
//
|
||||
// buttonDelete
|
||||
//
|
||||
buttonDelete.Location = new Point(512, 160);
|
||||
buttonDelete.Name = "buttonDelete";
|
||||
buttonDelete.Size = new Size(145, 29);
|
||||
buttonDelete.TabIndex = 3;
|
||||
buttonDelete.Text = "Удалить";
|
||||
buttonDelete.UseVisualStyleBackColor = true;
|
||||
buttonDelete.Click += ButtonDelete_Click;
|
||||
//
|
||||
// buttonReload
|
||||
//
|
||||
buttonReload.Location = new Point(512, 228);
|
||||
buttonReload.Name = "buttonReload";
|
||||
buttonReload.Size = new Size(145, 29);
|
||||
buttonReload.TabIndex = 4;
|
||||
buttonReload.Text = "Обновить";
|
||||
buttonReload.UseVisualStyleBackColor = true;
|
||||
buttonReload.Click += ButtonReload_Click;
|
||||
//
|
||||
// FormTypeTransportation
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(701, 450);
|
||||
Controls.Add(buttonReload);
|
||||
Controls.Add(buttonDelete);
|
||||
Controls.Add(buttonUpdate);
|
||||
Controls.Add(buttonCreate);
|
||||
Controls.Add(dataGridView);
|
||||
Name = "FormTypeTransportation";
|
||||
Text = "Типы перевозок";
|
||||
Load += FormTypeTransportation_Load;
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DataGridView dataGridView;
|
||||
private Button buttonCreate;
|
||||
private Button buttonUpdate;
|
||||
private Button buttonDelete;
|
||||
private Button buttonReload;
|
||||
}
|
||||
}
|
@ -1,126 +0,0 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using TransportCompanyContracts.BindingModels;
|
||||
using TransportCompanyContracts.BusinessLogicsContracts;
|
||||
|
||||
namespace TransportCompany
|
||||
{
|
||||
public partial class FormTypeTransportation : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private readonly ITransportationLogic _logic;
|
||||
|
||||
public FormTypeTransportation(ILogger<FormTypeTransportation> logger, ITransportationLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
}
|
||||
|
||||
private void FormTypeTransportation_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
try
|
||||
{
|
||||
var list = _logic.ReadList(null);
|
||||
|
||||
//растягиваем колонку Название на всю ширину, колонку Id скрываем
|
||||
if (list != null)
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
|
||||
_logger.LogInformation("Загрузка типа перевозок");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки типа перевозок");
|
||||
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonCreate_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormCreateTypeTransportation));
|
||||
|
||||
if (service is FormCreateTypeTransportation form)
|
||||
{
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonUpdate_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormCreateTypeTransportation));
|
||||
|
||||
if (service is FormCreateTypeTransportation form)
|
||||
{
|
||||
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonDelete_Click(object sender, EventArgs e)
|
||||
{
|
||||
//проверяем наличие выделенной строки
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
|
||||
_logger.LogInformation("Удаление типа перевозки");
|
||||
|
||||
try
|
||||
{
|
||||
if (!_logic.Delete(new TransportationBindingModel
|
||||
{
|
||||
Id = id
|
||||
}))
|
||||
{
|
||||
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
|
||||
}
|
||||
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка удаления типа перевозки");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonReload_Click(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,60 +0,0 @@
|
||||
<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>
|
@ -1,106 +0,0 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using NLog.Extensions.Logging;
|
||||
using TransportCompamyMongoDBImplementer.Implements;
|
||||
using TransportCompanyBusinessLogic.BusinessLogic;
|
||||
using TransportCompanyContracts.BusinessLogicsContracts;
|
||||
using TransportCompanyContracts.StoragesContracts;
|
||||
using TransportCompanyDatabaseImplements.Implements;
|
||||
|
||||
namespace TransportCompany
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
private static ServiceProvider? _serviceProvider;
|
||||
|
||||
public static ServiceProvider? ServiceProvider => _serviceProvider;
|
||||
|
||||
public static ServiceCollection _serviseCollection;
|
||||
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
// To customize application configuration such as set high DPI settings or default font;
|
||||
// see https://aka.ms/applicationconfiguration.
|
||||
ApplicationConfiguration.Initialize();
|
||||
_serviseCollection = new ServiceCollection();
|
||||
ConfigureServices(_serviseCollection);
|
||||
_serviceProvider = _serviseCollection.BuildServiceProvider();
|
||||
Application.Run(_serviceProvider.GetRequiredService<FormTrucking>());
|
||||
}
|
||||
|
||||
private static void ConfigureServices(ServiceCollection services)
|
||||
{
|
||||
services.AddLogging(option =>
|
||||
{
|
||||
option.SetMinimumLevel(LogLevel.Information);
|
||||
option.AddNLog("nlog.config");
|
||||
});
|
||||
|
||||
services.AddTransient<ICargoStorage, TransportCompanyDatabaseImplements.Implements.CargoStorage>();
|
||||
services.AddTransient<IClientStorage, TransportCompanyDatabaseImplements.Implements.ClientStorage>();
|
||||
services.AddTransient<ITransportStorage, TransportCompanyDatabaseImplements.Implements.TransportStorage>();
|
||||
services.AddTransient<ITransportationStorage, TransportationStorage>();
|
||||
services.AddTransient<ITruckingStorage, TransportCompanyDatabaseImplements.Implements.TruckingStorage>();
|
||||
|
||||
services.AddTransient<ICargoLogic, CargoLogic>();
|
||||
services.AddTransient<IClientLogic, ClientLogic>();
|
||||
services.AddTransient<ITransportLogic, TransportLogic>();
|
||||
services.AddTransient<ITransportationLogic, TransportationLogic>();
|
||||
services.AddTransient<ITruckingLogic, TruckingLogic>();
|
||||
|
||||
services.AddTransient<FormTrucking>();
|
||||
services.AddTransient<FormCargo>();
|
||||
services.AddTransient<FormClients>();
|
||||
services.AddTransient<FormTransport>();
|
||||
services.AddTransient<FormTypeTransportation>();
|
||||
services.AddTransient<FormCreateCargo>();
|
||||
services.AddTransient<FormCreateClient>();
|
||||
services.AddTransient<FormCreateTrucking>();
|
||||
services.AddTransient<FormCreateTransport>();
|
||||
services.AddTransient<FormCreateTypeTransportation>();
|
||||
services.AddTransient<FormRandomCreateClient>();
|
||||
services.AddTransient<FormRandomCreateTrucking>();
|
||||
services.AddTransient<FormTimeCheck>();
|
||||
services.AddTransient<FormCheckTimeJoin>();
|
||||
services.AddTransient<FormTransferData>();
|
||||
}
|
||||
|
||||
//ðàáîòà ñ Postgresql
|
||||
public static void ConnectPostgres()
|
||||
{
|
||||
_serviseCollection.Remove(_serviseCollection.FirstOrDefault(descriptor => descriptor.ServiceType == typeof(ICargoStorage)));
|
||||
_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, TransportCompanyDatabaseImplements.Implements.CargoStorage>();
|
||||
_serviseCollection.AddTransient<IClientStorage, TransportCompanyDatabaseImplements.Implements.ClientStorage>();
|
||||
_serviseCollection.AddTransient<ITruckingStorage, TransportCompanyDatabaseImplements.Implements.TruckingStorage>();
|
||||
_serviseCollection.AddTransient<ITransportationStorage, TransportationStorage>();
|
||||
_serviseCollection.AddTransient<ITransportStorage, TransportCompanyDatabaseImplements.Implements.TransportStorage>();
|
||||
|
||||
_serviceProvider = _serviseCollection.BuildServiceProvider();
|
||||
}
|
||||
|
||||
//ðàáîòà ñ MongoDB
|
||||
public static void ConnectMongo()
|
||||
{
|
||||
_serviseCollection.Remove(_serviseCollection.FirstOrDefault(descriptor => descriptor.ServiceType == typeof(ICargoStorage)));
|
||||
_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.AddTransient<ICargoStorage, TransportCompamyMongoDBImplementer.Implements.CargoStorage>();
|
||||
_serviseCollection.AddTransient<IClientStorage, TransportCompamyMongoDBImplementer.Implements.ClientStorage>();
|
||||
_serviseCollection.AddTransient<ITruckingStorage, TransportCompamyMongoDBImplementer.Implements.TruckingStorage>();
|
||||
_serviseCollection.AddTransient<ITransportStorage, TransportCompamyMongoDBImplementer.Implements.TransportStorage>();
|
||||
|
||||
_serviceProvider = _serviseCollection.BuildServiceProvider();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.5">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.5">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="NLog.Extensions.Logging" Version="5.2.3" />
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\TransportCompamyMongoDBImplementer\TransportCompamyMongoDBImplementer.csproj" />
|
||||
<ProjectReference Include="..\TransportCompanyBusinessLogic\TransportCompanyBusinessLogic.csproj" />
|
||||
<ProjectReference Include="..\TransportCompanyContracts\TransportCompanyContracts.csproj" />
|
||||
<ProjectReference Include="..\TransportCompanyDatabaseImplements\TransportCompanyDatabaseImplements.csproj" />
|
||||
<ProjectReference Include="..\TransportCompanyDataModels\TransportCompanyDataModels.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -1,154 +0,0 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TransportCompanyContracts.BindingModels;
|
||||
using TransportCompanyContracts.BusinessLogicsContracts;
|
||||
using TransportCompanyContracts.SearchModels;
|
||||
using TransportCompanyContracts.StoragesContracts;
|
||||
using TransportCompanyContracts.ViewModels;
|
||||
|
||||
namespace TransportCompanyBusinessLogic.BusinessLogic
|
||||
{
|
||||
public class CargoLogic : ICargoLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private readonly ICargoStorage _cargoStorage;
|
||||
|
||||
//конструктор
|
||||
public CargoLogic(ILogger<CargoLogic> logger, ICargoStorage cargoStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_cargoStorage = cargoStorage;
|
||||
}
|
||||
|
||||
public List<CargoViewModel>? ReadList(CargoSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. TypeCargo:{TypeCargo}. Id:{Id}", model?.TypeCargo, model?.Id);
|
||||
|
||||
//list хранит весь список в случае, если model пришло со значением null на вход метода
|
||||
var list = model == null ? _cargoStorage.GetFullList() : _cargoStorage.GetFilteredList(model);
|
||||
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public CargoViewModel? ReadElement(CargoSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadElement. TypeCargo:{TypeCargo}. Id:{Id}", model.TypeCargo, model.Id);
|
||||
|
||||
var element = _cargoStorage.GetElement(model);
|
||||
|
||||
if (element == null)
|
||||
{
|
||||
_logger.LogWarning("ReadElement element not found");
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadElement find. Id:{Id}", model.Id);
|
||||
|
||||
return element;
|
||||
}
|
||||
|
||||
public bool Create(CargoBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
|
||||
if (_cargoStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Create operation failed");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Update(CargoBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
|
||||
if (_cargoStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Delete(CargoBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
|
||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||
|
||||
if (_cargoStorage.Delete(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//проверка входного аргумента для методов Insert, Update и Delete
|
||||
private void CheckModel(CargoBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
//так как при удалении параметром withParams передаём false
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//проверка на наличие названия типа груза
|
||||
if (string.IsNullOrEmpty(model.TypeCargo))
|
||||
{
|
||||
throw new ArgumentNullException("названия типа груза", nameof(model.TypeCargo));
|
||||
}
|
||||
|
||||
_logger.LogInformation("Cargo. TypeCargo:{TypeCargo}. Id:{Id}",
|
||||
model.TypeCargo, model.Id);
|
||||
|
||||
//проверка на наличие такого же типа груза в списке
|
||||
var element = _cargoStorage.GetElement(new CargoSearchModel
|
||||
{
|
||||
TypeCargo = model.TypeCargo,
|
||||
});
|
||||
|
||||
//если элемент найден и его Id не совпадает с Id объекта, переданного на вход
|
||||
if (element != null && element.Id != model.Id)
|
||||
{
|
||||
throw new InvalidOperationException("Такой тип груза уже есть");
|
||||
}
|
||||
}
|
||||
|
||||
public bool TransferData(List<CargoViewModel> model)
|
||||
{
|
||||
return _cargoStorage.InsertFromPostgres(model);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,191 +0,0 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
using TransportCompanyContracts.BindingModels;
|
||||
using TransportCompanyContracts.BusinessLogicsContracts;
|
||||
using TransportCompanyContracts.SearchModels;
|
||||
using TransportCompanyContracts.StoragesContracts;
|
||||
using TransportCompanyContracts.ViewModels;
|
||||
|
||||
namespace TransportCompanyBusinessLogic.BusinessLogic
|
||||
{
|
||||
public class ClientLogic : IClientLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private readonly IClientStorage _clientStorage;
|
||||
|
||||
public ClientLogic(ILogger<ClientLogic> logger, IClientStorage clientStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_clientStorage = clientStorage;
|
||||
}
|
||||
|
||||
public List<ClientViewModel>? ReadList(ClientSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. Surname:{Surname}. Id:{Id}", model?.Surname, model?.Id);
|
||||
|
||||
//list хранит весь список в случае, если model пришло со значением null на вход метода
|
||||
var list = model == null ? _clientStorage.GetFullList() : _clientStorage.GetFilteredList(model);
|
||||
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public ClientViewModel? ReadElement(ClientSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadElement. Surname:{Surname}. Id:{Id}", model.Surname, model.Id);
|
||||
|
||||
var element = _clientStorage.GetElement(model);
|
||||
|
||||
if (element == null)
|
||||
{
|
||||
_logger.LogWarning("ReadElement element not found");
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadElement find. Id:{Id}", model.Id);
|
||||
|
||||
return element;
|
||||
}
|
||||
|
||||
public bool Create(ClientBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
|
||||
if (_clientStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Create operation failed");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//для замера времени рандомного добавления
|
||||
public string TestRandomCreate(int count, string[] _name, string[] _surname, string[] _patronymic, string[] _telephone, string[] _email)
|
||||
{
|
||||
return _clientStorage.TestRandomInsert(count, _name, _surname, _patronymic, _telephone, _email);
|
||||
}
|
||||
|
||||
//для проверки времени выполнения сложного запроса
|
||||
public string TestSecondJoin()
|
||||
{
|
||||
return _clientStorage.SecondJoin();
|
||||
}
|
||||
|
||||
public bool Update(ClientBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
|
||||
if (_clientStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Delete(ClientBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
|
||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||
|
||||
if (_clientStorage.Delete(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//проверка входного аргумента для методов Insert, Update и Delete
|
||||
private void CheckModel(ClientBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
//так как при удалении параметром withParams передаём false
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//проверка на наличие имени
|
||||
if (string.IsNullOrEmpty(model.Name))
|
||||
{
|
||||
throw new ArgumentNullException("Нет имени клиента", nameof(model.Name));
|
||||
}
|
||||
|
||||
//проверка на наличие фамилии
|
||||
if (string.IsNullOrEmpty(model.Surname))
|
||||
{
|
||||
throw new ArgumentNullException("Нет фамилии клиента", nameof(model.Surname));
|
||||
}
|
||||
|
||||
//проверка на наличие отчества
|
||||
if (string.IsNullOrEmpty(model.Patronymic))
|
||||
{
|
||||
throw new ArgumentNullException("Нет отчества клиента", nameof(model.Patronymic));
|
||||
}
|
||||
|
||||
//проверка на наличие телефонного номера
|
||||
if (string.IsNullOrEmpty(model.Telephone))
|
||||
{
|
||||
throw new ArgumentNullException("Нет телефонного номера клиента", nameof(model.Telephone));
|
||||
}
|
||||
|
||||
//проверка на наличие почты
|
||||
if (string.IsNullOrEmpty(model.Email))
|
||||
{
|
||||
throw new ArgumentNullException("Нет электронной почты клиента", nameof(model.Email));
|
||||
}
|
||||
|
||||
_logger.LogInformation("Client. Name:{Name}. Surname:{Surname}. Patronymic:{Patronymic}. " +
|
||||
"TelephoneNumber:{TelephoneNumber}. Email:{Email}. Id:{Id}",
|
||||
model.Name, model.Surname, model.Patronymic, model.Telephone, model.Email, model.Id);
|
||||
|
||||
//проверка на наличие такой же почты в списке
|
||||
var element = _clientStorage.GetElement(new ClientSearchModel
|
||||
{
|
||||
Email = model.Email,
|
||||
});
|
||||
|
||||
//если почта найдена и его Id не совпадает с Id объекта, переданного на вход
|
||||
if (element != null && element.Id != model.Id)
|
||||
{
|
||||
throw new InvalidOperationException("Клиент с такой почтой уже есть");
|
||||
}
|
||||
}
|
||||
|
||||
public bool TransferData(List<ClientViewModel> model)
|
||||
{
|
||||
return _clientStorage.InsertFromPostgres(model);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,153 +0,0 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TransportCompanyContracts.BindingModels;
|
||||
using TransportCompanyContracts.BusinessLogicsContracts;
|
||||
using TransportCompanyContracts.SearchModels;
|
||||
using TransportCompanyContracts.StoragesContracts;
|
||||
using TransportCompanyContracts.ViewModels;
|
||||
|
||||
namespace TransportCompanyBusinessLogic.BusinessLogic
|
||||
{
|
||||
public class TransportLogic : ITransportLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private readonly ITransportStorage _transportStorage;
|
||||
|
||||
//конструктор
|
||||
public TransportLogic(ILogger<TransportLogic> logger, ITransportStorage transportStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_transportStorage = transportStorage;
|
||||
}
|
||||
|
||||
public List<TransportViewModel>? ReadList(TransportSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. Tranport:{Tranport}. Id:{Id}", model?.Tranport, model?.Id);
|
||||
|
||||
//list хранит весь список в случае, если model пришло со значением null на вход метода
|
||||
var list = model == null ? _transportStorage.GetFullList() : _transportStorage.GetFilteredList(model);
|
||||
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public TransportViewModel? ReadElement(TransportSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadElement. Tranport:{Tranport}. Id:{Id}", model.Tranport, model.Id);
|
||||
|
||||
var element = _transportStorage.GetElement(model);
|
||||
|
||||
if (element == null)
|
||||
{
|
||||
_logger.LogWarning("ReadElement element not found");
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadElement find. Id:{Id}", model.Id);
|
||||
|
||||
return element;
|
||||
}
|
||||
|
||||
public bool Create(TransportBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
|
||||
if (_transportStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Create operation failed");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Update(TransportBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
|
||||
if (_transportStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Delete(TransportBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
|
||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||
|
||||
if (_transportStorage.Delete(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//проверка входного аргумента для методов Insert, Update и Delete
|
||||
private void CheckModel(TransportBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
//так как при удалении параметром withParams передаём false
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//проверка на наличие названия транспортного средства
|
||||
if (string.IsNullOrEmpty(model.Tranport))
|
||||
{
|
||||
throw new ArgumentNullException("Нет названия транспортного средства", nameof(model.Tranport));
|
||||
}
|
||||
|
||||
_logger.LogInformation("Tranport. Tranport:{Tranport}. Id:{Id}", model.Tranport, model.Id);
|
||||
|
||||
//проверка на наличие такого же транспортного средства в списке
|
||||
var element = _transportStorage.GetElement(new TransportSearchModel
|
||||
{
|
||||
Tranport = model.Tranport,
|
||||
});
|
||||
|
||||
//если элемент найден и его Id не совпадает с Id объекта, переданного на вход
|
||||
if (element != null && element.Id != model.Id)
|
||||
{
|
||||
throw new InvalidOperationException("Такое транспортное средство уже есть");
|
||||
}
|
||||
}
|
||||
|
||||
public bool TransferData(List<TransportViewModel> model)
|
||||
{
|
||||
return _transportStorage.InsertFromPostgres(model);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,150 +0,0 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TransportCompanyContracts.BindingModels;
|
||||
using TransportCompanyContracts.BusinessLogicsContracts;
|
||||
using TransportCompanyContracts.SearchModels;
|
||||
using TransportCompanyContracts.StoragesContracts;
|
||||
using TransportCompanyContracts.ViewModels;
|
||||
|
||||
namespace TransportCompanyBusinessLogic.BusinessLogic
|
||||
{
|
||||
public class TransportationLogic : ITransportationLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private readonly ITransportationStorage _transportationStorage;
|
||||
|
||||
//конструктор
|
||||
public TransportationLogic(ILogger<TransportationLogic> logger, ITransportationStorage transportationStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_transportationStorage = transportationStorage;
|
||||
}
|
||||
|
||||
|
||||
public List<TransportationViewModel>? ReadList(TransportationSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. TransportationType:{TransportationType}. Id:{Id}", model?.TransportationType, model?.Id);
|
||||
|
||||
//list хранит весь список в случае, если model пришло со значением null на вход метода
|
||||
var list = model == null ? _transportationStorage.GetFullList() : _transportationStorage.GetFilteredList(model);
|
||||
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public TransportationViewModel? ReadElement(TransportationSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadElement. TransportationType:{TransportationType}. Id:{Id}", model.TransportationType, model.Id);
|
||||
|
||||
var element = _transportationStorage.GetElement(model);
|
||||
|
||||
if (element == null)
|
||||
{
|
||||
_logger.LogWarning("ReadElement element not found");
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadElement find. Id:{Id}", model.Id);
|
||||
|
||||
return element;
|
||||
}
|
||||
|
||||
public bool Create(TransportationBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
|
||||
if (_transportationStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Create operation failed");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Update(TransportationBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
|
||||
if (_transportationStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Delete(TransportationBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
|
||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||
|
||||
if (_transportationStorage.Delete(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//проверка входного аргумента для методов Insert, Update и Delete
|
||||
private void CheckModel(TransportationBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
//так как при удалении параметром withParams передаём false
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//проверка на наличие типа перевозки
|
||||
if (string.IsNullOrEmpty(model.TransportationType))
|
||||
{
|
||||
throw new ArgumentNullException("Нет названия изделия", nameof(model.TransportationType));
|
||||
}
|
||||
|
||||
_logger.LogInformation("Transportation. TransportationType:{TransportationType}. Id:{Id}",
|
||||
model.TransportationType, model.Id);
|
||||
|
||||
//проверка на наличие такого же типа перевозки в списке
|
||||
var element = _transportationStorage.GetElement(new TransportationSearchModel
|
||||
{
|
||||
TransportationType = model.TransportationType,
|
||||
});
|
||||
|
||||
//если элемент найден и его Id не совпадает с Id объекта, переданного на вход
|
||||
if (element != null && element.Id != model.Id)
|
||||
{
|
||||
throw new InvalidOperationException("Такой тип перевозки уже есть");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,184 +0,0 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TransportCompanyContracts.BindingModels;
|
||||
using TransportCompanyContracts.BusinessLogicsContracts;
|
||||
using TransportCompanyContracts.SearchModels;
|
||||
using TransportCompanyContracts.StoragesContracts;
|
||||
using TransportCompanyContracts.ViewModels;
|
||||
|
||||
namespace TransportCompanyBusinessLogic.BusinessLogic
|
||||
{
|
||||
public class TruckingLogic : ITruckingLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private readonly ITruckingStorage _truckingStorage;
|
||||
|
||||
//конструктор
|
||||
public TruckingLogic(ILogger<TruckingLogic> logger, ITruckingStorage truckingStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_truckingStorage = truckingStorage;
|
||||
}
|
||||
|
||||
public List<TruckingViewModel>? ReadList(TruckingSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. ClientId:{ClientId}. DateStart:{DateStart} Id:{Id}", model?.ClientId, model?.DateStart, model?.Id);
|
||||
|
||||
//list хранит весь список в случае, если model пришло со значением null на вход метода
|
||||
var list = model == null ? _truckingStorage.GetFullList() : _truckingStorage.GetFilteredList(model);
|
||||
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
//для замера времени считывания значений
|
||||
public string? TestReadList()
|
||||
{
|
||||
return _truckingStorage.TestGetFullList();
|
||||
}
|
||||
|
||||
public TruckingViewModel? ReadElement(TruckingSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadElement. ClientId:{ClientId}. DateStart:{DateStart} Id:{Id}", model?.ClientId, model?.DateStart, model?.Id);
|
||||
|
||||
var element = _truckingStorage.GetElement(model);
|
||||
|
||||
if (element == null)
|
||||
{
|
||||
_logger.LogWarning("ReadElement element not found");
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadElement find. Id:{Id}", model.Id);
|
||||
|
||||
return element;
|
||||
}
|
||||
|
||||
public bool Create(TruckingBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
|
||||
if (_truckingStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Create operation failed");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public string TestRandomCreate(int count, List<ClientViewModel> clients, List<CargoViewModel> cargos, List<TransportViewModel> transports, List<TransportationViewModel> transportations)
|
||||
{
|
||||
return _truckingStorage.TestRandomInsert(count, clients, cargos, transports, transportations);
|
||||
}
|
||||
|
||||
//первый сложный запрос
|
||||
public string? TestFirstJoin()
|
||||
{
|
||||
return _truckingStorage.FirstJoin();
|
||||
}
|
||||
|
||||
public bool Update(TruckingBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
|
||||
if (_truckingStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Delete(TruckingBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
|
||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||
|
||||
if (_truckingStorage.Delete(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//проверка входного аргумента для методов Insert, Update и Delete
|
||||
private void CheckModel(TruckingBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
//так как при удалении параметром withParams передаём false
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//проверка на корректный id заказчика
|
||||
if (model.ClientId <= 0 && string.IsNullOrEmpty(model.Client))
|
||||
{
|
||||
throw new ArgumentNullException("Некорректный id заказчика", nameof(model.ClientId));
|
||||
}
|
||||
|
||||
//проверка на корректный id груза
|
||||
if (model.CargoId <= 0 && string.IsNullOrEmpty(model.Cargo))
|
||||
{
|
||||
throw new ArgumentNullException("Некорректный id груза", nameof(model.CargoId));
|
||||
}
|
||||
|
||||
//проверка на корректный id транспорта
|
||||
if (model.TransportId <= 0 && string.IsNullOrEmpty(model.Transport))
|
||||
{
|
||||
throw new ArgumentNullException("Некорректный id транспорта", nameof(model.TransportId));
|
||||
}
|
||||
|
||||
//проверка на корректный id типа транспортировки
|
||||
if (model.TransportationId <= 0 && string.IsNullOrEmpty(model.Transport))
|
||||
{
|
||||
throw new ArgumentNullException("Некорректный id типа транспортировки", nameof(model.TransportationId));
|
||||
}
|
||||
|
||||
//проверка на корректную дату начала транспортировки
|
||||
if (model.DateStart > model.DateEnd)
|
||||
{
|
||||
throw new ArgumentNullException("Дата начала транспортировки должна быть раньше даты окончания перевозки", nameof(model.DateStart));
|
||||
}
|
||||
|
||||
_logger.LogInformation("Trucking. ClientId:{ClientId}. CargoId:{CargoId}. TransportId:{TransportId}." +
|
||||
"TransportationId:{TransportationId}. DateStart:{DateStart}. DateEnd:{DateEnd}. Id:{Id}",
|
||||
model.ClientId, model.CargoId, model.TransportId, model.TransportationId, model.DateStart, model.DateEnd, model.Id);
|
||||
}
|
||||
|
||||
public bool TransferData(List<TruckingViewModel> model)
|
||||
{
|
||||
return _truckingStorage.InsertFromPostgres(model);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
|
||||
<PackageReference Include="Serilog" Version="2.12.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\TransportCompanyContracts\TransportCompanyContracts.csproj" />
|
||||
<ProjectReference Include="..\TransportCompanyDataModels\TransportCompanyDataModels.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -1,18 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TransportCompanyDataModels.Models;
|
||||
|
||||
namespace TransportCompanyContracts.BindingModels
|
||||
{
|
||||
public class CargoBindingModel : ICargoModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public string? MongoId { get; set; }
|
||||
|
||||
public string TypeCargo { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TransportCompanyDataModels.Models;
|
||||
|
||||
namespace TransportCompanyContracts.BindingModels
|
||||
{
|
||||
public class ClientBindingModel : IClientModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public string? MongoId { get; set; }
|
||||
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
public string Surname { get; set; } = string.Empty;
|
||||
|
||||
public string Patronymic { get; set; } = string.Empty;
|
||||
|
||||
public string Telephone { get; set; } = string.Empty;
|
||||
|
||||
public string Email { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TransportCompanyDataModels.Models;
|
||||
|
||||
namespace TransportCompanyContracts.BindingModels
|
||||
{
|
||||
public class TransportBindingModel : ITransportModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public string? MongoId { get; set; }
|
||||
|
||||
//для MongoDB
|
||||
public string? TransportationType { get; set; }
|
||||
|
||||
public string Tranport { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TransportCompanyDataModels.Models;
|
||||
|
||||
namespace TransportCompanyContracts.BindingModels
|
||||
{
|
||||
public class TransportationBindingModel : ITransportationModel
|
||||
{
|
||||
public int Id {get; set;}
|
||||
|
||||
public string? MongoId { get; set; }
|
||||
|
||||
public string TransportationType { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TransportCompanyDataModels.Models;
|
||||
|
||||
namespace TransportCompanyContracts.BindingModels
|
||||
{
|
||||
public class TruckingBindingModel : ITruckingModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public string? MongoId { get; set; }
|
||||
|
||||
public int ClientId { get; set; }
|
||||
|
||||
public int CargoId { get; set; }
|
||||
|
||||
public double Price { get; set; }
|
||||
|
||||
public DateTime DateStart { get; set; }
|
||||
|
||||
public DateTime DateEnd { get; set; }
|
||||
|
||||
public int TransportationId { get; set; }
|
||||
|
||||
public int TransportId { get; set; }
|
||||
|
||||
public string Client { get; set; }
|
||||
|
||||
public string Cargo { get; set; }
|
||||
|
||||
public string Transport { get; set; }
|
||||
}
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TransportCompanyContracts.BindingModels;
|
||||
using TransportCompanyContracts.SearchModels;
|
||||
using TransportCompanyContracts.ViewModels;
|
||||
|
||||
namespace TransportCompanyContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface ICargoLogic
|
||||
{
|
||||
List<CargoViewModel>? ReadList(CargoSearchModel? model);
|
||||
|
||||
CargoViewModel? ReadElement(CargoSearchModel model);
|
||||
|
||||
bool Create(CargoBindingModel model);
|
||||
|
||||
bool Update(CargoBindingModel model);
|
||||
|
||||
bool Delete(CargoBindingModel model);
|
||||
|
||||
bool TransferData(List<CargoViewModel> model);
|
||||
}
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TransportCompanyContracts.BindingModels;
|
||||
using TransportCompanyContracts.SearchModels;
|
||||
using TransportCompanyContracts.ViewModels;
|
||||
|
||||
namespace TransportCompanyContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IClientLogic
|
||||
{
|
||||
List<ClientViewModel>? ReadList(ClientSearchModel? model);
|
||||
|
||||
ClientViewModel? ReadElement(ClientSearchModel model);
|
||||
|
||||
bool Create(ClientBindingModel model);
|
||||
|
||||
string TestRandomCreate(int count, string[] _name, string[] _surname, string[] _patronymic, string[] _telephone, string[] _email);
|
||||
|
||||
string TestSecondJoin();
|
||||
|
||||
bool Update(ClientBindingModel model);
|
||||
|
||||
bool Delete(ClientBindingModel model);
|
||||
|
||||
bool TransferData(List<ClientViewModel> model);
|
||||
}
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TransportCompanyContracts.BindingModels;
|
||||
using TransportCompanyContracts.SearchModels;
|
||||
using TransportCompanyContracts.ViewModels;
|
||||
|
||||
namespace TransportCompanyContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface ITransportLogic
|
||||
{
|
||||
List<TransportViewModel>? ReadList(TransportSearchModel? model);
|
||||
|
||||
TransportViewModel? ReadElement(TransportSearchModel model);
|
||||
|
||||
bool Create(TransportBindingModel model);
|
||||
|
||||
bool Update(TransportBindingModel model);
|
||||
|
||||
bool Delete(TransportBindingModel model);
|
||||
|
||||
bool TransferData(List<TransportViewModel> model);
|
||||
}
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TransportCompanyContracts.BindingModels;
|
||||
using TransportCompanyContracts.SearchModels;
|
||||
using TransportCompanyContracts.ViewModels;
|
||||
|
||||
namespace TransportCompanyContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface ITransportationLogic
|
||||
{
|
||||
List<TransportationViewModel>? ReadList(TransportationSearchModel? model);
|
||||
|
||||
TransportationViewModel? ReadElement(TransportationSearchModel model);
|
||||
|
||||
bool Create(TransportationBindingModel model);
|
||||
|
||||
bool Update(TransportationBindingModel model);
|
||||
|
||||
bool Delete(TransportationBindingModel model);
|
||||
}
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TransportCompanyContracts.BindingModels;
|
||||
using TransportCompanyContracts.SearchModels;
|
||||
using TransportCompanyContracts.ViewModels;
|
||||
|
||||
namespace TransportCompanyContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface ITruckingLogic
|
||||
{
|
||||
List<TruckingViewModel>? ReadList(TruckingSearchModel? model);
|
||||
|
||||
string? TestReadList();
|
||||
|
||||
string? TestFirstJoin();
|
||||
|
||||
TruckingViewModel? ReadElement(TruckingSearchModel model);
|
||||
|
||||
bool Create(TruckingBindingModel model);
|
||||
|
||||
string TestRandomCreate(int count, List<ClientViewModel> clients, List<CargoViewModel> cargos, List<TransportViewModel> transports, List<TransportationViewModel> transportations);
|
||||
|
||||
bool Update(TruckingBindingModel model);
|
||||
|
||||
bool Delete(TruckingBindingModel model);
|
||||
|
||||
bool TransferData(List<TruckingViewModel> model);
|
||||
}
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TransportCompanyContracts.SearchModels
|
||||
{
|
||||
public class CargoSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
|
||||
public string? MongoId { get; set; }
|
||||
|
||||
public string? TypeCargo { get; set; }
|
||||
}
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TransportCompanyContracts.SearchModels
|
||||
{
|
||||
public class ClientSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
|
||||
public string? MongoId { get; set; }
|
||||
|
||||
public string? Name { get; set; }
|
||||
|
||||
public string? Surname { get; set; }
|
||||
|
||||
public string? Patronymic { get; set; }
|
||||
|
||||
public string? TelephoneNumber { get; set; }
|
||||
|
||||
public string? Email { get; set; }
|
||||
}
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TransportCompanyContracts.SearchModels
|
||||
{
|
||||
public class TransportSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
|
||||
public string? MongoId { get; set; }
|
||||
|
||||
public string? Tranport { get; set; }
|
||||
}
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TransportCompanyContracts.SearchModels
|
||||
{
|
||||
public class TransportationSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
|
||||
public string? MongoId { get; set; }
|
||||
|
||||
public string? TransportationType { get; set; }
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TransportCompanyContracts.SearchModels
|
||||
{
|
||||
public class TruckingSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
|
||||
public string? MongoId { get; set; }
|
||||
|
||||
public int? ClientId { get; set; }
|
||||
|
||||
public DateTime? DateStart { get; set; }
|
||||
|
||||
public DateTime? DateEnd { get; set; }
|
||||
}
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TransportCompanyContracts.BindingModels;
|
||||
using TransportCompanyContracts.SearchModels;
|
||||
using TransportCompanyContracts.ViewModels;
|
||||
|
||||
namespace TransportCompanyContracts.StoragesContracts
|
||||
{
|
||||
public interface ICargoStorage
|
||||
{
|
||||
List<CargoViewModel> GetFullList();
|
||||
|
||||
List<CargoViewModel> GetFilteredList(CargoSearchModel model);
|
||||
|
||||
CargoViewModel? GetElement(CargoSearchModel model);
|
||||
|
||||
CargoViewModel? Insert(CargoBindingModel model);
|
||||
|
||||
CargoViewModel? Update(CargoBindingModel model);
|
||||
|
||||
CargoViewModel? Delete(CargoBindingModel model);
|
||||
|
||||
bool InsertFromPostgres(List<CargoViewModel> model);
|
||||
}
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TransportCompanyContracts.BindingModels;
|
||||
using TransportCompanyContracts.SearchModels;
|
||||
using TransportCompanyContracts.ViewModels;
|
||||
|
||||
namespace TransportCompanyContracts.StoragesContracts
|
||||
{
|
||||
public interface IClientStorage
|
||||
{
|
||||
List<ClientViewModel> GetFullList();
|
||||
|
||||
List<ClientViewModel> GetFilteredList(ClientSearchModel model);
|
||||
|
||||
ClientViewModel? GetElement(ClientSearchModel model);
|
||||
|
||||
ClientViewModel? Insert(ClientBindingModel model);
|
||||
|
||||
string TestRandomInsert(int count, string[] _name, string[] _surname, string[] _patronymic, string[] _telephone, string[] _email);
|
||||
|
||||
string SecondJoin();
|
||||
|
||||
ClientViewModel? Update(ClientBindingModel model);
|
||||
|
||||
ClientViewModel? Delete(ClientBindingModel model);
|
||||
|
||||
bool InsertFromPostgres(List<ClientViewModel> model);
|
||||
}
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TransportCompanyContracts.BindingModels;
|
||||
using TransportCompanyContracts.SearchModels;
|
||||
using TransportCompanyContracts.ViewModels;
|
||||
|
||||
namespace TransportCompanyContracts.StoragesContracts
|
||||
{
|
||||
public interface ITransportStorage
|
||||
{
|
||||
List<TransportViewModel> GetFullList();
|
||||
|
||||
List<TransportViewModel> GetFilteredList(TransportSearchModel model);
|
||||
|
||||
TransportViewModel? GetElement(TransportSearchModel model);
|
||||
|
||||
TransportViewModel? Insert(TransportBindingModel model);
|
||||
|
||||
TransportViewModel? Update(TransportBindingModel model);
|
||||
|
||||
TransportViewModel? Delete(TransportBindingModel model);
|
||||
|
||||
bool InsertFromPostgres(List<TransportViewModel> model);
|
||||
}
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TransportCompanyContracts.BindingModels;
|
||||
using TransportCompanyContracts.SearchModels;
|
||||
using TransportCompanyContracts.ViewModels;
|
||||
|
||||
namespace TransportCompanyContracts.StoragesContracts
|
||||
{
|
||||
public interface ITransportationStorage
|
||||
{
|
||||
List<TransportationViewModel> GetFullList();
|
||||
|
||||
List<TransportationViewModel> GetFilteredList(TransportationSearchModel model);
|
||||
|
||||
TransportationViewModel? GetElement(TransportationSearchModel model);
|
||||
|
||||
TransportationViewModel? Insert(TransportationBindingModel model);
|
||||
|
||||
TransportationViewModel? Update(TransportationBindingModel model);
|
||||
|
||||
TransportationViewModel? Delete(TransportationBindingModel model);
|
||||
|
||||
bool InsertFromPostgres(List<TransportationViewModel> model);
|
||||
}
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TransportCompanyContracts.BindingModels;
|
||||
using TransportCompanyContracts.SearchModels;
|
||||
using TransportCompanyContracts.ViewModels;
|
||||
|
||||
namespace TransportCompanyContracts.StoragesContracts
|
||||
{
|
||||
public interface ITruckingStorage
|
||||
{
|
||||
List<TruckingViewModel> GetFullList();
|
||||
|
||||
string TestGetFullList();
|
||||
|
||||
string FirstJoin();
|
||||
|
||||
List<TruckingViewModel> GetFilteredList(TruckingSearchModel model);
|
||||
|
||||
TruckingViewModel? GetElement(TruckingSearchModel model);
|
||||
|
||||
TruckingViewModel? Insert(TruckingBindingModel model);
|
||||
|
||||
string TestRandomInsert(int count, List<ClientViewModel> clients, List<CargoViewModel> cargos, List<TransportViewModel> transports, List<TransportationViewModel> transportations);
|
||||
|
||||
TruckingViewModel? Update(TruckingBindingModel model);
|
||||
|
||||
TruckingViewModel? Delete(TruckingBindingModel model);
|
||||
|
||||
bool InsertFromPostgres(List<TruckingViewModel> model);
|
||||
}
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\TransportCompanyDataModels\TransportCompanyDataModels.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -1,20 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TransportCompanyDataModels.Models;
|
||||
|
||||
namespace TransportCompanyContracts.ViewModels
|
||||
{
|
||||
public class CargoViewModel : ICargoModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public string? MongoId { get; set; }
|
||||
|
||||
[DisplayName("Тип груза")]
|
||||
public string TypeCargo {get; set; } = string.Empty;
|
||||
}
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TransportCompanyDataModels.Models;
|
||||
|
||||
namespace TransportCompanyContracts.ViewModels
|
||||
{
|
||||
public class ClientViewModel : IClientModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public string? MongoId { get; set; }
|
||||
|
||||
[DisplayName("Имя")]
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Фамилия")]
|
||||
public string Surname { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Отчество")]
|
||||
public string Patronymic { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Телефон")]
|
||||
public string Telephone { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Почта")]
|
||||
public string Email { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TransportCompanyDataModels.Models;
|
||||
|
||||
namespace TransportCompanyContracts.ViewModels
|
||||
{
|
||||
public class TransportViewModel : ITransportModel
|
||||
{
|
||||
[DisplayName("Номер")]
|
||||
public int Id { get; set; }
|
||||
|
||||
[DisplayName("Номер")]
|
||||
public string? MongoId { get; set; }
|
||||
|
||||
[DisplayName("Вид транспорта")]
|
||||
public string Tranport { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Тип перевозки")]
|
||||
public string? TransportationType { get; set; }
|
||||
}
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TransportCompanyDataModels.Models;
|
||||
|
||||
namespace TransportCompanyContracts.ViewModels
|
||||
{
|
||||
public class TransportationViewModel : ITransportationModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public string? MongoId { get; set; }
|
||||
|
||||
[DisplayName("Тип транспортировки")]
|
||||
public string TransportationType { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
@ -1,57 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TransportCompanyDataModels.Models;
|
||||
|
||||
namespace TransportCompanyContracts.ViewModels
|
||||
{
|
||||
public class TruckingViewModel : ITruckingModel
|
||||
{
|
||||
[DisplayName("Номер")]
|
||||
public int Id { get; set; }
|
||||
|
||||
[DisplayName("Номер")]
|
||||
public string? MongoId { get; set; }
|
||||
|
||||
public int ClientId { get; set; }
|
||||
|
||||
[DisplayName("Имя")]
|
||||
public string ClientName { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Фамилия")]
|
||||
public string ClientSurname { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Отчество")]
|
||||
public string ClientPatronymic { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Почта")]
|
||||
public string ClientEmail { get; set; } = string.Empty;
|
||||
|
||||
public int CargoId { get; set; }
|
||||
|
||||
[DisplayName("Объект перевозки")]
|
||||
public string Cargo { get; set; } = string.Empty;
|
||||
|
||||
public int TransportId { get; set; }
|
||||
|
||||
[DisplayName("Тип транспорта")]
|
||||
public string TransportName { get; set; } = string.Empty;
|
||||
|
||||
public int TransportationId { get; set; }
|
||||
|
||||
[DisplayName("Тип перевозки")]
|
||||
public string TypeTransportation { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Цена")]
|
||||
public double Price { get; set; }
|
||||
|
||||
[DisplayName("Дата оформления перевозки")]
|
||||
public DateTime DateStart { get; set; }
|
||||
|
||||
[DisplayName("Дата завершения перевозки")]
|
||||
public DateTime DateEnd { get; set; }
|
||||
}
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TransportCompanyDataModels
|
||||
{
|
||||
public interface IId
|
||||
{
|
||||
int Id { get; }
|
||||
}
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TransportCompanyDataModels.Models
|
||||
{
|
||||
public interface ICargoModel : IId
|
||||
{
|
||||
//тип груза
|
||||
string TypeCargo { get; }
|
||||
}
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TransportCompanyDataModels.Models
|
||||
{
|
||||
public interface IClientModel : IId
|
||||
{
|
||||
string Name { get; }
|
||||
|
||||
string Surname { get; }
|
||||
|
||||
//отчество
|
||||
string Patronymic { get; }
|
||||
|
||||
string Telephone { get; }
|
||||
|
||||
string Email { get; }
|
||||
}
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TransportCompanyDataModels.Models
|
||||
{
|
||||
public interface ITransportModel : IId
|
||||
{
|
||||
//тип транспорта для перевозки
|
||||
string Tranport { get; }
|
||||
}
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TransportCompanyDataModels.Models
|
||||
{
|
||||
public interface ITransportationModel : IId
|
||||
{
|
||||
//тип транспортировки
|
||||
string TransportationType { get; }
|
||||
}
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TransportCompanyDataModels.Models
|
||||
{
|
||||
public interface ITruckingModel : IId
|
||||
{
|
||||
int ClientId { get; }
|
||||
|
||||
int CargoId { get; }
|
||||
|
||||
double Price { get; }
|
||||
|
||||
DateTime DateStart { get; }
|
||||
|
||||
DateTime DateEnd { get; }
|
||||
|
||||
int TransportationId { get; }
|
||||
|
||||
int TransportId { get; }
|
||||
}
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.3" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -1,168 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Internal;
|
||||
using Microsoft.Extensions.Options;
|
||||
using TransportCompanyDatabaseImplements.Models;
|
||||
|
||||
namespace TransportCompanyDatabaseImplements;
|
||||
|
||||
public partial class ElegevContext : DbContext
|
||||
{
|
||||
public ElegevContext()
|
||||
{
|
||||
}
|
||||
|
||||
public ElegevContext(DbContextOptions<ElegevContext> options)
|
||||
: base(options)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual DbSet<Cargo> Cargos { get; set; }
|
||||
|
||||
public virtual DbSet<Client> Clients { get; set; }
|
||||
|
||||
public virtual DbSet<Transport> Transports { get; set; }
|
||||
|
||||
public virtual DbSet<Trucking> Truckings { get; set; }
|
||||
|
||||
public virtual DbSet<TypeTransportation> TypeTransportations { get; set; }
|
||||
|
||||
string dbName = ConfigurationManager.AppSettings["connectToDb"];
|
||||
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
#warning To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see http://go.microsoft.com/fwlink/?LinkId=723263.
|
||||
=> optionsBuilder.UseNpgsql(dbName);
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.Entity<Cargo>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id).HasName("cargo_pkey");
|
||||
|
||||
entity.ToTable("cargo");
|
||||
|
||||
entity.Property(e => e.Id)
|
||||
.ValueGeneratedNever()
|
||||
.HasColumnName("id");
|
||||
entity.Property(e => e.TypeCargo)
|
||||
.HasMaxLength(255)
|
||||
.HasColumnName("type_cargo");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<Client>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id).HasName("client_pkey");
|
||||
|
||||
entity.ToTable("client");
|
||||
|
||||
entity.Property(e => e.Id)
|
||||
.ValueGeneratedNever()
|
||||
.HasColumnName("id");
|
||||
entity.Property(e => e.Email)
|
||||
.HasMaxLength(255)
|
||||
.HasColumnName("email");
|
||||
entity.Property(e => e.Name)
|
||||
.HasMaxLength(255)
|
||||
.HasColumnName("name");
|
||||
entity.Property(e => e.Patronymic)
|
||||
.HasMaxLength(255)
|
||||
.HasColumnName("patronymic");
|
||||
entity.Property(e => e.Surname)
|
||||
.HasMaxLength(255)
|
||||
.HasColumnName("surname");
|
||||
entity.Property(e => e.Telephone)
|
||||
.HasMaxLength(255)
|
||||
.HasColumnName("telephone");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<Transport>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id).HasName("transport_pkey");
|
||||
|
||||
entity.ToTable("transport");
|
||||
|
||||
entity.Property(e => e.Id)
|
||||
.ValueGeneratedNever()
|
||||
.HasColumnName("id");
|
||||
entity.Property(e => e.TransportType)
|
||||
.HasMaxLength(255)
|
||||
.HasColumnName("transport_type");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<Trucking>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id).HasName("trucking_pkey");
|
||||
|
||||
entity.ToTable("trucking");
|
||||
|
||||
entity.HasIndex(e => e.CargoId, "IX_trucking_cargo_id");
|
||||
|
||||
entity.HasIndex(e => e.ClientId, "IX_trucking_client_id");
|
||||
|
||||
entity.HasIndex(e => e.TransportId, "IX_trucking_transport_id");
|
||||
|
||||
entity.HasIndex(e => e.TransportationId, "IX_trucking_transportation_id");
|
||||
|
||||
entity.Property(e => e.Id)
|
||||
.ValueGeneratedNever()
|
||||
.HasColumnName("id");
|
||||
entity.Property(e => e.CargoId).HasColumnName("cargo_id");
|
||||
entity.Property(e => e.ClientId).HasColumnName("client_id");
|
||||
entity.Property(e => e.DateEnd)
|
||||
.HasColumnType("timestamp without time zone")
|
||||
.HasColumnName("date_end");
|
||||
entity.Property(e => e.DateStart)
|
||||
.HasColumnType("timestamp without time zone")
|
||||
.HasColumnName("date_start");
|
||||
entity.Property(e => e.Price).HasColumnName("price");
|
||||
entity.Property(e => e.TransportId).HasColumnName("transport_id");
|
||||
entity.Property(e => e.TransportationId).HasColumnName("transportation_id");
|
||||
|
||||
entity.HasOne(d => d.Cargo).WithMany(p => p.Truckings)
|
||||
.HasForeignKey(d => d.CargoId)
|
||||
.OnDelete(DeleteBehavior.ClientSetNull)
|
||||
.HasConstraintName("cargo_id");
|
||||
|
||||
entity.HasOne(d => d.Client).WithMany(p => p.Truckings)
|
||||
.HasForeignKey(d => d.ClientId)
|
||||
.OnDelete(DeleteBehavior.ClientSetNull)
|
||||
.HasConstraintName("client_id");
|
||||
|
||||
entity.HasOne(d => d.Transport).WithMany(p => p.Truckings)
|
||||
.HasForeignKey(d => d.TransportId)
|
||||
.OnDelete(DeleteBehavior.ClientSetNull)
|
||||
.HasConstraintName("transport_id");
|
||||
|
||||
entity.HasOne(d => d.Transportation).WithMany(p => p.Truckings)
|
||||
.HasForeignKey(d => d.TransportationId)
|
||||
.OnDelete(DeleteBehavior.ClientSetNull)
|
||||
.HasConstraintName("type_transportation_id");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<TypeTransportation>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id).HasName("type_transportation_pkey");
|
||||
|
||||
entity.ToTable("type_transportation");
|
||||
|
||||
entity.Property(e => e.Id)
|
||||
.ValueGeneratedNever()
|
||||
.HasColumnName("id");
|
||||
entity.Property(e => e.TransportationType)
|
||||
.HasMaxLength(255)
|
||||
.HasColumnName("transportation_type");
|
||||
});
|
||||
|
||||
modelBuilder.HasSequence("seq_cargo");
|
||||
modelBuilder.HasSequence("seq_client");
|
||||
modelBuilder.HasSequence("seq_trucking");
|
||||
modelBuilder.HasSequence("seq_type_transport");
|
||||
modelBuilder.HasSequence("seq_type_transportation");
|
||||
|
||||
OnModelCreatingPartial(modelBuilder);
|
||||
}
|
||||
|
||||
partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
|
||||
}
|
@ -1,123 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TransportCompanyContracts.BindingModels;
|
||||
using TransportCompanyContracts.SearchModels;
|
||||
using TransportCompanyContracts.StoragesContracts;
|
||||
using TransportCompanyContracts.ViewModels;
|
||||
using TransportCompanyDatabaseImplements.Models;
|
||||
|
||||
namespace TransportCompanyDatabaseImplements.Implements
|
||||
{
|
||||
public class CargoStorage : ICargoStorage
|
||||
{
|
||||
public CargoViewModel? Delete(CargoBindingModel model)
|
||||
{
|
||||
using var context = new ElegevContext();
|
||||
|
||||
var element = context.Cargos
|
||||
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
|
||||
if (element != null)
|
||||
{
|
||||
context.Cargos.Remove(element);
|
||||
context.SaveChanges();
|
||||
|
||||
return element.GetViewModel;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public CargoViewModel? GetElement(CargoSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.TypeCargo) && !model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
using var context = new ElegevContext();
|
||||
|
||||
return context.Cargos
|
||||
.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))
|
||||
?.GetViewModel;
|
||||
}
|
||||
|
||||
public List<CargoViewModel> GetFilteredList(CargoSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
|
||||
using var context = new ElegevContext();
|
||||
|
||||
return context.Cargos
|
||||
.Where(x => x.Id == model.Id)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<CargoViewModel> GetFullList()
|
||||
{
|
||||
using var context = new ElegevContext();
|
||||
|
||||
return context.Cargos
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public CargoViewModel? Insert(CargoBindingModel model)
|
||||
{
|
||||
using var context = new ElegevContext();
|
||||
|
||||
model.Id = context.Cargos.Count() > 0 ? context.Cargos.Max(x => x.Id) + 1 : 1;
|
||||
|
||||
var newCargo = Cargo.Create(model);
|
||||
|
||||
if (newCargo == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
context.Cargos.Add(newCargo);
|
||||
context.SaveChanges();
|
||||
|
||||
return newCargo.GetViewModel;
|
||||
}
|
||||
|
||||
public CargoViewModel? Update(CargoBindingModel model)
|
||||
{
|
||||
using var context = new ElegevContext();
|
||||
using var transaction = context.Database.BeginTransaction();
|
||||
|
||||
try
|
||||
{
|
||||
var cargo = context.Cargos.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
|
||||
if (cargo == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
cargo.Update(model);
|
||||
context.SaveChanges();
|
||||
transaction.Commit();
|
||||
|
||||
return cargo.GetViewModel;
|
||||
}
|
||||
catch
|
||||
{
|
||||
transaction.Rollback();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public bool InsertFromPostgres(List<CargoViewModel> model)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user