2024-04-10 08:56:56 +04:00
|
|
|
|
using SoftwareInstallationBusinessLogic.OfficePackage.HelperModels;
|
|
|
|
|
using SoftwareInstallationBusinessLogic.OfficePackage;
|
|
|
|
|
using SoftwareInstallationContracts.BindingModels;
|
|
|
|
|
using SoftwareInstallationContracts.SearchModels;
|
|
|
|
|
using SoftwareInstallationContracts.StoragesContracts;
|
|
|
|
|
using SoftwareInstallationContracts.ViewModels;
|
2024-04-29 13:44:53 +04:00
|
|
|
|
using SoftwareInstallationContracts.BusinessLogicsContracts;
|
2024-04-10 08:56:56 +04:00
|
|
|
|
|
|
|
|
|
namespace SoftwareInstallationBusinessLogic.BusinessLogics
|
|
|
|
|
{
|
|
|
|
|
public class ReportLogic : IReportLogic
|
|
|
|
|
{
|
|
|
|
|
private readonly IComponentStorage _componentStorage;
|
2024-04-29 13:44:53 +04:00
|
|
|
|
private readonly IPackageStorage _packageStorage;
|
2024-04-10 08:56:56 +04:00
|
|
|
|
private readonly IOrderStorage _orderStorage;
|
|
|
|
|
private readonly AbstractSaveToExcel _saveToExcel;
|
|
|
|
|
private readonly AbstractSaveToWord _saveToWord;
|
|
|
|
|
private readonly AbstractSaveToPdf _saveToPdf;
|
2024-04-29 13:44:53 +04:00
|
|
|
|
public ReportLogic(IPackageStorage packageStorage, IComponentStorage
|
|
|
|
|
componentStorage, IOrderStorage orderStorage,
|
|
|
|
|
AbstractSaveToExcel saveToExcel, AbstractSaveToWord saveToWord,
|
|
|
|
|
AbstractSaveToPdf saveToPdf)
|
2024-04-10 08:56:56 +04:00
|
|
|
|
{
|
2024-04-29 13:44:53 +04:00
|
|
|
|
_packageStorage = packageStorage;
|
2024-04-10 08:56:56 +04:00
|
|
|
|
_componentStorage = componentStorage;
|
|
|
|
|
_orderStorage = orderStorage;
|
|
|
|
|
_saveToExcel = saveToExcel;
|
|
|
|
|
_saveToWord = saveToWord;
|
|
|
|
|
_saveToPdf = saveToPdf;
|
|
|
|
|
}
|
|
|
|
|
public List<ReportPackageComponentViewModel> GetSoftwareComponents()
|
|
|
|
|
{
|
2024-04-29 13:44:53 +04:00
|
|
|
|
return _packageStorage.GetFullList().Select(x => new ReportPackageComponentViewModel
|
2024-04-10 08:56:56 +04:00
|
|
|
|
{
|
2024-04-29 13:44:53 +04:00
|
|
|
|
PackageName = x.PackageName,
|
|
|
|
|
Components = x.PackageComponents.Select(x => (x.Value.Item1.ComponentName, x.Value.Item2)).ToList(),
|
|
|
|
|
TotalCount = x.PackageComponents.Select(x => x.Value.Item2).Sum()
|
|
|
|
|
}).ToList();
|
2024-04-10 08:56:56 +04:00
|
|
|
|
}
|
2024-04-29 13:44:53 +04:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Получение списка заказов за определенный период
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="model"></param>
|
|
|
|
|
/// <returns></returns>
|
2024-04-10 08:56:56 +04:00
|
|
|
|
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,
|
2024-04-21 17:55:38 +04:00
|
|
|
|
PackageName = x.PackageName,
|
2024-04-10 08:56:56 +04:00
|
|
|
|
Sum = x.Sum,
|
2024-04-29 13:44:53 +04:00
|
|
|
|
Status = x.Status.ToString()
|
2024-04-10 08:56:56 +04:00
|
|
|
|
})
|
|
|
|
|
.ToList();
|
|
|
|
|
}
|
2024-04-29 13:44:53 +04:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Сохранение компонент в файл-Word
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="model"></param>
|
2024-04-10 08:56:56 +04:00
|
|
|
|
public void SaveSoftwaresToWordFile(ReportBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
_saveToWord.CreateDoc(new WordInfo
|
|
|
|
|
{
|
|
|
|
|
FileName = model.FileName,
|
2024-04-29 13:44:53 +04:00
|
|
|
|
Title = "Список пакетов",
|
|
|
|
|
Softwares = _packageStorage.GetFullList()
|
2024-04-10 08:56:56 +04:00
|
|
|
|
});
|
|
|
|
|
}
|
2024-04-29 13:44:53 +04:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Сохранение компонент с указаеним продуктов в файл-Excel
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="model"></param>
|
2024-04-10 08:56:56 +04:00
|
|
|
|
public void SavePackageComponentToExcelFile(ReportBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
_saveToExcel.CreateReport(new ExcelInfo
|
|
|
|
|
{
|
|
|
|
|
FileName = model.FileName,
|
2024-04-29 13:44:53 +04:00
|
|
|
|
Title = "Список изделий и их компонент",
|
2024-04-10 08:56:56 +04:00
|
|
|
|
SoftwareComponents = GetSoftwareComponents()
|
|
|
|
|
});
|
|
|
|
|
}
|
2024-04-29 13:44:53 +04:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Сохранение заказов в файл-Pdf
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="model"></param>
|
2024-04-10 08:56:56 +04:00
|
|
|
|
public void SaveOrdersToPdfFile(ReportBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
_saveToPdf.CreateDoc(new PdfInfo
|
|
|
|
|
{
|
|
|
|
|
FileName = model.FileName,
|
|
|
|
|
Title = "Список заказов",
|
|
|
|
|
DateFrom = model.DateFrom!.Value,
|
|
|
|
|
DateTo = model.DateTo!.Value,
|
|
|
|
|
Orders = GetOrders(model)
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|