Compare commits
No commits in common. "LabWork8" and "main" have entirely different histories.
2
.gitignore
vendored
2
.gitignore
vendored
@ -3,7 +3,7 @@
|
|||||||
## files generated by popular Visual Studio add-ons.
|
## files generated by popular Visual Studio add-ons.
|
||||||
##
|
##
|
||||||
## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
|
## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
|
||||||
ImplementationExtensions/
|
|
||||||
# User-specific files
|
# User-specific files
|
||||||
*.rsuser
|
*.rsuser
|
||||||
*.suo
|
*.suo
|
||||||
|
@ -1,22 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
</PropertyGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="DocumentFormat.OpenXml" Version="2.20.0" />
|
|
||||||
<PackageReference Include="MailKit" Version="4.0.0" />
|
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
|
|
||||||
<PackageReference Include="PdfSharp.MigraDoc.Standard" Version="1.51.15" />
|
|
||||||
<PackageReference Include="System.Text.Encoding" Version="4.3.0" />
|
|
||||||
<PackageReference Include="System.Text.Encoding.CodePages" Version="7.0.0" />
|
|
||||||
<PackageReference Include="System.Text.Encoding.Extensions" Version="4.3.0" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\AbstractAutoContracts\AutomobilePlantContracts.csproj" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
@ -1,103 +0,0 @@
|
|||||||
using AutomobilePlantContracts.BindingModels;
|
|
||||||
using AutomobilePlantContracts.BusinessLogicsContracts;
|
|
||||||
using AutomobilePlantContracts.StoragesContracts;
|
|
||||||
using AutomobilePlantDataModels;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO.Compression;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Runtime.Serialization.Json;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantBusinessLogic.BusinessLogics
|
|
||||||
{
|
|
||||||
public class BackUpLogic : IBackUpLogic
|
|
||||||
{
|
|
||||||
private readonly ILogger _logger;
|
|
||||||
|
|
||||||
private readonly IBackUpInfo _backUpInfo;
|
|
||||||
|
|
||||||
public BackUpLogic(ILogger<BackUpLogic> logger, IBackUpInfo backUpInfo)
|
|
||||||
{
|
|
||||||
_logger = logger;
|
|
||||||
_backUpInfo = backUpInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void CreateBackUp(BackUpSaveBinidngModel model)
|
|
||||||
{
|
|
||||||
if (_backUpInfo == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_logger.LogDebug("Clear folder");
|
|
||||||
// зачистка папки и удаление старого архива
|
|
||||||
var dirInfo = new DirectoryInfo(model.FolderName);
|
|
||||||
if (dirInfo.Exists)
|
|
||||||
{
|
|
||||||
foreach (var file in dirInfo.GetFiles())
|
|
||||||
{
|
|
||||||
file.Delete();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_logger.LogDebug("Delete archive");
|
|
||||||
string fileName = $"{model.FolderName}.zip";
|
|
||||||
if (File.Exists(fileName))
|
|
||||||
{
|
|
||||||
File.Delete(fileName);
|
|
||||||
}
|
|
||||||
// берем метод для сохранения
|
|
||||||
_logger.LogDebug("Get assembly");
|
|
||||||
var typeIId = typeof(IId);
|
|
||||||
var assembly = typeIId.Assembly;
|
|
||||||
if (assembly == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("Сборка не найдена", nameof(assembly));
|
|
||||||
}
|
|
||||||
var types = assembly.GetTypes();
|
|
||||||
var method = GetType().GetMethod("SaveToFile", BindingFlags.NonPublic | BindingFlags.Instance);
|
|
||||||
_logger.LogDebug("Find {count} types", types.Length);
|
|
||||||
foreach (var type in types)
|
|
||||||
{
|
|
||||||
if (type.IsInterface && type.GetInterface(typeIId.Name) != null)
|
|
||||||
{
|
|
||||||
var modelType = _backUpInfo.GetTypeByModelInterface(type.Name);
|
|
||||||
if (modelType == null)
|
|
||||||
{
|
|
||||||
throw new InvalidOperationException($"Не найден класс-модель для {type.Name}");
|
|
||||||
}
|
|
||||||
_logger.LogDebug("Call SaveToFile method for {name} type", type.Name);
|
|
||||||
// вызываем метод на выполнение
|
|
||||||
method?.MakeGenericMethod(modelType).Invoke(this, new object[] { model.FolderName });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_logger.LogDebug("Create zip and remove folder");
|
|
||||||
// архивируем
|
|
||||||
ZipFile.CreateFromDirectory(model.FolderName, fileName);
|
|
||||||
// удаляем папку
|
|
||||||
dirInfo.Delete(true);
|
|
||||||
}
|
|
||||||
catch (Exception)
|
|
||||||
{
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SaveToFile<T>(string folderName) where T : class, new()
|
|
||||||
{
|
|
||||||
var records = _backUpInfo.GetList<T>();
|
|
||||||
if (records == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("{type} type get null list", typeof(T).Name);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var jsonFormatter = new DataContractJsonSerializer(typeof(List<T>));
|
|
||||||
using var fs = new FileStream(string.Format("{0}/{1}.json", folderName, typeof(T).Name), FileMode.OpenOrCreate);
|
|
||||||
jsonFormatter.WriteObject(fs, records);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,113 +0,0 @@
|
|||||||
using AutomobilePlantContracts.BindingModels;
|
|
||||||
using AutomobilePlantContracts.BusinessLogicsContracts;
|
|
||||||
using AutomobilePlantContracts.SearchModel;
|
|
||||||
using AutomobilePlantContracts.StoragesContracts;
|
|
||||||
using AutomobilePlantContracts.ViewModel;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantBusinessLogic.BusinessLogics
|
|
||||||
{
|
|
||||||
public class CarLogic : ICarLogic
|
|
||||||
{
|
|
||||||
private readonly ILogger _logger;
|
|
||||||
private readonly ICarStorage _carStorage;
|
|
||||||
public CarLogic(ILogger<CarLogic> logger, ICarStorage carStorage)
|
|
||||||
{
|
|
||||||
_logger = logger;
|
|
||||||
_carStorage = carStorage;
|
|
||||||
}
|
|
||||||
public List<CarViewModel>? ReadList(CarSearchModel? model)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("ReadList. CarName:{CarName}.Id:{ Id}", model?.CarName, model?.Id);
|
|
||||||
var list = model == null ? _carStorage.GetFullList() : _carStorage.GetFilteredList(model);
|
|
||||||
if (list == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("ReadList return null list");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
public CarViewModel? ReadElement(CarSearchModel model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(model));
|
|
||||||
}
|
|
||||||
_logger.LogInformation("ReadElement. CarName:{CarName}. Id:{ Id}", model.CarName, model.Id);
|
|
||||||
var element = _carStorage.GetElement(model);
|
|
||||||
if (element == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("ReadElement element not found");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
|
|
||||||
return element;
|
|
||||||
}
|
|
||||||
public bool Create(CarBindingModel model)
|
|
||||||
{
|
|
||||||
CheckModel(model);
|
|
||||||
if (_carStorage.Insert(model) == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Insert operation failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
public bool Update(CarBindingModel model)
|
|
||||||
{
|
|
||||||
CheckModel(model);
|
|
||||||
if (_carStorage.Update(model) == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Update operation failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
public bool Delete(CarBindingModel model)
|
|
||||||
{
|
|
||||||
CheckModel(model, false);
|
|
||||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
|
||||||
if (_carStorage.Delete(model) == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Delete operation failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
private void CheckModel(CarBindingModel model, bool withParams =
|
|
||||||
true)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(model));
|
|
||||||
}
|
|
||||||
if (!withParams)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (string.IsNullOrEmpty(model.CarName))
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("Нет названия изделия", nameof(model.CarName));
|
|
||||||
}
|
|
||||||
if (model.Price <= 0)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("Цена изделия должна быть больше 0", nameof(model.Price));
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Car. CarName:{CarName}.Cost:{ Cost}. Id: { Id}", model.CarName, model.Price, model.Id);
|
|
||||||
var element = _carStorage.GetElement(new CarSearchModel
|
|
||||||
{
|
|
||||||
CarName = model.CarName
|
|
||||||
});
|
|
||||||
if (element != null && element.Id != model.Id)
|
|
||||||
{
|
|
||||||
throw new InvalidOperationException("Изделие с таким названием уже есть");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,129 +0,0 @@
|
|||||||
using AutomobilePlantContracts.BindingModels;
|
|
||||||
using AutomobilePlantContracts.BusinessLogicsContracts;
|
|
||||||
using AutomobilePlantContracts.SearchModel;
|
|
||||||
using AutomobilePlantContracts.StoragesContracts;
|
|
||||||
using AutomobilePlantContracts.ViewModel;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Text.RegularExpressions;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantBusinessLogic.BusinessLogics
|
|
||||||
{
|
|
||||||
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. ClientName:{ClientFIO}.Id:{ Id}", model?.ClientFIO, model?.Id);
|
|
||||||
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. ClientName:{ClientFIO}. Id:{ Id}", model.ClientFIO, model.Id);
|
|
||||||
var element = _clientStorage.GetElement(model);
|
|
||||||
if (element == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("ReadElement element not found");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
|
|
||||||
return element;
|
|
||||||
}
|
|
||||||
public bool Create(ClientBindingModel model)
|
|
||||||
{
|
|
||||||
CheckModel(model);
|
|
||||||
if (_clientStorage.Insert(model) == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Insert operation failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
private void CheckModel(ClientBindingModel model, bool withParams =
|
|
||||||
true)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(model));
|
|
||||||
}
|
|
||||||
if (!withParams)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (string.IsNullOrEmpty(model.ClientFIO))
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("Нет имени клиента", nameof(model.ClientFIO));
|
|
||||||
}
|
|
||||||
string email = model.Email;
|
|
||||||
Regex regex = new Regex(@"^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$");
|
|
||||||
Match match = regex.Match(email);
|
|
||||||
if (match.Success)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("Не верная почта клиента", nameof(model.Email));
|
|
||||||
}
|
|
||||||
if (string.IsNullOrEmpty(model.Password))
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("Не верный пароль клиента", nameof(model.Password));
|
|
||||||
}
|
|
||||||
string password = model.Password;
|
|
||||||
Regex regexPass = new Regex(@"^((\w+\d+\W+)|(\w+\W+\d+)|(\d+\w+\W+)|(\d+\W+\w+)|(\W+\w+\d+)|(\W+\d+\w+))[\w\d\W]*$");
|
|
||||||
Match matchPass = regexPass.Match(password);
|
|
||||||
if (!matchPass.Success)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("Не верный пароль клиента", nameof(model.Password));
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Client. ClientName:{ClientName}. Id: { Id}", model.ClientFIO, model.Id);
|
|
||||||
var element = _clientStorage.GetElement(new ClientSearchModel
|
|
||||||
{
|
|
||||||
Email = model.Email
|
|
||||||
});
|
|
||||||
if (element != null && element.Id != model.Id )
|
|
||||||
{
|
|
||||||
throw new InvalidOperationException("Клиент с таким логином уже есть");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,114 +0,0 @@
|
|||||||
using AutomobilePlantContracts.BindingModels;
|
|
||||||
using AutomobilePlantContracts.BusinessLogicsContracts;
|
|
||||||
using AutomobilePlantContracts.SearchModel;
|
|
||||||
using AutomobilePlantContracts.StoragesContracts;
|
|
||||||
using AutomobilePlantContracts.ViewModel;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
|
|
||||||
namespace AutomobilePlantBusinessLogic.BusinessLogics
|
|
||||||
{
|
|
||||||
public class ComponentLogic : IComponentLogic
|
|
||||||
{
|
|
||||||
private readonly ILogger _logger;
|
|
||||||
private readonly IComponentStorage _componentStorage;
|
|
||||||
public ComponentLogic(ILogger<ComponentLogic> logger, IComponentStorage
|
|
||||||
componentStorage)
|
|
||||||
{
|
|
||||||
_logger = logger;
|
|
||||||
_componentStorage = componentStorage;
|
|
||||||
}
|
|
||||||
public List<ComponentViewModel>? ReadList(ComponentSearchModel? model)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("ReadList. ComponentName:{ComponentName}.Id:{ Id}", model?.ComponentName, model?.Id);
|
|
||||||
var list = model == null ? _componentStorage.GetFullList() :_componentStorage.GetFilteredList(model);
|
|
||||||
if (list == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("ReadList return null list");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
public ComponentViewModel? ReadElement(ComponentSearchModel model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(model));
|
|
||||||
}
|
|
||||||
_logger.LogInformation("ReadElement. ComponentName:{ComponentName}. Id:{ Id}", model.ComponentName, model.Id);
|
|
||||||
var element = _componentStorage.GetElement(model);
|
|
||||||
if (element == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("ReadElement element not found");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
|
|
||||||
return element;
|
|
||||||
}
|
|
||||||
public bool Create(ComponentBindingModel model)
|
|
||||||
{
|
|
||||||
CheckModel(model);
|
|
||||||
if (_componentStorage.Insert(model) == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Insert operation failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
public bool Update(ComponentBindingModel model)
|
|
||||||
{
|
|
||||||
CheckModel(model);
|
|
||||||
if (_componentStorage.Update(model) == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Update operation failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
public bool Delete(ComponentBindingModel model)
|
|
||||||
{
|
|
||||||
CheckModel(model, false);
|
|
||||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
|
||||||
if (_componentStorage.Delete(model) == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Delete operation failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
private void CheckModel(ComponentBindingModel model, bool withParams =
|
|
||||||
true)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(model));
|
|
||||||
}
|
|
||||||
if (!withParams)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (string.IsNullOrEmpty(model.ComponentName))
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("Нет названия компонента",nameof(model.ComponentName));
|
|
||||||
}
|
|
||||||
if (model.Cost <= 0)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("Цена компонента должна быть больше 0", nameof(model.Cost));
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Component. ComponentName:{ComponentName}.Cost:{ Cost}. Id: { Id}", model.ComponentName, model.Cost, model.Id);
|
|
||||||
var element = _componentStorage.GetElement(new ComponentSearchModel
|
|
||||||
{
|
|
||||||
ComponentName = model.ComponentName
|
|
||||||
});
|
|
||||||
if (element != null && element.Id != model.Id)
|
|
||||||
{
|
|
||||||
throw new InvalidOperationException("Компонент с таким названием уже есть");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,122 +0,0 @@
|
|||||||
using AutomobilePlantContracts.BindingModels;
|
|
||||||
using AutomobilePlantContracts.BusinessLogicsContracts;
|
|
||||||
using AutomobilePlantContracts.SearchModel;
|
|
||||||
using AutomobilePlantContracts.StoragesContracts;
|
|
||||||
using AutomobilePlantContracts.ViewModel;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantBusinessLogic.BusinessLogics
|
|
||||||
{
|
|
||||||
public class ImplementerLogic : IImplementerLogic
|
|
||||||
{
|
|
||||||
private readonly ILogger _logger;
|
|
||||||
private readonly IImplementerStorage _implementerStorage;
|
|
||||||
public ImplementerLogic(ILogger<ImplementerLogic> logger, IImplementerStorage
|
|
||||||
implementerStorage)
|
|
||||||
{
|
|
||||||
_logger = logger;
|
|
||||||
_implementerStorage = implementerStorage;
|
|
||||||
}
|
|
||||||
public List<ImplementerViewModel>? ReadList(ImplementerSearchModel? model)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("ReadList. ImplementerName:{ImplementerFIO}.Id:{ Id}", model?.ImplementerFIO, model?.Id);
|
|
||||||
var list = model == null ? _implementerStorage.GetFullList() : _implementerStorage.GetFilteredList(model);
|
|
||||||
if (list == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("ReadList return null list");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
public ImplementerViewModel? ReadElement(ImplementerSearchModel model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(model));
|
|
||||||
}
|
|
||||||
_logger.LogInformation("ReadElement. ImplementerName:{ImplementerFIO}. Id:{ Id}", model.ImplementerFIO, model.Id);
|
|
||||||
var element = _implementerStorage.GetElement(model);
|
|
||||||
if (element == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("ReadElement element not found");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
|
|
||||||
return element;
|
|
||||||
}
|
|
||||||
public bool Create(ImplementerBindingModel model)
|
|
||||||
{
|
|
||||||
CheckModel(model);
|
|
||||||
if (_implementerStorage.Insert(model) == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Insert operation failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
public bool Update(ImplementerBindingModel model)
|
|
||||||
{
|
|
||||||
CheckModel(model);
|
|
||||||
if (_implementerStorage.Update(model) == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Update operation failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
public bool Delete(ImplementerBindingModel model)
|
|
||||||
{
|
|
||||||
CheckModel(model, false);
|
|
||||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
|
||||||
if (_implementerStorage.Delete(model) == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Delete operation failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
private void CheckModel(ImplementerBindingModel model, bool withParams =
|
|
||||||
true)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(model));
|
|
||||||
}
|
|
||||||
if (!withParams)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (string.IsNullOrEmpty(model.ImplementerFIO))
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("Нет имени исполнителя", nameof(model.ImplementerFIO));
|
|
||||||
}
|
|
||||||
if (model.WorkExperience <0)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("Нет стажа исполнителя", nameof(model.WorkExperience));
|
|
||||||
}
|
|
||||||
if (model.Qualification < 0)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("Нет квалификации исполнителя", nameof(model.Qualification));
|
|
||||||
}
|
|
||||||
if (string.IsNullOrEmpty(model.Password))
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("Нет пароля клиента", nameof(model.Password));
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Implementer. ImplementerName:{ImplementerName}. Id: { Id}", model.ImplementerFIO, model.Id);
|
|
||||||
var element = _implementerStorage.GetElement(new ImplementerSearchModel
|
|
||||||
{
|
|
||||||
ImplementerFIO = model.ImplementerFIO
|
|
||||||
});
|
|
||||||
if (element != null && element.Id != model.Id)
|
|
||||||
{
|
|
||||||
throw new InvalidOperationException("Исполнитель с таким логином уже есть");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,75 +0,0 @@
|
|||||||
using AbstractShopContracts.StoragesContracts;
|
|
||||||
using AutomobilePlantContracts.BindingModels;
|
|
||||||
using AutomobilePlantContracts.BusinessLogicsContracts;
|
|
||||||
using AutomobilePlantContracts.SearchModel;
|
|
||||||
using AutomobilePlantContracts.StoragesContracts;
|
|
||||||
using AutomobilePlantContracts.ViewModel;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantBusinessLogic.BusinessLogics
|
|
||||||
{
|
|
||||||
public class MessageLogic : IMessageInfoLogic
|
|
||||||
{
|
|
||||||
private readonly ILogger _logger;
|
|
||||||
private readonly IMessageInfoStorage _messageStorage;
|
|
||||||
public MessageLogic(ILogger<CarLogic> logger, IMessageInfoStorage messageStorage)
|
|
||||||
{
|
|
||||||
_logger = logger;
|
|
||||||
_messageStorage = messageStorage;
|
|
||||||
}
|
|
||||||
public List<MessageInfoViewModel>? ReadList(MessageInfoSearchModel? model)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("ReadList");
|
|
||||||
var list = model == null ? _messageStorage.GetFullList() : _messageStorage.GetFilteredList(model);
|
|
||||||
if (list == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("ReadList return null list");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
public bool Create(MessageInfoBindingModel model)
|
|
||||||
{
|
|
||||||
CheckModel(model);
|
|
||||||
if (_messageStorage.Insert(model) == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Insert operation failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
private void CheckModel(MessageInfoBindingModel model, bool withParams =
|
|
||||||
true)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(model));
|
|
||||||
}
|
|
||||||
if (!withParams)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (string.IsNullOrEmpty(model.MessageId))
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("Нет айди письма", nameof(model.MessageId));
|
|
||||||
}
|
|
||||||
if (string.IsNullOrEmpty(model.Body))
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("Нет тела письма", nameof(model.Body));
|
|
||||||
}
|
|
||||||
if (string.IsNullOrEmpty(model.SenderName))
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("Нет отправителя письма", nameof(model.SenderName));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,187 +0,0 @@
|
|||||||
using AutomobilePlantBusinessLogic.MailWorker;
|
|
||||||
using AutomobilePlantContracts.BindingModels;
|
|
||||||
using AutomobilePlantContracts.BusinessLogicsContracts;
|
|
||||||
using AutomobilePlantContracts.SearchModel;
|
|
||||||
using AutomobilePlantContracts.StoragesContracts;
|
|
||||||
using AutomobilePlantContracts.ViewModel;
|
|
||||||
using AutomobilePlantDataModels.Enums;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantBusinessLogic.BusinessLogics
|
|
||||||
{
|
|
||||||
|
|
||||||
public class OrderLogic : IOrderLogic
|
|
||||||
{
|
|
||||||
private readonly ILogger _logger;
|
|
||||||
private readonly IOrderStorage _orderStorage;
|
|
||||||
private readonly IClientStorage _clientStorage;
|
|
||||||
private readonly AbstractMailWorker _mailKitWorker;
|
|
||||||
public OrderLogic(ILogger<ComponentLogic> logger, IOrderStorage orderStorage, IClientStorage clientStorage, AbstractMailWorker abstractMailWorker)
|
|
||||||
{
|
|
||||||
_logger = logger;
|
|
||||||
_orderStorage = orderStorage;
|
|
||||||
_clientStorage = clientStorage;
|
|
||||||
_mailKitWorker = abstractMailWorker;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool CreateOrder(OrderBindingModel model)
|
|
||||||
{
|
|
||||||
CheckModel(model);
|
|
||||||
|
|
||||||
if (model.Status != OrderStatus.Неизвестен)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Insert operation failed. Order status incorrect.");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
model.Status = OrderStatus.Принят;
|
|
||||||
var newOrder = _orderStorage.Insert(model);
|
|
||||||
|
|
||||||
if (newOrder == null)
|
|
||||||
{
|
|
||||||
model.Status = OrderStatus.Неизвестен;
|
|
||||||
_logger.LogWarning("Insert operation failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
_mailKitWorker.MailSendAsync(new MailSendInfoBindingModel
|
|
||||||
{
|
|
||||||
MailAddress = (_clientStorage.GetElement(new ClientSearchModel { Id = newOrder.ClientId})).Email,
|
|
||||||
Subject = $"Заказ номер",
|
|
||||||
Text = $"Ваш заказ успешно принят. Машина: {model.CarName} в количестве: {model.Count} выйдет на сумму: {model.Sum}"
|
|
||||||
});
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool StatusUpdate(OrderBindingModel model, OrderStatus newStatus)
|
|
||||||
{
|
|
||||||
var viewModel = _orderStorage.GetElement(new OrderSearchModel { Id = model.Id });
|
|
||||||
if (viewModel == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(model));
|
|
||||||
}
|
|
||||||
if (viewModel.Status + 1 != newStatus)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Update operation failed. Order status incorrect.");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
model.Status = newStatus;
|
|
||||||
model.DateCreate = viewModel.DateCreate;
|
|
||||||
model.Sum = viewModel.Sum;
|
|
||||||
model.Count = viewModel.Count;
|
|
||||||
model.DateImplement = viewModel.DateImplement;
|
|
||||||
model.CarId = viewModel.CarId;
|
|
||||||
model.CarName = viewModel.CarName;
|
|
||||||
model.ClientId=viewModel.ClientId;
|
|
||||||
model.ClientName = viewModel.ClientName;
|
|
||||||
if (viewModel.ImplementerId.HasValue)
|
|
||||||
{
|
|
||||||
model.ImplementerId = viewModel.ImplementerId;
|
|
||||||
}
|
|
||||||
if(!string.IsNullOrEmpty(viewModel.ImplementerName)){
|
|
||||||
model.ImplementerName = viewModel.ImplementerName;
|
|
||||||
}
|
|
||||||
if (model.Status == OrderStatus.Готов) {
|
|
||||||
model.DateImplement = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
model.DateImplement = viewModel.DateImplement;
|
|
||||||
|
|
||||||
}
|
|
||||||
CheckModel(model);
|
|
||||||
if (_orderStorage.Update(model) == null)
|
|
||||||
{
|
|
||||||
model.Status--;
|
|
||||||
_logger.LogWarning("Update operation failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
_mailKitWorker.MailSendAsync(new MailSendInfoBindingModel
|
|
||||||
{
|
|
||||||
MailAddress = (_clientStorage.GetElement(new ClientSearchModel { Id = model.ClientId })).Email,
|
|
||||||
Subject = $"Заказ номер {model.Id}",
|
|
||||||
Text = $"Ваш заказ переведен в статус {newStatus}"
|
|
||||||
});
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool DeliveryOrder(OrderBindingModel model)
|
|
||||||
{
|
|
||||||
return StatusUpdate(model, OrderStatus.Выдан);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool FinishOrder(OrderBindingModel model)
|
|
||||||
{
|
|
||||||
return StatusUpdate(model, OrderStatus.Готов);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool TakeOrderInWork(OrderBindingModel model)
|
|
||||||
{
|
|
||||||
return StatusUpdate(model, OrderStatus.Выполняется);
|
|
||||||
}
|
|
||||||
public List<OrderViewModel>? ReadList(OrderSearchModel? model)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Order. OrderId:{Id}", model?.Id);
|
|
||||||
|
|
||||||
var list = model == null ? _orderStorage.GetFullList() : _orderStorage.GetFilteredList(model);
|
|
||||||
|
|
||||||
if (list == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("ReadList return null list");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
private void CheckModel(OrderBindingModel model, bool withParams = true)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(model));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!withParams)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (model.Id < 0)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("Некорректный идентификатор изделия", nameof(model.Id));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (model.Count <= 0)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("Количество изделий в заказе должно быть больше 0", nameof(model.Count));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (model.Sum <= 0)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("Сумма заказа должна быть больше 0", nameof(model.Sum));
|
|
||||||
}
|
|
||||||
|
|
||||||
_logger.LogInformation("Order. OrderId:{Id}.Sum:{ Sum}. WorkId: { WorkId}", model.Id, model.Sum, model.Id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public OrderViewModel? ReadElement(OrderSearchModel model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(model));
|
|
||||||
}
|
|
||||||
var element = _orderStorage.GetElement(model);
|
|
||||||
if (element == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("ReadElement element not found");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
|
|
||||||
return element;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,135 +0,0 @@
|
|||||||
using AutomobilePlantBusinessLogic.OfficePackage;
|
|
||||||
using AutomobilePlantBusinessLogic.OfficePackage.HelperModels;
|
|
||||||
using AutomobilePlantContracts.BindingModels;
|
|
||||||
using AutomobilePlantContracts.BusinessLogicsContracts;
|
|
||||||
using AutomobilePlantContracts.SearchModel;
|
|
||||||
using AutomobilePlantContracts.StoragesContracts;
|
|
||||||
using AutomobilePlantContracts.ViewModel;
|
|
||||||
|
|
||||||
namespace AutomobilePlantBusinessLogic.BusinessLogics
|
|
||||||
{
|
|
||||||
public class ReportLogic : IReportLogic
|
|
||||||
{
|
|
||||||
private readonly IComponentStorage _componentStorage;
|
|
||||||
|
|
||||||
private readonly ICarStorage _carStorage;
|
|
||||||
|
|
||||||
private readonly IOrderStorage _orderStorage;
|
|
||||||
|
|
||||||
private readonly AbstractSaveToExcel _saveToExcel;
|
|
||||||
|
|
||||||
private readonly AbstractSaveToWord _saveToWord;
|
|
||||||
|
|
||||||
private readonly AbstractSaveToPdf _saveToPdf;
|
|
||||||
|
|
||||||
public ReportLogic(ICarStorage carStorage, IComponentStorage componentStorage, IOrderStorage orderStorage,
|
|
||||||
AbstractSaveToExcel saveToExcel, AbstractSaveToWord saveToWord, AbstractSaveToPdf saveToPdf)
|
|
||||||
{
|
|
||||||
_carStorage = carStorage;
|
|
||||||
_componentStorage = componentStorage;
|
|
||||||
_orderStorage = orderStorage;
|
|
||||||
|
|
||||||
_saveToExcel = saveToExcel;
|
|
||||||
_saveToWord = saveToWord;
|
|
||||||
_saveToPdf = saveToPdf;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Получение списка компонент с указанием, в каких изделиях используются
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public List<ReportCarComponentViewModel> GetCarComponent()
|
|
||||||
{
|
|
||||||
var components = _componentStorage.GetFullList();
|
|
||||||
|
|
||||||
var cars = _carStorage.GetFullList();
|
|
||||||
|
|
||||||
var list = new List<ReportCarComponentViewModel>();
|
|
||||||
|
|
||||||
foreach (var car in cars)
|
|
||||||
{
|
|
||||||
var record = new ReportCarComponentViewModel
|
|
||||||
{
|
|
||||||
CarName = car.CarName,
|
|
||||||
Components = new List<(string, int)>(),
|
|
||||||
TotalCount = 0
|
|
||||||
};
|
|
||||||
foreach (var component in components)
|
|
||||||
{
|
|
||||||
if (car.CarComponents.ContainsKey(component.Id))
|
|
||||||
{
|
|
||||||
record.Components.Add(new (component.ComponentName, car.CarComponents[component.Id].Item2));
|
|
||||||
record.TotalCount += car.CarComponents[component.Id].Item2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
list.Add(record);
|
|
||||||
}
|
|
||||||
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Получение списка заказов за определенный период
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="model"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public List<ReportOrdersViewModel> GetOrders(ReportBindingModel model)
|
|
||||||
{
|
|
||||||
return _orderStorage.GetFilteredList(new OrderSearchModel { DateFrom = model.DateFrom, DateTo = model.DateTo })
|
|
||||||
.Select(x => new ReportOrdersViewModel
|
|
||||||
{
|
|
||||||
Id = x.Id,
|
|
||||||
DateCreate = x.DateCreate,
|
|
||||||
CarName = x.CarName,
|
|
||||||
Status=x.Status.ToString(),
|
|
||||||
Sum = x.Sum
|
|
||||||
})
|
|
||||||
.ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Сохранение компонент в файл-Word
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="model"></param>
|
|
||||||
public void SaveComponentsToWordFile(ReportBindingModel model)
|
|
||||||
{
|
|
||||||
_saveToWord.CreateDoc(new WordInfo
|
|
||||||
{
|
|
||||||
FileName = model.FileName,
|
|
||||||
Title = "Список компонент",
|
|
||||||
Components = _componentStorage.GetFullList()
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Сохранение компонент с указаеним продуктов в файл-Excel
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="model"></param>
|
|
||||||
public void SaveCarComponentToExcelFile(ReportBindingModel model)
|
|
||||||
{
|
|
||||||
_saveToExcel.CreateReport(new ExcelInfo
|
|
||||||
{
|
|
||||||
FileName = model.FileName,
|
|
||||||
Title = "Список компонент",
|
|
||||||
CarComponents = GetCarComponent()
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Сохранение заказов в файл-Pdf
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="model"></param>
|
|
||||||
public void SaveOrdersToPdfFile(ReportBindingModel model)
|
|
||||||
{
|
|
||||||
_saveToPdf.CreateDoc(new PdfInfo
|
|
||||||
{
|
|
||||||
FileName = model.FileName,
|
|
||||||
Title = "Список заказов",
|
|
||||||
DateFrom = DateTime.SpecifyKind(model.DateFrom!.Value, DateTimeKind.Utc),
|
|
||||||
DateTo = DateTime.SpecifyKind(model.DateTo!.Value, DateTimeKind.Utc),
|
|
||||||
Orders = GetOrders(model)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,157 +0,0 @@
|
|||||||
using AutomobilePlantContracts.BindingModels;
|
|
||||||
using AutomobilePlantContracts.BusinessLogicsContracts;
|
|
||||||
using AutomobilePlantContracts.SearchModel;
|
|
||||||
using AutomobilePlantContracts.ViewModel;
|
|
||||||
using AutomobilePlantDataModels.Enums;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantBusinessLogic.BusinessLogics
|
|
||||||
{
|
|
||||||
public class WorkModeling : IWorkProcess
|
|
||||||
{
|
|
||||||
private readonly ILogger _logger;
|
|
||||||
|
|
||||||
private readonly Random _rnd;
|
|
||||||
|
|
||||||
private IOrderLogic? _orderLogic;
|
|
||||||
|
|
||||||
public WorkModeling(ILogger<WorkModeling> logger)
|
|
||||||
{
|
|
||||||
_logger = logger;
|
|
||||||
_rnd = new Random(1000);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void DoWork(IImplementerLogic implementerLogic, IOrderLogic orderLogic)
|
|
||||||
{
|
|
||||||
_orderLogic = orderLogic;
|
|
||||||
var implementers = implementerLogic.ReadList(null);
|
|
||||||
if (implementers == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("DoWork. Implementers is null");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var orders = _orderLogic.ReadList(new OrderSearchModel { Status = OrderStatus.Принят });
|
|
||||||
if (orders == null || orders.Count == 0)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("DoWork. Orders is null or empty");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_logger.LogDebug("DoWork for {Count} orders", orders.Count);
|
|
||||||
foreach (var implementer in implementers)
|
|
||||||
{
|
|
||||||
Task.Run(() => WorkerWorkAsync(implementer, orders));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Иммитация работы исполнителя
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="implementer"></param>
|
|
||||||
/// <param name="orders"></param>
|
|
||||||
private async Task WorkerWorkAsync(ImplementerViewModel implementer, List<OrderViewModel> orders)
|
|
||||||
{
|
|
||||||
if (_orderLogic == null || implementer == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
await RunOrderInWork(implementer);
|
|
||||||
|
|
||||||
await Task.Run(() =>
|
|
||||||
{
|
|
||||||
foreach (var order in orders)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_logger.LogDebug("DoWork. Worker {Id} try get order {Order}", implementer.Id, order.Id);
|
|
||||||
// пытаемся назначить заказ на исполнителя
|
|
||||||
_orderLogic.TakeOrderInWork(new OrderBindingModel
|
|
||||||
{
|
|
||||||
Id = order.Id,
|
|
||||||
ImplementerId = implementer.Id,
|
|
||||||
ImplementerName = implementer.ImplementerFIO
|
|
||||||
|
|
||||||
|
|
||||||
});
|
|
||||||
// делаем работу
|
|
||||||
Thread.Sleep(implementer.WorkExperience * _rnd.Next(100, 1000) * order.Count);
|
|
||||||
_logger.LogDebug("DoWork. Worker {Id} finish order {Order}", implementer.Id, order.Id);
|
|
||||||
_orderLogic.FinishOrder(new OrderBindingModel
|
|
||||||
{
|
|
||||||
Id = order.Id,
|
|
||||||
|
|
||||||
|
|
||||||
});
|
|
||||||
// отдыхаем
|
|
||||||
Thread.Sleep(implementer.Qualification * _rnd.Next(10, 100));
|
|
||||||
}
|
|
||||||
// кто-то мог уже перехватить заказ, игнорируем ошибку
|
|
||||||
catch (InvalidOperationException ex)
|
|
||||||
{
|
|
||||||
_logger.LogWarning(ex, "Error try get work");
|
|
||||||
}
|
|
||||||
// заканчиваем выполнение имитации в случае иной ошибки
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Error while do work");
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Ищем заказ, которые уже в работе (вдруг исполнителя прервали)
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="implementer"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
private async Task RunOrderInWork(ImplementerViewModel implementer)
|
|
||||||
{
|
|
||||||
if (_orderLogic == null || implementer == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var runOrder = await Task.Run(() => _orderLogic.ReadElement(new OrderSearchModel
|
|
||||||
{
|
|
||||||
ImplementerId = implementer.Id,
|
|
||||||
Status = OrderStatus.Выполняется
|
|
||||||
}));
|
|
||||||
if (runOrder == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_logger.LogDebug("DoWork. Worker {Id} back to order {Order}", implementer.Id, runOrder.Id);
|
|
||||||
// доделываем работу
|
|
||||||
Thread.Sleep(implementer.WorkExperience * _rnd.Next(100, 300) * runOrder.Count);
|
|
||||||
_logger.LogDebug("DoWork. Worker {Id} finish order {Order}", implementer.Id, runOrder.Id);
|
|
||||||
_orderLogic.FinishOrder(new OrderBindingModel
|
|
||||||
{
|
|
||||||
Id = runOrder.Id,
|
|
||||||
|
|
||||||
|
|
||||||
});
|
|
||||||
// отдыхаем
|
|
||||||
Thread.Sleep(implementer.Qualification * _rnd.Next(10, 100));
|
|
||||||
}
|
|
||||||
// заказа может не быть, просто игнорируем ошибку
|
|
||||||
catch (InvalidOperationException ex)
|
|
||||||
{
|
|
||||||
_logger.LogWarning(ex, "Error try get work");
|
|
||||||
}
|
|
||||||
// а может возникнуть иная ошибка, тогда просто заканчиваем выполнение имитации
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Error while do work");
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,97 +0,0 @@
|
|||||||
using AutomobilePlantContracts.BindingModels;
|
|
||||||
using AutomobilePlantContracts.BusinessLogicsContracts;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantBusinessLogic.MailWorker
|
|
||||||
{
|
|
||||||
public abstract class AbstractMailWorker
|
|
||||||
{
|
|
||||||
protected string _mailLogin = string.Empty;
|
|
||||||
|
|
||||||
protected string _mailPassword = string.Empty;
|
|
||||||
|
|
||||||
protected string _smtpClientHost = string.Empty;
|
|
||||||
|
|
||||||
protected int _smtpClientPort;
|
|
||||||
|
|
||||||
protected string _popHost = string.Empty;
|
|
||||||
|
|
||||||
protected int _popPort;
|
|
||||||
|
|
||||||
private readonly IMessageInfoLogic _messageInfoLogic;
|
|
||||||
|
|
||||||
private readonly ILogger _logger;
|
|
||||||
|
|
||||||
public AbstractMailWorker(ILogger<AbstractMailWorker> logger, IMessageInfoLogic messageInfoLogic)
|
|
||||||
{
|
|
||||||
_logger = logger;
|
|
||||||
_messageInfoLogic = messageInfoLogic;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void MailConfig(MailConfigBindingModel config)
|
|
||||||
{
|
|
||||||
_mailLogin = config.MailLogin;
|
|
||||||
_mailPassword = config.MailPassword;
|
|
||||||
_smtpClientHost = config.SmtpClientHost;
|
|
||||||
_smtpClientPort = config.SmtpClientPort;
|
|
||||||
_popHost = config.PopHost;
|
|
||||||
_popPort = config.PopPort;
|
|
||||||
_logger.LogDebug("Config: {login}, {password}, {clientHost}, {clientPOrt}, {popHost}, {popPort}", _mailLogin, _mailPassword, _smtpClientHost, _smtpClientPort, _popHost, _popPort);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async void MailSendAsync(MailSendInfoBindingModel info)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(_mailLogin) || string.IsNullOrEmpty(_mailPassword))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(_smtpClientHost) || _smtpClientPort == 0)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(info.MailAddress) || string.IsNullOrEmpty(info.Subject) || string.IsNullOrEmpty(info.Text))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_logger.LogDebug("Send Mail: {To}, {Subject}", info.MailAddress, info.Subject);
|
|
||||||
await SendMailAsync(info);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async void MailCheck()
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(_mailLogin) || string.IsNullOrEmpty(_mailPassword))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(_popHost) || _popPort == 0)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_messageInfoLogic == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var list = await ReceiveMailAsync();
|
|
||||||
_logger.LogDebug("Check Mail: {Count} new mails", list.Count);
|
|
||||||
foreach (var mail in list)
|
|
||||||
{
|
|
||||||
_messageInfoLogic.Create(mail);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected abstract Task SendMailAsync(MailSendInfoBindingModel info);
|
|
||||||
|
|
||||||
protected abstract Task<List<MessageInfoBindingModel>> ReceiveMailAsync();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,83 +0,0 @@
|
|||||||
using AutomobilePlantContracts.BindingModels;
|
|
||||||
using AutomobilePlantContracts.BusinessLogicsContracts;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using MailKit.Net.Pop3;
|
|
||||||
using MailKit.Security;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using System.Net;
|
|
||||||
using System.Net.Mail;
|
|
||||||
using System.Text;
|
|
||||||
using AutomobilePlantContracts.StoragesContracts;
|
|
||||||
using AutomobilePlantContracts.SearchModel;
|
|
||||||
|
|
||||||
namespace AutomobilePlantBusinessLogic.MailWorker
|
|
||||||
{
|
|
||||||
public class MailKitWorker : AbstractMailWorker
|
|
||||||
{
|
|
||||||
private readonly IClientStorage _clientStorage;
|
|
||||||
public MailKitWorker(ILogger<MailKitWorker> logger, IMessageInfoLogic messageInfoLogic, IClientStorage clientStorage) : base(logger, messageInfoLogic) { _clientStorage = clientStorage; }
|
|
||||||
|
|
||||||
protected override async Task SendMailAsync(MailSendInfoBindingModel info)
|
|
||||||
{
|
|
||||||
using var objMailMessage = new MailMessage();
|
|
||||||
using var objSmtpClient = new SmtpClient(_smtpClientHost, _smtpClientPort);
|
|
||||||
try
|
|
||||||
{
|
|
||||||
objMailMessage.From = new MailAddress(_mailLogin);
|
|
||||||
objMailMessage.To.Add(new MailAddress(info.MailAddress));
|
|
||||||
objMailMessage.Subject = info.Subject;
|
|
||||||
objMailMessage.Body = info.Text;
|
|
||||||
objMailMessage.SubjectEncoding = Encoding.UTF8;
|
|
||||||
objMailMessage.BodyEncoding = Encoding.UTF8;
|
|
||||||
|
|
||||||
objSmtpClient.UseDefaultCredentials = false;
|
|
||||||
objSmtpClient.EnableSsl = true;
|
|
||||||
objSmtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
|
|
||||||
objSmtpClient.Credentials = new NetworkCredential(_mailLogin, _mailPassword);
|
|
||||||
|
|
||||||
await Task.Run(() => objSmtpClient.Send(objMailMessage));
|
|
||||||
}
|
|
||||||
catch (Exception)
|
|
||||||
{
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override async Task<List<MessageInfoBindingModel>> ReceiveMailAsync()
|
|
||||||
{
|
|
||||||
var list = new List<MessageInfoBindingModel>();
|
|
||||||
using var client = new Pop3Client();
|
|
||||||
await Task.Run(() =>
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
client.Connect(_popHost, _popPort, SecureSocketOptions.SslOnConnect);
|
|
||||||
client.Authenticate(_mailLogin, _mailPassword);
|
|
||||||
for (int i = 0; i < client.Count; i++)
|
|
||||||
{
|
|
||||||
var message = client.GetMessage(i);
|
|
||||||
foreach (var mail in message.From.Mailboxes)
|
|
||||||
{
|
|
||||||
list.Add(new MessageInfoBindingModel
|
|
||||||
{
|
|
||||||
DateDelivery = DateTime.SpecifyKind(message.Date.DateTime, DateTimeKind.Utc),
|
|
||||||
ClientId = _clientStorage.GetElement(new ClientSearchModel { Email = mail.Address }).Id,
|
|
||||||
MessageId = message.MessageId,
|
|
||||||
SenderName = mail.Address,
|
|
||||||
Subject = message.Subject,
|
|
||||||
Body = message.TextBody
|
|
||||||
}); ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (AuthenticationException)
|
|
||||||
{ }
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
client.Disconnect(true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,112 +0,0 @@
|
|||||||
using AutomobilePlantBusinessLogic.OfficePackage.HelperEnums;
|
|
||||||
using AutomobilePlantBusinessLogic.OfficePackage.HelperModels;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantBusinessLogic.OfficePackage
|
|
||||||
{
|
|
||||||
public abstract class AbstractSaveToExcel
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Создание отчета
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="info"></param>
|
|
||||||
public void CreateReport(ExcelInfo info)
|
|
||||||
{
|
|
||||||
CreateExcel(info);
|
|
||||||
|
|
||||||
InsertCellInWorksheet(new ExcelCellParameters
|
|
||||||
{
|
|
||||||
ColumnName = "A",
|
|
||||||
RowIndex = 1,
|
|
||||||
Text = info.Title,
|
|
||||||
StyleInfo = ExcelStyleInfoType.Title
|
|
||||||
});
|
|
||||||
|
|
||||||
MergeCells(new ExcelMergeParameters
|
|
||||||
{
|
|
||||||
CellFromName = "A1",
|
|
||||||
CellToName = "C1"
|
|
||||||
});
|
|
||||||
|
|
||||||
uint rowIndex = 2;
|
|
||||||
foreach (var pc in info.CarComponents)
|
|
||||||
{
|
|
||||||
InsertCellInWorksheet(new ExcelCellParameters
|
|
||||||
{
|
|
||||||
ColumnName = "A",
|
|
||||||
RowIndex = rowIndex,
|
|
||||||
Text = pc.CarName,
|
|
||||||
StyleInfo = ExcelStyleInfoType.Text
|
|
||||||
});
|
|
||||||
rowIndex++;
|
|
||||||
|
|
||||||
foreach (var (Component, Count) in pc.Components)
|
|
||||||
{
|
|
||||||
InsertCellInWorksheet(new ExcelCellParameters
|
|
||||||
{
|
|
||||||
ColumnName = "B",
|
|
||||||
RowIndex = rowIndex,
|
|
||||||
Text = Component,
|
|
||||||
StyleInfo = ExcelStyleInfoType.TextWithBroder
|
|
||||||
});
|
|
||||||
|
|
||||||
InsertCellInWorksheet(new ExcelCellParameters
|
|
||||||
{
|
|
||||||
ColumnName = "C",
|
|
||||||
RowIndex = rowIndex,
|
|
||||||
Text = Count.ToString(),
|
|
||||||
StyleInfo = ExcelStyleInfoType.TextWithBroder
|
|
||||||
});
|
|
||||||
|
|
||||||
rowIndex++;
|
|
||||||
}
|
|
||||||
|
|
||||||
InsertCellInWorksheet(new ExcelCellParameters
|
|
||||||
{
|
|
||||||
ColumnName = "A",
|
|
||||||
RowIndex = rowIndex,
|
|
||||||
Text = "Итого",
|
|
||||||
StyleInfo = ExcelStyleInfoType.Text
|
|
||||||
});
|
|
||||||
InsertCellInWorksheet(new ExcelCellParameters
|
|
||||||
{
|
|
||||||
ColumnName = "C",
|
|
||||||
RowIndex = rowIndex,
|
|
||||||
Text = pc.TotalCount.ToString(),
|
|
||||||
StyleInfo = ExcelStyleInfoType.Text
|
|
||||||
});
|
|
||||||
rowIndex++;
|
|
||||||
}
|
|
||||||
|
|
||||||
SaveExcel(info);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Создание excel-файла
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="info"></param>
|
|
||||||
protected abstract void CreateExcel(ExcelInfo info);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Добавляем новую ячейку в лист
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="cellParameters"></param>
|
|
||||||
protected abstract void InsertCellInWorksheet(ExcelCellParameters excelParams);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Объединение ячеек
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="mergeParameters"></param>
|
|
||||||
protected abstract void MergeCells(ExcelMergeParameters excelParams);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Сохранение файла
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="info"></param>
|
|
||||||
protected abstract void SaveExcel(ExcelInfo info);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,74 +0,0 @@
|
|||||||
using AutomobilePlantBusinessLogic.OfficePackage.HelperEnums;
|
|
||||||
using AutomobilePlantBusinessLogic.OfficePackage.HelperModels;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantBusinessLogic.OfficePackage
|
|
||||||
{
|
|
||||||
public abstract class AbstractSaveToPdf
|
|
||||||
{
|
|
||||||
public void CreateDoc(PdfInfo info)
|
|
||||||
{
|
|
||||||
CreatePdf(info);
|
|
||||||
CreateParagraph(new PdfParagraph { Text = info.Title, Style = "NormalTitle", ParagraphAlignment = PdfParagraphAlignmentType.Center });
|
|
||||||
CreateParagraph(new PdfParagraph { Text = $"с {info.DateFrom.ToShortDateString()} по {info.DateTo.ToShortDateString()}", Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Center });
|
|
||||||
|
|
||||||
CreateTable(new List<string> { "2cm", "3cm", "6cm", "3cm", "3cm" });
|
|
||||||
|
|
||||||
CreateRow(new PdfRowParameters
|
|
||||||
{
|
|
||||||
Texts = new List<string> { "Номер", "Дата заказа", "Машина","Статус", "Сумма" },
|
|
||||||
Style = "NormalTitle",
|
|
||||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
|
||||||
});
|
|
||||||
|
|
||||||
foreach (var order in info.Orders)
|
|
||||||
{
|
|
||||||
CreateRow(new PdfRowParameters
|
|
||||||
{
|
|
||||||
Texts = new List<string> { order.Id.ToString(), order.DateCreate.ToShortDateString(), order.CarName,order.Status, order.Sum.ToString() },
|
|
||||||
Style = "Normal",
|
|
||||||
ParagraphAlignment = PdfParagraphAlignmentType.Left
|
|
||||||
});
|
|
||||||
}
|
|
||||||
CreateParagraph(new PdfParagraph { Text = $"Итого: {info.Orders.Sum(x => x.Sum)}\t", Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Rigth });
|
|
||||||
|
|
||||||
SavePdf(info);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Создание doc-файла
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="info"></param>
|
|
||||||
protected abstract void CreatePdf(PdfInfo info);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Создание параграфа с текстом
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="title"></param>
|
|
||||||
/// <param name="style"></param>
|
|
||||||
protected abstract void CreateParagraph(PdfParagraph paragraph);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Создание таблицы
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="title"></param>
|
|
||||||
/// <param name="style"></param>
|
|
||||||
protected abstract void CreateTable(List<string> columns);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Создание и заполнение строки
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="rowParameters"></param>
|
|
||||||
protected abstract void CreateRow(PdfRowParameters rowParameters);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Сохранение файла
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="info"></param>
|
|
||||||
protected abstract void SavePdf(PdfInfo info);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,63 +0,0 @@
|
|||||||
using AutomobilePlantBusinessLogic.OfficePackage.HelperEnums;
|
|
||||||
using AutomobilePlantBusinessLogic.OfficePackage.HelperModels;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantBusinessLogic.OfficePackage
|
|
||||||
{
|
|
||||||
public abstract class AbstractSaveToWord
|
|
||||||
{
|
|
||||||
public void CreateDoc(WordInfo info)
|
|
||||||
{
|
|
||||||
CreateWord(info);
|
|
||||||
|
|
||||||
CreateParagraph(new WordParagraph
|
|
||||||
{
|
|
||||||
Texts = new List<(string, WordTextProperties)> { (info.Title, new WordTextProperties { Bold = true, Size = "24", }) },
|
|
||||||
TextProperties = new WordTextProperties
|
|
||||||
{
|
|
||||||
Size = "24",
|
|
||||||
JustificationType = WordJustificationType.Center
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
foreach (var component in info.Components)
|
|
||||||
{
|
|
||||||
CreateParagraph(new WordParagraph
|
|
||||||
{
|
|
||||||
Texts = new List<(string, WordTextProperties)> { (component.ComponentName, new WordTextProperties { Size = "24", Bold=true,}),
|
|
||||||
(component.Cost.ToString(), new WordTextProperties { Size = "24", Bold = false, }) },
|
|
||||||
TextProperties = new WordTextProperties
|
|
||||||
{
|
|
||||||
Size = "24",
|
|
||||||
JustificationType = WordJustificationType.Both
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
SaveWord(info);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Создание doc-файла
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="info"></param>
|
|
||||||
protected abstract void CreateWord(WordInfo info);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Создание абзаца с текстом
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="paragraph"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
protected abstract void CreateParagraph(WordParagraph paragraph);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Сохранение файла
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="info"></param>
|
|
||||||
protected abstract void SaveWord(WordInfo info);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,17 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantBusinessLogic.OfficePackage.HelperEnums
|
|
||||||
{
|
|
||||||
public enum ExcelStyleInfoType
|
|
||||||
{
|
|
||||||
Title,
|
|
||||||
|
|
||||||
Text,
|
|
||||||
|
|
||||||
TextWithBroder
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,17 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantBusinessLogic.OfficePackage.HelperEnums
|
|
||||||
{
|
|
||||||
public enum PdfParagraphAlignmentType
|
|
||||||
{
|
|
||||||
Center,
|
|
||||||
|
|
||||||
Left,
|
|
||||||
|
|
||||||
Rigth
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantBusinessLogic.OfficePackage.HelperEnums
|
|
||||||
{
|
|
||||||
public enum WordJustificationType
|
|
||||||
{
|
|
||||||
Center,
|
|
||||||
|
|
||||||
Both
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,17 +0,0 @@
|
|||||||
using AutomobilePlantBusinessLogic.OfficePackage.HelperEnums;
|
|
||||||
|
|
||||||
namespace AutomobilePlantBusinessLogic.OfficePackage.HelperModels
|
|
||||||
{
|
|
||||||
public class ExcelCellParameters
|
|
||||||
{
|
|
||||||
public string ColumnName { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
public uint RowIndex { get; set; }
|
|
||||||
|
|
||||||
public string Text { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
public string CellReference => $"{ColumnName}{RowIndex}";
|
|
||||||
|
|
||||||
public ExcelStyleInfoType StyleInfo { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,13 +0,0 @@
|
|||||||
using AutomobilePlantContracts.ViewModel;
|
|
||||||
|
|
||||||
namespace AutomobilePlantBusinessLogic.OfficePackage.HelperModels
|
|
||||||
{
|
|
||||||
public class ExcelInfo
|
|
||||||
{
|
|
||||||
public string FileName { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
public string Title { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
public List<ReportCarComponentViewModel> CarComponents { get; set; } = new();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
namespace AutomobilePlantBusinessLogic.OfficePackage.HelperModels
|
|
||||||
{
|
|
||||||
public class ExcelMergeParameters
|
|
||||||
{
|
|
||||||
public string CellFromName { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
public string CellToName { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
public string Merge => $"{CellFromName}:{CellToName}";
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,17 +0,0 @@
|
|||||||
using AutomobilePlantContracts.ViewModel;
|
|
||||||
|
|
||||||
namespace AutomobilePlantBusinessLogic.OfficePackage.HelperModels
|
|
||||||
{
|
|
||||||
public class PdfInfo
|
|
||||||
{
|
|
||||||
public string FileName { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
public string Title { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
public DateTime DateFrom { get; set; }
|
|
||||||
|
|
||||||
public DateTime DateTo { get; set; }
|
|
||||||
|
|
||||||
public List<ReportOrdersViewModel> Orders { get; set; } = new();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,13 +0,0 @@
|
|||||||
using AutomobilePlantBusinessLogic.OfficePackage.HelperEnums;
|
|
||||||
|
|
||||||
namespace AutomobilePlantBusinessLogic.OfficePackage.HelperModels
|
|
||||||
{
|
|
||||||
public class PdfParagraph
|
|
||||||
{
|
|
||||||
public string Text { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
public string Style { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
public PdfParagraphAlignmentType ParagraphAlignment { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,13 +0,0 @@
|
|||||||
using AutomobilePlantBusinessLogic.OfficePackage.HelperEnums;
|
|
||||||
|
|
||||||
namespace AutomobilePlantBusinessLogic.OfficePackage.HelperModels
|
|
||||||
{
|
|
||||||
public class PdfRowParameters
|
|
||||||
{
|
|
||||||
public List<string> Texts { get; set; } = new();
|
|
||||||
|
|
||||||
public string Style { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
public PdfParagraphAlignmentType ParagraphAlignment { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,13 +0,0 @@
|
|||||||
using AutomobilePlantContracts.ViewModel;
|
|
||||||
|
|
||||||
namespace AutomobilePlantBusinessLogic.OfficePackage.HelperModels
|
|
||||||
{
|
|
||||||
public class WordInfo
|
|
||||||
{
|
|
||||||
public string FileName { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
public string Title { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
public List<ComponentViewModel> Components { get; set; } = new();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,9 +0,0 @@
|
|||||||
namespace AutomobilePlantBusinessLogic.OfficePackage.HelperModels
|
|
||||||
{
|
|
||||||
public class WordParagraph
|
|
||||||
{
|
|
||||||
public List<(string, WordTextProperties)> Texts { get; set; } = new();
|
|
||||||
|
|
||||||
public WordTextProperties? TextProperties { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,13 +0,0 @@
|
|||||||
using AutomobilePlantBusinessLogic.OfficePackage.HelperEnums;
|
|
||||||
|
|
||||||
namespace AutomobilePlantBusinessLogic.OfficePackage.HelperModels
|
|
||||||
{
|
|
||||||
public class WordTextProperties
|
|
||||||
{
|
|
||||||
public string Size { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
public bool Bold { get; set; }
|
|
||||||
|
|
||||||
public WordJustificationType JustificationType { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,293 +0,0 @@
|
|||||||
using AutomobilePlantBusinessLogic.OfficePackage;
|
|
||||||
using AutomobilePlantBusinessLogic.OfficePackage.HelperEnums;
|
|
||||||
using AutomobilePlantBusinessLogic.OfficePackage.HelperModels;
|
|
||||||
using DocumentFormat.OpenXml;
|
|
||||||
using DocumentFormat.OpenXml.Office2010.Excel;
|
|
||||||
using DocumentFormat.OpenXml.Office2013.Excel;
|
|
||||||
using DocumentFormat.OpenXml.Packaging;
|
|
||||||
using DocumentFormat.OpenXml.Spreadsheet;
|
|
||||||
|
|
||||||
namespace AutomobilePlantBusinessLogic.OfficePackage.Implements
|
|
||||||
{
|
|
||||||
public class SaveToExcel : AbstractSaveToExcel
|
|
||||||
{
|
|
||||||
private SpreadsheetDocument? _spreadsheetDocument;
|
|
||||||
|
|
||||||
private SharedStringTablePart? _shareStringPart;
|
|
||||||
|
|
||||||
private Worksheet? _worksheet;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Настройка стилей для файла
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="workbookpart"></param>
|
|
||||||
private static void CreateStyles(WorkbookPart workbookpart)
|
|
||||||
{
|
|
||||||
var sp = workbookpart.AddNewPart<WorkbookStylesPart>();
|
|
||||||
sp.Stylesheet = new Stylesheet();
|
|
||||||
|
|
||||||
var fonts = new Fonts() { Count = 2U, KnownFonts = true };
|
|
||||||
|
|
||||||
var fontUsual = new Font();
|
|
||||||
fontUsual.Append(new FontSize() { Val = 12D });
|
|
||||||
fontUsual.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Theme = 1U });
|
|
||||||
fontUsual.Append(new FontName() { Val = "Times New Roman" });
|
|
||||||
fontUsual.Append(new FontFamilyNumbering() { Val = 2 });
|
|
||||||
fontUsual.Append(new FontScheme() { Val = FontSchemeValues.Minor });
|
|
||||||
|
|
||||||
var fontTitle = new Font();
|
|
||||||
fontTitle.Append(new Bold());
|
|
||||||
fontTitle.Append(new FontSize() { Val = 14D });
|
|
||||||
fontTitle.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Theme = 1U });
|
|
||||||
fontTitle.Append(new FontName() { Val = "Times New Roman" });
|
|
||||||
fontTitle.Append(new FontFamilyNumbering() { Val = 2 });
|
|
||||||
fontTitle.Append(new FontScheme() { Val = FontSchemeValues.Minor });
|
|
||||||
|
|
||||||
fonts.Append(fontUsual);
|
|
||||||
fonts.Append(fontTitle);
|
|
||||||
|
|
||||||
var fills = new Fills() { Count = 2U };
|
|
||||||
|
|
||||||
var fill1 = new Fill();
|
|
||||||
fill1.Append(new PatternFill() { PatternType = PatternValues.None });
|
|
||||||
|
|
||||||
var fill2 = new Fill();
|
|
||||||
fill2.Append(new PatternFill() { PatternType = PatternValues.Gray125 });
|
|
||||||
|
|
||||||
fills.Append(fill1);
|
|
||||||
fills.Append(fill2);
|
|
||||||
|
|
||||||
var borders = new Borders() { Count = 2U };
|
|
||||||
|
|
||||||
var borderNoBorder = new Border();
|
|
||||||
borderNoBorder.Append(new LeftBorder());
|
|
||||||
borderNoBorder.Append(new RightBorder());
|
|
||||||
borderNoBorder.Append(new TopBorder());
|
|
||||||
borderNoBorder.Append(new BottomBorder());
|
|
||||||
borderNoBorder.Append(new DiagonalBorder());
|
|
||||||
|
|
||||||
var borderThin = new Border();
|
|
||||||
|
|
||||||
var leftBorder = new LeftBorder() { Style = BorderStyleValues.Thin };
|
|
||||||
leftBorder.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Indexed = 64U });
|
|
||||||
|
|
||||||
var rightBorder = new RightBorder() { Style = BorderStyleValues.Thin };
|
|
||||||
rightBorder.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Indexed = 64U });
|
|
||||||
|
|
||||||
var topBorder = new TopBorder() { Style = BorderStyleValues.Thin };
|
|
||||||
topBorder.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Indexed = 64U });
|
|
||||||
|
|
||||||
var bottomBorder = new BottomBorder() { Style = BorderStyleValues.Thin };
|
|
||||||
bottomBorder.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Indexed = 64U });
|
|
||||||
|
|
||||||
borderThin.Append(leftBorder);
|
|
||||||
borderThin.Append(rightBorder);
|
|
||||||
borderThin.Append(topBorder);
|
|
||||||
borderThin.Append(bottomBorder);
|
|
||||||
borderThin.Append(new DiagonalBorder());
|
|
||||||
|
|
||||||
borders.Append(borderNoBorder);
|
|
||||||
borders.Append(borderThin);
|
|
||||||
|
|
||||||
var cellStyleFormats = new CellStyleFormats() { Count = 1U };
|
|
||||||
var cellFormatStyle = new CellFormat() { NumberFormatId = 0U, FontId = 0U, FillId = 0U, BorderId = 0U };
|
|
||||||
|
|
||||||
cellStyleFormats.Append(cellFormatStyle);
|
|
||||||
|
|
||||||
var cellFormats = new CellFormats() { Count = 3U };
|
|
||||||
var cellFormatFont = new CellFormat() { NumberFormatId = 0U, FontId = 0U, FillId = 0U, BorderId = 0U, FormatId = 0U, ApplyFont = true };
|
|
||||||
var cellFormatFontAndBorder = new CellFormat() { NumberFormatId = 0U, FontId = 0U, FillId = 0U, BorderId = 1U, FormatId = 0U, ApplyFont = true, ApplyBorder = true };
|
|
||||||
var cellFormatTitle = new CellFormat() { NumberFormatId = 0U, FontId = 1U, FillId = 0U, BorderId = 0U, FormatId = 0U, Alignment = new Alignment() { Vertical = VerticalAlignmentValues.Center, WrapText = true, Horizontal = HorizontalAlignmentValues.Center }, ApplyFont = true };
|
|
||||||
|
|
||||||
cellFormats.Append(cellFormatFont);
|
|
||||||
cellFormats.Append(cellFormatFontAndBorder);
|
|
||||||
cellFormats.Append(cellFormatTitle);
|
|
||||||
|
|
||||||
var cellStyles = new CellStyles() { Count = 1U };
|
|
||||||
|
|
||||||
cellStyles.Append(new CellStyle() { Name = "Normal", FormatId = 0U, BuiltinId = 0U });
|
|
||||||
|
|
||||||
var differentialFormats = new DocumentFormat.OpenXml.Office2013.Excel.DifferentialFormats() { Count = 0U };
|
|
||||||
|
|
||||||
var tableStyles = new TableStyles() { Count = 0U, DefaultTableStyle = "TableStyleMedium2", DefaultPivotStyle = "PivotStyleLight16" };
|
|
||||||
|
|
||||||
var stylesheetExtensionList = new StylesheetExtensionList();
|
|
||||||
|
|
||||||
var stylesheetExtension1 = new StylesheetExtension() { Uri = "{EB79DEF2-80B8-43e5-95BD-54CBDDF9020C}" };
|
|
||||||
stylesheetExtension1.AddNamespaceDeclaration("x14", "http://schemas.microsoft.com/office/spreadsheetml/2009/9/main");
|
|
||||||
stylesheetExtension1.Append(new SlicerStyles() { DefaultSlicerStyle = "SlicerStyleLight1" });
|
|
||||||
|
|
||||||
var stylesheetExtension2 = new StylesheetExtension() { Uri = "{9260A510-F301-46a8-8635-F512D64BE5F5}" };
|
|
||||||
stylesheetExtension2.AddNamespaceDeclaration("x15", "http://schemas.microsoft.com/office/spreadsheetml/2010/11/main");
|
|
||||||
stylesheetExtension2.Append(new TimelineStyles() { DefaultTimelineStyle = "TimeSlicerStyleLight1" });
|
|
||||||
|
|
||||||
stylesheetExtensionList.Append(stylesheetExtension1);
|
|
||||||
stylesheetExtensionList.Append(stylesheetExtension2);
|
|
||||||
|
|
||||||
sp.Stylesheet.Append(fonts);
|
|
||||||
sp.Stylesheet.Append(fills);
|
|
||||||
sp.Stylesheet.Append(borders);
|
|
||||||
sp.Stylesheet.Append(cellStyleFormats);
|
|
||||||
sp.Stylesheet.Append(cellFormats);
|
|
||||||
sp.Stylesheet.Append(cellStyles);
|
|
||||||
sp.Stylesheet.Append(differentialFormats);
|
|
||||||
sp.Stylesheet.Append(tableStyles);
|
|
||||||
sp.Stylesheet.Append(stylesheetExtensionList);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Получение номера стиля из типа
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="styleInfo"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
private static uint GetStyleValue(ExcelStyleInfoType styleInfo)
|
|
||||||
{
|
|
||||||
return styleInfo switch
|
|
||||||
{
|
|
||||||
ExcelStyleInfoType.Title => 2U,
|
|
||||||
ExcelStyleInfoType.TextWithBroder => 1U,
|
|
||||||
ExcelStyleInfoType.Text => 0U,
|
|
||||||
_ => 0U,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void CreateExcel(ExcelInfo info)
|
|
||||||
{
|
|
||||||
_spreadsheetDocument = SpreadsheetDocument.Create(info.FileName, SpreadsheetDocumentType.Workbook);
|
|
||||||
// Создаем книгу (в ней хранятся листы)
|
|
||||||
var workbookpart = _spreadsheetDocument.AddWorkbookPart();
|
|
||||||
workbookpart.Workbook = new Workbook();
|
|
||||||
|
|
||||||
CreateStyles(workbookpart);
|
|
||||||
|
|
||||||
// Получаем/создаем хранилище текстов для книги
|
|
||||||
_shareStringPart = _spreadsheetDocument.WorkbookPart!.GetPartsOfType<SharedStringTablePart>().Any()
|
|
||||||
? _spreadsheetDocument.WorkbookPart.GetPartsOfType<SharedStringTablePart>().First()
|
|
||||||
: _spreadsheetDocument.WorkbookPart.AddNewPart<SharedStringTablePart>();
|
|
||||||
|
|
||||||
// Создаем SharedStringTable, если его нет
|
|
||||||
if (_shareStringPart.SharedStringTable == null)
|
|
||||||
{
|
|
||||||
_shareStringPart.SharedStringTable = new SharedStringTable();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Создаем лист в книгу
|
|
||||||
var worksheetPart = workbookpart.AddNewPart<WorksheetPart>();
|
|
||||||
worksheetPart.Worksheet = new Worksheet(new SheetData());
|
|
||||||
|
|
||||||
// Добавляем лист в книгу
|
|
||||||
var sheets = _spreadsheetDocument.WorkbookPart.Workbook.AppendChild(new Sheets());
|
|
||||||
var sheet = new Sheet()
|
|
||||||
{
|
|
||||||
Id = _spreadsheetDocument.WorkbookPart.GetIdOfPart(worksheetPart),
|
|
||||||
SheetId = 1,
|
|
||||||
Name = "Лист"
|
|
||||||
};
|
|
||||||
sheets.Append(sheet);
|
|
||||||
|
|
||||||
_worksheet = worksheetPart.Worksheet;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void InsertCellInWorksheet(ExcelCellParameters excelParams)
|
|
||||||
{
|
|
||||||
if (_worksheet == null || _shareStringPart == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var sheetData = _worksheet.GetFirstChild<SheetData>();
|
|
||||||
if (sheetData == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ищем строку, либо добавляем ее
|
|
||||||
Row row;
|
|
||||||
if (sheetData.Elements<Row>().Where(r => r.RowIndex! == excelParams.RowIndex).Any())
|
|
||||||
{
|
|
||||||
row = sheetData.Elements<Row>().Where(r => r.RowIndex! == excelParams.RowIndex).First();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
row = new Row() { RowIndex = excelParams.RowIndex };
|
|
||||||
sheetData.Append(row);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ищем нужную ячейку
|
|
||||||
Cell cell;
|
|
||||||
if (row.Elements<Cell>().Where(c => c.CellReference!.Value == excelParams.CellReference).Any())
|
|
||||||
{
|
|
||||||
cell = row.Elements<Cell>().Where(c => c.CellReference!.Value == excelParams.CellReference).First();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Все ячейки должны быть последовательно друг за другом расположены
|
|
||||||
// нужно определить, после какой вставлять
|
|
||||||
Cell? refCell = null;
|
|
||||||
foreach (Cell rowCell in row.Elements<Cell>())
|
|
||||||
{
|
|
||||||
if (string.Compare(rowCell.CellReference!.Value, excelParams.CellReference, true) > 0)
|
|
||||||
{
|
|
||||||
refCell = rowCell;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var newCell = new Cell() { CellReference = excelParams.CellReference };
|
|
||||||
row.InsertBefore(newCell, refCell);
|
|
||||||
|
|
||||||
cell = newCell;
|
|
||||||
}
|
|
||||||
|
|
||||||
// вставляем новый текст
|
|
||||||
_shareStringPart.SharedStringTable.AppendChild(new SharedStringItem(new Text(excelParams.Text)));
|
|
||||||
_shareStringPart.SharedStringTable.Save();
|
|
||||||
|
|
||||||
cell.CellValue = new CellValue((_shareStringPart.SharedStringTable.Elements<SharedStringItem>().Count() - 1).ToString());
|
|
||||||
cell.DataType = new EnumValue<CellValues>(CellValues.SharedString);
|
|
||||||
cell.StyleIndex = GetStyleValue(excelParams.StyleInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void MergeCells(ExcelMergeParameters excelParams)
|
|
||||||
{
|
|
||||||
if (_worksheet == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
MergeCells mergeCells;
|
|
||||||
|
|
||||||
if (_worksheet.Elements<MergeCells>().Any())
|
|
||||||
{
|
|
||||||
mergeCells = _worksheet.Elements<MergeCells>().First();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mergeCells = new MergeCells();
|
|
||||||
|
|
||||||
if (_worksheet.Elements<CustomSheetView>().Any())
|
|
||||||
{
|
|
||||||
_worksheet.InsertAfter(mergeCells, _worksheet.Elements<CustomSheetView>().First());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_worksheet.InsertAfter(mergeCells, _worksheet.Elements<SheetData>().First());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var mergeCell = new MergeCell()
|
|
||||||
{
|
|
||||||
Reference = new StringValue(excelParams.Merge)
|
|
||||||
};
|
|
||||||
mergeCells.Append(mergeCell);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void SaveExcel(ExcelInfo info)
|
|
||||||
{
|
|
||||||
if (_spreadsheetDocument == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_spreadsheetDocument.WorkbookPart!.Workbook.Save();
|
|
||||||
_spreadsheetDocument.Close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,115 +0,0 @@
|
|||||||
using AutomobilePlantBusinessLogic.OfficePackage;
|
|
||||||
using AutomobilePlantBusinessLogic.OfficePackage.HelperEnums;
|
|
||||||
using AutomobilePlantBusinessLogic.OfficePackage.HelperModels;
|
|
||||||
using MigraDoc.DocumentObjectModel;
|
|
||||||
using MigraDoc.DocumentObjectModel.Tables;
|
|
||||||
using MigraDoc.Rendering;
|
|
||||||
|
|
||||||
namespace AutomobilePlantBusinessLogic.OfficePackage.Implements
|
|
||||||
{
|
|
||||||
public class SaveToPdf : AbstractSaveToPdf
|
|
||||||
{
|
|
||||||
private Document? _document;
|
|
||||||
|
|
||||||
private Section? _section;
|
|
||||||
|
|
||||||
private Table? _table;
|
|
||||||
|
|
||||||
private static ParagraphAlignment GetParagraphAlignment(PdfParagraphAlignmentType type)
|
|
||||||
{
|
|
||||||
return type switch
|
|
||||||
{
|
|
||||||
PdfParagraphAlignmentType.Center => ParagraphAlignment.Center,
|
|
||||||
PdfParagraphAlignmentType.Left => ParagraphAlignment.Left,
|
|
||||||
PdfParagraphAlignmentType.Rigth => ParagraphAlignment.Right,
|
|
||||||
_ => ParagraphAlignment.Justify,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Создание стилей для документа
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="document"></param>
|
|
||||||
private static void DefineStyles(Document document)
|
|
||||||
{
|
|
||||||
var style = document.Styles["Normal"];
|
|
||||||
style.Font.Name = "Times New Roman";
|
|
||||||
style.Font.Size = 14;
|
|
||||||
|
|
||||||
style = document.Styles.AddStyle("NormalTitle", "Normal");
|
|
||||||
style.Font.Bold = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void CreatePdf(PdfInfo info)
|
|
||||||
{
|
|
||||||
_document = new Document();
|
|
||||||
DefineStyles(_document);
|
|
||||||
|
|
||||||
_section = _document.AddSection();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void CreateParagraph(PdfParagraph pdfParagraph)
|
|
||||||
{
|
|
||||||
if (_section == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var paragraph = _section.AddParagraph(pdfParagraph.Text);
|
|
||||||
paragraph.Format.SpaceAfter = "1cm";
|
|
||||||
paragraph.Format.Alignment = GetParagraphAlignment(pdfParagraph.ParagraphAlignment);
|
|
||||||
paragraph.Style = pdfParagraph.Style;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void CreateTable(List<string> columns)
|
|
||||||
{
|
|
||||||
if (_document == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_table = _document.LastSection.AddTable();
|
|
||||||
|
|
||||||
foreach (var elem in columns)
|
|
||||||
{
|
|
||||||
_table.AddColumn(elem);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void CreateRow(PdfRowParameters rowParameters)
|
|
||||||
{
|
|
||||||
if (_table == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var row = _table.AddRow();
|
|
||||||
for (int i = 0; i < rowParameters.Texts.Count; ++i)
|
|
||||||
{
|
|
||||||
row.Cells[i].AddParagraph(rowParameters.Texts[i]);
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(rowParameters.Style))
|
|
||||||
{
|
|
||||||
row.Cells[i].Style = rowParameters.Style;
|
|
||||||
}
|
|
||||||
|
|
||||||
Unit borderWidth = 0.5;
|
|
||||||
|
|
||||||
row.Cells[i].Borders.Left.Width = borderWidth;
|
|
||||||
row.Cells[i].Borders.Right.Width = borderWidth;
|
|
||||||
row.Cells[i].Borders.Top.Width = borderWidth;
|
|
||||||
row.Cells[i].Borders.Bottom.Width = borderWidth;
|
|
||||||
|
|
||||||
row.Cells[i].Format.Alignment = GetParagraphAlignment(rowParameters.ParagraphAlignment);
|
|
||||||
row.Cells[i].VerticalAlignment = VerticalAlignment.Center;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void SavePdf(PdfInfo info)
|
|
||||||
{
|
|
||||||
var renderer = new PdfDocumentRenderer(true)
|
|
||||||
{
|
|
||||||
Document = _document
|
|
||||||
};
|
|
||||||
renderer.RenderDocument();
|
|
||||||
renderer.PdfDocument.Save(info.FileName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,136 +0,0 @@
|
|||||||
using AutomobilePlantBusinessLogic.OfficePackage;
|
|
||||||
using AutomobilePlantBusinessLogic.OfficePackage.HelperEnums;
|
|
||||||
using AutomobilePlantBusinessLogic.OfficePackage.HelperModels;
|
|
||||||
using DocumentFormat.OpenXml;
|
|
||||||
using DocumentFormat.OpenXml.Packaging;
|
|
||||||
using DocumentFormat.OpenXml.Wordprocessing;
|
|
||||||
|
|
||||||
namespace AutomobilePlantBusinessLogic.OfficePackage.Implements
|
|
||||||
{
|
|
||||||
public class SaveToWord : AbstractSaveToWord
|
|
||||||
{
|
|
||||||
private WordprocessingDocument? _wordDocument;
|
|
||||||
|
|
||||||
private Body? _docBody;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Получение типа выравнивания
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="type"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
private static JustificationValues GetJustificationValues(WordJustificationType type)
|
|
||||||
{
|
|
||||||
return type switch
|
|
||||||
{
|
|
||||||
WordJustificationType.Both => JustificationValues.Both,
|
|
||||||
WordJustificationType.Center => JustificationValues.Center,
|
|
||||||
_ => JustificationValues.Left,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Настройки страницы
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
private static SectionProperties CreateSectionProperties()
|
|
||||||
{
|
|
||||||
var properties = new SectionProperties();
|
|
||||||
|
|
||||||
var pageSize = new PageSize
|
|
||||||
{
|
|
||||||
Orient = PageOrientationValues.Portrait
|
|
||||||
};
|
|
||||||
|
|
||||||
properties.AppendChild(pageSize);
|
|
||||||
|
|
||||||
return properties;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Задание форматирования для абзаца
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="paragraphProperties"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
private static ParagraphProperties? CreateParagraphProperties(WordTextProperties? paragraphProperties)
|
|
||||||
{
|
|
||||||
if (paragraphProperties == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
var properties = new ParagraphProperties();
|
|
||||||
|
|
||||||
properties.AppendChild(new Justification()
|
|
||||||
{
|
|
||||||
Val = GetJustificationValues(paragraphProperties.JustificationType)
|
|
||||||
});
|
|
||||||
|
|
||||||
properties.AppendChild(new SpacingBetweenLines
|
|
||||||
{
|
|
||||||
LineRule = LineSpacingRuleValues.Auto
|
|
||||||
});
|
|
||||||
|
|
||||||
properties.AppendChild(new Indentation());
|
|
||||||
|
|
||||||
var paragraphMarkRunProperties = new ParagraphMarkRunProperties();
|
|
||||||
if (!string.IsNullOrEmpty(paragraphProperties.Size))
|
|
||||||
{
|
|
||||||
paragraphMarkRunProperties.AppendChild(new FontSize { Val = paragraphProperties.Size });
|
|
||||||
}
|
|
||||||
properties.AppendChild(paragraphMarkRunProperties);
|
|
||||||
|
|
||||||
return properties;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void CreateWord(WordInfo info)
|
|
||||||
{
|
|
||||||
_wordDocument = WordprocessingDocument.Create(info.FileName, WordprocessingDocumentType.Document);
|
|
||||||
MainDocumentPart mainPart = _wordDocument.AddMainDocumentPart();
|
|
||||||
mainPart.Document = new Document();
|
|
||||||
_docBody = mainPart.Document.AppendChild(new Body());
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void CreateParagraph(WordParagraph paragraph)
|
|
||||||
{
|
|
||||||
if (_docBody == null || paragraph == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var docParagraph = new Paragraph();
|
|
||||||
|
|
||||||
docParagraph.AppendChild(CreateParagraphProperties(paragraph.TextProperties));
|
|
||||||
|
|
||||||
foreach (var run in paragraph.Texts)
|
|
||||||
{
|
|
||||||
var docRun = new Run();
|
|
||||||
|
|
||||||
var properties = new RunProperties();
|
|
||||||
properties.AppendChild(new FontSize { Val = run.Item2.Size });
|
|
||||||
if (run.Item2.Bold)
|
|
||||||
{
|
|
||||||
properties.AppendChild(new Bold());
|
|
||||||
}
|
|
||||||
docRun.AppendChild(properties);
|
|
||||||
|
|
||||||
docRun.AppendChild(new Text { Text = run.Item1, Space = SpaceProcessingModeValues.Preserve });
|
|
||||||
|
|
||||||
docParagraph.AppendChild(docRun);
|
|
||||||
}
|
|
||||||
|
|
||||||
_docBody.AppendChild(docParagraph);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void SaveWord(WordInfo info)
|
|
||||||
{
|
|
||||||
if (_docBody == null || _wordDocument == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_docBody.AppendChild(CreateSectionProperties());
|
|
||||||
|
|
||||||
_wordDocument.MainDocumentPart!.Document.Save();
|
|
||||||
|
|
||||||
_wordDocument.Close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,31 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantContracts.Attributes
|
|
||||||
{
|
|
||||||
[AttributeUsage(AttributeTargets.Property)]
|
|
||||||
public class ColumnAttribute : Attribute
|
|
||||||
{
|
|
||||||
public string Title { get; private set; }
|
|
||||||
|
|
||||||
public bool Visible { get; private set; }
|
|
||||||
|
|
||||||
public int Width { get; private set; }
|
|
||||||
|
|
||||||
public GridViewAutoSize GridViewAutoSize { get; private set; }
|
|
||||||
|
|
||||||
public bool IsUseAutoSize { get; private set; }
|
|
||||||
|
|
||||||
public ColumnAttribute(string title = "", bool visible = true, int width = 0, GridViewAutoSize gridViewAutoSize = GridViewAutoSize.None, bool isUseAutoSize = false)
|
|
||||||
{
|
|
||||||
Title = title;
|
|
||||||
Visible = visible;
|
|
||||||
Width = width;
|
|
||||||
GridViewAutoSize = gridViewAutoSize;
|
|
||||||
IsUseAutoSize = isUseAutoSize;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,27 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantContracts.Attributes
|
|
||||||
{
|
|
||||||
public enum GridViewAutoSize
|
|
||||||
{
|
|
||||||
NotSet = 0,
|
|
||||||
|
|
||||||
None = 1,
|
|
||||||
|
|
||||||
ColumnHeader = 2,
|
|
||||||
|
|
||||||
AllCellsExceptHeader = 4,
|
|
||||||
|
|
||||||
AllCells = 6,
|
|
||||||
|
|
||||||
DisplayedCellsExceptHeader = 8,
|
|
||||||
|
|
||||||
DisplayedCells = 10,
|
|
||||||
|
|
||||||
Fill = 16
|
|
||||||
}
|
|
||||||
}
|
|
@ -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="Unity" Version="5.11.10" />
|
|
||||||
<PackageReference Include="Unity.Microsoft.Logging" Version="5.11.1" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\AbstractAutoDataModels\AutomobilePlantDataModels.csproj" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
@ -1,13 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantContracts.BindingModels
|
|
||||||
{
|
|
||||||
public class BackUpSaveBinidngModel
|
|
||||||
{
|
|
||||||
public string FolderName { 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 AutomobilePlantDataModels.Models;
|
|
||||||
|
|
||||||
namespace AutomobilePlantContracts.BindingModels
|
|
||||||
{
|
|
||||||
public class CarBindingModel : ICarModel
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
public string CarName { get; set; } = string.Empty;
|
|
||||||
public double Price { get; set; }
|
|
||||||
public Dictionary<int, (IComponentModel, int)> CarComponents
|
|
||||||
{
|
|
||||||
get;
|
|
||||||
set;
|
|
||||||
} = new();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,18 +0,0 @@
|
|||||||
using AutomobilePlantDataModels.Models;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantContracts.BindingModels
|
|
||||||
{
|
|
||||||
public class ClientBindingModel : IClientModel
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
public string ClientFIO { get; set; } = string.Empty;
|
|
||||||
public string Email { get; set; } = string.Empty;
|
|
||||||
public string Password { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,16 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using AutomobilePlantDataModels.Models;
|
|
||||||
|
|
||||||
namespace AutomobilePlantContracts.BindingModels
|
|
||||||
{
|
|
||||||
public class ComponentBindingModel : IComponentModel
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
public string ComponentName { get; set; } = string.Empty;
|
|
||||||
public double Cost { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,22 +0,0 @@
|
|||||||
using AutomobilePlantDataModels.Models;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantContracts.BindingModels
|
|
||||||
{
|
|
||||||
public class ImplementerBindingModel : IImplementerModel
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
|
|
||||||
public string ImplementerFIO { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
public string Password { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
public int WorkExperience { get; set; }
|
|
||||||
|
|
||||||
public int Qualification { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,17 +0,0 @@
|
|||||||
namespace AutomobilePlantContracts.BindingModels
|
|
||||||
{
|
|
||||||
public class MailConfigBindingModel
|
|
||||||
{
|
|
||||||
public string MailLogin { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
public string MailPassword { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
public string SmtpClientHost { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
public int SmtpClientPort { get; set; }
|
|
||||||
|
|
||||||
public string PopHost { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
public int PopPort { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
namespace AutomobilePlantContracts.BindingModels
|
|
||||||
{
|
|
||||||
public class MailSendInfoBindingModel
|
|
||||||
{
|
|
||||||
public string MailAddress { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
public string Subject { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
public string Text { get; set; } = string.Empty;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
using AutomobilePlantDataModels.Models;
|
|
||||||
|
|
||||||
namespace AutomobilePlantContracts.BindingModels
|
|
||||||
{
|
|
||||||
public class MessageInfoBindingModel : IMessageInfoModel
|
|
||||||
{
|
|
||||||
public string MessageId { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
public int? ClientId { get; set; }
|
|
||||||
|
|
||||||
public string SenderName { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
public string Subject { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
public string Body { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
public DateTime DateDelivery { get; set; }
|
|
||||||
|
|
||||||
public int Id { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,26 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using AutomobilePlantDataModels.Enums;
|
|
||||||
using AutomobilePlantDataModels.Models;
|
|
||||||
|
|
||||||
namespace AutomobilePlantContracts.BindingModels
|
|
||||||
{
|
|
||||||
public class OrderBindingModel : IOrderModel
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
public int CarId { get; set; }
|
|
||||||
public int ClientId { get; set; }
|
|
||||||
public string ClientName { get; set; } = string.Empty;
|
|
||||||
public int? ImplementerId { get; set; }
|
|
||||||
public string? ImplementerName { get; set; } = string.Empty;
|
|
||||||
public string CarName { get; set; } = string.Empty;
|
|
||||||
public int Count { get; set; }
|
|
||||||
public double Sum { get; set; }
|
|
||||||
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
|
|
||||||
public DateTime DateCreate { get; set; } = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc);
|
|
||||||
public DateTime? DateImplement { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,17 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantContracts.BindingModels
|
|
||||||
{
|
|
||||||
public class ReportBindingModel
|
|
||||||
{
|
|
||||||
public string FileName { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
public DateTime? DateFrom { get; set; }
|
|
||||||
|
|
||||||
public DateTime? DateTo { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
using AutomobilePlantContracts.BindingModels;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantContracts.BusinessLogicsContracts
|
|
||||||
{
|
|
||||||
public interface IBackUpLogic
|
|
||||||
{
|
|
||||||
void CreateBackUp(BackUpSaveBinidngModel model);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,20 +0,0 @@
|
|||||||
using AutomobilePlantContracts.BindingModels;
|
|
||||||
using AutomobilePlantContracts.SearchModel;
|
|
||||||
using AutomobilePlantContracts.ViewModel;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantContracts.BusinessLogicsContracts
|
|
||||||
{
|
|
||||||
public interface ICarLogic
|
|
||||||
{
|
|
||||||
List<CarViewModel>? ReadList(CarSearchModel? model);
|
|
||||||
CarViewModel? ReadElement(CarSearchModel model);
|
|
||||||
bool Create(CarBindingModel model);
|
|
||||||
bool Update(CarBindingModel model);
|
|
||||||
bool Delete(CarBindingModel model);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
using AutomobilePlantContracts.BindingModels;
|
|
||||||
using AutomobilePlantContracts.SearchModel;
|
|
||||||
using AutomobilePlantContracts.ViewModel;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantContracts.BusinessLogicsContracts
|
|
||||||
{
|
|
||||||
public interface IClientLogic
|
|
||||||
{
|
|
||||||
List<ClientViewModel>? ReadList(ClientSearchModel? model);
|
|
||||||
ClientViewModel? ReadElement(ClientSearchModel model);
|
|
||||||
bool Create(ClientBindingModel model);
|
|
||||||
bool Update(ClientBindingModel model);
|
|
||||||
bool Delete(ClientBindingModel model);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,20 +0,0 @@
|
|||||||
using AutomobilePlantContracts.BindingModels;
|
|
||||||
using AutomobilePlantContracts.SearchModel;
|
|
||||||
using AutomobilePlantContracts.ViewModel;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantContracts.BusinessLogicsContracts
|
|
||||||
{
|
|
||||||
public interface IComponentLogic
|
|
||||||
{
|
|
||||||
List<ComponentViewModel>? ReadList(ComponentSearchModel? model);
|
|
||||||
ComponentViewModel? ReadElement(ComponentSearchModel model);
|
|
||||||
bool Create(ComponentBindingModel model);
|
|
||||||
bool Update(ComponentBindingModel model);
|
|
||||||
bool Delete(ComponentBindingModel model);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,24 +0,0 @@
|
|||||||
using AutomobilePlantContracts.BindingModels;
|
|
||||||
using AutomobilePlantContracts.SearchModel;
|
|
||||||
using AutomobilePlantContracts.ViewModel;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantContracts.BusinessLogicsContracts
|
|
||||||
{
|
|
||||||
public interface IImplementerLogic
|
|
||||||
{
|
|
||||||
List<ImplementerViewModel>? ReadList(ImplementerSearchModel? model);
|
|
||||||
|
|
||||||
ImplementerViewModel? ReadElement(ImplementerSearchModel model);
|
|
||||||
|
|
||||||
bool Create(ImplementerBindingModel model);
|
|
||||||
|
|
||||||
bool Update(ImplementerBindingModel model);
|
|
||||||
|
|
||||||
bool Delete(ImplementerBindingModel model);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,13 +0,0 @@
|
|||||||
using AutomobilePlantContracts.BindingModels;
|
|
||||||
using AutomobilePlantContracts.SearchModel;
|
|
||||||
using AutomobilePlantContracts.ViewModel;
|
|
||||||
|
|
||||||
namespace AutomobilePlantContracts.BusinessLogicsContracts
|
|
||||||
{
|
|
||||||
public interface IMessageInfoLogic
|
|
||||||
{
|
|
||||||
List<MessageInfoViewModel>? ReadList(MessageInfoSearchModel? model);
|
|
||||||
|
|
||||||
bool Create(MessageInfoBindingModel model);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
using AutomobilePlantContracts.BindingModels;
|
|
||||||
using AutomobilePlantContracts.SearchModel;
|
|
||||||
using AutomobilePlantContracts.ViewModel;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantContracts.BusinessLogicsContracts
|
|
||||||
{
|
|
||||||
public interface IOrderLogic
|
|
||||||
{
|
|
||||||
List<OrderViewModel>? ReadList(OrderSearchModel? model);
|
|
||||||
OrderViewModel? ReadElement(OrderSearchModel model);
|
|
||||||
bool CreateOrder(OrderBindingModel model);
|
|
||||||
bool TakeOrderInWork(OrderBindingModel model);
|
|
||||||
bool FinishOrder(OrderBindingModel model);
|
|
||||||
bool DeliveryOrder(OrderBindingModel model);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,44 +0,0 @@
|
|||||||
using AutomobilePlantContracts.BindingModels;
|
|
||||||
using AutomobilePlantContracts.ViewModel;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantContracts.BusinessLogicsContracts
|
|
||||||
{
|
|
||||||
public interface IReportLogic
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Получение списка компонент с указанием, в каких машинах используются
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
List<ReportCarComponentViewModel> GetCarComponent();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Получение списка заказов за определенный период
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="model"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
List<ReportOrdersViewModel> GetOrders(ReportBindingModel model);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Сохранение компонент в файл-Word
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="model"></param>
|
|
||||||
void SaveComponentsToWordFile(ReportBindingModel model);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Сохранение компонент с указаеним машин в файл-Excel
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="model"></param>
|
|
||||||
void SaveCarComponentToExcelFile(ReportBindingModel model);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Сохранение заказов в файл-Pdf
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="model"></param>
|
|
||||||
void SaveOrdersToPdfFile(ReportBindingModel model);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,13 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantContracts.BusinessLogicsContracts
|
|
||||||
{
|
|
||||||
public interface IWorkProcess
|
|
||||||
{
|
|
||||||
void DoWork(IImplementerLogic implementerLogic, IOrderLogic orderLogic);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,67 +0,0 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Unity;
|
|
||||||
|
|
||||||
namespace AutomobilePlantContracts.DI
|
|
||||||
{
|
|
||||||
public class DependencyManager
|
|
||||||
{
|
|
||||||
private readonly IDependencyContainer _dependencyManager;
|
|
||||||
|
|
||||||
private static DependencyManager? _manager;
|
|
||||||
|
|
||||||
private static readonly object _locjObject = new();
|
|
||||||
|
|
||||||
private DependencyManager()
|
|
||||||
{
|
|
||||||
_dependencyManager = new UnityServiceContainer();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static DependencyManager Instance { get { if (_manager == null) { lock (_locjObject) { _manager = new DependencyManager(); } } return _manager; } }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Иницализация библиотек, в которых идут установки зависомстей
|
|
||||||
/// </summary>
|
|
||||||
public static void InitDependency()
|
|
||||||
{
|
|
||||||
var ext = ServiceProviderLoader.GetImplementationExtensions();
|
|
||||||
if (ext == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("Отсутствуют компоненты для загрузки зависимостей по модулям");
|
|
||||||
}
|
|
||||||
// регистрируем зависимости
|
|
||||||
ext.RegisterServices();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Регистрация логгера
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="configure"></param>
|
|
||||||
public void AddLogging(Action<ILoggingBuilder> configure) => _dependencyManager.AddLogging(configure);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Добавление зависимости
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="T"></typeparam>
|
|
||||||
/// <typeparam name="U"></typeparam>
|
|
||||||
public void RegisterType<T, U>(bool isSingle = false) where U : class, T where T : class => _dependencyManager.RegisterType<T, U>(isSingle);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Добавление зависимости
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="T"></typeparam>
|
|
||||||
/// <typeparam name="U"></typeparam>
|
|
||||||
public void RegisterType<T>(bool isSingle = false) where T : class => _dependencyManager.RegisterType<T>(isSingle);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Получение класса со всеми зависмостями
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="T"></typeparam>
|
|
||||||
/// <returns></returns>
|
|
||||||
public T Resolve<T>() => _dependencyManager.Resolve<T>();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,40 +0,0 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantContracts.DI
|
|
||||||
{
|
|
||||||
public interface IDependencyContainer
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Регистрация логгера
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="configure"></param>
|
|
||||||
void AddLogging(Action<ILoggingBuilder> configure);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Добавление зависимости
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="T"></typeparam>
|
|
||||||
/// <typeparam name="U"></typeparam>
|
|
||||||
/// <param name="isSingle"></param>
|
|
||||||
void RegisterType<T, U>(bool isSingle) where U : class, T where T : class;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Добавление зависимости
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="T"></typeparam>
|
|
||||||
/// <param name="isSingle"></param>
|
|
||||||
void RegisterType<T>(bool isSingle) where T : class;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Получение класса со всеми зависмостями
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="T"></typeparam>
|
|
||||||
/// <returns></returns>
|
|
||||||
T Resolve<T>();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,17 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantContracts.DI
|
|
||||||
{
|
|
||||||
public interface IImplementationExtension
|
|
||||||
{
|
|
||||||
public int Priority { get; }
|
|
||||||
/// <summary>
|
|
||||||
/// Регистрация сервисов
|
|
||||||
/// </summary>
|
|
||||||
public void RegisterServices();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,62 +0,0 @@
|
|||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantContracts.DI
|
|
||||||
{
|
|
||||||
public class ServiceDependencyContainer : IDependencyContainer
|
|
||||||
{
|
|
||||||
private ServiceProvider? _serviceProvider;
|
|
||||||
|
|
||||||
private readonly ServiceCollection _serviceCollection;
|
|
||||||
|
|
||||||
public ServiceDependencyContainer()
|
|
||||||
{
|
|
||||||
_serviceCollection = new ServiceCollection();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void AddLogging(Action<ILoggingBuilder> configure)
|
|
||||||
{
|
|
||||||
_serviceCollection.AddLogging(configure);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void RegisterType<T, U>(bool isSingle) where U : class, T where T : class
|
|
||||||
{
|
|
||||||
if (isSingle)
|
|
||||||
{
|
|
||||||
_serviceCollection.AddSingleton<T, U>();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_serviceCollection.AddTransient<T, U>();
|
|
||||||
}
|
|
||||||
_serviceProvider = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void RegisterType<T>(bool isSingle) where T : class
|
|
||||||
{
|
|
||||||
if (isSingle)
|
|
||||||
{
|
|
||||||
_serviceCollection.AddSingleton<T>();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_serviceCollection.AddTransient<T>();
|
|
||||||
}
|
|
||||||
_serviceProvider = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public T Resolve<T>()
|
|
||||||
{
|
|
||||||
if (_serviceProvider == null)
|
|
||||||
{
|
|
||||||
_serviceProvider = _serviceCollection.BuildServiceProvider();
|
|
||||||
}
|
|
||||||
return _serviceProvider.GetService<T>()!;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,55 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantContracts.DI
|
|
||||||
{
|
|
||||||
public class ServiceProviderLoader
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Загрузка всех классов-реализаций IImplementationExtension
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static IImplementationExtension? GetImplementationExtensions()
|
|
||||||
{
|
|
||||||
IImplementationExtension? source = null;
|
|
||||||
var files = Directory.GetFiles(TryGetImplementationExtensionsFolder(), "*.dll", SearchOption.AllDirectories);
|
|
||||||
foreach (var file in files.Distinct())
|
|
||||||
{
|
|
||||||
Assembly asm = Assembly.LoadFrom(file);
|
|
||||||
foreach (var t in asm.GetExportedTypes())
|
|
||||||
{
|
|
||||||
if (t.IsClass && typeof(IImplementationExtension).IsAssignableFrom(t))
|
|
||||||
{
|
|
||||||
if (source == null)
|
|
||||||
{
|
|
||||||
source = (IImplementationExtension)Activator.CreateInstance(t)!;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var newSource = (IImplementationExtension)Activator.CreateInstance(t)!;
|
|
||||||
if (newSource.Priority > source.Priority)
|
|
||||||
{
|
|
||||||
source = newSource;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return source;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static string TryGetImplementationExtensionsFolder()
|
|
||||||
{
|
|
||||||
var directory = new DirectoryInfo(Directory.GetCurrentDirectory());
|
|
||||||
while (directory != null && !directory.GetDirectories("ImplementationExtensions", SearchOption.AllDirectories).Any(x => x.Name == "ImplementationExtensions"))
|
|
||||||
{
|
|
||||||
directory = directory.Parent;
|
|
||||||
}
|
|
||||||
return $"{directory?.FullName}\\ImplementationExtensions";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,59 +0,0 @@
|
|||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Unity;
|
|
||||||
using Unity.Microsoft.Logging;
|
|
||||||
|
|
||||||
namespace AutomobilePlantContracts.DI
|
|
||||||
{
|
|
||||||
public class UnityServiceContainer : IDependencyContainer
|
|
||||||
{
|
|
||||||
private UnityContainer? _unityContainer;
|
|
||||||
|
|
||||||
public UnityServiceContainer()
|
|
||||||
{
|
|
||||||
_unityContainer = new UnityContainer();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void AddLogging(Action<ILoggingBuilder> configure)
|
|
||||||
{
|
|
||||||
_unityContainer.AddExtension(new LoggingExtension(LoggerFactory.Create(configure)));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void RegisterType<T, U>(bool isSingle) where U : class, T where T : class
|
|
||||||
{
|
|
||||||
if (isSingle)
|
|
||||||
{
|
|
||||||
_unityContainer.RegisterSingleton<T, U>();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_unityContainer.RegisterType<T, U>();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void RegisterType<T>(bool isSingle) where T : class
|
|
||||||
{
|
|
||||||
if (isSingle)
|
|
||||||
{
|
|
||||||
_unityContainer.RegisterSingleton<T>();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_unityContainer.RegisterType<T>();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public T Resolve<T>()
|
|
||||||
{
|
|
||||||
|
|
||||||
return _unityContainer.Resolve<T>()!;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,14 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantContracts.SearchModel
|
|
||||||
{
|
|
||||||
public class CarSearchModel
|
|
||||||
{
|
|
||||||
public int? Id { get; set; }
|
|
||||||
public string? CarName { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,16 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantContracts.SearchModel
|
|
||||||
{
|
|
||||||
public class ClientSearchModel
|
|
||||||
{
|
|
||||||
public int? Id { get; set; }
|
|
||||||
public string? ClientFIO { get; set; }
|
|
||||||
public string? Email { get; set; }
|
|
||||||
public string? Password { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,14 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantContracts.SearchModel
|
|
||||||
{
|
|
||||||
public class ComponentSearchModel
|
|
||||||
{
|
|
||||||
public int? Id { get; set; }
|
|
||||||
public string? ComponentName { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,17 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantContracts.SearchModel
|
|
||||||
{
|
|
||||||
public class ImplementerSearchModel
|
|
||||||
{
|
|
||||||
public int? Id { get; set; }
|
|
||||||
|
|
||||||
public string? ImplementerFIO { get; set; }
|
|
||||||
|
|
||||||
public string? Password { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,9 +0,0 @@
|
|||||||
namespace AutomobilePlantContracts.SearchModel
|
|
||||||
{
|
|
||||||
public class MessageInfoSearchModel
|
|
||||||
{
|
|
||||||
public int? ClientId { get; set; }
|
|
||||||
|
|
||||||
public string? MessageId { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
using AutomobilePlantDataModels.Enums;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantContracts.SearchModel
|
|
||||||
{
|
|
||||||
public class OrderSearchModel
|
|
||||||
{
|
|
||||||
public int? Id { get; set; }
|
|
||||||
public int? ClientId { get; set; }
|
|
||||||
public int? ImplementerId { get; set; }
|
|
||||||
public OrderStatus Status { get; set; }
|
|
||||||
public DateTime? DateFrom { get; set; }
|
|
||||||
|
|
||||||
public DateTime? DateTo { get; set; }
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantContracts.StoragesContracts
|
|
||||||
{
|
|
||||||
public interface IBackUpInfo
|
|
||||||
{
|
|
||||||
List<T>? GetList<T>() where T : class, new();
|
|
||||||
|
|
||||||
Type? GetTypeByModelInterface(string modelInterfaceName);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,22 +0,0 @@
|
|||||||
using AutomobilePlantContracts.BindingModels;
|
|
||||||
using AutomobilePlantContracts.SearchModel;
|
|
||||||
using AutomobilePlantContracts.ViewModel;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantContracts.StoragesContracts
|
|
||||||
{
|
|
||||||
public interface ICarStorage
|
|
||||||
{
|
|
||||||
List<CarViewModel> GetFullList();
|
|
||||||
List<CarViewModel> GetFilteredList(CarSearchModel model);
|
|
||||||
CarViewModel? GetElement(CarSearchModel model);
|
|
||||||
CarViewModel? Insert(CarBindingModel model);
|
|
||||||
CarViewModel? Update(CarBindingModel model);
|
|
||||||
CarViewModel? Delete(CarBindingModel model);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,22 +0,0 @@
|
|||||||
using AutomobilePlantContracts.BindingModels;
|
|
||||||
using AutomobilePlantContracts.SearchModel;
|
|
||||||
using AutomobilePlantContracts.ViewModel;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantContracts.StoragesContracts
|
|
||||||
{
|
|
||||||
public interface IClientStorage
|
|
||||||
{
|
|
||||||
List<ClientViewModel> GetFullList();
|
|
||||||
List<ClientViewModel> GetFilteredList(ClientSearchModel model);
|
|
||||||
ClientViewModel? GetElement(ClientSearchModel model);
|
|
||||||
ClientViewModel? Insert(ClientBindingModel model);
|
|
||||||
ClientViewModel? Update(ClientBindingModel model);
|
|
||||||
ClientViewModel? Delete(ClientBindingModel model);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,22 +0,0 @@
|
|||||||
using AutomobilePlantContracts.BindingModels;
|
|
||||||
using AutomobilePlantContracts.SearchModel;
|
|
||||||
using AutomobilePlantContracts.ViewModel;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantContracts.StoragesContracts
|
|
||||||
{
|
|
||||||
public interface IComponentStorage
|
|
||||||
{
|
|
||||||
List<ComponentViewModel> GetFullList();
|
|
||||||
List<ComponentViewModel> GetFilteredList(ComponentSearchModel model);
|
|
||||||
ComponentViewModel? GetElement(ComponentSearchModel model);
|
|
||||||
ComponentViewModel? Insert(ComponentBindingModel model);
|
|
||||||
ComponentViewModel? Update(ComponentBindingModel model);
|
|
||||||
ComponentViewModel? Delete(ComponentBindingModel model);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,26 +0,0 @@
|
|||||||
using AutomobilePlantContracts.BindingModels;
|
|
||||||
using AutomobilePlantContracts.SearchModel;
|
|
||||||
using AutomobilePlantContracts.ViewModel;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantContracts.StoragesContracts
|
|
||||||
{
|
|
||||||
public interface IImplementerStorage
|
|
||||||
{
|
|
||||||
List<ImplementerViewModel> GetFullList();
|
|
||||||
|
|
||||||
List<ImplementerViewModel> GetFilteredList(ImplementerSearchModel model);
|
|
||||||
|
|
||||||
ImplementerViewModel? GetElement(ImplementerSearchModel model);
|
|
||||||
|
|
||||||
ImplementerViewModel? Insert(ImplementerBindingModel model);
|
|
||||||
|
|
||||||
ImplementerViewModel? Update(ImplementerBindingModel model);
|
|
||||||
|
|
||||||
ImplementerViewModel? Delete(ImplementerBindingModel model);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,17 +0,0 @@
|
|||||||
using AutomobilePlantContracts.BindingModels;
|
|
||||||
using AutomobilePlantContracts.SearchModel;
|
|
||||||
using AutomobilePlantContracts.ViewModel;
|
|
||||||
|
|
||||||
namespace AbstractShopContracts.StoragesContracts
|
|
||||||
{
|
|
||||||
public interface IMessageInfoStorage
|
|
||||||
{
|
|
||||||
List<MessageInfoViewModel> GetFullList();
|
|
||||||
|
|
||||||
List<MessageInfoViewModel> GetFilteredList(MessageInfoSearchModel model);
|
|
||||||
|
|
||||||
MessageInfoViewModel? GetElement(MessageInfoSearchModel model);
|
|
||||||
|
|
||||||
MessageInfoViewModel? Insert(MessageInfoBindingModel model);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
using AutomobilePlantContracts.BindingModels;
|
|
||||||
using AutomobilePlantContracts.SearchModel;
|
|
||||||
using AutomobilePlantContracts.ViewModel;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantContracts.StoragesContracts
|
|
||||||
{
|
|
||||||
public interface IOrderStorage
|
|
||||||
{
|
|
||||||
List<OrderViewModel> GetFullList();
|
|
||||||
List<OrderViewModel> GetFilteredList(OrderSearchModel model);
|
|
||||||
OrderViewModel? GetElement(OrderSearchModel model);
|
|
||||||
OrderViewModel? Insert(OrderBindingModel model);
|
|
||||||
OrderViewModel? Update(OrderBindingModel model);
|
|
||||||
OrderViewModel? Delete(OrderBindingModel model);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,28 +0,0 @@
|
|||||||
using AutomobilePlantDataModels.Models;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using AutomobilePlantContracts.Attributes;
|
|
||||||
|
|
||||||
namespace AutomobilePlantContracts.ViewModel
|
|
||||||
{
|
|
||||||
public class CarViewModel : ICarModel
|
|
||||||
{
|
|
||||||
[Column(visible: false)]
|
|
||||||
public int Id { get; set; }
|
|
||||||
[Column(title: "Название", width: 150)]
|
|
||||||
public string CarName { get; set; } = string.Empty;
|
|
||||||
[Column(title: "Цена", width: 50)]
|
|
||||||
public double Price { get; set; }
|
|
||||||
[Column(visible: false)]
|
|
||||||
public Dictionary<int, (IComponentModel, int)> CarComponents
|
|
||||||
{
|
|
||||||
get;
|
|
||||||
set;
|
|
||||||
} = new();
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,23 +0,0 @@
|
|||||||
using AutomobilePlantContracts.Attributes;
|
|
||||||
using AutomobilePlantDataModels.Models;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantContracts.ViewModel
|
|
||||||
{
|
|
||||||
public class ClientViewModel : IClientModel
|
|
||||||
{
|
|
||||||
[Column(visible: false)]
|
|
||||||
public int Id { get; set; }
|
|
||||||
[Column(title: "Имя", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
|
||||||
public string ClientFIO { get; set; } = string.Empty;
|
|
||||||
[Column(title: "Логин (эл. почта)", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
|
||||||
public string Email { get; set; } = string.Empty;
|
|
||||||
[Column(title: "Пароль", width: 150)]
|
|
||||||
public string Password { get; set; } = string.Empty;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
using AutomobilePlantDataModels.Models;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using AutomobilePlantContracts.Attributes;
|
|
||||||
|
|
||||||
namespace AutomobilePlantContracts.ViewModel
|
|
||||||
{
|
|
||||||
public class ComponentViewModel : IComponentModel
|
|
||||||
{
|
|
||||||
[Column(visible: false)]
|
|
||||||
public int Id { get; set; }
|
|
||||||
[Column(title: "Название", width: 150)]
|
|
||||||
public string ComponentName { get; set; } = string.Empty;
|
|
||||||
[Column(title: "Цена", width: 150)]
|
|
||||||
public double Cost { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,29 +0,0 @@
|
|||||||
using AutomobilePlantContracts.Attributes;
|
|
||||||
using AutomobilePlantDataModels.Models;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantContracts.ViewModel
|
|
||||||
{
|
|
||||||
public class ImplementerViewModel : IImplementerModel
|
|
||||||
{
|
|
||||||
[Column(visible: false)]
|
|
||||||
public int Id { get; set; }
|
|
||||||
|
|
||||||
[Column(title: "Имя", width: 150)]
|
|
||||||
public string ImplementerFIO { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
[Column(title: "Пароль", width: 150)]
|
|
||||||
public string Password { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
[Column(title: "Стаж", width: 100)]
|
|
||||||
public int WorkExperience { get; set; }
|
|
||||||
|
|
||||||
[Column(title: "Квалификация", width: 100)]
|
|
||||||
public int Qualification { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,28 +0,0 @@
|
|||||||
using AutomobilePlantContracts.Attributes;
|
|
||||||
using AutomobilePlantDataModels.Models;
|
|
||||||
using System.ComponentModel;
|
|
||||||
|
|
||||||
namespace AutomobilePlantContracts.ViewModel
|
|
||||||
{
|
|
||||||
public class MessageInfoViewModel : IMessageInfoModel
|
|
||||||
{
|
|
||||||
[Column(visible: false)]
|
|
||||||
public string MessageId { get; set; } = string.Empty;
|
|
||||||
[Column(visible: false)]
|
|
||||||
public int? ClientId { get; set; }
|
|
||||||
|
|
||||||
[Column(title: "Отправитель", width: 150)]
|
|
||||||
public string SenderName { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
[Column(title: "Дата", width: 100)]
|
|
||||||
public DateTime DateDelivery { get; set; }
|
|
||||||
|
|
||||||
[Column(title: "Заголовок", width: 150)]
|
|
||||||
public string Subject { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
[Column(title: "Текст", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
|
||||||
public string Body { get; set; } = string.Empty;
|
|
||||||
[Column(visible: false)]
|
|
||||||
public int Id { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,41 +0,0 @@
|
|||||||
using AutomobilePlantDataModels.Models;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using AutomobilePlantDataModels.Enums;
|
|
||||||
using AutomobilePlantContracts.Attributes;
|
|
||||||
|
|
||||||
namespace AutomobilePlantContracts.ViewModel
|
|
||||||
{
|
|
||||||
public class OrderViewModel : IOrderModel
|
|
||||||
{
|
|
||||||
[Column(visible: false)]
|
|
||||||
public int Id { get; set; }
|
|
||||||
[Column(title: "Клиент", width: 150)]
|
|
||||||
public string ClientName { get; set; } = string.Empty;
|
|
||||||
[Column(visible: false)]
|
|
||||||
public int ClientId { get; set; }
|
|
||||||
[Column(visible: false)]
|
|
||||||
public int? ImplementerId { get; set; }
|
|
||||||
[Column(title: "Исполнитель", width: 150)]
|
|
||||||
public string? ImplementerName { get; set; } = string.Empty;
|
|
||||||
[Column(visible: false)]
|
|
||||||
public int CarId { get; set; }
|
|
||||||
[Column(title: "Машина", width: 150)]
|
|
||||||
public string CarName { get; set; } = string.Empty;
|
|
||||||
[Column(title: "Кол-во", width: 150)]
|
|
||||||
public int Count { get; set; }
|
|
||||||
[Column(title: "Сумма", width: 150)]
|
|
||||||
public double Sum { get; set; }
|
|
||||||
[Column(title: "Статус", width: 150)]
|
|
||||||
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
|
|
||||||
[Column(title: "Дата создания", width: 150)]
|
|
||||||
public DateTime DateCreate { get; set; } = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc);
|
|
||||||
[Column(title: "Дата выполнения", width: 150)]
|
|
||||||
public DateTime? DateImplement { get; set; }
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,17 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantContracts.ViewModel
|
|
||||||
{
|
|
||||||
public class ReportCarComponentViewModel
|
|
||||||
{
|
|
||||||
public string CarName { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
public int TotalCount { get; set; }
|
|
||||||
|
|
||||||
public List<(string Component, int Count)> Components { get; set; } = new();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,20 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantContracts.ViewModel
|
|
||||||
{
|
|
||||||
public class ReportOrdersViewModel
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
|
|
||||||
public DateTime DateCreate { get; set; }
|
|
||||||
|
|
||||||
public string CarName { get; set; } = string.Empty;
|
|
||||||
public string Status { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
public double Sum { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,9 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
@ -1,18 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantDataModels.Enums
|
|
||||||
{
|
|
||||||
public enum OrderStatus
|
|
||||||
{
|
|
||||||
Неизвестен = -1,
|
|
||||||
Принят = 0,
|
|
||||||
Выполняется = 1,
|
|
||||||
Готов = 2,
|
|
||||||
Выдан = 3
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,13 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantDataModels
|
|
||||||
{
|
|
||||||
public interface IId
|
|
||||||
{
|
|
||||||
int Id { get; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,16 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantDataModels.Models
|
|
||||||
{
|
|
||||||
public interface ICarModel : IId
|
|
||||||
{
|
|
||||||
string CarName { get; }
|
|
||||||
double Price { get; }
|
|
||||||
Dictionary<int, (IComponentModel, int)> CarComponents { get; }
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantDataModels.Models
|
|
||||||
{
|
|
||||||
public interface IClientModel : IId
|
|
||||||
{
|
|
||||||
string ClientFIO { get; }
|
|
||||||
string Email { get; }
|
|
||||||
string Password { get; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,14 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantDataModels.Models
|
|
||||||
{
|
|
||||||
public interface IComponentModel : IId
|
|
||||||
{
|
|
||||||
string ComponentName { get; }
|
|
||||||
double Cost { get; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,19 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantDataModels.Models
|
|
||||||
{
|
|
||||||
public interface IImplementerModel : IId
|
|
||||||
{
|
|
||||||
string ImplementerFIO { get; }
|
|
||||||
|
|
||||||
string Password { get; }
|
|
||||||
|
|
||||||
int WorkExperience { get; }
|
|
||||||
|
|
||||||
int Qualification { get; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,23 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantDataModels.Models
|
|
||||||
{
|
|
||||||
public interface IMessageInfoModel : IId
|
|
||||||
{
|
|
||||||
string MessageId { get; }
|
|
||||||
|
|
||||||
int? ClientId { get; }
|
|
||||||
|
|
||||||
string SenderName { get; }
|
|
||||||
|
|
||||||
DateTime DateDelivery { get; }
|
|
||||||
|
|
||||||
string Subject { get; }
|
|
||||||
|
|
||||||
string Body { get; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,24 +0,0 @@
|
|||||||
using AutomobilePlantDataModels.Enums;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantDataModels.Models
|
|
||||||
{
|
|
||||||
public interface IOrderModel : IId
|
|
||||||
{
|
|
||||||
int CarId { get; }
|
|
||||||
string CarName { get; }
|
|
||||||
int ClientId { get; }
|
|
||||||
string ClientName { get; }
|
|
||||||
int? ImplementerId { get; }
|
|
||||||
string? ImplementerName { get; }
|
|
||||||
int Count { get; }
|
|
||||||
double Sum { get; }
|
|
||||||
OrderStatus Status { get; }
|
|
||||||
DateTime DateCreate { get; }
|
|
||||||
DateTime? DateImplement { get; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,18 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\AbstractAutoContracts\AutomobilePlantContracts.csproj" />
|
|
||||||
<ProjectReference Include="..\AbstractAutoDataModels\AutomobilePlantDataModels.csproj" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
|
||||||
<Exec Command="copy /Y "$(TargetDir)*.dll" "$(SolutionDir)ImplementationExtensions\*.dll"" />
|
|
||||||
</Target>
|
|
||||||
|
|
||||||
</Project>
|
|
@ -1,37 +0,0 @@
|
|||||||
using AutomobilePlantListImplement.Models;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantListImplement
|
|
||||||
{
|
|
||||||
public class DataListSingleton
|
|
||||||
{
|
|
||||||
private static DataListSingleton? _instance;
|
|
||||||
public List<Component> Components { get; set; }
|
|
||||||
public List<Order> Orders { get; set; }
|
|
||||||
public List<Car> Cars { get; set; }
|
|
||||||
public List<Client> Clients { get; set; }
|
|
||||||
public List<Implementer> Implementers { get; set; }
|
|
||||||
public List<MessageInfoModel> Messages { get; set; }
|
|
||||||
private DataListSingleton()
|
|
||||||
{
|
|
||||||
Components = new List<Component>();
|
|
||||||
Orders = new List<Order>();
|
|
||||||
Cars = new List<Car>();
|
|
||||||
Clients = new List<Client>();
|
|
||||||
Implementers = new List<Implementer>();
|
|
||||||
Messages = new List<MessageInfoModel>();
|
|
||||||
}
|
|
||||||
public static DataListSingleton GetInstance()
|
|
||||||
{
|
|
||||||
if (_instance == null)
|
|
||||||
{
|
|
||||||
_instance = new DataListSingleton();
|
|
||||||
}
|
|
||||||
return _instance;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,17 +0,0 @@
|
|||||||
using AutomobilePlantContracts.StoragesContracts;
|
|
||||||
|
|
||||||
namespace AutomobilePlantListImplement.Implements
|
|
||||||
{
|
|
||||||
public class BackUpInfo : IBackUpInfo
|
|
||||||
{
|
|
||||||
public List<T>? GetList<T>() where T : class, new()
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Type? GetTypeByModelInterface(string modelInterfaceName)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,126 +0,0 @@
|
|||||||
using AutomobilePlantContracts.StoragesContracts;
|
|
||||||
using AutomobilePlantContracts.ViewModel;
|
|
||||||
using AutomobilePlantContracts.BindingModels;
|
|
||||||
using AutomobilePlantContracts.SearchModel;
|
|
||||||
using AutomobilePlantListImplement.Models;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantListImplement.Implements
|
|
||||||
{
|
|
||||||
public class CarStorage : ICarStorage
|
|
||||||
{
|
|
||||||
private readonly DataListSingleton _source;
|
|
||||||
|
|
||||||
public CarStorage()
|
|
||||||
{
|
|
||||||
_source = DataListSingleton.GetInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<CarViewModel> GetFullList()
|
|
||||||
{
|
|
||||||
var result = new List<CarViewModel>();
|
|
||||||
|
|
||||||
foreach (var car in _source.Cars)
|
|
||||||
{
|
|
||||||
result.Add(car.GetViewModel);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<CarViewModel> GetFilteredList(CarSearchModel model)
|
|
||||||
{
|
|
||||||
var result = new List<CarViewModel>();
|
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(model.CarName))
|
|
||||||
{
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var car in _source.Cars)
|
|
||||||
{
|
|
||||||
if (car.CarName.Contains(model.CarName))
|
|
||||||
{
|
|
||||||
result.Add(car.GetViewModel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CarViewModel? GetElement(CarSearchModel model)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(model.CarName) && !model.Id.HasValue)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var car in _source.Cars)
|
|
||||||
{
|
|
||||||
if ((!string.IsNullOrEmpty(model.CarName) && car.CarName == model.CarName) || (model.Id.HasValue && car.Id == model.Id))
|
|
||||||
{
|
|
||||||
return car.GetViewModel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CarViewModel? Insert(CarBindingModel model)
|
|
||||||
{
|
|
||||||
model.Id = 1;
|
|
||||||
|
|
||||||
foreach (var car in _source.Cars)
|
|
||||||
{
|
|
||||||
if (model.Id <= car.Id)
|
|
||||||
{
|
|
||||||
model.Id = car.Id + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var newCar = Car.Create(model);
|
|
||||||
|
|
||||||
if (newCar == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
_source.Cars.Add(newCar);
|
|
||||||
|
|
||||||
return newCar.GetViewModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CarViewModel? Update(CarBindingModel model)
|
|
||||||
{
|
|
||||||
foreach (var car in _source.Cars)
|
|
||||||
{
|
|
||||||
if (car.Id == model.Id)
|
|
||||||
{
|
|
||||||
car.Update(model);
|
|
||||||
return car.GetViewModel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CarViewModel? Delete(CarBindingModel model)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < _source.Cars.Count; ++i)
|
|
||||||
{
|
|
||||||
if (_source.Cars[i].Id == model.Id)
|
|
||||||
{
|
|
||||||
var element = _source.Cars[i];
|
|
||||||
_source.Cars.RemoveAt(i);
|
|
||||||
return element.GetViewModel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,126 +0,0 @@
|
|||||||
using AutomobilePlantContracts.BindingModels;
|
|
||||||
using AutomobilePlantContracts.SearchModel;
|
|
||||||
using AutomobilePlantContracts.StoragesContracts;
|
|
||||||
using AutomobilePlantContracts.ViewModel;
|
|
||||||
using AutomobilePlantListImplement.Models;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantListImplement.Implements
|
|
||||||
{
|
|
||||||
public class ClientStorage : IClientStorage
|
|
||||||
{
|
|
||||||
private readonly DataListSingleton _source;
|
|
||||||
|
|
||||||
public ClientStorage()
|
|
||||||
{
|
|
||||||
_source = DataListSingleton.GetInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<ClientViewModel> GetFullList()
|
|
||||||
{
|
|
||||||
var result = new List<ClientViewModel>();
|
|
||||||
|
|
||||||
foreach (var client in _source.Clients)
|
|
||||||
{
|
|
||||||
result.Add(client.GetViewModel);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<ClientViewModel> GetFilteredList(ClientSearchModel model)
|
|
||||||
{
|
|
||||||
var result = new List<ClientViewModel>();
|
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(model.ClientFIO)&& string.IsNullOrEmpty(model.Email) && string.IsNullOrEmpty(model.Password))
|
|
||||||
{
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var client in _source.Clients)
|
|
||||||
{
|
|
||||||
if (client.ClientFIO.Contains(model.ClientFIO)|| client.Email.Contains(model.Email)|| client.Password.Contains(model.Password))
|
|
||||||
{
|
|
||||||
result.Add(client.GetViewModel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ClientViewModel? GetElement(ClientSearchModel model)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(model.ClientFIO) && !model.Id.HasValue)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var client in _source.Clients)
|
|
||||||
{
|
|
||||||
if ((!string.IsNullOrEmpty(model.ClientFIO) && client.ClientFIO == model.ClientFIO) || (model.Id.HasValue && client.Id == model.Id))
|
|
||||||
{
|
|
||||||
return client.GetViewModel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ClientViewModel? Insert(ClientBindingModel model)
|
|
||||||
{
|
|
||||||
model.Id = 1;
|
|
||||||
|
|
||||||
foreach (var client in _source.Clients)
|
|
||||||
{
|
|
||||||
if (model.Id <= client.Id)
|
|
||||||
{
|
|
||||||
model.Id = client.Id + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var newClient = Client.Create(model);
|
|
||||||
|
|
||||||
if (newClient == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
_source.Clients.Add(newClient);
|
|
||||||
|
|
||||||
return newClient.GetViewModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ClientViewModel? Update(ClientBindingModel model)
|
|
||||||
{
|
|
||||||
foreach (var client in _source.Clients)
|
|
||||||
{
|
|
||||||
if (client.Id == model.Id)
|
|
||||||
{
|
|
||||||
client.Update(model);
|
|
||||||
return client.GetViewModel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ClientViewModel? Delete(ClientBindingModel model)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < _source.Clients.Count; ++i)
|
|
||||||
{
|
|
||||||
if (_source.Clients[i].Id == model.Id)
|
|
||||||
{
|
|
||||||
var element = _source.Clients[i];
|
|
||||||
_source.Clients.RemoveAt(i);
|
|
||||||
return element.GetViewModel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,108 +0,0 @@
|
|||||||
using AutomobilePlantContracts.BindingModels;
|
|
||||||
using AutomobilePlantContracts.SearchModel;
|
|
||||||
using AutomobilePlantContracts.StoragesContracts;
|
|
||||||
using AutomobilePlantContracts.ViewModel;
|
|
||||||
using AutomobilePlantListImplement.Models;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantListImplement.Implements
|
|
||||||
{
|
|
||||||
public class ComponentStorage : IComponentStorage
|
|
||||||
{
|
|
||||||
private readonly DataListSingleton _source;
|
|
||||||
public ComponentStorage()
|
|
||||||
{
|
|
||||||
_source = DataListSingleton.GetInstance();
|
|
||||||
}
|
|
||||||
public List<ComponentViewModel> GetFullList()
|
|
||||||
{
|
|
||||||
var result = new List<ComponentViewModel>();
|
|
||||||
foreach (var component in _source.Components)
|
|
||||||
{
|
|
||||||
result.Add(component.GetViewModel);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
public List<ComponentViewModel> GetFilteredList(ComponentSearchModel
|
|
||||||
model)
|
|
||||||
{
|
|
||||||
var result = new List<ComponentViewModel>();
|
|
||||||
if (string.IsNullOrEmpty(model.ComponentName))
|
|
||||||
{
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
foreach (var component in _source.Components)
|
|
||||||
{
|
|
||||||
if (component.ComponentName.Contains(model.ComponentName))
|
|
||||||
{
|
|
||||||
result.Add(component.GetViewModel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
public ComponentViewModel? GetElement(ComponentSearchModel model)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(model.ComponentName) && !model.Id.HasValue)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
foreach (var component in _source.Components)
|
|
||||||
{
|
|
||||||
if ((!string.IsNullOrEmpty(model.ComponentName) &&
|
|
||||||
component.ComponentName == model.ComponentName) ||
|
|
||||||
(model.Id.HasValue && component.Id == model.Id))
|
|
||||||
{
|
|
||||||
return component.GetViewModel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
public ComponentViewModel? Insert(ComponentBindingModel model)
|
|
||||||
{
|
|
||||||
model.Id = 1;
|
|
||||||
foreach (var component in _source.Components)
|
|
||||||
{
|
|
||||||
if (model.Id <= component.Id)
|
|
||||||
{
|
|
||||||
model.Id = component.Id + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var newComponent = Component.Create(model);
|
|
||||||
if (newComponent == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
_source.Components.Add(newComponent);
|
|
||||||
return newComponent.GetViewModel;
|
|
||||||
}
|
|
||||||
public ComponentViewModel? Update(ComponentBindingModel model)
|
|
||||||
{
|
|
||||||
foreach (var component in _source.Components)
|
|
||||||
{
|
|
||||||
if (component.Id == model.Id)
|
|
||||||
{
|
|
||||||
component.Update(model);
|
|
||||||
return component.GetViewModel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
public ComponentViewModel? Delete(ComponentBindingModel model)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < _source.Components.Count; ++i)
|
|
||||||
{
|
|
||||||
if (_source.Components[i].Id == model.Id)
|
|
||||||
{
|
|
||||||
var element = _source.Components[i];
|
|
||||||
_source.Components.RemoveAt(i);
|
|
||||||
return element.GetViewModel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,126 +0,0 @@
|
|||||||
using AutomobilePlantContracts.BindingModels;
|
|
||||||
using AutomobilePlantContracts.SearchModel;
|
|
||||||
using AutomobilePlantContracts.StoragesContracts;
|
|
||||||
using AutomobilePlantContracts.ViewModel;
|
|
||||||
using AutomobilePlantListImplement.Models;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantListImplement.Implements
|
|
||||||
{
|
|
||||||
public class ImplementerStorage : IImplementerStorage
|
|
||||||
{
|
|
||||||
private readonly DataListSingleton _source;
|
|
||||||
|
|
||||||
public ImplementerStorage()
|
|
||||||
{
|
|
||||||
_source = DataListSingleton.GetInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<ImplementerViewModel> GetFullList()
|
|
||||||
{
|
|
||||||
var result = new List<ImplementerViewModel>();
|
|
||||||
|
|
||||||
foreach (var implementer in _source.Implementers)
|
|
||||||
{
|
|
||||||
result.Add(implementer.GetViewModel);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<ImplementerViewModel> GetFilteredList(ImplementerSearchModel model)
|
|
||||||
{
|
|
||||||
var result = new List<ImplementerViewModel>();
|
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(model.ImplementerFIO) && string.IsNullOrEmpty(model.Password))
|
|
||||||
{
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var implementer in _source.Implementers)
|
|
||||||
{
|
|
||||||
if (implementer.ImplementerFIO.Contains(model.ImplementerFIO) || implementer.Password.Contains(model.Password))
|
|
||||||
{
|
|
||||||
result.Add(implementer.GetViewModel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ImplementerViewModel? GetElement(ImplementerSearchModel model)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(model.ImplementerFIO) && !model.Id.HasValue)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var implementer in _source.Implementers)
|
|
||||||
{
|
|
||||||
if ((!string.IsNullOrEmpty(model.ImplementerFIO) && implementer.ImplementerFIO == model.ImplementerFIO) || (model.Id.HasValue && implementer.Id == model.Id))
|
|
||||||
{
|
|
||||||
return implementer.GetViewModel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ImplementerViewModel? Insert(ImplementerBindingModel model)
|
|
||||||
{
|
|
||||||
model.Id = 1;
|
|
||||||
|
|
||||||
foreach (var implementer in _source.Implementers)
|
|
||||||
{
|
|
||||||
if (model.Id <= implementer.Id)
|
|
||||||
{
|
|
||||||
model.Id = implementer.Id + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var newImplementer = Implementer.Create(model);
|
|
||||||
|
|
||||||
if (newImplementer == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
_source.Implementers.Add(newImplementer);
|
|
||||||
|
|
||||||
return newImplementer.GetViewModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ImplementerViewModel? Update(ImplementerBindingModel model)
|
|
||||||
{
|
|
||||||
foreach (var implementer in _source.Implementers)
|
|
||||||
{
|
|
||||||
if (implementer.Id == model.Id)
|
|
||||||
{
|
|
||||||
implementer.Update(model);
|
|
||||||
return implementer.GetViewModel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ImplementerViewModel? Delete(ImplementerBindingModel model)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < _source.Implementers.Count; ++i)
|
|
||||||
{
|
|
||||||
if (_source.Implementers[i].Id == model.Id)
|
|
||||||
{
|
|
||||||
var element = _source.Implementers[i];
|
|
||||||
_source.Implementers.RemoveAt(i);
|
|
||||||
return element.GetViewModel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,98 +0,0 @@
|
|||||||
using AbstractShopContracts.StoragesContracts;
|
|
||||||
using AutomobilePlantContracts.BindingModels;
|
|
||||||
using AutomobilePlantContracts.SearchModel;
|
|
||||||
using AutomobilePlantContracts.ViewModel;
|
|
||||||
using AutomobilePlantListImplement.Models;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantListImplement.Implements
|
|
||||||
{
|
|
||||||
public class MessageInfoStorage : IMessageInfoStorage
|
|
||||||
|
|
||||||
{
|
|
||||||
|
|
||||||
private readonly DataListSingleton _source;
|
|
||||||
public MessageInfoStorage()
|
|
||||||
{
|
|
||||||
_source = DataListSingleton.GetInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
public MessageInfoViewModel? GetElement(MessageInfoSearchModel model)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(model.MessageId) )
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var message in _source.Messages)
|
|
||||||
{
|
|
||||||
if (!string.IsNullOrEmpty(model.MessageId) && message.MessageId.Equals(model.MessageId) )
|
|
||||||
{
|
|
||||||
return message.GetViewModel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<MessageInfoViewModel> GetFilteredList(MessageInfoSearchModel model)
|
|
||||||
{
|
|
||||||
var result = new List<MessageInfoViewModel>();
|
|
||||||
|
|
||||||
if (!model.ClientId.HasValue)
|
|
||||||
{
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var message in _source.Messages)
|
|
||||||
{
|
|
||||||
if (message.ClientId == model.ClientId)
|
|
||||||
{
|
|
||||||
result.Add(message.GetViewModel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<MessageInfoViewModel> GetFullList()
|
|
||||||
{
|
|
||||||
var result = new List<MessageInfoViewModel>();
|
|
||||||
|
|
||||||
foreach (var message in _source.Messages)
|
|
||||||
{
|
|
||||||
result.Add(message.GetViewModel);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MessageInfoViewModel? Insert(MessageInfoBindingModel model)
|
|
||||||
{
|
|
||||||
model.MessageId = "1";
|
|
||||||
|
|
||||||
foreach (var message in _source.Messages)
|
|
||||||
{
|
|
||||||
if (model.MessageId.Equals(message.MessageId))
|
|
||||||
{
|
|
||||||
model.MessageId = (Convert.ToInt32(message.MessageId) +1).ToString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var newMes = MessageInfoModel.Create(model);
|
|
||||||
|
|
||||||
if (newMes == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
_source.Messages.Add(newMes);
|
|
||||||
|
|
||||||
return newMes.GetViewModel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,130 +0,0 @@
|
|||||||
using AutomobilePlantContracts.StoragesContracts;
|
|
||||||
using AutomobilePlantContracts.ViewModel;
|
|
||||||
using AutomobilePlantContracts.BindingModels;
|
|
||||||
using AutomobilePlantContracts.SearchModel;
|
|
||||||
using AutomobilePlantListImplement.Models;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantListImplement.Implements
|
|
||||||
{
|
|
||||||
public class OrderStorage : IOrderStorage
|
|
||||||
{
|
|
||||||
private readonly DataListSingleton _source;
|
|
||||||
public OrderStorage()
|
|
||||||
{
|
|
||||||
_source = DataListSingleton.GetInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<OrderViewModel> GetFullList()
|
|
||||||
{
|
|
||||||
var result = new List<OrderViewModel>();
|
|
||||||
|
|
||||||
foreach (var order in _source.Orders)
|
|
||||||
{
|
|
||||||
result.Add(order.GetViewModel);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
|
||||||
{
|
|
||||||
var result = new List<OrderViewModel>();
|
|
||||||
|
|
||||||
if (!model.Id.HasValue)
|
|
||||||
{
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var order in _source.Orders)
|
|
||||||
{
|
|
||||||
if (model.ClientId.HasValue && order.ClientId == model.ClientId)
|
|
||||||
{ result.Add(order.GetViewModel);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (model.Id.HasValue && order.Id == model.Id && order.DateCreate > model.DateFrom && order.DateCreate < model.DateTo)
|
|
||||||
{
|
|
||||||
result.Add(order.GetViewModel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OrderViewModel? GetElement(OrderSearchModel model)
|
|
||||||
{
|
|
||||||
if (!model.Id.HasValue)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var order in _source.Orders)
|
|
||||||
{
|
|
||||||
if (model.Id.HasValue && order.Id == model.Id)
|
|
||||||
{
|
|
||||||
return order.GetViewModel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OrderViewModel? Insert(OrderBindingModel model)
|
|
||||||
{
|
|
||||||
model.Id = 1;
|
|
||||||
|
|
||||||
foreach (var order in _source.Orders)
|
|
||||||
{
|
|
||||||
if (model.Id <= order.Id)
|
|
||||||
{
|
|
||||||
model.Id = order.Id + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var newOrder = Order.Create(model);
|
|
||||||
|
|
||||||
if (newOrder == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
_source.Orders.Add(newOrder);
|
|
||||||
|
|
||||||
return newOrder.GetViewModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OrderViewModel? Update(OrderBindingModel model)
|
|
||||||
{
|
|
||||||
foreach (var order in _source.Orders)
|
|
||||||
{
|
|
||||||
if (order.Id == model.Id)
|
|
||||||
{
|
|
||||||
order.Update(model);
|
|
||||||
return order.GetViewModel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
public OrderViewModel? Delete(OrderBindingModel model)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < _source.Orders.Count; ++i)
|
|
||||||
{
|
|
||||||
if (_source.Orders[i].Id == model.Id)
|
|
||||||
{
|
|
||||||
var element = _source.Orders[i];
|
|
||||||
_source.Orders.RemoveAt(i);
|
|
||||||
return element.GetViewModel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,28 +0,0 @@
|
|||||||
using AbstractShopContracts.StoragesContracts;
|
|
||||||
using AutomobilePlantContracts.DI;
|
|
||||||
using AutomobilePlantContracts.StoragesContracts;
|
|
||||||
using AutomobilePlantListImplement.Implements;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantListImplement
|
|
||||||
{
|
|
||||||
public class ListImplementationExtension : IImplementationExtension
|
|
||||||
{
|
|
||||||
public int Priority => 0;
|
|
||||||
|
|
||||||
public void RegisterServices()
|
|
||||||
{
|
|
||||||
DependencyManager.Instance.RegisterType<IClientStorage, ClientStorage>();
|
|
||||||
DependencyManager.Instance.RegisterType<IComponentStorage, ComponentStorage>();
|
|
||||||
DependencyManager.Instance.RegisterType<IImplementerStorage, ImplementerStorage>();
|
|
||||||
DependencyManager.Instance.RegisterType<IMessageInfoStorage, MessageInfoStorage>();
|
|
||||||
DependencyManager.Instance.RegisterType<IOrderStorage, OrderStorage>();
|
|
||||||
DependencyManager.Instance.RegisterType<ICarStorage, CarStorage>();
|
|
||||||
DependencyManager.Instance.RegisterType<IBackUpInfo, BackUpInfo>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,55 +0,0 @@
|
|||||||
using AutomobilePlantContracts.BindingModels;
|
|
||||||
using AutomobilePlantContracts.ViewModel;
|
|
||||||
using AutomobilePlantDataModels.Models;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantListImplement.Models
|
|
||||||
{
|
|
||||||
public class Car : ICarModel
|
|
||||||
{
|
|
||||||
public int Id { get; private set; }
|
|
||||||
public string CarName { get; private set; } = string.Empty;
|
|
||||||
public double Price { get; private set; }
|
|
||||||
public Dictionary<int, (IComponentModel, int)> CarComponents
|
|
||||||
{
|
|
||||||
get;
|
|
||||||
private set;
|
|
||||||
} = new Dictionary<int, (IComponentModel, int)>();
|
|
||||||
public static Car? Create(CarBindingModel? model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return new Car()
|
|
||||||
{
|
|
||||||
Id = model.Id,
|
|
||||||
CarName = model.CarName,
|
|
||||||
Price = model.Price,
|
|
||||||
CarComponents = model.CarComponents
|
|
||||||
};
|
|
||||||
}
|
|
||||||
public void Update(CarBindingModel? model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
CarName = model.CarName;
|
|
||||||
Price = model.Price;
|
|
||||||
CarComponents = model.CarComponents;
|
|
||||||
}
|
|
||||||
public CarViewModel GetViewModel => new()
|
|
||||||
{
|
|
||||||
Id = Id,
|
|
||||||
CarName = CarName,
|
|
||||||
Price = Price,
|
|
||||||
CarComponents = CarComponents
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user