Merge branch 'LabWork04' of https://git.is.ulstu.ru/ekallin/PIbd-21_Bakalskaya_E.D._SushiBar into LabWork04
This commit is contained in:
commit
8ffd918013
@ -7,9 +7,10 @@ using SushiBarBusinessLogic.OfficePackage;
|
|||||||
using SushiBarBusinessLogic.OfficePackage.Implements;
|
using SushiBarBusinessLogic.OfficePackage.Implements;
|
||||||
using SushiBarContracts.BusinessLogicsContracts;
|
using SushiBarContracts.BusinessLogicsContracts;
|
||||||
using SushiBarContracts.StoragesContracts;
|
using SushiBarContracts.StoragesContracts;
|
||||||
using SushiBarDatabaseImplement.Implements;
|
using SushiBarFileImplement.Implements;
|
||||||
using SushiBarView;
|
using SushiBarView;
|
||||||
using SushiBarView.Reports;
|
using SushiBarView.Reports;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
namespace SushiBar
|
namespace SushiBar
|
||||||
{
|
{
|
||||||
@ -29,6 +30,9 @@ namespace SushiBar
|
|||||||
// see https://aka.ms/applicationconfiguration.
|
// see https://aka.ms/applicationconfiguration.
|
||||||
ApplicationConfiguration.Initialize();
|
ApplicationConfiguration.Initialize();
|
||||||
var services = new ServiceCollection();
|
var services = new ServiceCollection();
|
||||||
|
// Добавлено для устранения ошибки с кодировкой при сохранении в PDF
|
||||||
|
// чтобы заработало нужно поставить NuGet пакет System.Text.Encoding.CodePages
|
||||||
|
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
|
||||||
ConfigureServices(services);
|
ConfigureServices(services);
|
||||||
_serviceProvider = services.BuildServiceProvider();
|
_serviceProvider = services.BuildServiceProvider();
|
||||||
Application.Run(_serviceProvider.GetRequiredService<FormMain>());
|
Application.Run(_serviceProvider.GetRequiredService<FormMain>());
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
|
||||||
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.8" />
|
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.8" />
|
||||||
<PackageReference Include="ReportViewerCore.WinForms" Version="15.1.19" />
|
<PackageReference Include="ReportViewerCore.WinForms" Version="15.1.19" />
|
||||||
|
<PackageReference Include="System.Text.Encoding.CodePages" Version="8.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
using MigraDoc.DocumentObjectModel;
|
using MigraDoc.DocumentObjectModel;
|
||||||
|
using MigraDoc.DocumentObjectModel.Tables;
|
||||||
using MigraDoc.Rendering;
|
using MigraDoc.Rendering;
|
||||||
using SushiBarBusinessLogic.OfficePackage.HelperEnums;
|
using SushiBarBusinessLogic.OfficePackage.HelperEnums;
|
||||||
using SushiBarBusinessLogic.OfficePackage.HelperModels;
|
using SushiBarBusinessLogic.OfficePackage.HelperModels;
|
||||||
using MigraDoc.DocumentObjectModel.Tables;
|
|
||||||
|
|
||||||
namespace SushiBarBusinessLogic.OfficePackage.Implements
|
namespace SushiBarBusinessLogic.OfficePackage.Implements
|
||||||
{
|
{
|
||||||
@ -89,28 +89,12 @@ namespace SushiBarBusinessLogic.OfficePackage.Implements
|
|||||||
|
|
||||||
protected override void SavePdf(PdfInfo info)
|
protected override void SavePdf(PdfInfo info)
|
||||||
{
|
{
|
||||||
if (_document != null)
|
var renderer = new PdfDocumentRenderer(true)
|
||||||
{
|
{
|
||||||
var renderer = new PdfDocumentRenderer(true)
|
Document = _document
|
||||||
{
|
};
|
||||||
|
renderer.RenderDocument();
|
||||||
Document = _document
|
renderer.PdfDocument.Save(info.FileName);
|
||||||
};
|
|
||||||
if (renderer.PdfDocument != null)
|
|
||||||
{
|
|
||||||
renderer.RenderDocument();
|
|
||||||
renderer.PdfDocument.Save(info.FileName);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new NullReferenceException("renderer.RenderDocument is null");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new NullReferenceException("_document is null");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,15 +17,24 @@ namespace SushiBarDatabaseImplement.Implements
|
|||||||
|
|
||||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||||
{
|
{
|
||||||
if (!model.Id.HasValue && !model.DateTo.HasValue && !model.DateFrom.HasValue)
|
using var context = new SecuritySystemDatabase();
|
||||||
{
|
var orders = context.Orders
|
||||||
return new();
|
.Include(x => x.Secure)
|
||||||
}
|
.Select(x => x.GetViewModel)
|
||||||
using var context = new SushiBarDatabase();
|
.ToList();
|
||||||
if (model.Id.HasValue)
|
if (model.Id.HasValue)
|
||||||
return context.Orders.Where(x => x.Id == model.Id).Select(x => AccessViewModel(x.GetViewModel)).ToList();
|
{
|
||||||
else
|
orders = orders.Where(x => x.Id == model.Id.Value).ToList();
|
||||||
return context.Orders.Where(x => x.DateCreate >= model.DateFrom).Where(x => x.DateCreate <= model.DateTo).Select(x => AccessViewModel(x.GetViewModel)).ToList();
|
}
|
||||||
|
if (model.DateFrom.HasValue)
|
||||||
|
{
|
||||||
|
orders = orders.Where(x => x.DateCreate >= model.DateFrom.Value).ToList();
|
||||||
|
}
|
||||||
|
if (model.DateTo.HasValue)
|
||||||
|
{
|
||||||
|
orders = orders.Where(x => x.DateCreate <= model.DateTo.Value).ToList();
|
||||||
|
}
|
||||||
|
return orders;
|
||||||
}
|
}
|
||||||
public OrderViewModel? GetElement(OrderSearchModel model)
|
public OrderViewModel? GetElement(OrderSearchModel model)
|
||||||
{
|
{
|
||||||
|
@ -20,11 +20,22 @@ namespace SushiBarFileImplement.Implements
|
|||||||
}
|
}
|
||||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||||
{
|
{
|
||||||
if (!model.Id.HasValue)
|
var orders = source.Orders
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
if (model.Id.HasValue)
|
||||||
{
|
{
|
||||||
return new();
|
orders = orders.Where(x => x.Id == model.Id.Value).ToList();
|
||||||
}
|
}
|
||||||
return source.Orders.Where(x => x.Id == model.Id).Select(x => GetViewModel(x)).ToList();
|
if (model.DateFrom.HasValue)
|
||||||
|
{
|
||||||
|
orders = orders.Where(x => x.DateCreate >= model.DateFrom.Value).ToList();
|
||||||
|
}
|
||||||
|
if (model.DateTo.HasValue)
|
||||||
|
{
|
||||||
|
orders = orders.Where(x => x.DateCreate <= model.DateTo.Value).ToList();
|
||||||
|
}
|
||||||
|
return orders;
|
||||||
}
|
}
|
||||||
public OrderViewModel? GetElement(OrderSearchModel model)
|
public OrderViewModel? GetElement(OrderSearchModel model)
|
||||||
{
|
{
|
||||||
|
@ -28,19 +28,22 @@ namespace SushiBarListImplements.Implements
|
|||||||
|
|
||||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||||
{
|
{
|
||||||
var result = new List<OrderViewModel>();
|
var orders = _source.Orders
|
||||||
if (model == null || !model.Id.HasValue)
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
if (model.Id.HasValue)
|
||||||
{
|
{
|
||||||
return result;
|
orders = orders.Where(x => x.Id == model.Id.Value).ToList();
|
||||||
}
|
}
|
||||||
foreach (var order in _source.Orders)
|
if (model.DateFrom.HasValue)
|
||||||
{
|
{
|
||||||
if (order.Id == model.Id)
|
orders = orders.Where(x => x.DateCreate >= model.DateFrom.Value).ToList();
|
||||||
{
|
|
||||||
result.Add(order.GetViewModel);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return result;
|
if (model.DateTo.HasValue)
|
||||||
|
{
|
||||||
|
orders = orders.Where(x => x.DateCreate <= model.DateTo.Value).ToList();
|
||||||
|
}
|
||||||
|
return orders;
|
||||||
}
|
}
|
||||||
|
|
||||||
public OrderViewModel? GetElement(OrderSearchModel model)
|
public OrderViewModel? GetElement(OrderSearchModel model)
|
||||||
|
Loading…
Reference in New Issue
Block a user