Warehouses #1
@@ -13,6 +13,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FaKrosnoEfDataModel", "FaKr
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SytelineSaAppEfDataModel", "SytelineSaAppEfDataModel\SytelineSaAppEfDataModel.csproj", "{02B7F642-62C1-4BA2-87B0-0B9214319095}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SytelineSaAppEfDataModel", "SytelineSaAppEfDataModel\SytelineSaAppEfDataModel.csproj", "{02B7F642-62C1-4BA2-87B0-0B9214319095}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OrdersManagementDataModel", "OrdersManagementDataModel\OrdersManagementDataModel.csproj", "{5971D564-5108-4777-8273-DDE90BF39879}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@@ -35,6 +37,10 @@ Global
|
|||||||
{02B7F642-62C1-4BA2-87B0-0B9214319095}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{02B7F642-62C1-4BA2-87B0-0B9214319095}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{02B7F642-62C1-4BA2-87B0-0B9214319095}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{02B7F642-62C1-4BA2-87B0-0B9214319095}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{02B7F642-62C1-4BA2-87B0-0B9214319095}.Release|Any CPU.Build.0 = Release|Any CPU
|
{02B7F642-62C1-4BA2-87B0-0B9214319095}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{5971D564-5108-4777-8273-DDE90BF39879}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{5971D564-5108-4777-8273-DDE90BF39879}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{5971D564-5108-4777-8273-DDE90BF39879}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{5971D564-5108-4777-8273-DDE90BF39879}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
@@ -42,5 +48,6 @@ Global
|
|||||||
GlobalSection(NestedProjects) = preSolution
|
GlobalSection(NestedProjects) = preSolution
|
||||||
{4671E3B6-4D11-4521-A927-DC3B1072FC4A} = {6607ACC9-71B9-4095-9A81-B6FBB0AAAF17}
|
{4671E3B6-4D11-4521-A927-DC3B1072FC4A} = {6607ACC9-71B9-4095-9A81-B6FBB0AAAF17}
|
||||||
{02B7F642-62C1-4BA2-87B0-0B9214319095} = {6607ACC9-71B9-4095-9A81-B6FBB0AAAF17}
|
{02B7F642-62C1-4BA2-87B0-0B9214319095} = {6607ACC9-71B9-4095-9A81-B6FBB0AAAF17}
|
||||||
|
{5971D564-5108-4777-8273-DDE90BF39879} = {6607ACC9-71B9-4095-9A81-B6FBB0AAAF17}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
|||||||
17
FaKrosnoApi/Controllers/CustomerController.cs
Normal file
17
FaKrosnoApi/Controllers/CustomerController.cs
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using SytelineSaAppEfDataModel.Dtos;
|
||||||
|
using SytelineSaAppEfDataModel.Services;
|
||||||
|
|
||||||
|
namespace FaKrosnoApi.Controllers;
|
||||||
|
|
||||||
|
[ApiController]
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
public class CustomerController(ICustomerService service) : Controller
|
||||||
|
{
|
||||||
|
[HttpGet]
|
||||||
|
public async Task<ActionResult<IEnumerable<CustomerDto>>> GetAllCustomers()
|
||||||
|
{
|
||||||
|
IList<CustomerDto> customers = await service.GetAllCustomers();
|
||||||
|
return Ok(customers);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using SytelineSaAppEfDataModel.Dtos;
|
using SytelineSaAppEfDataModel.Dtos;
|
||||||
using SytelineSaAppEfDataModel.Services;
|
using SytelineSaAppEfDataModel.Services;
|
||||||
|
|
||||||
@@ -11,15 +12,96 @@ namespace FaKrosnoApi.Controllers
|
|||||||
[HttpGet]
|
[HttpGet]
|
||||||
public async Task<ActionResult<IEnumerable<CustomerOrderDto>>> GetAll()
|
public async Task<ActionResult<IEnumerable<CustomerOrderDto>>> GetAll()
|
||||||
{
|
{
|
||||||
IEnumerable<CustomerOrderDto?> ediCustomerOrders = await service.GetAll();
|
IEnumerable<CustomerOrderDto?> customerOrders = await service.GetAll();
|
||||||
return Ok(ediCustomerOrders);
|
return Ok(customerOrders);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("by-order-number")]
|
[HttpGet("by-order-number")]
|
||||||
public async Task<ActionResult<CustomerOrderDto?>> GetByCustomerOrderNumber([FromQuery] Guid customerOrderNumber)
|
public async Task<ActionResult<CustomerOrderDto?>> GetByCustomerOrderNumber(
|
||||||
|
[FromQuery] Guid customerOrderNumber)
|
||||||
{
|
{
|
||||||
CustomerOrderDto? scheduleOrder = await service.GetByOrderNumber(customerOrderNumber);
|
CustomerOrderDto? customerOrder = await service.GetByOrderNumber(customerOrderNumber);
|
||||||
return scheduleOrder != null ? Ok(scheduleOrder) : NotFound();
|
return customerOrder != null ? Ok(customerOrder) : NotFound();
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("by-co-number")]
|
||||||
|
public async Task<ActionResult<CustomerOrderDto?>> GetByCoNumber([FromQuery] string customerOrderNumber)
|
||||||
|
{
|
||||||
|
CustomerOrderDto? customerOrder = await service.GetByCoNumber(customerOrderNumber);
|
||||||
|
return customerOrder != null ? Ok(customerOrder) : NotFound();
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("lines-by-co-number")]
|
||||||
|
public async Task<ActionResult<IEnumerable<CustomerOrderLineDto>?>> GetLinesByCoNumber(
|
||||||
|
[FromQuery] string customerOrderNumber)
|
||||||
|
{
|
||||||
|
var customerOrderLines = await service.GetLinesByCoNumber(customerOrderNumber);
|
||||||
|
return customerOrderLines != null ? Ok(customerOrderLines) : NotFound();
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("items-by-co-number")]
|
||||||
|
public async Task<ActionResult<IEnumerable<CustomerOrderLineItemDto>?>> GetItemsByCoNumber(
|
||||||
|
[FromQuery] string customerOrderNumber)
|
||||||
|
{
|
||||||
|
var customerOrderLineItems = await service.GetItemsByCoNumber(customerOrderNumber);
|
||||||
|
return customerOrderLineItems != null ? Ok(customerOrderLineItems) : NotFound();
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("by-customer-and-po")]
|
||||||
|
public async Task<ActionResult<CustomerOrderDto?>> GetByCustomerAndPo([FromQuery] string customerNumber,
|
||||||
|
[FromQuery] int customerSequence, [FromQuery] string poNumber)
|
||||||
|
{
|
||||||
|
CustomerOrderDto? customerOrder =
|
||||||
|
await service.GetByCustomerAndPo(customerNumber, customerSequence, poNumber);
|
||||||
|
return customerOrder != null ? Ok(customerOrder) : NotFound();
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("by-po")]
|
||||||
|
public async Task<ActionResult<CustomerOrderDto?>> GetByPo([FromQuery] string poNumber)
|
||||||
|
{
|
||||||
|
CustomerOrderDto? customerOrder = await service.GetByPo(poNumber);
|
||||||
|
return customerOrder != null ? Ok(customerOrder) : NotFound();
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("list-by-customer-and-po")]
|
||||||
|
public async Task<ActionResult<IList<CustomerOrderDto?>>> GetListByCustomerAndPo(
|
||||||
|
[FromQuery] string customerNumber, [FromQuery] int customerSequence, [FromQuery] string poNumber)
|
||||||
|
{
|
||||||
|
IList<CustomerOrderDto> customerOrders =
|
||||||
|
await service.GetListByCustomerAndPo(customerNumber, customerSequence, poNumber);
|
||||||
|
|
||||||
|
foreach (CustomerOrderDto customerOrder in customerOrders)
|
||||||
|
{
|
||||||
|
customerOrder.CustomerOrderLines = await service.GetLinesByCoNumber(customerOrder.CoNum) ?? [];
|
||||||
|
|
||||||
|
foreach (CustomerOrderLineDto customerOrderLine in customerOrder.CustomerOrderLines)
|
||||||
|
{
|
||||||
|
customerOrderLine.CustomerOrderLineItems =
|
||||||
|
await service.GetItemsByCoNumber(customerOrder.CoNum) ?? [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Ok(customerOrders);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("list-by-customer")]
|
||||||
|
public async Task<ActionResult<IList<CustomerOrderDto?>>> GetListByCustomer([FromQuery] string customerNumber,
|
||||||
|
[FromQuery] int customerSequence)
|
||||||
|
{
|
||||||
|
IList<CustomerOrderDto> customerOrders = await service.GetListByCustomer(customerNumber, customerSequence);
|
||||||
|
|
||||||
|
foreach (CustomerOrderDto customerOrder in customerOrders)
|
||||||
|
{
|
||||||
|
customerOrder.CustomerOrderLines = await service.GetLinesByCoNumber(customerOrder.CoNum) ?? [];
|
||||||
|
|
||||||
|
foreach (CustomerOrderLineDto customerOrderLine in customerOrder.CustomerOrderLines)
|
||||||
|
{
|
||||||
|
customerOrderLine.CustomerOrderLineItems =
|
||||||
|
await service.GetItemsByCoNumber(customerOrder.CoNum) ?? [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Ok(customerOrders);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
17
FaKrosnoApi/Controllers/CustomerTpController.cs
Normal file
17
FaKrosnoApi/Controllers/CustomerTpController.cs
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using SytelineSaAppEfDataModel.Dtos;
|
||||||
|
using SytelineSaAppEfDataModel.Services;
|
||||||
|
|
||||||
|
namespace FaKrosnoApi.Controllers;
|
||||||
|
|
||||||
|
[ApiController]
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
public class CustomerTpController(ICustomerTpService service) : Controller
|
||||||
|
{
|
||||||
|
[HttpGet]
|
||||||
|
public async Task<ActionResult<IEnumerable<CustomerTpDto>>> GetAllCustomers()
|
||||||
|
{
|
||||||
|
IList<CustomerTpDto> customers = await service.GetAllCustomersTp();
|
||||||
|
return Ok(customers);
|
||||||
|
}
|
||||||
|
}
|
||||||
35
FaKrosnoApi/Controllers/EdiCustomerOrderImportController.cs
Normal file
35
FaKrosnoApi/Controllers/EdiCustomerOrderImportController.cs
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using SytelineSaAppEfDataModel.Dtos;
|
||||||
|
using SytelineSaAppEfDataModel.Services;
|
||||||
|
|
||||||
|
namespace FaKrosnoApi.Controllers;
|
||||||
|
|
||||||
|
[ApiController]
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
public class EdiCustomerOrderImportController(IEdiCustomerOrderImportService service) : Controller
|
||||||
|
{
|
||||||
|
[HttpGet("last-update-date")]
|
||||||
|
public async Task<ActionResult<DateTime>> GetLastUpdateDate()
|
||||||
|
{
|
||||||
|
DateTime lastUpdateDate = await service.GetLastUpdateDate();
|
||||||
|
return Ok(lastUpdateDate);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<ActionResult> Add([FromBody] EdiCustomerOrderImportDto ediCustomerOrderImport)
|
||||||
|
{
|
||||||
|
var result = await service.AddEdiCustomerOrderImport(ediCustomerOrderImport);
|
||||||
|
return result
|
||||||
|
? Ok("Utworzono rekord w tabeli EdiCustomerOrderImport.")
|
||||||
|
: BadRequest($"Nie mogę utworzyć rekordu w tabeli EdiCustomerOrderImport.");
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost("add-bulk")]
|
||||||
|
public async Task<ActionResult> Add([FromBody] IList<EdiCustomerOrderImportDto> ediCustomerOrderImports)
|
||||||
|
{
|
||||||
|
var result = await service.AddEdiCustomerOrderImports(ediCustomerOrderImports);
|
||||||
|
return result
|
||||||
|
? Ok("Utworzono rekordy w tabeli EdiCustomerOrderImport.")
|
||||||
|
: BadRequest($"Nie mogę utworzyć rekordów w tabeli EdiCustomerOrderImport.");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using SytelineSaAppEfDataModel.Dtos;
|
using SytelineSaAppEfDataModel.Dtos;
|
||||||
using SytelineSaAppEfDataModel.Services;
|
using SytelineSaAppEfDataModel.Services;
|
||||||
|
|
||||||
@@ -29,11 +30,33 @@ namespace FaKrosnoApi.Controllers
|
|||||||
return scheduleOrder != null ? Ok(scheduleOrder) : NotFound();
|
return scheduleOrder != null ? Ok(scheduleOrder) : NotFound();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpGet("last-order-number")]
|
||||||
|
public async Task<ActionResult<int>> GetLastOrderNumber()
|
||||||
|
{
|
||||||
|
int lastOrderNumber = await service.GetLastOrderNumber();
|
||||||
|
return Ok(lastOrderNumber);
|
||||||
|
}
|
||||||
|
|
||||||
[HttpPost("send-to-syteline")]
|
[HttpPost("send-to-syteline")]
|
||||||
public async Task<ActionResult<int>> SendOrderToSyteline([FromQuery] Guid customerOrderNumber)
|
public async Task<ActionResult<int>> SendOrderToSyteline([FromQuery] Guid customerOrderNumber)
|
||||||
{
|
{
|
||||||
int result = await service.SendOrderToSyteline(customerOrderNumber);
|
int result = await service.SendOrderToSyteline(customerOrderNumber);
|
||||||
return result > 0 ? Ok() : BadRequest();
|
return result > 0 ? Ok() : BadRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpPost("save-orders")]
|
||||||
|
public async Task<ActionResult> SaveOrdersWithDetails([FromBody] List<EdiCustomerOrderDto> ediCustomerOrders)
|
||||||
|
{
|
||||||
|
if (!ediCustomerOrders.Any())
|
||||||
|
{
|
||||||
|
return BadRequest("The list of orders cannot be null or empty.");
|
||||||
|
}
|
||||||
|
|
||||||
|
var result = await service.SaveOrdersWithDetails(ediCustomerOrders);
|
||||||
|
|
||||||
|
return result.Item1
|
||||||
|
? Ok(result)
|
||||||
|
: BadRequest($"Failed to save orders. Error: {result.Item2}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using SytelineSaAppEfDataModel.Dtos;
|
||||||
|
using SytelineSaAppEfDataModel.Services;
|
||||||
|
|
||||||
|
namespace FaKrosnoApi.Controllers;
|
||||||
|
|
||||||
|
[ApiController]
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
public class EdiCustomerOrdersTranslationsController(IEdiCustomerOrderTranslateService service) : Controller
|
||||||
|
{
|
||||||
|
[HttpGet]
|
||||||
|
public async Task<ActionResult<IEnumerable<EdiCustomerOrderTranslateDto>>> GetAll()
|
||||||
|
{
|
||||||
|
IEnumerable<EdiCustomerOrderTranslateDto?> ediCustomerOrdersTranlations = await service.GetAll();
|
||||||
|
return Ok(ediCustomerOrdersTranlations);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpDelete]
|
||||||
|
public async Task<IActionResult> Delete([FromQuery] int id)
|
||||||
|
{
|
||||||
|
await service.Delete(id);
|
||||||
|
return NoContent();
|
||||||
|
}
|
||||||
|
}
|
||||||
19
FaKrosnoApi/Controllers/EdiLogController.cs
Normal file
19
FaKrosnoApi/Controllers/EdiLogController.cs
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using SytelineSaAppEfDataModel.Dtos;
|
||||||
|
using SytelineSaAppEfDataModel.Services;
|
||||||
|
|
||||||
|
namespace FaKrosnoApi.Controllers;
|
||||||
|
|
||||||
|
[ApiController]
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
public class EdiLogController(IEdiLogService service) : Controller
|
||||||
|
{
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<ActionResult> Add([FromBody] EdiLogDto ediLog)
|
||||||
|
{
|
||||||
|
var result = await service.AddEdiLog(ediLog);
|
||||||
|
return result
|
||||||
|
? Ok("Utworzono rekord w tabeli EdiLog.")
|
||||||
|
: BadRequest($"Nie mogę utworzyć rekordu w tabeli EdiLog.");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using SytelineSaAppEfDataModel.Dtos;
|
using SytelineSaAppEfDataModel.Dtos;
|
||||||
using SytelineSaAppEfDataModel.Services;
|
using SytelineSaAppEfDataModel.Services;
|
||||||
|
|
||||||
|
|||||||
224
FaKrosnoApi/Controllers/ExcelGeneratorController.cs
Normal file
224
FaKrosnoApi/Controllers/ExcelGeneratorController.cs
Normal file
@@ -0,0 +1,224 @@
|
|||||||
|
using System.Net;
|
||||||
|
using System.Net.Mail;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Syncfusion.Drawing;
|
||||||
|
using Syncfusion.XlsIO;
|
||||||
|
using SytelineSaAppEfDataModel.Dtos;
|
||||||
|
using SytelineSaAppEfDataModel.Services;
|
||||||
|
|
||||||
|
namespace FaKrosnoApi.Controllers;
|
||||||
|
|
||||||
|
[ApiController]
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
public class ExcelGeneratorController(IWzHeaderService wzHeaderService, IWzClientService wzClientService, IMaterialTransactionService materialTransactionService, IConfiguration configuration) : Controller
|
||||||
|
{
|
||||||
|
[HttpGet("generate-meyle")]
|
||||||
|
public async Task GeneratePackListForMeyle(Guid packListId)
|
||||||
|
{
|
||||||
|
WzHeaderDto wzHeader = await wzHeaderService.GetById(packListId);
|
||||||
|
MaterialTransactionDto? materialTransaction = await materialTransactionService.GetByWzNumber(wzHeader.WzRowsMeyle.First().WzNumber);
|
||||||
|
|
||||||
|
using ExcelEngine excelEngine = new ExcelEngine();
|
||||||
|
IApplication application = excelEngine.Excel;
|
||||||
|
application.DefaultVersion = ExcelVersion.Xlsx;
|
||||||
|
|
||||||
|
IWorkbook workbook = application.Workbooks.Create(1);
|
||||||
|
IWorksheet worksheet = workbook.Worksheets[0];
|
||||||
|
|
||||||
|
IStyle boldFontStyle = workbook.Styles.Add("BoldFontStyle");
|
||||||
|
boldFontStyle.Font.Bold = true;
|
||||||
|
|
||||||
|
var mainHeaders = new List<string>
|
||||||
|
{ "Numer zamówienia Meyle", "Meyle Numer", "Ilość w dostawie", "Numer Palety", "Nr Wz", "Nr Partii" };
|
||||||
|
|
||||||
|
worksheet["B1"].Value = "Packing List";
|
||||||
|
worksheet["B1"].CellStyle = boldFontStyle;
|
||||||
|
|
||||||
|
worksheet["B3"].Value = "Supplier Name";
|
||||||
|
worksheet["B3"].CellStyle = boldFontStyle;
|
||||||
|
|
||||||
|
worksheet["D3"].Value = "FA KROSNO";
|
||||||
|
worksheet["D3"].CellStyle = boldFontStyle;
|
||||||
|
|
||||||
|
worksheet["B4"].Value = "Packing List nr";
|
||||||
|
worksheet["B4"].CellStyle = boldFontStyle;
|
||||||
|
|
||||||
|
worksheet["B6"].Value = "Related delivery note";
|
||||||
|
worksheet["B6"].CellStyle = boldFontStyle;
|
||||||
|
|
||||||
|
worksheet["D6"].Value = string.Join(", ", wzHeader.WzRowsMeyle.Select(x => x.WzNumber).Distinct());
|
||||||
|
worksheet["D6"].CellStyle = boldFontStyle;
|
||||||
|
|
||||||
|
worksheet["B9"].Value = "Forwarder";
|
||||||
|
worksheet["B9"].CellStyle = boldFontStyle;
|
||||||
|
|
||||||
|
worksheet["B10"].Value = "Date";
|
||||||
|
worksheet["B10"].CellStyle = boldFontStyle;
|
||||||
|
|
||||||
|
worksheet["D10"].DateTime = materialTransaction?.CreateDate ?? DateTime.Now;
|
||||||
|
|
||||||
|
int currentRow = 12;
|
||||||
|
|
||||||
|
for (int i = 0; i < mainHeaders.Count; i++)
|
||||||
|
{
|
||||||
|
string columnLetter = GetColumnLetter(i);
|
||||||
|
worksheet.Range[$"{columnLetter}{currentRow}"].Text = mainHeaders[i];
|
||||||
|
worksheet.Range[$"{columnLetter}{currentRow}"].CellStyle = boldFontStyle;
|
||||||
|
}
|
||||||
|
|
||||||
|
currentRow++;
|
||||||
|
|
||||||
|
foreach (var wzRow in wzHeader.WzRowsMeyle)
|
||||||
|
{
|
||||||
|
worksheet.Range[$"A{currentRow}"].Text = wzRow.OrderNumber;
|
||||||
|
worksheet.Range[$"B{currentRow}"].Text = wzRow.ItemNumber;
|
||||||
|
worksheet.Range[$"C{currentRow}"].Number = (double)wzRow.Quantity!;
|
||||||
|
worksheet.Range[$"D{currentRow}"].Number = (double)wzRow.PalletNumber!;
|
||||||
|
worksheet.Range[$"E{currentRow}"].Text = wzRow.WzNumber;
|
||||||
|
worksheet.Range[$"F{currentRow}"].Text = wzRow.PartNumber;
|
||||||
|
|
||||||
|
currentRow++;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < 6; i++)
|
||||||
|
{
|
||||||
|
worksheet.AutofitColumn(i + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
using MemoryStream stream = new MemoryStream();
|
||||||
|
workbook.SaveAs(stream);
|
||||||
|
stream.Position = 0;
|
||||||
|
|
||||||
|
SendEmail(stream, wzHeader, "Meyle");
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("generate-marelli")]
|
||||||
|
public async Task GeneratePackListForMarelli(Guid packListId)
|
||||||
|
{
|
||||||
|
WzHeaderDto wzHeader = await wzHeaderService.GetByIdMarelli(packListId);
|
||||||
|
WzClientDto? wzClient = await wzClientService.GetById(wzHeader.FK_Client ?? Guid.NewGuid());
|
||||||
|
MaterialTransactionDto? materialTransaction = await materialTransactionService.GetByWzNumber(wzHeader.WzRowsMarelli.First().WzNumber);
|
||||||
|
|
||||||
|
using ExcelEngine excelEngine = new ExcelEngine();
|
||||||
|
IApplication application = excelEngine.Excel;
|
||||||
|
application.DefaultVersion = ExcelVersion.Xlsx;
|
||||||
|
|
||||||
|
IWorkbook workbook = application.Workbooks.Create(1);
|
||||||
|
IWorksheet worksheet = workbook.Worksheets[0];
|
||||||
|
|
||||||
|
IStyle boldFontStyle = workbook.Styles.Add("BoldFontStyle");
|
||||||
|
boldFontStyle.Font.Bold = true;
|
||||||
|
|
||||||
|
var mainHeaders = new List<string>
|
||||||
|
{ "", "ColliNr", "Magneti Marelli Sales nr", "Engineer number", "Quantity", "Order nr", "Supplier Comments" };
|
||||||
|
|
||||||
|
worksheet.Range["A1:B1"].Merge();
|
||||||
|
worksheet.Range["A1"].Text = "PACKING LIST";
|
||||||
|
worksheet.Range["A1"].CellStyle = boldFontStyle;
|
||||||
|
|
||||||
|
worksheet["A3"].Value = "Supplier Name";
|
||||||
|
worksheet["A3"].CellStyle = boldFontStyle;
|
||||||
|
|
||||||
|
worksheet["B3"].Value = "FA KROSNO";
|
||||||
|
worksheet["B3"].CellStyle = boldFontStyle;
|
||||||
|
|
||||||
|
worksheet["A4"].Value = "Packing List nr";
|
||||||
|
worksheet["A4"].CellStyle = boldFontStyle;
|
||||||
|
|
||||||
|
worksheet["B4"].Value = string.Join(", ", wzHeader.WzRowsMarelli.Select(x => x.WzNumber).Distinct());
|
||||||
|
worksheet["B4"].CellStyle = boldFontStyle;
|
||||||
|
|
||||||
|
worksheet["A6"].Value = "Date";
|
||||||
|
worksheet["A6"].CellStyle = boldFontStyle;
|
||||||
|
|
||||||
|
worksheet["B6"].DateTime = materialTransaction?.CreateDate ?? DateTime.Now;
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(wzClient?.LogoBase64))
|
||||||
|
{
|
||||||
|
byte[] logoBytes = Convert.FromBase64String(wzClient.LogoBase64);
|
||||||
|
|
||||||
|
worksheet.Range["D1:F6"].Merge();
|
||||||
|
|
||||||
|
using MemoryStream imageStream = new MemoryStream(logoBytes);
|
||||||
|
worksheet.Pictures.AddPicture(1, 4, imageStream);
|
||||||
|
}
|
||||||
|
|
||||||
|
int currentRow = 12;
|
||||||
|
|
||||||
|
for (int i = 0; i < mainHeaders.Count; i++)
|
||||||
|
{
|
||||||
|
string columnLetter = GetColumnLetter(i);
|
||||||
|
worksheet.Range[$"{columnLetter}{currentRow}"].Text = mainHeaders[i];
|
||||||
|
worksheet.Range[$"{columnLetter}{currentRow}"].CellStyle = boldFontStyle;
|
||||||
|
}
|
||||||
|
|
||||||
|
currentRow++;
|
||||||
|
|
||||||
|
foreach (var wzRow in wzHeader.WzRowsMarelli)
|
||||||
|
{
|
||||||
|
worksheet.Range[$"A{currentRow}"].Text = "MIX";
|
||||||
|
worksheet.Range[$"B{currentRow}"].Number = (double)wzRow.PalletNumber!;
|
||||||
|
worksheet.Range[$"C{currentRow}"].Text = wzRow.ItemNumber;
|
||||||
|
worksheet.Range[$"D{currentRow}"].Text = wzRow.EngineerNumber;
|
||||||
|
worksheet.Range[$"E{currentRow}"].Number = (double)wzRow.Quantity!;
|
||||||
|
worksheet.Range[$"F{currentRow}"].Text = wzRow.OrderNumber;
|
||||||
|
worksheet.Range[$"G{currentRow}"].Text = wzRow.WzNumber;
|
||||||
|
|
||||||
|
currentRow++;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < 6; i++)
|
||||||
|
{
|
||||||
|
worksheet.AutofitColumn(i + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
using MemoryStream stream = new MemoryStream();
|
||||||
|
workbook.SaveAs(stream);
|
||||||
|
stream.Position = 0;
|
||||||
|
|
||||||
|
SendEmail(stream, wzHeader, "Marelli Magneti");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string GetColumnLetter(int columnIndex)
|
||||||
|
{
|
||||||
|
string columnName = string.Empty;
|
||||||
|
while (columnIndex >= 0)
|
||||||
|
{
|
||||||
|
columnName = (char)('A' + (columnIndex % 26)) + columnName;
|
||||||
|
columnIndex = (columnIndex / 26) - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return columnName;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SendEmail(MemoryStream stream, WzHeaderDto wzHeader, string client)
|
||||||
|
{
|
||||||
|
IConfigurationSection smtpSettings = configuration.GetSection("EmailSettings");
|
||||||
|
string smtpHost = smtpSettings["SmtpServer"] ?? string.Empty;
|
||||||
|
int smtpPort = int.Parse(smtpSettings["Port"] ?? "0");
|
||||||
|
string smtpUsername = smtpSettings["SenderEmail"] ?? string.Empty;
|
||||||
|
string smtpPassword = smtpSettings["SenderPassword"] ?? string.Empty;
|
||||||
|
string fromEmail = smtpSettings["SenderEmail"] ?? string.Empty;
|
||||||
|
List<string> toEmail = wzHeader.EmailAddresses?.Split(',')?.ToList() ??
|
||||||
|
(smtpSettings["RecipientEmail"] ?? string.Empty).Split(',').ToList();
|
||||||
|
string subject = $"{client}: Packing List";
|
||||||
|
string body =
|
||||||
|
$"W załączeniu znajduje się Packing List dla klienta ${client} wygenerowany {DateTime.Now:dd.MM.yyyy HH:mm:ss}";
|
||||||
|
|
||||||
|
using var mailMessage = new MailMessage();
|
||||||
|
mailMessage.From = new MailAddress(fromEmail);
|
||||||
|
mailMessage.Subject = subject;
|
||||||
|
mailMessage.Body = body;
|
||||||
|
mailMessage.IsBodyHtml = false;
|
||||||
|
|
||||||
|
mailMessage.Attachments.Add(new Attachment(stream, $"PackingList_{client}_{DateTime.Now:yyyyMMddHHmmss}.xlsx",
|
||||||
|
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"));
|
||||||
|
|
||||||
|
toEmail.ForEach(x => mailMessage.To.Add(x));
|
||||||
|
|
||||||
|
using var smtpClient = new SmtpClient(smtpHost, smtpPort);
|
||||||
|
smtpClient.EnableSsl = true;
|
||||||
|
smtpClient.Credentials = new NetworkCredential(smtpUsername, smtpPassword);
|
||||||
|
smtpClient.Send(mailMessage);
|
||||||
|
}
|
||||||
|
}
|
||||||
52
FaKrosnoApi/Controllers/FunctionsController.cs
Normal file
52
FaKrosnoApi/Controllers/FunctionsController.cs
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using OrdersManagementDataModel.Dtos;
|
||||||
|
using OrdersManagementDataModel.Services;
|
||||||
|
|
||||||
|
namespace FaKrosnoApi.Controllers;
|
||||||
|
|
||||||
|
[ApiController]
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
public class FunctionsController(IFunctionService service) : Controller
|
||||||
|
{
|
||||||
|
[HttpGet]
|
||||||
|
public async Task<ActionResult<IEnumerable<FunctionDto>>> GetAll()
|
||||||
|
{
|
||||||
|
IEnumerable<FunctionDto?> functions = await service.GetAll();
|
||||||
|
return Ok(functions);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("by-id")]
|
||||||
|
public async Task<ActionResult<FunctionDto?>> GetById([FromQuery] Guid id)
|
||||||
|
{
|
||||||
|
FunctionDto? function = await service.GetById(id);
|
||||||
|
return function != null ? Ok(function) : NotFound();
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("by-name")]
|
||||||
|
public async Task<ActionResult<FunctionDto?>> GetByName([FromQuery] string name)
|
||||||
|
{
|
||||||
|
FunctionDto? function = await service.GetByName(name);
|
||||||
|
return function != null ? Ok(function) : NotFound();
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<ActionResult<FunctionDto>> Add([FromBody] FunctionDto function)
|
||||||
|
{
|
||||||
|
await service.Add(function);
|
||||||
|
return Ok(function);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPut]
|
||||||
|
public async Task<ActionResult<FunctionDto>> Update([FromBody] FunctionDto function)
|
||||||
|
{
|
||||||
|
await service.Update(function);
|
||||||
|
return Ok(function);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpDelete]
|
||||||
|
public async Task<ActionResult<FunctionDto>> Delete([FromQuery] Guid id)
|
||||||
|
{
|
||||||
|
await service.Delete(id);
|
||||||
|
return Ok();
|
||||||
|
}
|
||||||
|
}
|
||||||
184
FaKrosnoApi/Controllers/HangfireJobsController.cs
Normal file
184
FaKrosnoApi/Controllers/HangfireJobsController.cs
Normal file
@@ -0,0 +1,184 @@
|
|||||||
|
using System.Diagnostics;
|
||||||
|
using FaKrosnoApi.Models;
|
||||||
|
using Hangfire;
|
||||||
|
using Hangfire.Storage;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using OrdersManagementDataModel.Dtos;
|
||||||
|
using OrdersManagementDataModel.Services;
|
||||||
|
|
||||||
|
namespace FaKrosnoApi.Controllers;
|
||||||
|
|
||||||
|
[ApiController]
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
public class HangfireJobsController(
|
||||||
|
JobStorage jobStorage,
|
||||||
|
IRecurringJobManager recurringJobManager,
|
||||||
|
ITaskSchedulerService service) : Controller
|
||||||
|
{
|
||||||
|
public async Task<ActionResult<IEnumerable<JobModel>>> GetJobsToRun()
|
||||||
|
{
|
||||||
|
IList<JobModel> jobsToRun = new List<JobModel>();
|
||||||
|
|
||||||
|
using (IStorageConnection? connection = jobStorage.GetConnection())
|
||||||
|
{
|
||||||
|
IList<RecurringJobDto>? recurringJobs = connection.GetRecurringJobs();
|
||||||
|
IList<TaskSchedulerDto>? taskSchedulers = (await service.GetTaskSchedulers()).ToList();
|
||||||
|
|
||||||
|
foreach (var recurringJob in recurringJobs)
|
||||||
|
{
|
||||||
|
TaskSchedulerDto? taskScheduler = taskSchedulers?.FirstOrDefault(ts => ts.Name == recurringJob.Id);
|
||||||
|
|
||||||
|
if (taskScheduler != null)
|
||||||
|
{
|
||||||
|
jobsToRun.Add(new JobModel(recurringJob.Id, recurringJob.Cron, taskScheduler.Path,
|
||||||
|
recurringJob.LastExecution, recurringJob.NextExecution, recurringJob.Job));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Ok(jobsToRun);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost("run")]
|
||||||
|
public async Task<IActionResult> RunJobs()
|
||||||
|
{
|
||||||
|
var jobsToRun = (await GetJobsToRun()).Value?.ToList();
|
||||||
|
|
||||||
|
if (jobsToRun == null || jobsToRun.Count == 0)
|
||||||
|
{
|
||||||
|
return BadRequest("Nie udało się pobrać zadań do uruchomienia.");
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var job in jobsToRun)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(job.Path))
|
||||||
|
{
|
||||||
|
recurringJobManager.AddOrUpdate(job.JobId, () => RunConsoleApplication(job.Path), job.Cron,
|
||||||
|
new RecurringJobOptions { TimeZone = TimeZoneInfo.Local });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Ok("Zadania zostały zaplanowane do uruchamiania zgodnie z ich CRON.");
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost("add")]
|
||||||
|
public async Task<IActionResult> AddTask([FromBody] TaskSchedulerDto taskSchedulerDto)
|
||||||
|
{
|
||||||
|
var taskScheduler = new OrdersManagementDataModel.Entities.TaskScheduler
|
||||||
|
{
|
||||||
|
Name = taskSchedulerDto.Name,
|
||||||
|
Path = taskSchedulerDto.Path,
|
||||||
|
CronOptions = taskSchedulerDto.CronOptions,
|
||||||
|
CreateDate = DateTime.UtcNow
|
||||||
|
};
|
||||||
|
|
||||||
|
int result = await service.AddTaskScheduler(taskSchedulerDto);
|
||||||
|
|
||||||
|
if (result == 0)
|
||||||
|
{
|
||||||
|
return BadRequest("Nie udało się dodać zadania.");
|
||||||
|
}
|
||||||
|
|
||||||
|
recurringJobManager.AddOrUpdate(taskScheduler.Name, () => RunConsoleApplication(taskScheduler.Path),
|
||||||
|
taskScheduler.CronOptions, new RecurringJobOptions { TimeZone = TimeZoneInfo.Local });
|
||||||
|
|
||||||
|
return Ok("Zadanie zostało dodane.");
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost("delete")]
|
||||||
|
public async Task<IActionResult> DeleteTask([FromBody] TaskSchedulerDto taskSchedulerDto)
|
||||||
|
{
|
||||||
|
int result = await service.DeleteTaskScheduler(taskSchedulerDto.RowPointer);
|
||||||
|
|
||||||
|
if (result == 0)
|
||||||
|
{
|
||||||
|
return BadRequest("Nie udało się usunąć zadania.");
|
||||||
|
}
|
||||||
|
|
||||||
|
recurringJobManager.RemoveIfExists(taskSchedulerDto.Name);
|
||||||
|
|
||||||
|
return Ok("Zadanie zostało usunięte.");
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost("update")]
|
||||||
|
public async Task<IActionResult> UpdateTask([FromBody] TaskSchedulerDto taskSchedulerDto)
|
||||||
|
{
|
||||||
|
int result = await service.UpdateTaskScheduler(taskSchedulerDto);
|
||||||
|
|
||||||
|
if (result == 0)
|
||||||
|
{
|
||||||
|
return BadRequest("Nie udało się uaktualnic zadania.");
|
||||||
|
}
|
||||||
|
|
||||||
|
recurringJobManager.AddOrUpdate(taskSchedulerDto.Name, () => RunConsoleApplication(taskSchedulerDto.Path),
|
||||||
|
taskSchedulerDto.CronOptions, new RecurringJobOptions { TimeZone = TimeZoneInfo.Local });
|
||||||
|
|
||||||
|
return Ok("Zadanie zostało zaktualizowane.");
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public async Task<ActionResult<IEnumerable<TaskSchedulerDto>>> GetTasks()
|
||||||
|
{
|
||||||
|
var tasks = await service.GetTaskSchedulers();
|
||||||
|
|
||||||
|
foreach (TaskSchedulerDto taskSchedulerDto in tasks)
|
||||||
|
{
|
||||||
|
var job = GetJob(taskSchedulerDto.Name);
|
||||||
|
taskSchedulerDto.LastExecution = job?.LastExecution;
|
||||||
|
taskSchedulerDto.NextExecution = job?.NextExecution;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Ok(tasks);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("by-name")]
|
||||||
|
public async Task<ActionResult<TaskSchedulerDto>> GetTaskSchedulerByTaskName([FromQuery] string name)
|
||||||
|
{
|
||||||
|
var taskSchedulerDto = await service.GetTaskSchedulerByTaskName(name);
|
||||||
|
|
||||||
|
if (taskSchedulerDto == null) return NotFound();
|
||||||
|
|
||||||
|
var job = GetJob(taskSchedulerDto.Name);
|
||||||
|
taskSchedulerDto.LastExecution = job?.LastExecution;
|
||||||
|
taskSchedulerDto.NextExecution = job?.NextExecution;
|
||||||
|
|
||||||
|
return Ok(taskSchedulerDto);
|
||||||
|
}
|
||||||
|
|
||||||
|
private RecurringJobDto? GetJob(string jobId)
|
||||||
|
{
|
||||||
|
using IStorageConnection? connection = jobStorage.GetConnection();
|
||||||
|
IList<RecurringJobDto>? recurringJobs = connection.GetRecurringJobs();
|
||||||
|
return recurringJobs.FirstOrDefault(x => x.Id == jobId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RunConsoleApplication(string pathToApp)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var process = new Process
|
||||||
|
{
|
||||||
|
StartInfo = new ProcessStartInfo
|
||||||
|
{
|
||||||
|
FileName = pathToApp,
|
||||||
|
UseShellExecute = false,
|
||||||
|
RedirectStandardOutput = true,
|
||||||
|
RedirectStandardError = true,
|
||||||
|
CreateNoWindow = true,
|
||||||
|
WorkingDirectory = Path.GetDirectoryName(pathToApp)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
process.Start();
|
||||||
|
string output = process.StandardOutput.ReadToEnd();
|
||||||
|
string error = process.StandardError.ReadToEnd();
|
||||||
|
process.WaitForExit();
|
||||||
|
|
||||||
|
Console.WriteLine($"Output: {output}");
|
||||||
|
Console.WriteLine($"Error: {error}");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Error executing console application: {ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
17
FaKrosnoApi/Controllers/ItemController.cs
Normal file
17
FaKrosnoApi/Controllers/ItemController.cs
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using SytelineSaAppEfDataModel.Dtos;
|
||||||
|
using SytelineSaAppEfDataModel.Services;
|
||||||
|
|
||||||
|
namespace FaKrosnoApi.Controllers;
|
||||||
|
|
||||||
|
[ApiController]
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
public class ItemController(IItemService service) : Controller
|
||||||
|
{
|
||||||
|
[HttpGet("by-number")]
|
||||||
|
public async Task<ActionResult<ItemDto>> Get([FromQuery] string itemNumber)
|
||||||
|
{
|
||||||
|
ItemDto item = await service.GetItem(itemNumber);
|
||||||
|
return Ok(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
16
FaKrosnoApi/Controllers/ItemCustController.cs
Normal file
16
FaKrosnoApi/Controllers/ItemCustController.cs
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using SytelineSaAppEfDataModel.Dtos;
|
||||||
|
using SytelineSaAppEfDataModel.Services;
|
||||||
|
|
||||||
|
namespace FaKrosnoApi.Controllers;
|
||||||
|
|
||||||
|
[ApiController]
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
public class ItemCustController(IItemCustService service) : Controller
|
||||||
|
{
|
||||||
|
public async Task<ActionResult<ItemCustDto>> GetItem([FromQuery] string itemNumber, [FromQuery] string customerNumber)
|
||||||
|
{
|
||||||
|
ItemCustDto item = await service.GetItem(itemNumber, customerNumber);
|
||||||
|
return item != null ? Ok(item) : NotFound();
|
||||||
|
}
|
||||||
|
}
|
||||||
23
FaKrosnoApi/Controllers/ItemCustPriceAllController.cs
Normal file
23
FaKrosnoApi/Controllers/ItemCustPriceAllController.cs
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
using AutoMapper;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using SytelineSaAppEfDataModel.Dtos;
|
||||||
|
using SytelineSaAppEfDataModel.Services;
|
||||||
|
|
||||||
|
namespace FaKrosnoApi.Controllers;
|
||||||
|
|
||||||
|
[ApiController]
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
public class ItemCustPriceAllController(IItemCustPriceAllService service, IMapper mapper) : Controller
|
||||||
|
{
|
||||||
|
[HttpGet("by-parameters")]
|
||||||
|
public async Task<ActionResult<ItemCustPriceAllDto>> GetItemCustPriceAll([FromQuery] string itemNumber, [FromQuery] string customerNumber)
|
||||||
|
{
|
||||||
|
var result = await service.GetItemCustPriceAllAsync(itemNumber, customerNumber);
|
||||||
|
if (result == null)
|
||||||
|
{
|
||||||
|
return NotFound();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Ok(mapper.Map<ItemCustPriceAllDto>(result));
|
||||||
|
}
|
||||||
|
}
|
||||||
42
FaKrosnoApi/Controllers/MaterialTransactionsController.cs
Normal file
42
FaKrosnoApi/Controllers/MaterialTransactionsController.cs
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
using AutoMapper;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using SytelineSaAppEfDataModel.Dtos;
|
||||||
|
using SytelineSaAppEfDataModel.Services;
|
||||||
|
|
||||||
|
namespace FaKrosnoApi.Controllers;
|
||||||
|
|
||||||
|
[ApiController]
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
public class MaterialTransactionsController(IMaterialTransactionService service) : Controller
|
||||||
|
{
|
||||||
|
[HttpGet]
|
||||||
|
public async Task<IEnumerable<MaterialTransactionDto>> GetAll()
|
||||||
|
{
|
||||||
|
return await service.GetAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("by-wz-number")]
|
||||||
|
public Task<MaterialTransactionDto?> GetByWzNumber([FromQuery] string wzNumber)
|
||||||
|
{
|
||||||
|
return service.GetByWzNumber(wzNumber);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("list-by-wz-numbers")]
|
||||||
|
public Task<IEnumerable<MaterialTransactionDto>> GetListByWzNumber([FromBody] ISet<string> wzNumbers)
|
||||||
|
{
|
||||||
|
return service.GetOrderNumbersByWz(wzNumbers);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("by-order-number")]
|
||||||
|
public Task<IEnumerable<MaterialTransactionDto>> GetByOrderNumber([FromQuery] string orderNumber)
|
||||||
|
{
|
||||||
|
return service.GetByOrderNumber(orderNumber);
|
||||||
|
}
|
||||||
|
|
||||||
|
// public Task<IEnumerable<MaterialTransactionDto>> GetOrderNumbersByWz(ISet<string> wzNumbers);
|
||||||
|
// public Task<IEnumerable<MaterialTransactionDto>> GetByCustomerNumber(string customerNumber, int customerSequence);
|
||||||
|
// public Task<MaterialTransactionDto?> GetByPartNumber(string partNumber);
|
||||||
|
// public Task<IEnumerable<MaterialTransactionDto>> GetWithPartNumber();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
31
FaKrosnoApi/Controllers/ProductController.cs
Normal file
31
FaKrosnoApi/Controllers/ProductController.cs
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
using FaKrosnoEfDataModel.Dtos;
|
||||||
|
using FaKrosnoEfDataModel.Services;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace FaKrosnoApi.Controllers;
|
||||||
|
|
||||||
|
[ApiController]
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
public class ProductController(IProductService service) : Controller
|
||||||
|
{
|
||||||
|
[HttpGet]
|
||||||
|
public async Task<ActionResult<IEnumerable<ProductDto>>> GetAll()
|
||||||
|
{
|
||||||
|
IEnumerable<ProductDto?> products = await service.GetEntities();
|
||||||
|
return Ok(products);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("by-index")]
|
||||||
|
public async Task<ActionResult<IEnumerable<ProductDto>>> GetByIndex([FromQuery] string indexName)
|
||||||
|
{
|
||||||
|
IEnumerable<ProductDto?> products = await service.GetEntitiesToFix(indexName);
|
||||||
|
return Ok(products);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPut]
|
||||||
|
public async Task<ActionResult> Update([FromBody] ProductDto product)
|
||||||
|
{
|
||||||
|
await service.UpdateEntity(product);
|
||||||
|
return Ok();
|
||||||
|
}
|
||||||
|
}
|
||||||
45
FaKrosnoApi/Controllers/RolesController.cs
Normal file
45
FaKrosnoApi/Controllers/RolesController.cs
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using OrdersManagementDataModel.Dtos;
|
||||||
|
using OrdersManagementDataModel.Services;
|
||||||
|
|
||||||
|
namespace FaKrosnoApi.Controllers;
|
||||||
|
|
||||||
|
[ApiController]
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
public class RolesController(IRoleService service) : Controller
|
||||||
|
{
|
||||||
|
[HttpGet]
|
||||||
|
public async Task<ActionResult<IEnumerable<RoleDto>>> GetAll()
|
||||||
|
{
|
||||||
|
IEnumerable<RoleDto?> roles = await service.GetAll();
|
||||||
|
return Ok(roles);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("by-id")]
|
||||||
|
public async Task<ActionResult<RoleDto?>> GetById([FromQuery] Guid id)
|
||||||
|
{
|
||||||
|
RoleDto? role = await service.GetById(id);
|
||||||
|
return role != null ? Ok(role) : NotFound();
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("by-name")]
|
||||||
|
public async Task<ActionResult<RoleDto?>> GetByName([FromQuery] string name)
|
||||||
|
{
|
||||||
|
RoleDto? role = await service.GetByName(name);
|
||||||
|
return role != null ? Ok(role) : NotFound();
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<ActionResult<RoleDto>> Add([FromBody] RoleDto role)
|
||||||
|
{
|
||||||
|
await service.Add(role);
|
||||||
|
return Ok(role);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpDelete]
|
||||||
|
public async Task<ActionResult<RoleDto>> Delete([FromQuery] Guid id)
|
||||||
|
{
|
||||||
|
await service.Delete(id);
|
||||||
|
return Ok();
|
||||||
|
}
|
||||||
|
}
|
||||||
18
FaKrosnoApi/Controllers/ScheduleJobController.cs
Normal file
18
FaKrosnoApi/Controllers/ScheduleJobController.cs
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
using FaKrosnoApi.Services;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace FaKrosnoApi.Controllers;
|
||||||
|
|
||||||
|
[ApiController]
|
||||||
|
[Route("[controller]")]
|
||||||
|
public class ScheduleJobController(IScheduleJobService scheduledJob) : ControllerBase
|
||||||
|
{
|
||||||
|
[HttpPost("start")]
|
||||||
|
public IActionResult StartJob()
|
||||||
|
{
|
||||||
|
scheduledJob.ExecuteAsync();
|
||||||
|
return Ok("Job started");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
using FaKrosnoEfDataModel.Dtos;
|
|
||||||
using FaKrosnoEfDataModel.Services;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
|
|
||||||
namespace FaKrosnoApi.Controllers
|
|
||||||
{
|
|
||||||
[ApiController]
|
|
||||||
[Route("api/[controller]")]
|
|
||||||
public class ScheduleOrderDetailsController(IScheduleOrderDetailsService service) : Controller
|
|
||||||
{
|
|
||||||
[HttpGet("order/{scheduleOrderId:int}")]
|
|
||||||
public async Task<ActionResult<IEnumerable<ScheduleOrderDto>>> GetByScheduleOrderId(int scheduleOrderId)
|
|
||||||
{
|
|
||||||
IEnumerable<ScheduleOrderDetailDto>? scheduleOrderDetails = await service.GetScheduleOrderDetailsAsync(scheduleOrderId);
|
|
||||||
return Ok(scheduleOrderDetails);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,4 @@
|
|||||||
using AutoMapper;
|
using FaKrosnoEfDataModel.Dtos;
|
||||||
using FaKrosnoEfDataModel;
|
|
||||||
using FaKrosnoEfDataModel.Dtos;
|
|
||||||
using FaKrosnoEfDataModel.Services;
|
using FaKrosnoEfDataModel.Services;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
@@ -9,7 +7,6 @@ namespace FaKrosnoApi.Controllers
|
|||||||
{
|
{
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[Route("api/[controller]")]
|
[Route("api/[controller]")]
|
||||||
//[Authorize]
|
|
||||||
public class ScheduleOrdersController(IScheduleOrderService service) : Controller
|
public class ScheduleOrdersController(IScheduleOrderService service) : Controller
|
||||||
{
|
{
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
|
|||||||
45
FaKrosnoApi/Controllers/UserRolesController.cs
Normal file
45
FaKrosnoApi/Controllers/UserRolesController.cs
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using OrdersManagementDataModel.Dtos;
|
||||||
|
using OrdersManagementDataModel.Services;
|
||||||
|
|
||||||
|
namespace FaKrosnoApi.Controllers;
|
||||||
|
|
||||||
|
[ApiController]
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
public class UserRolesController(IUserRoleService service) : Controller
|
||||||
|
{
|
||||||
|
[HttpGet]
|
||||||
|
public async Task<ActionResult<IEnumerable<UserRoleDto>>> GetAll()
|
||||||
|
{
|
||||||
|
IEnumerable<UserRoleDto?> userRoles = await service.GetAll();
|
||||||
|
return Ok(userRoles);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("by-id")]
|
||||||
|
public async Task<ActionResult<UserRoleDto?>> GetById([FromQuery] Guid id)
|
||||||
|
{
|
||||||
|
UserRoleDto? userRole = await service.GetById(id);
|
||||||
|
return userRole != null ? Ok(userRole) : NotFound();
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<ActionResult<UserRoleDto>> Add([FromBody] UserRoleDto userRole)
|
||||||
|
{
|
||||||
|
await service.Add(userRole);
|
||||||
|
return Ok(userRole);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPut]
|
||||||
|
public async Task<ActionResult<UserRoleDto>> Update([FromBody] UserRoleDto userRole)
|
||||||
|
{
|
||||||
|
await service.Update(userRole);
|
||||||
|
return Ok(userRole);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpDelete]
|
||||||
|
public async Task<ActionResult<UserRoleDto>> Delete([FromQuery] Guid id)
|
||||||
|
{
|
||||||
|
await service.Delete(id);
|
||||||
|
return Ok();
|
||||||
|
}
|
||||||
|
}
|
||||||
91
FaKrosnoApi/Controllers/UsersController.cs
Normal file
91
FaKrosnoApi/Controllers/UsersController.cs
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
using System.IdentityModel.Tokens.Jwt;
|
||||||
|
using System.Security.Claims;
|
||||||
|
using System.Text;
|
||||||
|
using FaKrosnoApi.Models;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.IdentityModel.Tokens;
|
||||||
|
using OrdersManagementDataModel.Dtos;
|
||||||
|
using OrdersManagementDataModel.Services;
|
||||||
|
|
||||||
|
namespace FaKrosnoApi.Controllers;
|
||||||
|
|
||||||
|
[ApiController]
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
public class UsersController(IUserService service, IConfiguration configuration) : Controller
|
||||||
|
{
|
||||||
|
[HttpGet]
|
||||||
|
public async Task<ActionResult<IEnumerable<UserDto>>> GetAll()
|
||||||
|
{
|
||||||
|
IEnumerable<UserDto?> users = await service.GetAll();
|
||||||
|
return Ok(users);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("by-id")]
|
||||||
|
public async Task<ActionResult<UserDto?>> GetById([FromQuery] Guid id)
|
||||||
|
{
|
||||||
|
UserDto? user = await service.GetById(id);
|
||||||
|
return user != null ? Ok(user) : NotFound();
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("by-username")]
|
||||||
|
public async Task<ActionResult<UserDto?>> GetByUsername([FromQuery] string username)
|
||||||
|
{
|
||||||
|
UserDto? user = await service.GetByUsername(username);
|
||||||
|
return user != null ? Ok(user) : NotFound();
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost("login")]
|
||||||
|
public async Task<IActionResult> Login([FromBody] AuthenticateRequestModel loginDto)
|
||||||
|
{
|
||||||
|
var user = await service.GetByUsername(loginDto.Login);
|
||||||
|
|
||||||
|
if(user == null || !BCrypt.Net.BCrypt.Verify(loginDto.Password, user.PasswordHash))
|
||||||
|
{
|
||||||
|
return Unauthorized("Nieprawidłowa nazwa użytkownika lub hasło.");
|
||||||
|
}
|
||||||
|
|
||||||
|
var claims = new[]
|
||||||
|
{
|
||||||
|
new Claim(JwtRegisteredClaimNames.Sub, user.Login),
|
||||||
|
new Claim(JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString())
|
||||||
|
};
|
||||||
|
|
||||||
|
var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(configuration["Jwt:Key"]));
|
||||||
|
var credentials = new SigningCredentials(key, SecurityAlgorithms.HmacSha256);
|
||||||
|
|
||||||
|
var token = new JwtSecurityToken(
|
||||||
|
issuer: configuration["Jwt:Issuer"],
|
||||||
|
audience: configuration["Jwt:Audience"],
|
||||||
|
claims: claims,
|
||||||
|
expires: DateTime.Now.AddHours(1),
|
||||||
|
signingCredentials: credentials);
|
||||||
|
|
||||||
|
return Ok(new
|
||||||
|
{
|
||||||
|
token = new JwtSecurityTokenHandler().WriteToken(token),
|
||||||
|
expires = token.ValidTo
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<ActionResult<UserDto>> Add([FromBody] UserDto user)
|
||||||
|
{
|
||||||
|
await service.Add(user);
|
||||||
|
return Ok(user);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPut]
|
||||||
|
public async Task<ActionResult<UserDto>> Update([FromBody] UserDto user)
|
||||||
|
{
|
||||||
|
await service.Update(user);
|
||||||
|
return Ok(user);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpDelete]
|
||||||
|
public async Task<ActionResult<UserDto>> Delete([FromQuery] Guid id)
|
||||||
|
{
|
||||||
|
await service.Delete(id);
|
||||||
|
return Ok();
|
||||||
|
}
|
||||||
|
}
|
||||||
25
FaKrosnoApi/Controllers/VatCodeAssociationController.cs
Normal file
25
FaKrosnoApi/Controllers/VatCodeAssociationController.cs
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
using AutoMapper;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using SytelineSaAppEfDataModel.Dtos;
|
||||||
|
using SytelineSaAppEfDataModel.Services;
|
||||||
|
|
||||||
|
namespace FaKrosnoApi.Controllers;
|
||||||
|
|
||||||
|
[ApiController]
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
public class VatCodeAssociationController(IVatCodeAssociationService service, IMapper mapper) : Controller
|
||||||
|
{
|
||||||
|
[HttpGet("by-parameters")]
|
||||||
|
public async Task<ActionResult<VatCodeAssociationDto>> GetVatCodesAssociation(string customerDoInvoice,
|
||||||
|
string endUserType, string productCode)
|
||||||
|
{
|
||||||
|
var result = await service.GetVatCodesAssociation(customerDoInvoice, endUserType, productCode);
|
||||||
|
if (result == null)
|
||||||
|
{
|
||||||
|
return NotFound();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Ok(mapper.Map<VatCodeAssociationDto>(result));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
24
FaKrosnoApi/Controllers/WzClientController.cs
Normal file
24
FaKrosnoApi/Controllers/WzClientController.cs
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using SytelineSaAppEfDataModel.Dtos;
|
||||||
|
using SytelineSaAppEfDataModel.Services;
|
||||||
|
|
||||||
|
namespace FaKrosnoApi.Controllers;
|
||||||
|
|
||||||
|
[ApiController]
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
public class WzClientController(IWzClientService service) : Controller
|
||||||
|
{
|
||||||
|
[HttpGet]
|
||||||
|
public async Task<ActionResult<IEnumerable<WzClientDto>>> GetAll()
|
||||||
|
{
|
||||||
|
IEnumerable<WzClientDto> wzClients = await service.GetAll();
|
||||||
|
return Ok(wzClients);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("by-id")]
|
||||||
|
public async Task<ActionResult<WzClientDto>> GetById(Guid id)
|
||||||
|
{
|
||||||
|
WzClientDto? wzClient = await service.GetById(id);
|
||||||
|
return Ok(wzClient);
|
||||||
|
}
|
||||||
|
}
|
||||||
67
FaKrosnoApi/Controllers/WzHeaderController.cs
Normal file
67
FaKrosnoApi/Controllers/WzHeaderController.cs
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using SytelineSaAppEfDataModel.Dtos;
|
||||||
|
using SytelineSaAppEfDataModel.Services;
|
||||||
|
|
||||||
|
namespace FaKrosnoApi.Controllers;
|
||||||
|
|
||||||
|
[ApiController]
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
public class WzHeaderController(IWzHeaderService service, IMaterialTransactionService materialTransactionService) : Controller
|
||||||
|
{
|
||||||
|
[HttpGet]
|
||||||
|
public async Task<ActionResult<IEnumerable<WzHeaderDto>>> GetAll()
|
||||||
|
{
|
||||||
|
IEnumerable<WzHeaderDto> wzHeaders = await service.GetAll();
|
||||||
|
return Ok(wzHeaders);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("by-customer-number")]
|
||||||
|
public async Task<ActionResult<IEnumerable<MaterialTransactionDto>>> GetByCustomerNumber(
|
||||||
|
[FromQuery] string customerNumber, [FromQuery] int customerSequence)
|
||||||
|
{
|
||||||
|
IEnumerable<MaterialTransactionDto> materialTransactions =
|
||||||
|
await materialTransactionService.GetByCustomerNumber(customerNumber, customerSequence);
|
||||||
|
return Ok(materialTransactions);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("all-wz-headers")]
|
||||||
|
public async Task<ActionResult<IEnumerable<MaterialTransactionDto>>> GetHeadersByCustomerNumber(
|
||||||
|
[FromQuery] string customerNumber, [FromQuery] int customerSequence)
|
||||||
|
{
|
||||||
|
IEnumerable<WzHeaderDto> wzHeaders =
|
||||||
|
await service.GetByCustomerNumber(customerNumber, customerSequence);
|
||||||
|
|
||||||
|
return Ok(wzHeaders.OrderByDescending(x => x.CreatedDate));
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<ActionResult> CreateHeader([FromBody] WzHeaderDto wzHeader)
|
||||||
|
{
|
||||||
|
if (wzHeader == null)
|
||||||
|
{
|
||||||
|
return BadRequest("WzHeader cannot be null.");
|
||||||
|
}
|
||||||
|
|
||||||
|
await service.CreateHeader(wzHeader);
|
||||||
|
return CreatedAtAction(nameof(CreateHeader), wzHeader);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("by-id")]
|
||||||
|
public async Task<ActionResult<WzHeaderDto>> GetById([FromQuery] Guid id)
|
||||||
|
{
|
||||||
|
WzHeaderDto? wzHeader = await service.GetById(id);
|
||||||
|
return wzHeader != null ? Ok(wzHeader) : NotFound();
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost("add-emails")]
|
||||||
|
public async Task<IActionResult> AddEmailsToWzHeader([FromQuery] Guid id, [FromBody] string emailAddresses)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(emailAddresses))
|
||||||
|
{
|
||||||
|
return BadRequest("Email addresses cannot be empty.");
|
||||||
|
}
|
||||||
|
|
||||||
|
await service.AddEmailsToWzHeader(id, emailAddresses);
|
||||||
|
return NoContent();
|
||||||
|
}
|
||||||
|
}
|
||||||
62
FaKrosnoApi/Controllers/WzRowMarelliController.cs
Normal file
62
FaKrosnoApi/Controllers/WzRowMarelliController.cs
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using SytelineSaAppEfDataModel.Dtos;
|
||||||
|
using SytelineSaAppEfDataModel.Services;
|
||||||
|
|
||||||
|
namespace FaKrosnoApi.Controllers;
|
||||||
|
|
||||||
|
[ApiController]
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
public class WzRowMarelliController(IWzRowMareliService service, IMaterialTransactionService materialTransactionService) : Controller
|
||||||
|
{
|
||||||
|
[HttpGet]
|
||||||
|
public async Task<ActionResult<IEnumerable<WzRowMarelliDto>>> GetAll()
|
||||||
|
{
|
||||||
|
IEnumerable<WzRowMarelliDto> wzRows = await service.GetAll();
|
||||||
|
return Ok(wzRows);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<ActionResult> CreateRows([FromBody] IEnumerable<WzRowMarelliDto> rows)
|
||||||
|
{
|
||||||
|
if (rows == null || !rows.Any())
|
||||||
|
{
|
||||||
|
return BadRequest("No rows provided.");
|
||||||
|
}
|
||||||
|
|
||||||
|
await service.CreateRows(rows);
|
||||||
|
return CreatedAtAction(nameof(GetAll), new { count = rows.Count() }, rows);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("by-wz-header-id")]
|
||||||
|
public async Task<ActionResult<IEnumerable<WzRowMarelliDto>>> GetByWzHeaderId(Guid wzHeaderId)
|
||||||
|
{
|
||||||
|
IEnumerable<WzRowMarelliDto> wzRows = await service.GetByWzHeaderId(wzHeaderId);
|
||||||
|
return Ok(wzRows);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("by-part-number")]
|
||||||
|
public async Task<ActionResult<MaterialTransactionDto>> GetByPartNumber([FromQuery] string partNumber)
|
||||||
|
{
|
||||||
|
MaterialTransactionDto materialTransaction = await materialTransactionService.GetByPartNumber(partNumber);
|
||||||
|
return Ok(materialTransaction);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("transactions-with-part-number")]
|
||||||
|
public async Task<ActionResult<MaterialTransactionDto>> GetTransactionsWithPartNumber()
|
||||||
|
{
|
||||||
|
IEnumerable<MaterialTransactionDto> materialTransactions = await materialTransactionService.GetWithPartNumber();
|
||||||
|
return Ok(materialTransactions);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPut]
|
||||||
|
public async Task<ActionResult> UpdateRows([FromBody] IEnumerable<WzRowMarelliDto> rows)
|
||||||
|
{
|
||||||
|
if (rows == null || !rows.Any())
|
||||||
|
{
|
||||||
|
return BadRequest("No rows provided.");
|
||||||
|
}
|
||||||
|
|
||||||
|
await service.UpdateRows(rows);
|
||||||
|
return NoContent();
|
||||||
|
}
|
||||||
|
}
|
||||||
62
FaKrosnoApi/Controllers/WzRowMeyleController.cs
Normal file
62
FaKrosnoApi/Controllers/WzRowMeyleController.cs
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using SytelineSaAppEfDataModel.Dtos;
|
||||||
|
using SytelineSaAppEfDataModel.Services;
|
||||||
|
|
||||||
|
namespace FaKrosnoApi.Controllers;
|
||||||
|
|
||||||
|
[ApiController]
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
public class WzRowMeyleController(IWzRowMeyleService service, IMaterialTransactionService materialTransactionService) : Controller
|
||||||
|
{
|
||||||
|
[HttpGet]
|
||||||
|
public async Task<ActionResult<IEnumerable<WzRowMeyleDto>>> GetAll()
|
||||||
|
{
|
||||||
|
IEnumerable<WzRowMeyleDto> wzRows = await service.GetAll();
|
||||||
|
return Ok(wzRows);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<ActionResult> CreateRows([FromBody] IEnumerable<WzRowMeyleDto> rows)
|
||||||
|
{
|
||||||
|
if (rows == null || !rows.Any())
|
||||||
|
{
|
||||||
|
return BadRequest("No rows provided.");
|
||||||
|
}
|
||||||
|
|
||||||
|
await service.CreateRows(rows);
|
||||||
|
return CreatedAtAction(nameof(GetAll), new { count = rows.Count() }, rows);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("by-wz-header-id")]
|
||||||
|
public async Task<ActionResult<IEnumerable<WzRowMeyleDto>>> GetByWzHeaderId(Guid wzHeaderId)
|
||||||
|
{
|
||||||
|
IEnumerable<WzRowMeyleDto> wzRows = await service.GetByWzHeaderId(wzHeaderId);
|
||||||
|
return Ok(wzRows);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("by-part-number")]
|
||||||
|
public async Task<ActionResult<MaterialTransactionDto>> GetByPartNumber([FromQuery] string partNumber)
|
||||||
|
{
|
||||||
|
MaterialTransactionDto materialTransaction = await materialTransactionService.GetByPartNumber(partNumber);
|
||||||
|
return Ok(materialTransaction);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("transactions-with-part-number")]
|
||||||
|
public async Task<ActionResult<MaterialTransactionDto>> GetTransactionsWithPartNumber()
|
||||||
|
{
|
||||||
|
IEnumerable<MaterialTransactionDto> materialTransactions = await materialTransactionService.GetWithPartNumber();
|
||||||
|
return Ok(materialTransactions);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPut]
|
||||||
|
public async Task<ActionResult> UpdateRows([FromBody] IEnumerable<WzRowMeyleDto> rows)
|
||||||
|
{
|
||||||
|
if (rows == null || !rows.Any())
|
||||||
|
{
|
||||||
|
return BadRequest("No rows provided.");
|
||||||
|
}
|
||||||
|
|
||||||
|
await service.UpdateRows(rows);
|
||||||
|
return NoContent();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,20 +7,25 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageReference Include="BCrypt.Net-Core" Version="1.6.0" />
|
||||||
|
<PackageReference Include="FaKrosnoEfDataModel" Version="2.0.0" />
|
||||||
|
<PackageReference Include="Hangfire" Version="1.8.17" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.11" />
|
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.11" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.11" />
|
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.11" />
|
||||||
|
<PackageReference Include="Microsoft.Data.SqlClient" Version="6.0.1" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.0">
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.0">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="9.0.0" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="9.0.0" />
|
||||||
<PackageReference Include="NSwag.AspNetCore" Version="14.2.0" />
|
<PackageReference Include="NSwag.AspNetCore" Version="14.2.0" />
|
||||||
|
<PackageReference Include="Syncfusion.XlsIO.Net.Core" Version="29.2.4" />
|
||||||
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="8.3.0" />
|
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="8.3.0" />
|
||||||
|
<PackageReference Include="SytelineSaAppEfDataModel" Version="1.1.2" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\FaKrosnoEfDataModel\FaKrosnoEfDataModel.csproj" />
|
<ProjectReference Include="..\OrdersManagementDataModel\OrdersManagementDataModel.csproj" />
|
||||||
<ProjectReference Include="..\SytelineSaAppEfDataModel\SytelineSaAppEfDataModel.csproj" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
7
FaKrosnoApi/Models/AuthenticateRequestModel.cs
Normal file
7
FaKrosnoApi/Models/AuthenticateRequestModel.cs
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
namespace FaKrosnoApi.Models;
|
||||||
|
|
||||||
|
public class AuthenticateRequestModel
|
||||||
|
{
|
||||||
|
public string Login { get; set; }
|
||||||
|
public string Password { get; set; }
|
||||||
|
}
|
||||||
11
FaKrosnoApi/Models/EmailSettingsModel.cs
Normal file
11
FaKrosnoApi/Models/EmailSettingsModel.cs
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
namespace FaKrosnoApi.Models;
|
||||||
|
|
||||||
|
public class EmailSettingsModel
|
||||||
|
{
|
||||||
|
public string SmtpServer { get; set; }
|
||||||
|
public int Port { get; set; }
|
||||||
|
public string SenderEmail { get; set; }
|
||||||
|
public string SenderPassword { get; set; }
|
||||||
|
public string RecipientEmail { get; set; }
|
||||||
|
public bool UseSsl { get; set; }
|
||||||
|
}
|
||||||
19
FaKrosnoApi/Models/JobModel.cs
Normal file
19
FaKrosnoApi/Models/JobModel.cs
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
using Hangfire.Common;
|
||||||
|
|
||||||
|
namespace FaKrosnoApi.Models;
|
||||||
|
|
||||||
|
public class JobModel(
|
||||||
|
string jobId,
|
||||||
|
string cron,
|
||||||
|
string path,
|
||||||
|
DateTime? lastExecution,
|
||||||
|
DateTime? nextExecution,
|
||||||
|
Job jobDetails)
|
||||||
|
{
|
||||||
|
public string JobId { get; set; } = jobId;
|
||||||
|
public string Cron { get; set; } = cron;
|
||||||
|
public string Path { get; set; } = path;
|
||||||
|
public DateTime? LastExecution { get; set; } = lastExecution;
|
||||||
|
public DateTime? NextExecution { get; set; } = nextExecution;
|
||||||
|
public Job JobDetails { get; set; } = jobDetails;
|
||||||
|
}
|
||||||
6
FaKrosnoApi/Models/JobSettingsModel.cs
Normal file
6
FaKrosnoApi/Models/JobSettingsModel.cs
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
namespace FaKrosnoApi.Models;
|
||||||
|
|
||||||
|
public class JobSettingsModel
|
||||||
|
{
|
||||||
|
public int QueryIntervalMinutes { get; set; }
|
||||||
|
}
|
||||||
@@ -1,69 +1,124 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.IdentityModel.Tokens;
|
using FaKrosnoApi.Models;
|
||||||
using System.Text;
|
using FaKrosnoApi.Services;
|
||||||
using FaKrosnoEfDataModel;
|
using FaKrosnoEfDataModel;
|
||||||
using FaKrosnoEfDataModel.Services;
|
using FaKrosnoEfDataModel.Services;
|
||||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
using Hangfire;
|
||||||
|
using Hangfire.SqlServer;
|
||||||
|
using OrdersManagementDataModel;
|
||||||
|
using OrdersManagementDataModel.Services;
|
||||||
using SytelineSaAppEfDataModel;
|
using SytelineSaAppEfDataModel;
|
||||||
using SytelineSaAppEfDataModel.Services;
|
using SytelineSaAppEfDataModel.Services;
|
||||||
|
using NSwag;
|
||||||
|
using NSwag.Generation.Processors.Security;
|
||||||
using FaKrosnoMappingProfile = FaKrosnoEfDataModel.MappingProfile;
|
using FaKrosnoMappingProfile = FaKrosnoEfDataModel.MappingProfile;
|
||||||
using SytelineSaAppMappingProfile = SytelineSaAppEfDataModel.MappingProfile;
|
using SytelineSaAppMappingProfile = SytelineSaAppEfDataModel.MappingProfile;
|
||||||
|
using OrdersManagementMappingProfile = OrdersManagementDataModel.MappingProfile;
|
||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
var configuration = builder.Configuration;
|
|
||||||
// Add services to the container.
|
|
||||||
builder.Services.AddDbContext<FaKrosnoDbContext>(options =>
|
builder.Services.AddDbContext<FaKrosnoDbContext>(options =>
|
||||||
options.UseSqlServer(builder.Configuration.GetConnectionString("FaKrosnoConnection")));
|
options.UseSqlServer(builder.Configuration.GetConnectionString("FaKrosnoConnection")));
|
||||||
builder.Services.AddDbContext<SytelineSaAppDbContext>(options =>
|
builder.Services.AddDbContext<SytelineSaAppDbContext>(options =>
|
||||||
options.UseSqlServer(builder.Configuration.GetConnectionString("SytelineSaAppConnection")));
|
options.UseSqlServer(builder.Configuration.GetConnectionString("SytelineSaAppConnection")));
|
||||||
|
builder.Services.AddDbContext<OrdersManagementDbContext>(options =>
|
||||||
|
options.UseSqlServer(builder.Configuration.GetConnectionString("OrdersManagementConnection")));
|
||||||
|
|
||||||
builder.WebHost.UseUrls("http://*:5555");
|
builder.Services.Configure<EmailSettingsModel>(builder.Configuration.GetSection("EmailSettings"));
|
||||||
|
builder.Services.Configure<JobSettingsModel>(builder.Configuration.GetSection("JobSettings"));
|
||||||
|
|
||||||
|
builder.WebHost.UseUrls("http://*:5001");
|
||||||
|
|
||||||
|
// builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
|
||||||
|
// .AddJwtBearer(options =>
|
||||||
|
// {
|
||||||
|
// options.TokenValidationParameters = new TokenValidationParameters
|
||||||
|
// {
|
||||||
|
// ValidateIssuer = true,
|
||||||
|
// ValidateAudience = true,
|
||||||
|
// ValidateLifetime = true,
|
||||||
|
// ValidateIssuerSigningKey = true,
|
||||||
|
// ValidIssuer = builder.Configuration["Jwt:Issuer"],
|
||||||
|
// ValidAudience = builder.Configuration["Jwt:Audience"],
|
||||||
|
// IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(builder.Configuration["Jwt:Key"] ?? string.Empty)),
|
||||||
|
// NameClaimType = "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier"
|
||||||
|
// };
|
||||||
|
// });
|
||||||
|
|
||||||
builder.Services.AddControllers();
|
builder.Services.AddControllers();
|
||||||
builder.Services.AddEndpointsApiExplorer();
|
builder.Services.AddEndpointsApiExplorer();
|
||||||
builder.Services.AddEndpointsApiExplorer();
|
|
||||||
builder.Services.AddOpenApiDocument(config =>
|
builder.Services.AddOpenApiDocument(config =>
|
||||||
{
|
{
|
||||||
config.Title = "FaKrosnoApi";
|
config.Title = "FaKrosnoApi";
|
||||||
config.Version = "v1";
|
config.Version = "v1";
|
||||||
});
|
|
||||||
|
|
||||||
// Configure AutoMapper
|
config.AddSecurity("Bearer", new OpenApiSecurityScheme
|
||||||
builder.Services.AddAutoMapper(typeof(FaKrosnoMappingProfile), typeof(SytelineSaAppMappingProfile));
|
|
||||||
|
|
||||||
// Configure JWT Authentication
|
|
||||||
builder.Services.AddAuthentication(options =>
|
|
||||||
{
|
|
||||||
options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
|
|
||||||
options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
|
|
||||||
}).AddJwtBearer(options =>
|
|
||||||
{
|
|
||||||
options.TokenValidationParameters = new TokenValidationParameters
|
|
||||||
{
|
{
|
||||||
ValidateIssuer = true,
|
Name = "Authorization",
|
||||||
ValidateAudience = true,
|
Type = OpenApiSecuritySchemeType.Http,
|
||||||
ValidateLifetime = true,
|
Scheme = "Bearer",
|
||||||
ValidateIssuerSigningKey = true,
|
BearerFormat = "JWT",
|
||||||
ValidIssuer = builder.Configuration["Jwt:Issuer"],
|
In = OpenApiSecurityApiKeyLocation.Header,
|
||||||
ValidAudience = builder.Configuration["Jwt:Audience"],
|
Description = "Wprowadź token JWT w formacie: Bearer {token}"
|
||||||
IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(builder.Configuration["Jwt:Key"]))
|
});
|
||||||
};
|
|
||||||
|
config.OperationProcessors.Add(new OperationSecurityScopeProcessor("Bearer"));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
builder.Services.AddHangfire(config => config
|
||||||
|
.SetDataCompatibilityLevel(CompatibilityLevel.Version_170)
|
||||||
|
.UseSimpleAssemblyNameTypeSerializer()
|
||||||
|
.UseRecommendedSerializerSettings()
|
||||||
|
.UseSqlServerStorage(builder.Configuration.GetConnectionString("OrdersManagementConnection"), new SqlServerStorageOptions
|
||||||
|
{
|
||||||
|
CommandBatchMaxTimeout = TimeSpan.FromMinutes(5),
|
||||||
|
SlidingInvisibilityTimeout = TimeSpan.FromMinutes(5),
|
||||||
|
QueuePollInterval = TimeSpan.Zero,
|
||||||
|
UseRecommendedIsolationLevel = true,
|
||||||
|
DisableGlobalLocks = true
|
||||||
|
}));
|
||||||
|
builder.Services.AddHangfireServer();
|
||||||
|
|
||||||
|
builder.Services.AddAutoMapper(typeof(FaKrosnoMappingProfile), typeof(SytelineSaAppMappingProfile),
|
||||||
|
typeof(OrdersManagementMappingProfile));
|
||||||
|
|
||||||
builder.Services.AddScoped<IScheduleOrderService, ScheduleOrderService>();
|
builder.Services.AddScoped<IScheduleOrderService, ScheduleOrderService>();
|
||||||
builder.Services.AddScoped<IScheduleOrderDetailsService, ScheduleOrderDetailsService>();
|
builder.Services.AddScoped<IScheduleOrderDetailsService, ScheduleOrderDetailsService>();
|
||||||
builder.Services.AddScoped<IEdiCustomerOrderService, EdiCustomerOrderService>();
|
builder.Services.AddScoped<IEdiCustomerOrderService, EdiCustomerOrderService>();
|
||||||
|
builder.Services.AddScoped<IEdiCustomerOrderTranslateService, EdiCustomerOrderTranslateService>();
|
||||||
builder.Services.AddScoped<IErrorLogService, ErrorLogService>();
|
builder.Services.AddScoped<IErrorLogService, ErrorLogService>();
|
||||||
builder.Services.AddScoped<ICustomerOrderService, CustomerOrderService>();
|
builder.Services.AddScoped<ICustomerOrderService, CustomerOrderService>();
|
||||||
|
builder.Services.AddScoped<IEmailService, EmailService>();
|
||||||
|
builder.Services.AddScoped<IScheduleJobService, ScheduleJobService>();
|
||||||
|
builder.Services.AddScoped<ITaskSchedulerService, TaskSchedulerService>();
|
||||||
|
builder.Services.AddScoped<IUserService, UserService>();
|
||||||
|
builder.Services.AddScoped<IRoleService, RoleService>();
|
||||||
|
builder.Services.AddScoped<IFunctionService, FunctionService>();
|
||||||
|
builder.Services.AddScoped<IUserRoleService, UserRoleService>();
|
||||||
|
builder.Services.AddScoped<IProductService, ProductService>();
|
||||||
|
builder.Services.AddScoped<IMaterialTransactionService, MaterialTransactionService>();
|
||||||
|
builder.Services.AddScoped<IWzClientService, WzClientService>();
|
||||||
|
builder.Services.AddScoped<IWzHeaderService, WzHeaderService>();
|
||||||
|
builder.Services.AddScoped<IWzRowMeyleService, WzRowMeyleService>();
|
||||||
|
builder.Services.AddScoped<IItemCustService, ItemCustService>();
|
||||||
|
builder.Services.AddScoped<IEdiCustomerOrderImportService, EdiCustomerOrderImportService>();
|
||||||
|
builder.Services.AddScoped<ICustomerService, CustomerService>();
|
||||||
|
builder.Services.AddScoped<ICustomerTpService, CustomerTpService>();
|
||||||
|
builder.Services.AddScoped<IItemService, ItemService>();
|
||||||
|
builder.Services.AddScoped<IVatCodeAssociationService, VatCodeAssociationService>();
|
||||||
|
builder.Services.AddScoped<IItemCustPriceAllService, ItemCustPriceAllService>();
|
||||||
|
builder.Services.AddScoped<IEdiLogService, EdiLogService>();
|
||||||
|
builder.Services.AddScoped<IWzRowMareliService, WzRowMareliService>();
|
||||||
|
|
||||||
|
builder.Services.AddHostedService<TimedHostedService>();
|
||||||
|
|
||||||
|
Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense("NRAiBiAaIQQuGjN/V09+XU9HdVRDX3xKf0x/TGpQb19xflBPallYVBYiSV9jS3tTckVgWHldc3ZUR2lfVE90Vg==");
|
||||||
|
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
|
||||||
// Configure the HTTP request pipeline.
|
app.UseOpenApi();
|
||||||
//if (app.Environment.IsDevelopment())
|
app.UseSwaggerUi();
|
||||||
//{
|
|
||||||
app.UseOpenApi(); // Serwuje dokument OpenAPI
|
|
||||||
app.UseSwaggerUi(); // Dodaje interfejs u<>ytkownika Swagger
|
|
||||||
//}
|
|
||||||
|
|
||||||
app.UseHttpsRedirection();
|
app.UseHttpsRedirection();
|
||||||
|
|
||||||
@@ -72,4 +127,6 @@ app.UseAuthorization();
|
|||||||
|
|
||||||
app.MapControllers();
|
app.MapControllers();
|
||||||
|
|
||||||
|
app.UseHangfireDashboard();
|
||||||
|
|
||||||
app.Run();
|
app.Run();
|
||||||
30
FaKrosnoApi/Services/EmailService.cs
Normal file
30
FaKrosnoApi/Services/EmailService.cs
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
using System.Net;
|
||||||
|
using System.Net.Mail;
|
||||||
|
using FaKrosnoApi.Models;
|
||||||
|
using Microsoft.Extensions.Options;
|
||||||
|
|
||||||
|
namespace FaKrosnoApi.Services;
|
||||||
|
|
||||||
|
public class EmailService(IOptions<EmailSettingsModel> emailSettings) : IEmailService
|
||||||
|
{
|
||||||
|
private readonly EmailSettingsModel _emailSettings = emailSettings.Value;
|
||||||
|
|
||||||
|
public void SendEmail(string subject, string body)
|
||||||
|
{
|
||||||
|
using var smtpClient = new SmtpClient(_emailSettings.SmtpServer, _emailSettings.Port);
|
||||||
|
smtpClient.EnableSsl = true;
|
||||||
|
smtpClient.UseDefaultCredentials = false;
|
||||||
|
smtpClient.Credentials = new NetworkCredential(_emailSettings.SenderEmail, _emailSettings.SenderPassword);
|
||||||
|
|
||||||
|
var mailMessage = new MailMessage
|
||||||
|
{
|
||||||
|
From = new MailAddress(_emailSettings.SenderEmail),
|
||||||
|
Subject = subject,
|
||||||
|
Body = body
|
||||||
|
};
|
||||||
|
|
||||||
|
mailMessage.To.Add(_emailSettings.RecipientEmail);
|
||||||
|
|
||||||
|
smtpClient.Send(mailMessage);
|
||||||
|
}
|
||||||
|
}
|
||||||
6
FaKrosnoApi/Services/IEmailService.cs
Normal file
6
FaKrosnoApi/Services/IEmailService.cs
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
namespace FaKrosnoApi.Services;
|
||||||
|
|
||||||
|
public interface IEmailService
|
||||||
|
{
|
||||||
|
void SendEmail(string subject, string body);
|
||||||
|
}
|
||||||
6
FaKrosnoApi/Services/IScheduleJobService.cs
Normal file
6
FaKrosnoApi/Services/IScheduleJobService.cs
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
namespace FaKrosnoApi.Services;
|
||||||
|
|
||||||
|
public interface IScheduleJobService
|
||||||
|
{
|
||||||
|
Task ExecuteAsync();
|
||||||
|
}
|
||||||
29
FaKrosnoApi/Services/ScheduleJobService.cs
Normal file
29
FaKrosnoApi/Services/ScheduleJobService.cs
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
using System.Text;
|
||||||
|
using SytelineSaAppEfDataModel.Dtos;
|
||||||
|
using SytelineSaAppEfDataModel.Services;
|
||||||
|
|
||||||
|
namespace FaKrosnoApi.Services;
|
||||||
|
|
||||||
|
public class ScheduleJobService(IEmailService emailService, IServiceScopeFactory scopeFactory) : IScheduleJobService
|
||||||
|
{
|
||||||
|
public async Task ExecuteAsync()
|
||||||
|
{
|
||||||
|
using var scope = scopeFactory.CreateScope();
|
||||||
|
IEdiCustomerOrderService ediCustomerOrderService = scope.ServiceProvider.GetRequiredService<IEdiCustomerOrderService>();
|
||||||
|
IEnumerable<EdiCustomerOrderTranslateDto> missingOrders =
|
||||||
|
(await ediCustomerOrderService.FindMissingOrders(DateTime.Now.AddDays(-1))).ToList();
|
||||||
|
|
||||||
|
if (missingOrders.Any())
|
||||||
|
{
|
||||||
|
StringBuilder result = new StringBuilder();
|
||||||
|
result.AppendLine("Znaleziono brakujące zamówienia w bazie 'edi_co':");
|
||||||
|
|
||||||
|
foreach (EdiCustomerOrderTranslateDto missingOrder in missingOrders)
|
||||||
|
{
|
||||||
|
result.AppendLine($"- {missingOrder.EdiCoCoNum}");
|
||||||
|
}
|
||||||
|
|
||||||
|
emailService.SendEmail("Znaleziono brakujące zamówienia!", result.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
32
FaKrosnoApi/Services/TimedHostedService.cs
Normal file
32
FaKrosnoApi/Services/TimedHostedService.cs
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
using SytelineSaAppEfDataModel.Services;
|
||||||
|
|
||||||
|
namespace FaKrosnoApi.Services;
|
||||||
|
|
||||||
|
public class TimedHostedService(IServiceScopeFactory scopeFactory) : IHostedService, IDisposable
|
||||||
|
{
|
||||||
|
private Timer? _timer;
|
||||||
|
|
||||||
|
public Task StartAsync(CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
_timer = new Timer(DoWork, null, TimeSpan.Zero, TimeSpan.FromMinutes(30));
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DoWork(object? state)
|
||||||
|
{
|
||||||
|
using var scope = scopeFactory.CreateScope();
|
||||||
|
var scheduledJob = scope.ServiceProvider.GetRequiredService<IScheduleJobService>();
|
||||||
|
scheduledJob.ExecuteAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task StopAsync(CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
_timer?.Change(Timeout.Infinite, 0);
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
_timer?.Dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,8 @@
|
|||||||
{
|
{
|
||||||
"ConnectionStrings": {
|
"ConnectionStrings": {
|
||||||
"FaKrosnoConnection": "Server=192.168.0.7;Database=fakrosnotest;User Id=sa;Password=Tetum#2021!;TrustServerCertificate=true",
|
"FaKrosnoConnection": "Server=192.168.0.7;Database=fakrosno;User Id=sa;Password=Tetum#2021!;TrustServerCertificate=true",
|
||||||
"SytelineSaAppConnection": "Server=192.168.0.7;Database=SL_PRODTEST_SA_APP;User Id=sa;Password=Tetum#2021!;TrustServerCertificate=true"
|
"SytelineSaAppConnection": "Server=192.168.0.7;Database=SL_PROD_SA_APP;User Id=sa;Password=Tetum#2021!;TrustServerCertificate=true",
|
||||||
|
"OrdersManagementConnection": "Server=192.168.0.7;Database=OrdersManagement;User Id=sa;Password=Tetum#2021!;TrustServerCertificate=true"
|
||||||
},
|
},
|
||||||
"Logging": {
|
"Logging": {
|
||||||
"LogLevel": {
|
"LogLevel": {
|
||||||
@@ -10,11 +11,22 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Jwt": {
|
"Jwt": {
|
||||||
"Key": "ThisIsASecretKeyForJwt",
|
"Key": "a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0u1v2w3x4y5z6A7B8C9D0E1F",
|
||||||
"Issuer": "FaKrosnoApi",
|
"Issuer": "FaKrosnoApi",
|
||||||
"Audience": "FaKrosnoClient"
|
"Audience": "FaKrosnoClient"
|
||||||
},
|
},
|
||||||
"Host": {
|
"Host": {
|
||||||
"Urls": "http://0.0.0.0:5555"
|
"Urls": "http://0.0.0.0:5001"
|
||||||
|
},
|
||||||
|
"EmailSettings": {
|
||||||
|
"SmtpServer": "poczta.fakrosno.pl",
|
||||||
|
"Port": 587,
|
||||||
|
"SenderEmail": "edi@fakrosno.pl",
|
||||||
|
"SenderPassword": "F@Krosno2014",
|
||||||
|
"RecipientEmail": "piotr.kus@fakrosno.pl",
|
||||||
|
"UseSsl": false
|
||||||
|
},
|
||||||
|
"JobSettings": {
|
||||||
|
"QueryIntervalMinutes": 30
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
12
FaKrosnoEfDataModel/Dtos/ProductDto.cs
Normal file
12
FaKrosnoEfDataModel/Dtos/ProductDto.cs
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
namespace FaKrosnoEfDataModel.Dtos;
|
||||||
|
|
||||||
|
public class ProductDto : DtoBase
|
||||||
|
{
|
||||||
|
public int ID { get; set; }
|
||||||
|
public int RecipientID { get; set; }
|
||||||
|
public string RecipientIdx { get; set; }
|
||||||
|
public string FaIdx { get; set; }
|
||||||
|
public string RecipientName { get; set; }
|
||||||
|
|
||||||
|
public RecipientDto Recipient { get; set; }
|
||||||
|
}
|
||||||
@@ -20,6 +20,6 @@ namespace FaKrosnoEfDataModel.Dtos
|
|||||||
public DateTime? ShipDate { get; set; }
|
public DateTime? ShipDate { get; set; }
|
||||||
public DateTime LastUpdateDate { get; set; }
|
public DateTime LastUpdateDate { get; set; }
|
||||||
|
|
||||||
public IList<ScheduleOrderDetailDetailMiscDto> ScheduleOrderDetailDetailMiscs { get; set; }
|
public IList<ScheduleOrderDetailDetailMiscDto>? ScheduleOrderDetailDetailMiscs { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,5 +13,7 @@ namespace FaKrosnoEfDataModel.Dtos
|
|||||||
public string Value { get; set; }
|
public string Value { get; set; }
|
||||||
public string? Label { get; set; }
|
public string? Label { get; set; }
|
||||||
public bool Display { get; set; }
|
public bool Display { get; set; }
|
||||||
|
|
||||||
|
public string Text => $"{Label}:\t{Value}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,11 @@ namespace FaKrosnoEfDataModel.Dtos
|
|||||||
public string Sh_productCode { get; set; }
|
public string Sh_productCode { get; set; }
|
||||||
public int? Price { get; set; }
|
public int? Price { get; set; }
|
||||||
|
|
||||||
|
public string? OrderNumber {get; set;}
|
||||||
|
public string? RecipientName {get; set;}
|
||||||
|
public string? RecipientCode {get; set;}
|
||||||
|
public string? PurchaserName {get; set;}
|
||||||
public IList<ScheduleOrderDetailDetailDto> ScheduleOrderDetailDetails { get; set; }
|
public IList<ScheduleOrderDetailDetailDto> ScheduleOrderDetailDetails { get; set; }
|
||||||
public IList<ScheduleOrderDetailMiscDto> ScheduleOrderDetailMiscs { get; set; }
|
public IList<ScheduleOrderDetailMiscDto>? ScheduleOrderDetailMiscs { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,5 +13,7 @@ namespace FaKrosnoEfDataModel.Dtos
|
|||||||
public string Value { get; set; }
|
public string Value { get; set; }
|
||||||
public string? Label { get; set; }
|
public string? Label { get; set; }
|
||||||
public bool Display { get; set; }
|
public bool Display { get; set; }
|
||||||
|
|
||||||
|
public string Text => $"{Label}:\t{Value}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,8 +15,10 @@ namespace FaKrosnoEfDataModel.Dtos
|
|||||||
public int DocNumber { get; set; }
|
public int DocNumber { get; set; }
|
||||||
public string? DocType { get; set; }
|
public string? DocType { get; set; }
|
||||||
|
|
||||||
public string? RecipientCode => Recipient.RecipientCode;
|
public string RecipientCode => Recipient.RecipientCode;
|
||||||
public string? PurchaserCode => Recipient.Purchaser?.PurchaserCode;
|
public string? PurchaserCode => Recipient.Purchaser?.PurchaserCode;
|
||||||
|
public string RecipientName => Recipient.RecipientDesc;
|
||||||
|
public string? PurchaserName => Recipient.Purchaser?.PurchaserDesc;
|
||||||
public RecipientDto Recipient { get; set; }
|
public RecipientDto Recipient { get; set; }
|
||||||
|
|
||||||
public IList<ScheduleOrderDetailDto> ScheduleOrderDetails { get; set; }
|
public IList<ScheduleOrderDetailDto> ScheduleOrderDetails { get; set; }
|
||||||
|
|||||||
@@ -13,5 +13,7 @@ namespace FaKrosnoEfDataModel.Dtos
|
|||||||
public string Value { get; set; }
|
public string Value { get; set; }
|
||||||
public string? Label { get; set; }
|
public string? Label { get; set; }
|
||||||
public bool Display { get; set; }
|
public bool Display { get; set; }
|
||||||
|
|
||||||
|
public string Text => $"{Label}:\t{Value}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
11
FaKrosnoEfDataModel/Entities/Product.cs
Normal file
11
FaKrosnoEfDataModel/Entities/Product.cs
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
namespace FaKrosnoEfDataModel.Entities;
|
||||||
|
|
||||||
|
public class Product : EntityBase
|
||||||
|
{
|
||||||
|
public int ID { get; set; }
|
||||||
|
public int RecipientID { get; set; }
|
||||||
|
public string RecipientIdx { get; set; }
|
||||||
|
public string FaIdx { get; set; }
|
||||||
|
|
||||||
|
public Recipient Recipient { get; set; }
|
||||||
|
}
|
||||||
@@ -21,6 +21,7 @@ namespace FaKrosnoEfDataModel
|
|||||||
public DbSet<ScheduleOrderDetailDetailMisc> ScheduleOrderDetailDetailMiscs { get; set; }
|
public DbSet<ScheduleOrderDetailDetailMisc> ScheduleOrderDetailDetailMiscs { get; set; }
|
||||||
public DbSet<ScheduleOrderDetailMisc> ScheduleOrderDetailMiscs { get; set; }
|
public DbSet<ScheduleOrderDetailMisc> ScheduleOrderDetailMiscs { get; set; }
|
||||||
public DbSet<ScheduleOrderMisc> ScheduleOrderMiscs { get; set; }
|
public DbSet<ScheduleOrderMisc> ScheduleOrderMiscs { get; set; }
|
||||||
|
public DbSet<Product> Products { get; set; }
|
||||||
|
|
||||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||||
{
|
{
|
||||||
@@ -85,6 +86,36 @@ namespace FaKrosnoEfDataModel
|
|||||||
entity.Property(x => x.QtyDesc).IsRequired(false);
|
entity.Property(x => x.QtyDesc).IsRequired(false);
|
||||||
entity.Property(x => x.ShipDate).IsRequired(false);
|
entity.Property(x => x.ShipDate).IsRequired(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity<Product>(entity =>
|
||||||
|
{
|
||||||
|
entity.ToTable("product");
|
||||||
|
|
||||||
|
entity.HasKey(e => e.ID);
|
||||||
|
|
||||||
|
entity.Property(e => e.ID)
|
||||||
|
.HasColumnName("ID")
|
||||||
|
.ValueGeneratedOnAdd();
|
||||||
|
|
||||||
|
entity.Property(e => e.RecipientID)
|
||||||
|
.HasColumnName("recipientID")
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
entity.Property(e => e.RecipientIdx)
|
||||||
|
.HasColumnName("recipientIdx")
|
||||||
|
.HasMaxLength(50)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
entity.Property(e => e.FaIdx)
|
||||||
|
.HasColumnName("faIdx")
|
||||||
|
.HasMaxLength(50)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
// Define the unique constraint for recipientID and recipientIdx
|
||||||
|
entity.HasIndex(e => new { e.RecipientID, e.RecipientIdx })
|
||||||
|
.HasDatabaseName("IX_product")
|
||||||
|
.IsUnique();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,14 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
|
<PackageId>FaKrosnoEfDataModel</PackageId>
|
||||||
|
<Authors>Piotr Kus</Authors>
|
||||||
|
<Description>FaKrosno Entity Framework Data Model</Description>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
<MinVerAutoIncrement>patch</MinVerAutoIncrement>
|
||||||
|
<MinVerMinimumMajorMinor>1.0</MinVerMinimumMajorMinor>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@@ -20,6 +25,10 @@
|
|||||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="9.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Configuration" Version="9.0.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="9.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="9.0.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.0" />
|
||||||
|
<PackageReference Include="MinVer" Version="6.0.0">
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
</PackageReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ namespace FaKrosnoEfDataModel
|
|||||||
CreateMap<ScheduleOrderDetailMisc, ScheduleOrderDetailMiscDto>().IncludeBase<EntityBase, DtoBase>()
|
CreateMap<ScheduleOrderDetailMisc, ScheduleOrderDetailMiscDto>().IncludeBase<EntityBase, DtoBase>()
|
||||||
.ReverseMap();
|
.ReverseMap();
|
||||||
CreateMap<ScheduleOrderMisc, ScheduleOrderMiscDto>().IncludeBase<EntityBase, DtoBase>().ReverseMap();
|
CreateMap<ScheduleOrderMisc, ScheduleOrderMiscDto>().IncludeBase<EntityBase, DtoBase>().ReverseMap();
|
||||||
|
CreateMap<Product, ProductDto>().IncludeBase<EntityBase, DtoBase>().ReverseMap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,4 @@
|
|||||||
using System;
|
using FaKrosnoEfDataModel.Entities;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using FaKrosnoEfDataModel.Entities;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
namespace FaKrosnoEfDataModel.Queries
|
namespace FaKrosnoEfDataModel.Queries
|
||||||
@@ -16,6 +11,11 @@ namespace FaKrosnoEfDataModel.Queries
|
|||||||
.Include(x => x.ScheduleOrderDetails).ThenInclude(x => x.ScheduleOrderDetailDetails)
|
.Include(x => x.ScheduleOrderDetails).ThenInclude(x => x.ScheduleOrderDetailDetails)
|
||||||
.ThenInclude(x => x.ScheduleOrderDetailDetailMiscs).Include(x => x.ScheduleOrderMiscs));
|
.ThenInclude(x => x.ScheduleOrderDetailDetailMiscs).Include(x => x.ScheduleOrderMiscs));
|
||||||
|
|
||||||
|
public static readonly Func<FaKrosnoDbContext, int, IEnumerable<ScheduleOrder?>> GetEntitiesByPurchaser =
|
||||||
|
EF.CompileQuery((FaKrosnoDbContext context, int purchaser) => context.ScheduleOrders
|
||||||
|
.Include(x => x.Recipient).ThenInclude(x => x.Purchaser).Include(x => x.ScheduleOrderDetails)
|
||||||
|
.ThenInclude(x => x.ScheduleOrderDetailMiscs).Where(x => x.Recipient.Purchaser.ID == purchaser));
|
||||||
|
|
||||||
public static readonly Func<FaKrosnoDbContext, DateTime, IEnumerable<ScheduleOrder?>> GetEntitiesByDate =
|
public static readonly Func<FaKrosnoDbContext, DateTime, IEnumerable<ScheduleOrder?>> GetEntitiesByDate =
|
||||||
EF.CompileQuery((FaKrosnoDbContext context, DateTime fromDate) => context.ScheduleOrders
|
EF.CompileQuery((FaKrosnoDbContext context, DateTime fromDate) => context.ScheduleOrders
|
||||||
.Include(x => x.Recipient).ThenInclude(x => x.Purchaser).Include(x => x.ScheduleOrderDetails)
|
.Include(x => x.Recipient).ThenInclude(x => x.Purchaser).Include(x => x.ScheduleOrderDetails)
|
||||||
|
|||||||
10
FaKrosnoEfDataModel/Services/IProductService.cs
Normal file
10
FaKrosnoEfDataModel/Services/IProductService.cs
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
using FaKrosnoEfDataModel.Dtos;
|
||||||
|
|
||||||
|
namespace FaKrosnoEfDataModel.Services;
|
||||||
|
|
||||||
|
public interface IProductService
|
||||||
|
{
|
||||||
|
Task<IEnumerable<ProductDto?>> GetEntities();
|
||||||
|
Task<IEnumerable<ProductDto?>> GetEntitiesToFix(string indexName);
|
||||||
|
Task UpdateEntity(ProductDto entity);
|
||||||
|
}
|
||||||
@@ -10,5 +10,8 @@ namespace FaKrosnoEfDataModel.Services
|
|||||||
public interface IScheduleOrderDetailsService
|
public interface IScheduleOrderDetailsService
|
||||||
{
|
{
|
||||||
Task<IEnumerable<ScheduleOrderDetailDto>?> GetScheduleOrderDetailsAsync(int scheduleOrderId);
|
Task<IEnumerable<ScheduleOrderDetailDto>?> GetScheduleOrderDetailsAsync(int scheduleOrderId);
|
||||||
|
|
||||||
|
Task<IEnumerable<ScheduleOrderDetailDetailDto>> GetScheduleOrderDetailsDetailsByIdAsync(
|
||||||
|
int scheduleOrderDetailId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ namespace FaKrosnoEfDataModel.Services
|
|||||||
Task<IEnumerable<ScheduleOrderDto?>> GetEntities();
|
Task<IEnumerable<ScheduleOrderDto?>> GetEntities();
|
||||||
Task<ScheduleOrderDto?> GetById(int id);
|
Task<ScheduleOrderDto?> GetById(int id);
|
||||||
Task<IEnumerable<ScheduleOrderDto?>> GetByRecipientId(int recipientId);
|
Task<IEnumerable<ScheduleOrderDto?>> GetByRecipientId(int recipientId);
|
||||||
|
Task<IEnumerable<ScheduleOrderDto>> GetByPurchaserId(int purchaserId);
|
||||||
Task<IEnumerable<ScheduleOrderDto?>> GetEntitiesByLastUpdateDate(DateTime date);
|
Task<IEnumerable<ScheduleOrderDto?>> GetEntitiesByLastUpdateDate(DateTime date);
|
||||||
Task<IEnumerable<ScheduleOrderDto?>> GetByRecipientAndLastUpdateDate(int recipientId, DateTime date);
|
Task<IEnumerable<ScheduleOrderDto?>> GetByRecipientAndLastUpdateDate(int recipientId, DateTime date);
|
||||||
}
|
}
|
||||||
|
|||||||
59
FaKrosnoEfDataModel/Services/ProductService.cs
Normal file
59
FaKrosnoEfDataModel/Services/ProductService.cs
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
using AutoMapper;
|
||||||
|
using FaKrosnoEfDataModel.Dtos;
|
||||||
|
using FaKrosnoEfDataModel.Entities;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace FaKrosnoEfDataModel.Services;
|
||||||
|
|
||||||
|
public class ProductService(FaKrosnoDbContext context, IMapper mapper)
|
||||||
|
: ServiceBase<ProductDto>(context, mapper), IProductService
|
||||||
|
{
|
||||||
|
public async Task<IEnumerable<ProductDto?>> GetEntities()
|
||||||
|
{
|
||||||
|
IList<ProductDto> products = (await GetAll()).ToList();
|
||||||
|
|
||||||
|
return products;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<ProductDto?>> GetEntitiesToFix(string indexName)
|
||||||
|
{
|
||||||
|
IList<RecipientDto> recipients =
|
||||||
|
(await Context.Recipients.ToListAsync()).Select(x => Mapper.Map<RecipientDto>(x)).ToList();
|
||||||
|
IList<PurchaserDto> purchasers = (await Context.Purchasers.ToListAsync()).Select(x => Mapper.Map<PurchaserDto>(x)).ToList();
|
||||||
|
IList<ProductDto> products = (await GetAll()).ToList();
|
||||||
|
|
||||||
|
IEnumerable<ProductDto> productDtos = products.Where(x => x.FaIdx == indexName).ToList();
|
||||||
|
|
||||||
|
foreach (ProductDto productDto in productDtos)
|
||||||
|
{
|
||||||
|
RecipientDto? recipient = recipients.FirstOrDefault(x => x.ID == productDto.RecipientID);
|
||||||
|
|
||||||
|
if (recipient != null)
|
||||||
|
{
|
||||||
|
productDto.Recipient = recipient;
|
||||||
|
productDto.RecipientName = recipient.RecipientDesc;
|
||||||
|
}
|
||||||
|
|
||||||
|
PurchaserDto? purchaser = purchasers.FirstOrDefault(x => x.ID == productDto.Recipient.PurchaserID);
|
||||||
|
|
||||||
|
if (purchaser != null)
|
||||||
|
{
|
||||||
|
productDto.Recipient.Purchaser = purchaser;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return productDtos;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task UpdateEntity(ProductDto entity)
|
||||||
|
{
|
||||||
|
Product? product = await Context.Products.FirstOrDefaultAsync(x => x.ID == entity.ID);
|
||||||
|
|
||||||
|
if (product != null)
|
||||||
|
{
|
||||||
|
product.FaIdx = entity.FaIdx;
|
||||||
|
Context.Products.Update(product);
|
||||||
|
await Context.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,9 +1,4 @@
|
|||||||
using System;
|
using AutoMapper;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using AutoMapper;
|
|
||||||
using AutoMapper.QueryableExtensions;
|
using AutoMapper.QueryableExtensions;
|
||||||
using FaKrosnoEfDataModel.Dtos;
|
using FaKrosnoEfDataModel.Dtos;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
@@ -21,5 +16,11 @@ namespace FaKrosnoEfDataModel.Services
|
|||||||
return await Context.ScheduleOrderDetails.Where(x => x.ScheduleOrderID == scheduleOrderId)
|
return await Context.ScheduleOrderDetails.Where(x => x.ScheduleOrderID == scheduleOrderId)
|
||||||
.ProjectTo<ScheduleOrderDetailDto>(Mapper.ConfigurationProvider).ToListAsync();
|
.ProjectTo<ScheduleOrderDetailDto>(Mapper.ConfigurationProvider).ToListAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<ScheduleOrderDetailDetailDto>> GetScheduleOrderDetailsDetailsByIdAsync(int scheduleOrderDetailId)
|
||||||
|
{
|
||||||
|
return await Context.ScheduleOrderDetailDetails.Where(x => x.ScheduleOrderDetailID == scheduleOrderDetailId)
|
||||||
|
.ProjectTo<ScheduleOrderDetailDetailDto>(Mapper.ConfigurationProvider).ToListAsync();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,14 @@ namespace FaKrosnoEfDataModel.Services
|
|||||||
return scheduleOrders.Where(x => x?.RecipientID == recipientId);
|
return scheduleOrders.Where(x => x?.RecipientID == recipientId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<ScheduleOrderDto>> GetByPurchaserId(int purchaserId)
|
||||||
|
{
|
||||||
|
IEnumerable<ScheduleOrder?> scheduleOrders =
|
||||||
|
(await Task.FromResult(ScheduleOrderQueries.GetEntitiesByPurchaser(Context, purchaserId))).ToList();
|
||||||
|
|
||||||
|
return scheduleOrders.Select(x => Mapper.Map<ScheduleOrderDto>(x));
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<IEnumerable<ScheduleOrderDto?>> GetByRecipientAndLastUpdateDate(int recipientId, DateTime date)
|
public async Task<IEnumerable<ScheduleOrderDto?>> GetByRecipientAndLastUpdateDate(int recipientId, DateTime date)
|
||||||
{
|
{
|
||||||
IList<ScheduleOrderDto?> scheduleOrders = (await GetEntitiesByLastUpdateDate(date)).ToList();
|
IList<ScheduleOrderDto?> scheduleOrders = (await GetEntitiesByLastUpdateDate(date)).ToList();
|
||||||
@@ -35,7 +43,7 @@ namespace FaKrosnoEfDataModel.Services
|
|||||||
|
|
||||||
public async Task<IEnumerable<ScheduleOrderDto?>> GetEntities()
|
public async Task<IEnumerable<ScheduleOrderDto?>> GetEntities()
|
||||||
{
|
{
|
||||||
IList<ScheduleOrder> scheduleOrders = await Context.ScheduleOrders.Include(x => x.Recipient)
|
IList<ScheduleOrder> scheduleOrders = await Context.ScheduleOrders.Include(x => x.ScheduleOrderDetails).Include(x => x.Recipient)
|
||||||
.ThenInclude(x => x.Purchaser).ToListAsync();
|
.ThenInclude(x => x.Purchaser).ToListAsync();
|
||||||
|
|
||||||
return Mapper.Map<IEnumerable<ScheduleOrderDto>>(scheduleOrders);
|
return Mapper.Map<IEnumerable<ScheduleOrderDto>>(scheduleOrders);
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
<!DOCTYPE html>
|
@using Microsoft.AspNetCore.Components.Authorization
|
||||||
|
@using OrdersManagement.Components.Layout
|
||||||
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
@@ -8,21 +10,23 @@
|
|||||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous" />
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous" />
|
||||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.3/font/bootstrap-icons.css" rel="stylesheet" />
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.3/font/bootstrap-icons.css" rel="stylesheet" />
|
||||||
<link href="_content/Blazor.Bootstrap/blazor.bootstrap.css" rel="stylesheet" />
|
<link href="_content/Blazor.Bootstrap/blazor.bootstrap.css" rel="stylesheet" />
|
||||||
|
<link href="_content/Syncfusion.Blazor.Themes/bootstrap5.css" rel="stylesheet" />
|
||||||
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css" integrity="sha512-Fo3rlrZj/k7ujTnHg4CGR2D7kSs0v4LLanw2qksYuRlEzO+tcaEPQogQ0KaoGN26/zrn20ImR1DfuLWnOo7aBA==" crossorigin="anonymous" referrerpolicy="no-referrer" />
|
||||||
<link rel="stylesheet" href="app.css" />
|
<link rel="stylesheet" href="app.css" />
|
||||||
<link rel="stylesheet" href="OrdersManagement.styles.css" />
|
<link rel="stylesheet" href="OrdersManagement.styles.css" />
|
||||||
|
<link href="material.css" rel="stylesheet"/>
|
||||||
<HeadOutlet @rendermode="@InteractiveServer" />
|
<HeadOutlet @rendermode="@InteractiveServer" />
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<Routes @rendermode="@InteractiveServer" />
|
<Routes @rendermode="@InteractiveServer" />
|
||||||
<script src="_framework/blazor.web.js"></script>
|
<script src="_framework/blazor.web.js"></script>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-kenU1KFdBIe4zVF0s0G1M5b4hcpxyD9F7jL+jjXkk+Q2h455rYXK/7HAuoJl+0I4" crossorigin="anonymous"></script>
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-kenU1KFdBIe4zVF0s0G1M5b4hcpxyD9F7jL+jjXkk+Q2h455rYXK/7HAuoJl+0I4" crossorigin="anonymous"></script>
|
||||||
<!-- Add chart.js reference if chart components are used in your application. -->
|
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/4.0.1/chart.umd.js" integrity="sha512-gQhCDsnnnUfaRzD8k1L5llCCV6O9HN09zClIzzeJ8OJ9MpGmIlCxm+pdCkqTwqJ4JcjbojFr79rl2F1mzcoLMQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/4.0.1/chart.umd.js" integrity="sha512-gQhCDsnnnUfaRzD8k1L5llCCV6O9HN09zClIzzeJ8OJ9MpGmIlCxm+pdCkqTwqJ4JcjbojFr79rl2F1mzcoLMQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
||||||
<!-- Add chartjs-plugin-datalabels.min.js reference if chart components with data label feature is used in your application. -->
|
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/chartjs-plugin-datalabels/2.2.0/chartjs-plugin-datalabels.min.js" integrity="sha512-JPcRR8yFa8mmCsfrw4TNte1ZvF1e3+1SdGMslZvmrzDYxS69J7J49vkFL8u6u8PlPJK+H3voElBtUCzaXj+6ig==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/chartjs-plugin-datalabels/2.2.0/chartjs-plugin-datalabels.min.js" integrity="sha512-JPcRR8yFa8mmCsfrw4TNte1ZvF1e3+1SdGMslZvmrzDYxS69J7J49vkFL8u6u8PlPJK+H3voElBtUCzaXj+6ig==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/sortablejs@latest/Sortable.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/sortablejs@latest/Sortable.min.js"></script>
|
||||||
<script src="_content/Blazor.Bootstrap/blazor.bootstrap.js"></script>
|
<script src="_content/Blazor.Bootstrap/blazor.bootstrap.js"></script>
|
||||||
|
<script src="_content/Syncfusion.Blazor.Core/scripts/syncfusion-blazor.min.js" type="text/javascript"></script>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
@@ -1,52 +1,101 @@
|
|||||||
@using BlazorBootstrap
|
@inherits LayoutComponentBase
|
||||||
@inherits LayoutComponentBase
|
|
||||||
|
|
||||||
<div class="bb-page">
|
@using System.Security.Claims
|
||||||
|
@using Microsoft.AspNetCore.Components.Authorization
|
||||||
<Sidebar @ref="_sidebar"
|
@using Syncfusion.Blazor.Navigations
|
||||||
IconName="IconName.App"
|
@using static Syncfusion.Blazor.Navigations.Orientation
|
||||||
Title="FA Krosno Manager"
|
@using Syncfusion.Blazor.Buttons
|
||||||
DataProvider="SidebarDataProvider" />
|
@inject NavigationManager NavigationManager
|
||||||
|
@inject CustomAuthenticationStateProvider AuthenticationStateProvider
|
||||||
<main>
|
|
||||||
<div class="bb-top-row px-4 d-flex justify-content-end">
|
|
||||||
<a href="https://docs.microsoft.com/aspnet/" target="_blank">About</a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<article class="content px-4">
|
|
||||||
<div class="py-2">@Body</div>
|
|
||||||
</article>
|
|
||||||
</main>
|
|
||||||
|
|
||||||
|
<div class="page h-100 d-flex flex-column">
|
||||||
|
<main class="container-fluid d-flex flex-column h-100">
|
||||||
|
<div class="bb-top-row px-4 d-flex justify-content-between align-items-center mb-3 shadow-sm"
|
||||||
|
style="background-color: #f8f9fa;">
|
||||||
|
<div class="d-flex align-items-center" style="margin: 10px">
|
||||||
|
<img src="logo.svg" class="me-2" width="35" height="35" alt="Icon">
|
||||||
|
<h3 class="text-primary m-0">FA Krosno Manager</h3>
|
||||||
|
</div>
|
||||||
|
@* <div class="d-flex align-items-center"> *@
|
||||||
|
@* @if (IsAuthenticated) *@
|
||||||
|
@* { *@
|
||||||
|
@* <span class="me-2">Jesteś zalogowany jako <strong>@UserName</strong></span> *@
|
||||||
|
@* <SfButton CssClass="e-primary" IsPrimary="true" @onclick="Logout">Wyloguj</SfButton> *@
|
||||||
|
@* } *@
|
||||||
|
@* else *@
|
||||||
|
@* { *@
|
||||||
|
@* <a href="/login" class="text-muted">Zaloguj</a> *@
|
||||||
|
@* } *@
|
||||||
|
@* </div> *@
|
||||||
|
</div>
|
||||||
|
<div class="row gx-1 flex-grow-1">
|
||||||
|
<div class="col-auto custom-menu-width">
|
||||||
|
<SfMenu TValue="MenuItem" HamburgerMode="true" Orientation="Vertical" Title="Menu">
|
||||||
|
<MenuItems>
|
||||||
|
<MenuItem Text="Zamówienia DELFOR" Url="/" IconCss="fa-solid fa-landmark"></MenuItem>
|
||||||
|
<MenuItem Text="Zarządzanie Indeksami" Url="/Products" IconCss="fa-solid fa-basket-shopping"></MenuItem>
|
||||||
|
<MenuItem Text="Magazyn" Url="/Warehouse" IconCss="fa-solid fa-warehouse"></MenuItem>
|
||||||
|
@if (IsAdminRoute())
|
||||||
|
{
|
||||||
|
<MenuItem Text="Administracja" Url="/Admin/PK" IconCss="fa-solid fa-screwdriver-wrench">
|
||||||
|
<MenuItems>
|
||||||
|
<MenuItem Text="Użytkownicy" Url = "/Admin/PK/UsersManager" IconCss="fa-solid fa-user-tie"></MenuItem>
|
||||||
|
<MenuItem Text="Scheduler" Url = "/Admin/PK/Scheduler" IconCss="fa-solid fa-calendar-week"></MenuItem>
|
||||||
|
<MenuItem Text="Zamówienia klienta EDI" Url="/Admin/PK/EdiCustomerOrders" IconCss="fa-solid fa-list-check"></MenuItem>
|
||||||
|
<MenuItem Text="Zamówienia klienta" Url="/Admin/PK/CustomerOrders" IconCss="fa-solid fa-database"></MenuItem>
|
||||||
|
</MenuItems>
|
||||||
|
</MenuItem>
|
||||||
|
}
|
||||||
|
</MenuItems>
|
||||||
|
<MenuAnimationSettings Effect="MenuEffect.SlideDown" Duration="800"></MenuAnimationSettings>
|
||||||
|
</SfMenu>
|
||||||
|
</div>
|
||||||
|
<article class="content col d-flex flex-column">
|
||||||
|
<div class="py-2 flex-grow-1">@Body</div>
|
||||||
|
<footer class="text-center text-muted py-2">
|
||||||
|
<small>FA Krosno Manager © @(DateTime.Now.Year)</small>
|
||||||
|
</footer>
|
||||||
|
</article>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
Sidebar? _sidebar;
|
private bool IsAuthenticated { get; set; }
|
||||||
IEnumerable<NavItem>? _navItems;
|
private string UserName { get; set; } = string.Empty;
|
||||||
|
|
||||||
private async Task<SidebarDataProviderResult> SidebarDataProvider(SidebarDataProviderRequest request)
|
private bool IsAdminRoute()
|
||||||
{
|
{
|
||||||
_navItems ??= GetNavItems();
|
var path = new Uri(NavigationManager.Uri).AbsolutePath;
|
||||||
|
return path.StartsWith("/admin", StringComparison.OrdinalIgnoreCase);
|
||||||
|
}
|
||||||
|
|
||||||
return await Task.FromResult(request.ApplyTo(_navItems));
|
protected override void OnInitialized()
|
||||||
}
|
{
|
||||||
|
// ClaimsPrincipal currentUser = AuthenticationStateProvider.GetCurrentUser();
|
||||||
|
// IsAuthenticated = currentUser.Identity?.IsAuthenticated == true;
|
||||||
|
// UserName = currentUser.Identity?.Name ?? "Nieznany użytkownik";
|
||||||
|
//
|
||||||
|
// AuthenticationStateProvider.AuthenticationStateChanged += OnAuthenticationStateChanged;
|
||||||
|
}
|
||||||
|
|
||||||
private IEnumerable<NavItem>? GetNavItems()
|
private async void OnAuthenticationStateChanged(Task<AuthenticationState> task)
|
||||||
{
|
{
|
||||||
_navItems = new List<NavItem>
|
var authState = await task;
|
||||||
{
|
IsAuthenticated = authState.User.Identity?.IsAuthenticated ?? false;
|
||||||
new NavItem { Id = "1", Href = "/", IconName = IconName.HouseDoorFill, Text = "Zamówienia DELFOR", Match=NavLinkMatch.All},
|
UserName = IsAuthenticated ? authState.User.Identity?.Name ?? "Nieznany użytkownik" : string.Empty;
|
||||||
new NavItem { Id = "2", Href = "/EdiCustomerOrders", IconName = IconName.Database, Text = "Zamówienia klienta EDI"},
|
StateHasChanged();
|
||||||
new NavItem { Id = "3", Href = "/CustomerOrders", IconName = IconName.Database, Text = "Zamówienia klienta"}
|
}
|
||||||
};
|
|
||||||
|
private void Logout()
|
||||||
|
{
|
||||||
|
NavigationManager.NavigateTo("/");
|
||||||
|
}
|
||||||
|
|
||||||
return _navItems;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
<div id="blazor-error-ui">
|
<div id="blazor-error-ui">
|
||||||
An unhandled error has occurred.
|
An unhandled error has occurred.
|
||||||
<a href="" class="reload">Reload</a>
|
<a href="" class="reload">Reload</a>
|
||||||
<a class="dismiss">🗙</a>
|
<a class="dismiss">🗙</a>
|
||||||
</div>
|
</div>
|
||||||
@@ -94,3 +94,12 @@ main {
|
|||||||
right: 0.75rem;
|
right: 0.75rem;
|
||||||
top: 0.5rem;
|
top: 0.5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.e-grid .e-row.e-selection {
|
||||||
|
background-color: #D3D3D3 !important; /* Jasny szary */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Domyślny styl dla wierszy (na wszelki wypadek) */
|
||||||
|
.e-grid .e-row {
|
||||||
|
background-color: #FFFFFF; /* Biały, domyślny kolor */
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,30 +0,0 @@
|
|||||||
<div class="top-row ps-3 navbar navbar-dark">
|
|
||||||
<div class="container-fluid">
|
|
||||||
<a class="navbar-brand" href="">OrdersManagement</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<input type="checkbox" title="Navigation menu" class="navbar-toggler" />
|
|
||||||
|
|
||||||
<div class="nav-scrollable" onclick="document.querySelector('.navbar-toggler').click()">
|
|
||||||
<nav class="flex-column">
|
|
||||||
<div class="nav-item px-3">
|
|
||||||
<NavLink class="nav-link" href="" Match="NavLinkMatch.All">
|
|
||||||
<span class="bi bi-house-door-fill-nav-menu" aria-hidden="true"></span> Home
|
|
||||||
</NavLink>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="nav-item px-3">
|
|
||||||
<NavLink class="nav-link" href="counter">
|
|
||||||
<span class="bi bi-plus-square-fill-nav-menu" aria-hidden="true"></span> Counter
|
|
||||||
</NavLink>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="nav-item px-3">
|
|
||||||
<NavLink class="nav-link" href="weather">
|
|
||||||
<span class="bi bi-list-nested-nav-menu" aria-hidden="true"></span> Weather
|
|
||||||
</NavLink>
|
|
||||||
</div>
|
|
||||||
</nav>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
@@ -1,105 +0,0 @@
|
|||||||
.navbar-toggler {
|
|
||||||
appearance: none;
|
|
||||||
cursor: pointer;
|
|
||||||
width: 3.5rem;
|
|
||||||
height: 2.5rem;
|
|
||||||
color: white;
|
|
||||||
position: absolute;
|
|
||||||
top: 0.5rem;
|
|
||||||
right: 1rem;
|
|
||||||
border: 1px solid rgba(255, 255, 255, 0.1);
|
|
||||||
background: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28255, 255, 255, 0.55%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e") no-repeat center/1.75rem rgba(255, 255, 255, 0.1);
|
|
||||||
}
|
|
||||||
|
|
||||||
.navbar-toggler:checked {
|
|
||||||
background-color: rgba(255, 255, 255, 0.5);
|
|
||||||
}
|
|
||||||
|
|
||||||
.top-row {
|
|
||||||
height: 3.5rem;
|
|
||||||
background-color: rgba(0,0,0,0.4);
|
|
||||||
}
|
|
||||||
|
|
||||||
.navbar-brand {
|
|
||||||
font-size: 1.1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.bi {
|
|
||||||
display: inline-block;
|
|
||||||
position: relative;
|
|
||||||
width: 1.25rem;
|
|
||||||
height: 1.25rem;
|
|
||||||
margin-right: 0.75rem;
|
|
||||||
top: -1px;
|
|
||||||
background-size: cover;
|
|
||||||
}
|
|
||||||
|
|
||||||
.bi-house-door-fill-nav-menu {
|
|
||||||
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-house-door-fill' viewBox='0 0 16 16'%3E%3Cpath d='M6.5 14.5v-3.505c0-.245.25-.495.5-.495h2c.25 0 .5.25.5.5v3.5a.5.5 0 0 0 .5.5h4a.5.5 0 0 0 .5-.5v-7a.5.5 0 0 0-.146-.354L13 5.793V2.5a.5.5 0 0 0-.5-.5h-1a.5.5 0 0 0-.5.5v1.293L8.354 1.146a.5.5 0 0 0-.708 0l-6 6A.5.5 0 0 0 1.5 7.5v7a.5.5 0 0 0 .5.5h4a.5.5 0 0 0 .5-.5Z'/%3E%3C/svg%3E");
|
|
||||||
}
|
|
||||||
|
|
||||||
.bi-plus-square-fill-nav-menu {
|
|
||||||
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-plus-square-fill' viewBox='0 0 16 16'%3E%3Cpath d='M2 0a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2H2zm6.5 4.5v3h3a.5.5 0 0 1 0 1h-3v3a.5.5 0 0 1-1 0v-3h-3a.5.5 0 0 1 0-1h3v-3a.5.5 0 0 1 1 0z'/%3E%3C/svg%3E");
|
|
||||||
}
|
|
||||||
|
|
||||||
.bi-list-nested-nav-menu {
|
|
||||||
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-list-nested' viewBox='0 0 16 16'%3E%3Cpath fill-rule='evenodd' d='M4.5 11.5A.5.5 0 0 1 5 11h10a.5.5 0 0 1 0 1H5a.5.5 0 0 1-.5-.5zm-2-4A.5.5 0 0 1 3 7h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5zm-2-4A.5.5 0 0 1 1 3h10a.5.5 0 0 1 0 1H1a.5.5 0 0 1-.5-.5z'/%3E%3C/svg%3E");
|
|
||||||
}
|
|
||||||
|
|
||||||
.nav-item {
|
|
||||||
font-size: 0.9rem;
|
|
||||||
padding-bottom: 0.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.nav-item:first-of-type {
|
|
||||||
padding-top: 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.nav-item:last-of-type {
|
|
||||||
padding-bottom: 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.nav-item ::deep .nav-link {
|
|
||||||
color: #d7d7d7;
|
|
||||||
background: none;
|
|
||||||
border: none;
|
|
||||||
border-radius: 4px;
|
|
||||||
height: 3rem;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
line-height: 3rem;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.nav-item ::deep a.active {
|
|
||||||
background-color: rgba(255,255,255,0.37);
|
|
||||||
color: white;
|
|
||||||
}
|
|
||||||
|
|
||||||
.nav-item ::deep .nav-link:hover {
|
|
||||||
background-color: rgba(255,255,255,0.1);
|
|
||||||
color: white;
|
|
||||||
}
|
|
||||||
|
|
||||||
.nav-scrollable {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.navbar-toggler:checked ~ .nav-scrollable {
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (min-width: 641px) {
|
|
||||||
.navbar-toggler {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.nav-scrollable {
|
|
||||||
/* Never collapse the sidebar for wide screens */
|
|
||||||
display: block;
|
|
||||||
|
|
||||||
/* Allow sidebar to scroll for tall menus */
|
|
||||||
height: calc(100vh - 3.5rem);
|
|
||||||
overflow-y: auto;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
128
OrdersManagement/Components/Pages/Admin/Scheduler.razor
Normal file
128
OrdersManagement/Components/Pages/Admin/Scheduler.razor
Normal file
@@ -0,0 +1,128 @@
|
|||||||
|
@page "/Admin/PK/Scheduler"
|
||||||
|
|
||||||
|
@using System.Security.Claims
|
||||||
|
@using Microsoft.AspNetCore.Authorization
|
||||||
|
@using OrdersManagementDataModel.Dtos
|
||||||
|
@using Syncfusion.Blazor.Grids
|
||||||
|
@using Action = Syncfusion.Blazor.Grids.Action
|
||||||
|
@using Syncfusion.Blazor.Cards
|
||||||
|
|
||||||
|
@inject HangfireService HangfireService
|
||||||
|
@inject NavigationManager NavigationManager
|
||||||
|
@inject CustomAuthenticationStateProvider CustomAuthenticationStateProvider
|
||||||
|
|
||||||
|
<div class="h-100 d-flex justify-content-center align-items-start">
|
||||||
|
<SfCard CssClass="shadow" style="width: 100%; max-width: 1200px;">
|
||||||
|
<CardHeader>
|
||||||
|
<h3 class="text-primary">Zarządzanie Zadaniami</h3>
|
||||||
|
</CardHeader>
|
||||||
|
<CardContent>
|
||||||
|
<SfGrid DataSource="@Tasks"
|
||||||
|
AllowPaging="true"
|
||||||
|
ShowColumnMenu="true"
|
||||||
|
Toolbar="@(new List<string> { "Add", "Edit", "Delete", "Cancel", "Update" })">
|
||||||
|
<GridColumns>
|
||||||
|
<GridColumn Field=@nameof(TaskSchedulerDto.RowPointer) AllowEditing="false" IsPrimaryKey="true" HeaderText="Id"
|
||||||
|
Width="100"></GridColumn>
|
||||||
|
<GridColumn Field=@nameof(TaskSchedulerDto.Name) HeaderText="Nazwa" Width="150"></GridColumn>
|
||||||
|
<GridColumn Field=@nameof(TaskSchedulerDto.Path) HeaderText="Ścieżka" Width="200"></GridColumn>
|
||||||
|
<GridColumn Field=@nameof(TaskSchedulerDto.CronOptions) HeaderText="CRON" Width="120"></GridColumn>
|
||||||
|
<GridColumn Field=@nameof(TaskSchedulerDto.LastExecution) AllowEditing="false" HeaderText="Ostatnie Uruchomienie"
|
||||||
|
Width="150"></GridColumn>
|
||||||
|
<GridColumn Field=@nameof(TaskSchedulerDto.NextExecution) AllowEditing="false" HeaderText="Następne Uruchomienie"
|
||||||
|
Width="150"></GridColumn>
|
||||||
|
</GridColumns>
|
||||||
|
<GridEditSettings AllowDeleting="true"
|
||||||
|
ShowDeleteConfirmDialog="true"
|
||||||
|
AllowAdding="true"
|
||||||
|
NewRowPosition="NewRowPosition.Bottom"
|
||||||
|
AllowEditing="true">
|
||||||
|
</GridEditSettings>
|
||||||
|
<GridEvents OnActionBegin="OnActionBegin"
|
||||||
|
OnActionComplete="OnActionComplete"
|
||||||
|
TValue="TaskSchedulerDto">
|
||||||
|
</GridEvents>
|
||||||
|
<GridPageSettings PageSize="10"></GridPageSettings>
|
||||||
|
</SfGrid>
|
||||||
|
</CardContent>
|
||||||
|
<CardFooter>
|
||||||
|
<small class="text-muted">FA Krosno Manager © @(DateTime.Now.Year)</small>
|
||||||
|
</CardFooter>
|
||||||
|
</SfCard>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
private List<TaskSchedulerDto> Tasks { get; set; } = new();
|
||||||
|
|
||||||
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||||
|
{
|
||||||
|
if (firstRender)
|
||||||
|
{
|
||||||
|
// ClaimsPrincipal currentUser = CustomAuthenticationStateProvider.GetCurrentUser();
|
||||||
|
//
|
||||||
|
// if (currentUser.Identity?.IsAuthenticated == false || currentUser.Identity?.Name != "pkus")
|
||||||
|
// {
|
||||||
|
// NavigationManager.NavigateTo("/Unauthorized");
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
await LoadTasks();
|
||||||
|
StateHasChanged();
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task OnActionBegin(ActionEventArgs<TaskSchedulerDto> args)
|
||||||
|
{
|
||||||
|
if (args.RequestType.Equals(Action.Delete))
|
||||||
|
{
|
||||||
|
await HangfireService.DeleteTaskSchedulerAsync(args.Data);
|
||||||
|
}
|
||||||
|
else if (args.RequestType.Equals(Action.Add))
|
||||||
|
{
|
||||||
|
args.Data.RowPointer = Guid.NewGuid();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task AddTask(TaskSchedulerDto taskSchedulerDto)
|
||||||
|
{
|
||||||
|
var response = await HangfireService.AddTaskSchedulerAsync(taskSchedulerDto);
|
||||||
|
if (response == 1)
|
||||||
|
{
|
||||||
|
await LoadTasks();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task UpdateTask(TaskSchedulerDto taskSchedulerDto)
|
||||||
|
{
|
||||||
|
var response = await HangfireService.UpdateTaskSchedulerAsync(taskSchedulerDto);
|
||||||
|
if (response == 1)
|
||||||
|
{
|
||||||
|
await LoadTasks();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private async Task LoadTasks()
|
||||||
|
{
|
||||||
|
Tasks = (await HangfireService.GetTaskSchedulersAsync() ?? Array.Empty<TaskSchedulerDto>()).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task OnActionComplete(ActionEventArgs<TaskSchedulerDto> args)
|
||||||
|
{
|
||||||
|
switch (args.RequestType)
|
||||||
|
{
|
||||||
|
case Action.Delete:
|
||||||
|
await LoadTasks();
|
||||||
|
break;
|
||||||
|
case Action.Save when args.Data.Id == 0:
|
||||||
|
await AddTask(args.Data);
|
||||||
|
break;
|
||||||
|
case Action.Save when args.Data.Id != 0:
|
||||||
|
await UpdateTask(args.Data);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
296
OrdersManagement/Components/Pages/Admin/UsersManager.razor
Normal file
296
OrdersManagement/Components/Pages/Admin/UsersManager.razor
Normal file
@@ -0,0 +1,296 @@
|
|||||||
|
@page "/Admin/PK/UsersManager"
|
||||||
|
|
||||||
|
@using System.Security.Claims
|
||||||
|
@using Microsoft.AspNetCore.Authorization
|
||||||
|
@using OrdersManagementDataModel.Dtos
|
||||||
|
@using Syncfusion.Blazor.Grids
|
||||||
|
@using Action = Syncfusion.Blazor.Grids.Action
|
||||||
|
@using UserService = OrdersManagement.Services.UserService
|
||||||
|
@using Syncfusion.Blazor.Cards
|
||||||
|
@using Syncfusion.Blazor.Popups
|
||||||
|
@using Syncfusion.Blazor.Buttons
|
||||||
|
@inject UserService UserService
|
||||||
|
@inject RoleService RoleService
|
||||||
|
@inject FunctionService FunctionService
|
||||||
|
@inject NavigationManager NavigationManager
|
||||||
|
@inject CustomAuthenticationStateProvider CustomAuthenticationStateProvider
|
||||||
|
|
||||||
|
<div class="h-100 d-flex justify-content-center align-items-start">
|
||||||
|
<SfCard CssClass="shadow" style="width: 100%; max-width: 1200px;">
|
||||||
|
<CardHeader>
|
||||||
|
<h3 class="text-primary">Zarządzanie Użytkownikami i Rolami</h3>
|
||||||
|
</CardHeader>
|
||||||
|
<CardContent>
|
||||||
|
<h5 class="text-primary mb-3">Użytkownicy</h5>
|
||||||
|
<SfGrid DataSource="@UserList"
|
||||||
|
AllowPaging="true"
|
||||||
|
ShowColumnMenu="true"
|
||||||
|
Toolbar="@(new List<string> { "Add", "Edit", "Delete", "Cancel", "Update" })">
|
||||||
|
<GridColumns>
|
||||||
|
<GridColumn Field="@nameof(UserDto.RowPointer)" AllowEditing="false" IsPrimaryKey="true" HeaderText="ID" Width="70"></GridColumn>
|
||||||
|
<GridColumn Field="@nameof(UserDto.Login)" HeaderText="Login" Width="100"></GridColumn>
|
||||||
|
<GridColumn Field="@nameof(UserDto.Email)" HeaderText="Email" Width="150"></GridColumn>
|
||||||
|
<GridColumn Field="@nameof(UserDto.FirstName)" HeaderText="Imię" Width="100"></GridColumn>
|
||||||
|
<GridColumn Field="@nameof(UserDto.LastName)" HeaderText="Nazwisko" Width="100"></GridColumn>
|
||||||
|
<GridColumn Field="@nameof(UserDto.IsActive)" HeaderText="Aktywny" Width="80"></GridColumn>
|
||||||
|
<GridColumn Field="@nameof(UserDto.CreatedDate)" AllowEditing="false" HeaderText="Utworzono" Format="d" Width="120"></GridColumn>
|
||||||
|
<GridColumn HeaderText="" Width="100">
|
||||||
|
<Template>
|
||||||
|
@{
|
||||||
|
var user = (context as UserDto);
|
||||||
|
<SfButton CssClass="e-small e-primary" @onclick="() => ResetPassword(user)">Zresetuj haslo</SfButton>
|
||||||
|
}
|
||||||
|
</Template>
|
||||||
|
</GridColumn>
|
||||||
|
</GridColumns>
|
||||||
|
<GridEditSettings AllowDeleting="true"
|
||||||
|
ShowDeleteConfirmDialog="true"
|
||||||
|
AllowAdding="true"
|
||||||
|
NewRowPosition="NewRowPosition.Bottom"
|
||||||
|
AllowEditing="true">
|
||||||
|
</GridEditSettings>
|
||||||
|
<GridEvents OnActionBegin="UserActionBegin"
|
||||||
|
OnActionComplete="UserActionComplete"
|
||||||
|
TValue="UserDto">
|
||||||
|
</GridEvents>
|
||||||
|
<GridPageSettings PageSize="10"></GridPageSettings>
|
||||||
|
</SfGrid>
|
||||||
|
|
||||||
|
<h5 class="text-primary mb-3 mt-4">Role</h5>
|
||||||
|
<SfGrid DataSource="@Roles"
|
||||||
|
AllowPaging="true"
|
||||||
|
ShowColumnMenu="true"
|
||||||
|
Toolbar="@(new List<string> { "Add", "Edit", "Delete", "Cancel", "Update" })">
|
||||||
|
<GridColumns>
|
||||||
|
<GridColumn Field="@nameof(RoleDto.Id)" IsPrimaryKey="true" HeaderText="ID" Width="70"></GridColumn>
|
||||||
|
<GridColumn Field="@nameof(RoleDto.Name)" HeaderText="Nazwa" Width="150"></GridColumn>
|
||||||
|
</GridColumns>
|
||||||
|
<GridEditSettings AllowDeleting="true"
|
||||||
|
ShowDeleteConfirmDialog="true"
|
||||||
|
AllowAdding="true"
|
||||||
|
AllowEditing="true"
|
||||||
|
Mode="EditMode.Normal">
|
||||||
|
</GridEditSettings>
|
||||||
|
<GridEvents OnActionBegin="RoleActionBegin"
|
||||||
|
OnActionComplete="RoleActionComplete"
|
||||||
|
TValue="RoleDto">
|
||||||
|
</GridEvents>
|
||||||
|
<GridPageSettings PageSize="10"></GridPageSettings>
|
||||||
|
</SfGrid>
|
||||||
|
|
||||||
|
<h5 class="text-primary mb-3 mt-4">Funkcje</h5>
|
||||||
|
<SfGrid DataSource="@Functions"
|
||||||
|
AllowPaging="true"
|
||||||
|
ShowColumnMenu="true"
|
||||||
|
Toolbar="@(new List<string> { "Add", "Edit", "Delete", "Cancel", "Update" })">
|
||||||
|
<GridColumns>
|
||||||
|
<GridColumn Field="@nameof(FunctionDto.Id)" IsPrimaryKey="true" HeaderText="ID" Width="70"></GridColumn>
|
||||||
|
<GridColumn Field="@nameof(FunctionDto.RoleId)" HeaderText="ID Roli" Width="70"></GridColumn>
|
||||||
|
<GridColumn Field="@nameof(FunctionDto.Name)" HeaderText="Nazwa Funkcji" Width="200"></GridColumn>
|
||||||
|
</GridColumns>
|
||||||
|
<GridEditSettings AllowDeleting="true"
|
||||||
|
ShowDeleteConfirmDialog="true"
|
||||||
|
AllowAdding="true"
|
||||||
|
AllowEditing="true"
|
||||||
|
Mode="EditMode.Normal">
|
||||||
|
</GridEditSettings>
|
||||||
|
<GridEvents OnActionBegin="FunctionActionBegin"
|
||||||
|
OnActionComplete="FunctionActionComplete"
|
||||||
|
TValue="FunctionDto">
|
||||||
|
</GridEvents>
|
||||||
|
<GridPageSettings PageSize="10"></GridPageSettings>
|
||||||
|
</SfGrid>
|
||||||
|
|
||||||
|
<SfDialog Width="500px" Title="Dodano użytkownika!" IsModal="true" @bind-Visible="Visibility" AllowPrerender="true">
|
||||||
|
<DialogTemplates>
|
||||||
|
<Content>
|
||||||
|
<p>Użytkownik <strong>@Login</strong> został dodany pomyślnie!</p>
|
||||||
|
<p>Hasło tymczasowe: <strong>@TempPassword</strong></p>
|
||||||
|
</Content>
|
||||||
|
</DialogTemplates>
|
||||||
|
<DialogButtons>
|
||||||
|
<DialogButton Content="OK" IsPrimary="true" OnClick="@HideModal"/>
|
||||||
|
</DialogButtons>
|
||||||
|
</SfDialog>
|
||||||
|
</CardContent>
|
||||||
|
<CardFooter>
|
||||||
|
<small class="text-muted">FA Krosno Manager © @(DateTime.Now.Year)</small>
|
||||||
|
</CardFooter>
|
||||||
|
</SfCard>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
private List<UserDto> UserList { get; set; } = new();
|
||||||
|
private List<RoleDto> Roles { get; set; } = new();
|
||||||
|
private List<FunctionDto> Functions { get; set; } = new();
|
||||||
|
|
||||||
|
private bool Visibility { get; set; }
|
||||||
|
|
||||||
|
private string Login { get; set; } = string.Empty;
|
||||||
|
private string TempPassword { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||||
|
{
|
||||||
|
if (firstRender)
|
||||||
|
{
|
||||||
|
Visibility = false;
|
||||||
|
// ClaimsPrincipal currentUser = CustomAuthenticationStateProvider.GetCurrentUser();
|
||||||
|
//
|
||||||
|
// if (currentUser.Identity?.IsAuthenticated == false || currentUser.Identity?.Name != "pkus")
|
||||||
|
// {
|
||||||
|
// NavigationManager.NavigateTo("/Unauthorized");
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
await LoadUsers();
|
||||||
|
await LoadRoles();
|
||||||
|
//await LoadFunctions();
|
||||||
|
StateHasChanged();
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task LoadUsers()
|
||||||
|
{
|
||||||
|
UserList = (await UserService.GetUsersAsync() ?? Array.Empty<UserDto>()).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task LoadRoles()
|
||||||
|
{
|
||||||
|
Roles = (await RoleService.GetRolesAsync() ?? Array.Empty<RoleDto>()).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task LoadFunctions()
|
||||||
|
{
|
||||||
|
Functions = (await FunctionService.GetFunctionsAsync() ?? Array.Empty<FunctionDto>()).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task ResetPassword(UserDto? user)
|
||||||
|
{
|
||||||
|
if(user == null) return;
|
||||||
|
|
||||||
|
TempPassword = Guid.NewGuid().ToString().Substring(0, 8);
|
||||||
|
Login = user.Login;
|
||||||
|
|
||||||
|
string passwordHash = BCrypt.Net.BCrypt.HashPassword(TempPassword);
|
||||||
|
|
||||||
|
user.PasswordHash = passwordHash;
|
||||||
|
user.IsTemporaryPassword = true;
|
||||||
|
|
||||||
|
await UserService.UpdateUserAsync(user);
|
||||||
|
await LoadUsers();
|
||||||
|
|
||||||
|
Visibility = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task UserActionBegin(ActionEventArgs<UserDto> args)
|
||||||
|
{
|
||||||
|
switch (args.RequestType)
|
||||||
|
{
|
||||||
|
case Action.Delete:
|
||||||
|
await UserService.DeleteUserAsync(args.Data.RowPointer);
|
||||||
|
break;
|
||||||
|
case Action.Add:
|
||||||
|
args.Data.RowPointer = Guid.NewGuid();
|
||||||
|
args.Data.CreatedDate = DateTime.Now;
|
||||||
|
args.Data.IsActive = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task UserActionComplete(ActionEventArgs<UserDto> args)
|
||||||
|
{
|
||||||
|
switch (args.RequestType)
|
||||||
|
{
|
||||||
|
case Action.Delete:
|
||||||
|
await LoadUsers();
|
||||||
|
break;
|
||||||
|
case Action.Save when args.Data.Id == 0:
|
||||||
|
UserDto? user = args.Data;
|
||||||
|
TempPassword = Guid.NewGuid().ToString().Substring(0, 8);
|
||||||
|
Login = user.Login;
|
||||||
|
|
||||||
|
string? passwordHash = BCrypt.Net.BCrypt.HashPassword(TempPassword);
|
||||||
|
|
||||||
|
user.PasswordHash = passwordHash;
|
||||||
|
user.IsTemporaryPassword = true;
|
||||||
|
user.ActiveFrom = DateTime.Now;
|
||||||
|
user.CreatedDate = DateTime.Now;
|
||||||
|
|
||||||
|
await UserService.AddUserAsync(user);
|
||||||
|
await LoadUsers();
|
||||||
|
|
||||||
|
Visibility = true;
|
||||||
|
break;
|
||||||
|
case Action.Save when args.Data.Id != 0:
|
||||||
|
await UserService.UpdateUserAsync(args.Data);
|
||||||
|
await LoadUsers();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task RoleActionBegin(ActionEventArgs<RoleDto> args)
|
||||||
|
{
|
||||||
|
if (args.RequestType.Equals(Action.Delete))
|
||||||
|
{
|
||||||
|
await RoleService.DeleteRoleAsync(args.Data.RowPointer);
|
||||||
|
}
|
||||||
|
else if (args.RequestType.Equals(Action.Add))
|
||||||
|
{
|
||||||
|
args.Data.RowPointer = Guid.NewGuid();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task RoleActionComplete(ActionEventArgs<RoleDto> args)
|
||||||
|
{
|
||||||
|
switch (args.RequestType)
|
||||||
|
{
|
||||||
|
case Action.Delete:
|
||||||
|
await LoadRoles();
|
||||||
|
break;
|
||||||
|
case Action.Save when args.Data.Id == 0:
|
||||||
|
await RoleService.AddRoleAsync(args.Data);
|
||||||
|
await LoadUsers();
|
||||||
|
break;
|
||||||
|
case Action.Save when args.Data.Id != 0:
|
||||||
|
await RoleService.UpdateRoleAsync(args.Data);
|
||||||
|
await LoadRoles();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task FunctionActionBegin(ActionEventArgs<FunctionDto> args)
|
||||||
|
{
|
||||||
|
if (args.RequestType.Equals(Action.Delete))
|
||||||
|
{
|
||||||
|
await FunctionService.DeleteFunctionAsync(args.Data.RowPointer);
|
||||||
|
}
|
||||||
|
else if (args.RequestType.Equals(Action.Add))
|
||||||
|
{
|
||||||
|
args.Data.RowPointer = Guid.NewGuid();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task FunctionActionComplete(ActionEventArgs<FunctionDto> args)
|
||||||
|
{
|
||||||
|
switch (args.RequestType)
|
||||||
|
{
|
||||||
|
case Action.Delete:
|
||||||
|
await LoadFunctions();
|
||||||
|
break;
|
||||||
|
case Action.Save when args.Data.Id == 0:
|
||||||
|
await FunctionService.AddFunctionAsync(args.Data);
|
||||||
|
await LoadFunctions();
|
||||||
|
break;
|
||||||
|
case Action.Save when args.Data.Id != 0:
|
||||||
|
await FunctionService.UpdateFunctionAsync(args.Data);
|
||||||
|
await LoadFunctions();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void HideModal()
|
||||||
|
{
|
||||||
|
Visibility = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,263 +1,219 @@
|
|||||||
@page "/CustomerOrder/{CustomerOrderId:guid}"
|
@page "/Admin/PK/CustomerOrder/{CustomerOrderId:guid}"
|
||||||
|
|
||||||
@inject CustomerOrderService CustomerOrderService
|
@inject CustomerOrderService CustomerOrderService
|
||||||
@inject ScheduleOrderService ScheduleOrderService
|
@inject ScheduleOrderService ScheduleOrderService
|
||||||
|
@inject NavigationManager NavigationManager
|
||||||
|
@inject CustomAuthenticationStateProvider CustomAuthenticationStateProvider
|
||||||
|
|
||||||
|
@using System.Security.Claims
|
||||||
|
@using Microsoft.AspNetCore.Authorization
|
||||||
@using SytelineSaAppEfDataModel.Dtos
|
@using SytelineSaAppEfDataModel.Dtos
|
||||||
@using OrdersManagement.Components.Pages.Shared
|
@using OrdersManagement.Components.Pages.Shared
|
||||||
|
@using Syncfusion.Blazor.Grids
|
||||||
|
@using Syncfusion.Blazor.Cards
|
||||||
|
@using Syncfusion.Blazor.Buttons
|
||||||
|
@using SelectionType = Syncfusion.Blazor.Grids.SelectionType
|
||||||
@inherits LayoutComponentBase
|
@inherits LayoutComponentBase
|
||||||
|
|
||||||
<h3>Zamówienie klienta nr @CustomerOrders.FirstOrDefault()?.CoNum</h3>
|
<div class="h-100 d-flex justify-content-center align-items-start">
|
||||||
<br/>
|
<SfCard CssClass="shadow" style="width: 100%; max-width: 1200px;">
|
||||||
<div class="row">
|
<CardHeader>
|
||||||
<div class="col">
|
<h3 class="text-primary">Zamówienie klienta nr @(CustomerOrderDto?.CoNum ?? "Brak numeru")</h3>
|
||||||
<SortableList TItem="CustomerOrderDto" Data="CustomerOrders" Class="bg-light">
|
</CardHeader>
|
||||||
<ItemTemplate>
|
<CardContent>
|
||||||
<u>Numer Zamówienia:</u> <b>@context.CoNum</b><br/>
|
<SfCard CssClass="mb-4">
|
||||||
<u>Numer Zamówienia Klienta:</u> <b>@context.CustPo</b><br/>
|
<CardContent>
|
||||||
<u>Klient:</u> <b>@context.CustNum</b><br/>
|
<div class="row">
|
||||||
<u>Numer Odbiorcy:</u> <b>@context.CustSeq</b><br/>
|
<div class="col">
|
||||||
<u>Kontakt:</u> <b>@context.Contact</b><br/>
|
<u>Numer Zamówienia:</u> <b>@CustomerOrderDto?.CoNum</b><br/>
|
||||||
<u>Telefon:</u> <b>@context.Phone</b><br/>
|
<u>Numer Zamówienia Klienta:</u> <b>@CustomerOrderDto?.CustPo</b><br/>
|
||||||
<u>Data Zamówienia:</u> <b>@context.OrderDate.ToString("yyyy-MM-dd HH:mm:ss")</b><br/>
|
<u>Klient:</u> <b>@CustomerOrderDto?.CustNum</b><br/>
|
||||||
<u>Warunki:</u> <b>@context.TermsCode</b><br/>
|
<u>Numer Odbiorcy:</u> <b>@CustomerOrderDto?.CustSeq</b><br/>
|
||||||
<u>Wartość Brutto:</u> <b>@(context.Price?.ToString("F2") ?? "N/A")</b><br/>
|
<u>Kontakt:</u> <b>@CustomerOrderDto?.Contact</b><br/>
|
||||||
<u>Status:</u> <b>@context.TranslatedStatus</b><br/>
|
<u>Telefon:</u> <b>@CustomerOrderDto?.Phone</b><br/>
|
||||||
</ItemTemplate>
|
<u>Data Zamówienia:</u> <b>@CustomerOrderDto?.OrderDate.ToString("yyyy-MM-dd HH:mm:ss")</b><br/>
|
||||||
</SortableList>
|
<u>Warunki:</u> <b>@CustomerOrderDto?.TermsCode</b><br/>
|
||||||
</div>
|
<u>Wartość Brutto:</u> <b>@(CustomerOrderDto?.Price?.ToString("F2") ?? "N/A")</b><br/>
|
||||||
<div class="col">
|
<u>Status:</u> <b>@CustomerOrderDto?.TranslatedStatus</b><br/>
|
||||||
<SortableList TItem="CustomerOrderDto" Data="CustomerOrders" Class="bg-light">
|
</div>
|
||||||
<ItemTemplate>
|
<div class="col">
|
||||||
<u>Magazyn:</u> <b>@context.Whse</b><br/>
|
<u>Magazyn:</u> <b>@CustomerOrderDto?.Whse</b><br/>
|
||||||
<u>VAT:</u> <b>@context.FrtTaxCode1</b><br/>
|
<u>VAT:</u> <b>@CustomerOrderDto?.FrtTaxCode1</b><br/>
|
||||||
<u>Typ Odbiorcy:</u> <b>@context.EndUserType</b><br/>
|
<u>Typ Odbiorcy:</u> <b>@CustomerOrderDto?.EndUserType</b><br/>
|
||||||
<u>Kurs Wymiany:</u> <b>@(context.ExchRate?.ToString("F4") ?? "N/A")</b><br/>
|
<u>Kurs Wymiany:</u> <b>@(CustomerOrderDto?.ExchRate?.ToString("F4") ?? "N/A")</b><br/>
|
||||||
<u>Gate:</u> <b>@context.Uf_FKR_EDI_Gate</b><br/>
|
<u>Gate:</u> <b>@CustomerOrderDto?.Uf_FKR_EDI_Gate</b><br/>
|
||||||
<u>RecipientCode:</u> <b>@context.Uf_FKR_EDI_RecipientCode</b><br/>
|
<u>RecipientCode:</u> <b>@CustomerOrderDto?.Uf_FKR_EDI_RecipientCode</b><br/>
|
||||||
<u>SelletCode:</u> <b>@context.Uf_FKR_EDI_SellerCode</b><br/>
|
<u>SellerCode:</u> <b>@CustomerOrderDto?.Uf_FKR_EDI_SellerCode</b><br/>
|
||||||
<u>SenderCode:</u> <b>@context.Uf_FKR_EDI_SenderCode</b><br/>
|
<u>SenderCode:</u> <b>@CustomerOrderDto?.Uf_FKR_EDI_SenderCode</b><br/>
|
||||||
<u>BuyerCode:</u> <b>@context.Uf_FKR_EDI_BuyerCode</b><br/>
|
<u>BuyerCode:</u> <b>@CustomerOrderDto?.Uf_FKR_EDI_BuyerCode</b><br/>
|
||||||
<u>Typ Dokumentu:</u> <b>@context.Uf_DocType</b><br/>
|
<u>Typ Dokumentu:</u> <b>@CustomerOrderDto?.Uf_DocType</b><br/>
|
||||||
</ItemTemplate>
|
</div>
|
||||||
</SortableList>
|
</div>
|
||||||
</div>
|
</CardContent>
|
||||||
</div>
|
</SfCard>
|
||||||
<br/>
|
|
||||||
<div class="row">
|
<div class="row mb-4">
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
<Button Color="ButtonColor.Primary" @onclick="ShowLastDelfors">@_text</Button>
|
<SfButton CssClass="e-primary" IsPrimary="true" @onclick="ShowLastDelfors">@_text</SfButton>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
<br/>
|
|
||||||
@if (_isVisible)
|
|
||||||
{
|
|
||||||
<div class="row">
|
|
||||||
<h3>Zamówienie DELFOR do zamówienia @CustomerOrders.FirstOrDefault()?.CoNum</h3>
|
|
||||||
</div>
|
|
||||||
<br/>
|
|
||||||
<div class="row">
|
|
||||||
<ScheduleOrdersGrid PageSize="5" PassGridRef="SetGridRef" DataProvider="ScheduleOrdersDataProvider"></ScheduleOrdersGrid>
|
|
||||||
</div>
|
|
||||||
<br/>
|
|
||||||
}
|
|
||||||
<div class="row">
|
|
||||||
<h3>Indeksy</h3>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<Grid @ref="_customerOrderLinesGrid"
|
|
||||||
TItem="CustomerOrderLineDto"
|
|
||||||
Class="table table-hover table-bordered table-striped"
|
|
||||||
Data="_customerOrderLines"
|
|
||||||
AllowFiltering="true"
|
|
||||||
Responsive="true"
|
|
||||||
AllowPaging="true"
|
|
||||||
PageSize="10"
|
|
||||||
AllowSelection="true"
|
|
||||||
AllowRowClick="true"
|
|
||||||
SelectionMode="GridSelectionMode.Single"
|
|
||||||
SelectedItemsChanged="SelectedCustomerOrderLineChanged">
|
|
||||||
<GridColumns>
|
|
||||||
<GridColumn TItem="CustomerOrderLineDto" HeaderText="Linia" PropertyName="CoLine">
|
|
||||||
@context.CoLine
|
|
||||||
</GridColumn>
|
|
||||||
<GridColumn TItem="CustomerOrderLineDto" HeaderText="Pozycja" PropertyName="Item">
|
|
||||||
@context.Item
|
|
||||||
</GridColumn>
|
|
||||||
<GridColumn TItem="CustomerOrderLineDto" HeaderText="Pozycja Klienta" PropertyName="CustItem">
|
|
||||||
@context.CustItem
|
|
||||||
</GridColumn>
|
|
||||||
<GridColumn TItem="CustomerOrderLineDto" HeaderText="Opis" PropertyName="Description">
|
|
||||||
@context.Description
|
|
||||||
</GridColumn>
|
|
||||||
<GridColumn TItem="CustomerOrderLineDto" HeaderText="Ilość" TextAlignment="Alignment.End"
|
|
||||||
PropertyName="BlanketQty">
|
|
||||||
@context.BlanketQty
|
|
||||||
</GridColumn>
|
|
||||||
<GridColumn TItem="CustomerOrderLineDto" HeaderText="J/M" PropertyName="UM">
|
|
||||||
@context.UM
|
|
||||||
</GridColumn>
|
|
||||||
<GridColumn TItem="CustomerOrderLineDto" HeaderText="Cena" PropertyName="ContPrice">
|
|
||||||
@context.ContPrice
|
|
||||||
</GridColumn>
|
|
||||||
<GridColumn TItem="CustomerOrderLineDto" HeaderText="Status" PropertyName="TranslatedStatus">
|
|
||||||
@context.TranslatedStatus
|
|
||||||
</GridColumn>
|
|
||||||
</GridColumns>
|
|
||||||
</Grid>
|
|
||||||
</div>
|
|
||||||
@if (_isVisibleCustomerOrderLine)
|
|
||||||
{
|
|
||||||
<div class="row">
|
|
||||||
<h3>Szczegóły</h3>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col">
|
|
||||||
<SortableList TItem="CustomerOrderLineDto" Data="_selectedCustomerOrderLine">
|
|
||||||
<ItemTemplate>
|
|
||||||
<u>Numer zamówienia:</u> <b>@context.CoNum</b><br/>
|
|
||||||
<u>Linia:</u> <b>@context.CoLine</b><br/>
|
|
||||||
<u>Pozycja:</u> <b>@context.Item</b><br/>
|
|
||||||
<u>Pozycja Klienta:</u> <b>@context.CustItem</b><br/>
|
|
||||||
<u>Opis:</u> <b>@context.Description</b><br/>
|
|
||||||
<u>Łączna Ilość:</u> <b>@context.BlanketQty.ToString("F2")</b><br/>
|
|
||||||
<u>Status:</u> <b>@context.TranslatedStatus</b><br/>
|
|
||||||
</ItemTemplate>
|
|
||||||
</SortableList>
|
|
||||||
</div>
|
|
||||||
<div class="col">
|
|
||||||
<SortableList TItem="CustomerOrderLineDto" Data="_selectedCustomerOrderLine">
|
|
||||||
<ItemTemplate>
|
|
||||||
<u>Cena:</u> <b>@(context.ContPrice?.ToString("F2") ?? "N/A")</b><br/>
|
|
||||||
<u>Ważne Od:</u> <b>@(context.EffDate?.ToString("dd.MM.yyyy") ?? "N/A")</b><br/>
|
|
||||||
<u>J/M:</u> <b>@context.UM</b><br/>
|
|
||||||
<u>BoxType:</u> <b>@context.Uf_FKR_EDI_BLN_BoxType</b><br/>
|
|
||||||
<u>Address:</u> <b>@context.Uf_FKR_EDI_BLN_Address</b><br/>
|
|
||||||
<u>FinalDestination:</u> <b>@context.Uf_FKR_EDI_BLN_FinalDestination</b><br/>
|
|
||||||
<u>QtyPerBox:</u> <b>@(context.Uf_FKR_EDI_BLN_QtyPerBox?.ToString() ?? "N/A")</b>
|
|
||||||
</ItemTemplate>
|
|
||||||
</SortableList>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<br/>
|
|
||||||
<h3>Harmonogramy</h3>
|
|
||||||
<div class="row">
|
|
||||||
<Grid @ref="_customerOrderLineItemsGrid"
|
|
||||||
TItem="CustomerOrderLineItemDto"
|
|
||||||
Class="table table-hover table-bordered table-striped"
|
|
||||||
Data="_customerOrderLineItems"
|
|
||||||
AllowFiltering="true"
|
|
||||||
Responsive="true"
|
|
||||||
AllowPaging="true"
|
|
||||||
PageSize="10"
|
|
||||||
AllowSelection="true"
|
|
||||||
AllowRowClick="true"
|
|
||||||
SelectionMode="GridSelectionMode.Single"
|
|
||||||
SelectedItemsChanged="SelectedCustomerOrderLineItemChanged">
|
|
||||||
<GridColumns>
|
|
||||||
<GridColumn TItem="CustomerOrderLineItemDto" HeaderText="Linia" PropertyName="CustomerOrderLine">
|
|
||||||
@context.CoLine
|
|
||||||
</GridColumn>
|
|
||||||
<GridColumn TItem="CustomerOrderLineItemDto" HeaderText="Zwolnienie"
|
|
||||||
PropertyName="CustomerOrderRelease">
|
|
||||||
@context.CoRelease
|
|
||||||
</GridColumn>
|
|
||||||
<GridColumn TItem="CustomerOrderLineItemDto" HeaderText="Pozycja" PropertyName="Item">
|
|
||||||
@context.Item
|
|
||||||
</GridColumn>
|
|
||||||
<GridColumn TItem="CustomerOrderLineItemDto" HeaderText="Pozycja" PropertyName="CustomerItem">
|
|
||||||
@context.CustItem
|
|
||||||
</GridColumn>
|
|
||||||
<GridColumn TItem="CustomerOrderLineItemDto" HeaderText="Łączna Ilość" TextAlignment="Alignment.End"
|
|
||||||
PropertyName="QtyOrdered">
|
|
||||||
@context.QtyOrdered
|
|
||||||
</GridColumn>
|
|
||||||
<GridColumn TItem="CustomerOrderLineItemDto" HeaderText="Data Wykonania" PropertyName="DueDate">
|
|
||||||
@context.DueDate?.ToString("dd.MM.yyyy")
|
|
||||||
</GridColumn>
|
|
||||||
<GridColumn TItem="CustomerOrderLineItemDto" HeaderText="Status" PropertyName="TranslatedStatus">
|
|
||||||
@context.TranslatedStatus
|
|
||||||
</GridColumn>
|
|
||||||
</GridColumns>
|
|
||||||
</Grid>
|
|
||||||
</div>
|
|
||||||
@if (_isVisibleCustomerOrderLineItem)
|
|
||||||
{
|
|
||||||
<div class="row">
|
|
||||||
<h3>Szczegóły</h3>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col">
|
|
||||||
<SortableList TItem="CustomerOrderLineItemDto" Data="_selectedCustomerOrderLineItem">
|
|
||||||
<ItemTemplate>
|
|
||||||
<u>Numer Zamówienia:</u> <b>@context.CoNum</b><br/>
|
|
||||||
<u>Linia:</u> <b>@context.CoLine</b><br/>
|
|
||||||
<u>Zwolnienie:</u> <b>@context.CoRelease</b><br/>
|
|
||||||
<u>Pozycja:</u> <b>@context.Item</b><br/>
|
|
||||||
<u>Pozycja Klienta:</u> <b>@context.CustItem</b><br/>
|
|
||||||
<u>Łączna Ilość Sztuk:</u> <b>@(context.QtyOrdered.ToString("F2") ?? "N/A")</b><br/>
|
|
||||||
<u>Cena:</u> <b>@(context.Price.ToString("F2") ?? "N/A")</b><br/>
|
|
||||||
<u>Data Wykonania:</u> <b>@(context.DueDate?.ToString("dd.MM.yyyy") ?? "N/A")</b><br/>
|
|
||||||
<u>Data
|
|
||||||
Rejestracji:</u> <b>@(context.ReleaseDate?.ToString("dd.MM.yyyy") ?? "N/A")</b><br/>
|
|
||||||
<u>Magazyn:</u> <b>@context.Whse</b><br/>
|
|
||||||
<u>Typ Documentu:</u> <b>@context.Uf_FKR_EDI_ITEM_DocumentType</b><br/>
|
|
||||||
</ItemTemplate>
|
|
||||||
</SortableList>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="col">
|
|
||||||
<SortableList TItem="CustomerOrderLineItemDto" Data="_selectedCustomerOrderLineItem">
|
@if (_isVisible)
|
||||||
<ItemTemplate>
|
{
|
||||||
<u>Kod VAT:</u> <b>@context.TaxCode1</b><br/>
|
<h5 class="text-primary mb-3">Zamówienie DELFOR do zamówienia @(CustomerOrderDto?.CoNum ?? "Brak numeru")</h5>
|
||||||
<u>J/M:</u> <b>@context.UM</b><br/>
|
<ScheduleOrdersGrid PageSize="5" PassGridRef="SetGridRef" GridData="_scheduleOrders" />
|
||||||
<u>Numer Klienta:</u> <b>@context.CoCustNum</b><br/>
|
}
|
||||||
<u>Opis:</u> <b>@context.Description</b><br/>
|
|
||||||
<u>Status:</u> <b>@context.TranslatedStatus</b><br/>
|
<h5 class="text-primary mb-3 pt-5">Indeksy</h5>
|
||||||
<u>RoutingCode:</u> <b>@context.Uf_FKR_EDI_ITEM_RoutingCode</b><br/>
|
<SfGrid @ref="_customerOrderLinesGrid"
|
||||||
<u>DeliveryCallNumber:</u> <b>@context.Uf_FKR_EDI_ITEM_DeliveryCallNum</b><br/>
|
AllowFiltering="true"
|
||||||
<u>UnloadingPoint:</u> <b>@context.Uf_LOC_11_UnloadingPoint</b><br/>
|
AllowPaging="true"
|
||||||
<u>DestinationPoint:</u> <b>@context.Uf_LOC_159_DestinationPoint</b><br/>
|
AllowSorting="true"
|
||||||
<u>PalletCode:</u> <b>@context.Uf_FKR_EDI_ITEM_PalletCode</b><br/>
|
AllowSelection="true"
|
||||||
</ItemTemplate>
|
TValue="CustomerOrderLineDto"
|
||||||
</SortableList>
|
DataSource="@_customerOrderLines"
|
||||||
</div>
|
EnableAdaptiveUI="true">
|
||||||
</div>
|
<GridTemplates>
|
||||||
}
|
<DetailTemplate>
|
||||||
}
|
@{
|
||||||
|
var order = context as CustomerOrderLineDto;
|
||||||
|
<SfCard>
|
||||||
|
<CardContent>
|
||||||
|
<div class="row">
|
||||||
|
<h6>Szczegóły</h6>
|
||||||
|
<div class="col">
|
||||||
|
<u>Numer zamówienia:</u> <b>@order?.CoNum</b><br/>
|
||||||
|
<u>Linia:</u> <b>@order?.CoLine</b><br/>
|
||||||
|
<u>Pozycja:</u> <b>@order?.Item</b><br/>
|
||||||
|
<u>Pozycja Klienta:</u> <b>@order?.CustItem</b><br/>
|
||||||
|
<u>Opis:</u> <b>@order?.Description</b><br/>
|
||||||
|
<u>Łączna Ilość:</u> <b>@order?.BlanketQty.ToString("F2")</b><br/>
|
||||||
|
<u>Status:</u> <b>@order?.TranslatedStatus</b><br/>
|
||||||
|
</div>
|
||||||
|
<div class="col">
|
||||||
|
<u>Cena:</u> <b>@(order?.ContPrice?.ToString("F2") ?? "N/A")</b><br/>
|
||||||
|
<u>Ważne Od:</u> <b>@(order?.EffDate?.ToString("dd.MM.yyyy") ?? "N/A")</b><br/>
|
||||||
|
<u>J/M:</u> <b>@order?.UM</b><br/>
|
||||||
|
<u>BoxType:</u> <b>@order?.Uf_FKR_EDI_BLN_BoxType</b><br/>
|
||||||
|
<u>Address:</u> <b>@order?.Uf_FKR_EDI_BLN_Address</b><br/>
|
||||||
|
<u>FinalDestination:</u> <b>@order?.Uf_FKR_EDI_BLN_FinalDestination</b><br/>
|
||||||
|
<u>QtyPerBox:</u> <b>@(order?.Uf_FKR_EDI_BLN_QtyPerBox?.ToString() ?? "N/A")</b>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</CardContent>
|
||||||
|
</SfCard>
|
||||||
|
}
|
||||||
|
</DetailTemplate>
|
||||||
|
</GridTemplates>
|
||||||
|
<GridColumns>
|
||||||
|
<GridColumn Field=@nameof(CustomerOrderLineDto.CoLine) HeaderText="Linia" Width="70"></GridColumn>
|
||||||
|
<GridColumn Field=@nameof(CustomerOrderLineDto.Item) HeaderText="Pozycja" Width="100"></GridColumn>
|
||||||
|
<GridColumn Field=@nameof(CustomerOrderLineDto.CustItem) HeaderText="Pozycja Klienta" Width="120"></GridColumn>
|
||||||
|
<GridColumn Field=@nameof(CustomerOrderLineDto.Description) HeaderText="Opis" Width="200"></GridColumn>
|
||||||
|
<GridColumn Field=@nameof(CustomerOrderLineDto.BlanketQty) HeaderText="Ilość" TextAlign="TextAlign.Right" Width="100"></GridColumn>
|
||||||
|
<GridColumn Field=@nameof(CustomerOrderLineDto.UM) HeaderText="J/M" Width="50"></GridColumn>
|
||||||
|
<GridColumn Field=@nameof(CustomerOrderLineDto.ContPrice) HeaderText="Cena" Width="100"></GridColumn>
|
||||||
|
<GridColumn Field=@nameof(CustomerOrderLineDto.TranslatedStatus) HeaderText="Status" Width="100"></GridColumn>
|
||||||
|
</GridColumns>
|
||||||
|
<GridFilterSettings Type="FilterType.Excel"/>
|
||||||
|
<GridPageSettings PageSize="10"/>
|
||||||
|
<GridSelectionSettings Mode="SelectionMode.Row" Type="SelectionType.Single"/>
|
||||||
|
<GridEvents TValue="CustomerOrderLineDto" RowSelected="OnSelectedLineRow"></GridEvents>
|
||||||
|
</SfGrid>
|
||||||
|
|
||||||
|
@if (_isVisibleCustomerOrderLine)
|
||||||
|
{
|
||||||
|
<h5 class="text-primary mb-3 mt-4">Harmonogramy</h5>
|
||||||
|
<SfGrid @ref="_customerOrderLineItemsGrid"
|
||||||
|
TValue="CustomerOrderLineItemDto"
|
||||||
|
DataSource="@_customerOrderLineItems"
|
||||||
|
AllowFiltering="true"
|
||||||
|
AllowPaging="true"
|
||||||
|
AllowSelection="true"
|
||||||
|
AllowSorting="true"
|
||||||
|
SelectionMode="Syncfusion.Blazor.Grids.SelectionMode.Single"
|
||||||
|
SelectedItemsChanged="SelectedCustomerOrderLineItemChanged">
|
||||||
|
<GridTemplates>
|
||||||
|
<DetailTemplate>
|
||||||
|
@{
|
||||||
|
var detailLineItem = context as CustomerOrderLineItemDto;
|
||||||
|
<SfCard>
|
||||||
|
<CardContent>
|
||||||
|
<div class="row">
|
||||||
|
<h6>Szczegóły</h6>
|
||||||
|
<div class="col">
|
||||||
|
<u>Numer Zamówienia:</u> <b>@detailLineItem?.CoNum</b><br/>
|
||||||
|
<u>Linia:</u> <b>@detailLineItem?.CoLine</b><br/>
|
||||||
|
<u>Zwolnienie:</u> <b>@detailLineItem?.CoRelease</b><br/>
|
||||||
|
<u>Pozycja:</u> <b>@detailLineItem?.Item</b><br/>
|
||||||
|
<u>Pozycja Klienta:</u> <b>@detailLineItem?.CustItem</b><br/>
|
||||||
|
<u>Łączna Ilość Sztuk:</u> <b>@(detailLineItem?.QtyOrdered.ToString("F2") ?? "N/A")</b><br/>
|
||||||
|
<u>Cena:</u> <b>@(detailLineItem?.Price.ToString("F2") ?? "N/A")</b><br/>
|
||||||
|
<u>Data Wykonania:</u> <b>@(detailLineItem?.DueDate?.ToString("dd.MM.yyyy") ?? "N/A")</b><br/>
|
||||||
|
<u>Data Rejestracji:</u> <b>@(detailLineItem?.ReleaseDate?.ToString("dd.MM.yyyy") ?? "N/A")</b><br/>
|
||||||
|
<u>Magazyn:</u> <b>@detailLineItem?.Whse</b><br/>
|
||||||
|
<u>Typ Documentu:</u> <b>@detailLineItem?.Uf_FKR_EDI_ITEM_DocumentType</b><br/>
|
||||||
|
</div>
|
||||||
|
<div class="col">
|
||||||
|
<u>Kod VAT:</u> <b>@detailLineItem?.TaxCode1</b><br/>
|
||||||
|
<u>J/M:</u> <b>@detailLineItem?.UM</b><br/>
|
||||||
|
<u>Numer Klienta:</u> <b>@detailLineItem?.CoCustNum</b><br/>
|
||||||
|
<u>Opis:</u> <b>@detailLineItem?.Description</b><br/>
|
||||||
|
<u>Status:</u> <b>@detailLineItem?.TranslatedStatus</b><br/>
|
||||||
|
<u>RoutingCode:</u> <b>@detailLineItem?.Uf_FKR_EDI_ITEM_RoutingCode</b><br/>
|
||||||
|
<u>DeliveryCallNumber:</u> <b>@detailLineItem?.Uf_FKR_EDI_ITEM_DeliveryCallNum</b><br/>
|
||||||
|
<u>UnloadingPoint:</u> <b>@detailLineItem?.Uf_LOC_11_UnloadingPoint</b><br/>
|
||||||
|
<u>DestinationPoint:</u> <b>@detailLineItem?.Uf_LOC_159_DestinationPoint</b><br/>
|
||||||
|
<u>PalletCode:</u> <b>@detailLineItem?.Uf_FKR_EDI_ITEM_PalletCode</b><br/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</CardContent>
|
||||||
|
</SfCard>
|
||||||
|
}
|
||||||
|
</DetailTemplate>
|
||||||
|
</GridTemplates>
|
||||||
|
<Syncfusion.Blazor.Grids.GridColumns>
|
||||||
|
<Syncfusion.Blazor.Grids.GridColumn Field=@nameof(CustomerOrderLineItemDto.CoLine) HeaderText="Linia" Width="70"/>
|
||||||
|
<Syncfusion.Blazor.Grids.GridColumn Field=@nameof(CustomerOrderLineItemDto.CoRelease) HeaderText="Zwolnienie" Width="70"/>
|
||||||
|
<Syncfusion.Blazor.Grids.GridColumn Field=@nameof(CustomerOrderLineItemDto.Item) HeaderText="Pozycja" Width="100"></Syncfusion.Blazor.Grids.GridColumn>
|
||||||
|
<Syncfusion.Blazor.Grids.GridColumn Field=@nameof(CustomerOrderLineItemDto.CustItem) HeaderText="Pozycja" Width="100"></Syncfusion.Blazor.Grids.GridColumn>
|
||||||
|
<Syncfusion.Blazor.Grids.GridColumn Field=@nameof(CustomerOrderLineItemDto.QtyOrdered) HeaderText="Łączna Ilość" TextAlign="TextAlign.Right" Width="120"></Syncfusion.Blazor.Grids.GridColumn>
|
||||||
|
<Syncfusion.Blazor.Grids.GridColumn Field=@nameof(CustomerOrderLineItemDto.DueDate) HeaderText="Data Wykonania" Width="100"/>
|
||||||
|
<Syncfusion.Blazor.Grids.GridColumn Field=@nameof(CustomerOrderLineItemDto.TranslatedStatus) HeaderText="Status" Width="100"></Syncfusion.Blazor.Grids.GridColumn>
|
||||||
|
</Syncfusion.Blazor.Grids.GridColumns>
|
||||||
|
<GridFilterSettings Type="FilterType.Excel"/>
|
||||||
|
<GridPageSettings PageSize="10"/>
|
||||||
|
<GridSelectionSettings Mode="SelectionMode.Row" Type="SelectionType.Single"/>
|
||||||
|
</SfGrid>
|
||||||
|
}
|
||||||
|
</CardContent>
|
||||||
|
<CardFooter>
|
||||||
|
<small class="text-muted">FA Krosno Manager © @(DateTime.Now.Year)</small>
|
||||||
|
</CardFooter>
|
||||||
|
</SfCard>
|
||||||
|
</div>
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
[Parameter] public Guid CustomerOrderId { get; set; }
|
[Parameter] public Guid CustomerOrderId { get; set; }
|
||||||
|
|
||||||
private List<CustomerOrderDto> CustomerOrders { get; set; } = [];
|
private CustomerOrderDto CustomerOrderDto { get; set; }
|
||||||
private List<CustomerOrderLineDto> _customerOrderLines = [];
|
private List<CustomerOrderLineDto> _customerOrderLines = [];
|
||||||
private List<CustomerOrderLineItemDto> _customerOrderLineItems = [];
|
private List<CustomerOrderLineItemDto> _customerOrderLineItems = [];
|
||||||
|
|
||||||
private IEnumerable<ScheduleOrderDto>? _scheduleOrders;
|
private IEnumerable<ScheduleOrderDto>? _scheduleOrders;
|
||||||
|
|
||||||
private List<CustomerOrderLineDto?> _selectedCustomerOrderLine = [];
|
CustomerOrderLineDto? _selectedCustomerOrderLine;
|
||||||
private List<CustomerOrderLineItemDto?> _selectedCustomerOrderLineItem = [];
|
|
||||||
|
|
||||||
private Grid<CustomerOrderLineDto>? _customerOrderLinesGrid;
|
private SfGrid<CustomerOrderLineDto>? _customerOrderLinesGrid;
|
||||||
private Grid<CustomerOrderLineItemDto>? _customerOrderLineItemsGrid;
|
private SfGrid<CustomerOrderLineItemDto>? _customerOrderLineItemsGrid;
|
||||||
|
|
||||||
private bool _isVisibleCustomerOrderLine;
|
private bool _isVisibleCustomerOrderLine;
|
||||||
private bool _isVisibleCustomerOrderLineItem;
|
|
||||||
|
|
||||||
private Grid<ScheduleOrderDto> _gridRef = new();
|
private SfGrid<ScheduleOrderDto> _gridRef = new();
|
||||||
|
|
||||||
private bool _isVisible = true;
|
private bool _isVisible = true;
|
||||||
private string _text = "Pokaż powiązane zamówienia DELFOR";
|
private string _text = "Pokaż powiązane zamówienia DELFOR";
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
|
||||||
{
|
|
||||||
CustomerOrderDto? customerOrder = await CustomerOrderService.GetCustomerOrderAsync(CustomerOrderId);
|
|
||||||
|
|
||||||
if (customerOrder != null)
|
|
||||||
{
|
|
||||||
CustomerOrders = [customerOrder];
|
|
||||||
_customerOrderLines = customerOrder.CustomerOrderLines.ToList() ?? [];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||||
{
|
{
|
||||||
if (firstRender)
|
if (firstRender)
|
||||||
@@ -265,22 +221,28 @@
|
|||||||
await SetGridRef(_gridRef);
|
await SetGridRef(_gridRef);
|
||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
_isVisible = false;
|
_isVisible = false;
|
||||||
|
|
||||||
|
// ClaimsPrincipal currentUser = CustomAuthenticationStateProvider.GetCurrentUser();
|
||||||
|
//
|
||||||
|
// if (currentUser.Identity?.IsAuthenticated == false)
|
||||||
|
// {
|
||||||
|
// NavigationManager.NavigateTo("/Unauthorized");
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
CustomerOrderDto? customerOrder = await CustomerOrderService.GetCustomerOrderAsync(CustomerOrderId);
|
||||||
|
|
||||||
|
if (customerOrder != null)
|
||||||
|
{
|
||||||
|
CustomerOrderDto = customerOrder;
|
||||||
|
_customerOrderLines = CustomerOrderDto.CustomerOrderLines.ToList() ?? [];
|
||||||
|
}
|
||||||
|
|
||||||
|
StateHasChanged();
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SelectedCustomerOrderLineChanged(HashSet<CustomerOrderLineDto> obj)
|
|
||||||
{
|
|
||||||
_isVisibleCustomerOrderLine = obj.Any();
|
|
||||||
_selectedCustomerOrderLine = [obj.FirstOrDefault()];
|
|
||||||
_customerOrderLineItems = obj.FirstOrDefault()?.CustomerOrderLineItems.ToList() ?? [];
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SelectedCustomerOrderLineItemChanged(HashSet<CustomerOrderLineItemDto> obj)
|
|
||||||
{
|
|
||||||
_isVisibleCustomerOrderLineItem = obj.Any();
|
|
||||||
_selectedCustomerOrderLineItem = [obj.FirstOrDefault()];
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task ShowLastDelfors()
|
private async Task ShowLastDelfors()
|
||||||
{
|
{
|
||||||
if (_isVisible)
|
if (_isVisible)
|
||||||
@@ -291,23 +253,23 @@
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
await _gridRef.RefreshDataAsync();
|
_scheduleOrders = await FetchScheduleOrdersAsync();
|
||||||
|
await _gridRef.Refresh();
|
||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
_isVisible = true;
|
_isVisible = true;
|
||||||
_text = "Ukryj";
|
_text = "Ukryj";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task SetGridRef(Grid<ScheduleOrderDto> grid)
|
private async Task SetGridRef(SfGrid<ScheduleOrderDto> grid)
|
||||||
{
|
{
|
||||||
_gridRef = grid;
|
_gridRef = grid;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<GridDataProviderResult<ScheduleOrderDto>> ScheduleOrdersDataProvider(GridDataProviderRequest<ScheduleOrderDto> request)
|
private async Task<IEnumerable<ScheduleOrderDto>> FetchScheduleOrdersAsync()
|
||||||
{
|
{
|
||||||
_scheduleOrders = [];
|
_scheduleOrders = [];
|
||||||
|
IList<int> scheduleOrderDetails = CustomerOrderDto?.EdiCustomerOrderTranslates?.Select(x => x.ScheduleOrderId).Distinct().ToList() ?? [];
|
||||||
IList<int> scheduleOrderDetails = CustomerOrders?.FirstOrDefault()?.EdiCustomerOrderTranslates?.Select(x => x.ScheduleOrderId).Distinct().ToList() ?? [];
|
|
||||||
|
|
||||||
if (scheduleOrderDetails.Any())
|
if (scheduleOrderDetails.Any())
|
||||||
{
|
{
|
||||||
@@ -315,6 +277,14 @@
|
|||||||
_scheduleOrders = _scheduleOrders.Where(x => scheduleOrderDetails.Contains(x.ID)).OrderByDescending(x => x.LastUpdateDate).ToList();
|
_scheduleOrders = _scheduleOrders.Where(x => scheduleOrderDetails.Contains(x.ID)).OrderByDescending(x => x.LastUpdateDate).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
return await Task.FromResult(request.ApplyTo(_scheduleOrders));
|
return _scheduleOrders;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnSelectedLineRow<TValue>(RowSelectEventArgs<TValue> obj)
|
||||||
|
{
|
||||||
|
_selectedCustomerOrderLine = obj.Data as CustomerOrderLineDto;
|
||||||
|
_isVisibleCustomerOrderLine = _selectedCustomerOrderLine != null;
|
||||||
|
_customerOrderLineItems = _selectedCustomerOrderLine?.CustomerOrderLineItems.ToList() ?? [];
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,75 +1,115 @@
|
|||||||
@page "/CustomerOrders"
|
@page "/Admin/PK/CustomerOrders"
|
||||||
|
|
||||||
@inject CustomerOrderService CustomerOrderService
|
@inject CustomerOrderService CustomerOrderService
|
||||||
@inject NavigationManager NavigationManager
|
@inject NavigationManager NavigationManager
|
||||||
|
@inject CustomAuthenticationStateProvider CustomAuthenticationStateProvider
|
||||||
|
|
||||||
|
@using System.Security.Claims
|
||||||
|
@using Microsoft.AspNetCore.Authorization
|
||||||
@using SytelineSaAppEfDataModel.Dtos
|
@using SytelineSaAppEfDataModel.Dtos
|
||||||
|
@using Syncfusion.Blazor.Grids
|
||||||
|
@using Syncfusion.Blazor.Cards
|
||||||
@inherits LayoutComponentBase
|
@inherits LayoutComponentBase
|
||||||
|
|
||||||
<div class="row">
|
<div class="h-100 d-flex justify-content-center align-items-start">
|
||||||
<h3>Zamówienia Klienta</h3>
|
<SfCard CssClass="shadow" style="width: 100%; max-width: 1200px;">
|
||||||
</div>
|
<CardHeader>
|
||||||
<br />
|
<h3 class="text-primary">Zamówienia Klienta</h3>
|
||||||
<div class="row">
|
</CardHeader>
|
||||||
<Grid @ref="_grid"
|
<CardContent>
|
||||||
TItem="CustomerOrderDto"
|
<SfGrid AllowFiltering="true"
|
||||||
Class="table table-hover table-bordered table-striped"
|
AllowPaging="true"
|
||||||
DataProvider="CustomerOrdersDataProvider"
|
AllowSorting="true"
|
||||||
AllowFiltering="true"
|
AllowSelection="true"
|
||||||
Responsive="true"
|
TValue="CustomerOrderDto"
|
||||||
AllowPaging="true"
|
DataSource="@_customerOrders"
|
||||||
PageSize="20"
|
EnableAdaptiveUI="true">
|
||||||
AllowSelection="true"
|
<GridTemplates>
|
||||||
AllowRowClick="true"
|
<DetailTemplate>
|
||||||
OnRowDoubleClick="OnRowDoubleClick"
|
@{
|
||||||
SelectedItemsChanged="SelectedItemsChanged">
|
var order = context as CustomerOrderDto;
|
||||||
|
<SfCard>
|
||||||
<GridColumns>
|
<CardContent>
|
||||||
<GridColumn TItem="CustomerOrderDto" HeaderText="Numer Zamówienia" PropertyName="CoNum">
|
<div class="row">
|
||||||
@context.CoNum
|
<div class="col">
|
||||||
</GridColumn>
|
<u>Numer Zamówienia:</u> <b>@order?.CoNum</b><br/>
|
||||||
<GridColumn TItem="CustomerOrderDto" HeaderText="Zamówienie Klienta" PropertyName="CustNum">
|
<u>Numer Zamówienia Klienta:</u> <b>@order?.CustPo</b><br/>
|
||||||
@context.CustPo
|
<u>Klient:</u> <b>@order?.CustNum</b><br/>
|
||||||
</GridColumn>
|
<u>Numer Odbiorcy:</u> <b>@order?.CustSeq</b><br/>
|
||||||
<GridColumn TItem="CustomerOrderDto" HeaderText="Numer Klienta" PropertyName="CustNum">
|
<u>Kontakt:</u> <b>@order?.Contact</b><br/>
|
||||||
@context.CustNum
|
<u>Telefon:</u> <b>@order?.Phone</b><br/>
|
||||||
</GridColumn>
|
<u>Data Zamówienia:</u>
|
||||||
<GridColumn TItem="CustomerOrderDto" HeaderText="Odbiorca" PropertyName="CustSeq">
|
<b>@order?.OrderDate.ToString("yyyy-MM-dd HH:mm:ss")</b><br/>
|
||||||
@context.CustSeq
|
<u>Warunki:</u> <b>@order?.TermsCode</b><br/>
|
||||||
</GridColumn>
|
<u>Wartość Brutto:</u> <b>@(order?.Price?.ToString("F2") ?? "N/A")</b><br/>
|
||||||
<GridColumn TItem="CustomerOrderDto" HeaderText="Data zamówienia" PropertyName="CreateDate">
|
<u>Status:</u> <b>@order?.TranslatedStatus</b><br/>
|
||||||
@context.CreateDate
|
</div>
|
||||||
</GridColumn>
|
<div class="col">
|
||||||
<GridColumn TItem="CustomerOrderDto" HeaderText="Status" PropertyName="Stat">
|
<u>Magazyn:</u> <b>@order?.Whse</b><br/>
|
||||||
@context.TranslatedStatus
|
<u>VAT:</u> <b>@order?.FrtTaxCode1</b><br/>
|
||||||
</GridColumn>
|
<u>Typ Odbiorcy:</u> <b>@order?.EndUserType</b><br/>
|
||||||
</GridColumns>
|
<u>Kurs Wymiany:</u> <b>@(order?.ExchRate?.ToString("F4") ?? "N/A")</b><br/>
|
||||||
</Grid>
|
<u>Gate:</u> <b>@order?.Uf_FKR_EDI_Gate</b><br/>
|
||||||
|
<u>RecipientCode:</u> <b>@order?.Uf_FKR_EDI_RecipientCode</b><br/>
|
||||||
|
<u>SellerCode:</u> <b>@order?.Uf_FKR_EDI_SellerCode</b><br/>
|
||||||
|
<u>SenderCode:</u> <b>@order?.Uf_FKR_EDI_SenderCode</b><br/>
|
||||||
|
<u>BuyerCode:</u> <b>@order?.Uf_FKR_EDI_BuyerCode</b><br/>
|
||||||
|
<u>Typ Dokumentu:</u> <b>@order?.Uf_DocType</b><br/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</CardContent>
|
||||||
|
</SfCard>
|
||||||
|
}
|
||||||
|
</DetailTemplate>
|
||||||
|
</GridTemplates>
|
||||||
|
<GridColumns>
|
||||||
|
<GridColumn Field=@nameof(CustomerOrderDto.CoNum) HeaderText="Numer Zamówienia" Width="110"></GridColumn>
|
||||||
|
<GridColumn Field=@nameof(CustomerOrderDto.CustPo) HeaderText="Zamówienie Klienta" Width="100"></GridColumn>
|
||||||
|
<GridColumn Field=@nameof(CustomerOrderDto.CustNum) HeaderText="Numer Klienta" Width="90"></GridColumn>
|
||||||
|
<GridColumn Field=@nameof(CustomerOrderDto.CustSeq) HeaderText="Odbiorca" Width="80"></GridColumn>
|
||||||
|
<GridColumn Field=@nameof(CustomerOrderDto.CreateDate) HeaderText="Data zamówienia" TextAlign="TextAlign.Right" Width="110"></GridColumn>
|
||||||
|
<GridColumn Field=@nameof(CustomerOrderDto.TranslatedStatus) HeaderText="Status" Width="100"></GridColumn>
|
||||||
|
</GridColumns>
|
||||||
|
<GridFilterSettings Type="FilterType.Excel"/>
|
||||||
|
<GridPageSettings PageSize="10"/>
|
||||||
|
<GridSelectionSettings Mode="SelectionMode.Row" Type="SelectionType.Single"/>
|
||||||
|
<GridEvents TValue="CustomerOrderDto" OnRecordDoubleClick="OnRowDoubleClick"/>
|
||||||
|
</SfGrid>
|
||||||
|
</CardContent>
|
||||||
|
<CardFooter>
|
||||||
|
<small class="text-muted">FA Krosno Manager © @(DateTime.Now.Year)</small>
|
||||||
|
</CardFooter>
|
||||||
|
</SfCard>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
Grid<CustomerOrderDto>? _grid;
|
|
||||||
private IEnumerable<CustomerOrderDto>? _customerOrders;
|
private IEnumerable<CustomerOrderDto>? _customerOrders;
|
||||||
|
|
||||||
private CustomerOrderDto? _selectedCustomerOrder;
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||||
|
|
||||||
private async Task<GridDataProviderResult<CustomerOrderDto>> CustomerOrdersDataProvider(GridDataProviderRequest<CustomerOrderDto> request)
|
|
||||||
{
|
{
|
||||||
_customerOrders = await CustomerOrderService.GetCustomerOrdersAsync() ?? new List<CustomerOrderDto>();
|
if (firstRender)
|
||||||
_customerOrders = _customerOrders.OrderByDescending(x => x.CreateDate).ToList();
|
{
|
||||||
|
// ClaimsPrincipal currentUser = CustomAuthenticationStateProvider.GetCurrentUser();
|
||||||
|
//
|
||||||
|
// if (currentUser.Identity?.IsAuthenticated == false)
|
||||||
|
// {
|
||||||
|
// NavigationManager.NavigateTo("/Unauthorized");
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
_customerOrders = await CustomerOrderService.GetCustomerOrdersAsync() ?? new List<CustomerOrderDto>();
|
||||||
|
_customerOrders = _customerOrders.OrderByDescending(x => x.CreateDate).ToList();
|
||||||
|
|
||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
|
// }
|
||||||
return await Task.FromResult(request.ApplyTo(_customerOrders));
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnRowDoubleClick(GridRowEventArgs<CustomerOrderDto> obj)
|
private void OnRowDoubleClick(RecordDoubleClickEventArgs<CustomerOrderDto> obj)
|
||||||
{
|
{
|
||||||
Guid customerOrderId = obj.Item.RowPointer;
|
Guid customerOrderId = obj.RowData.RowPointer;
|
||||||
|
|
||||||
NavigationManager.NavigateTo($"/CustomerOrder/{customerOrderId}");
|
NavigationManager.NavigateTo($"/Admin/PK/CustomerOrder/{customerOrderId}");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SelectedItemsChanged(HashSet<CustomerOrderDto> obj)
|
|
||||||
{
|
|
||||||
_selectedCustomerOrder = obj.FirstOrDefault() ?? null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,96 @@
|
|||||||
|
@page "/admin/pk"
|
||||||
|
|
||||||
|
@using SytelineSaAppEfDataModel.Dtos
|
||||||
|
@using Syncfusion.Blazor.Cards
|
||||||
|
@using Syncfusion.Blazor.Grids
|
||||||
|
@using Action = Syncfusion.Blazor.Grids.Action
|
||||||
|
|
||||||
|
@inject EdiCustomerOrderTranslateService EdiCustomerOrderTranslateService
|
||||||
|
|
||||||
|
<div class="h-100 d-flex justify-content-center align-items-start">
|
||||||
|
<SfCard CssClass="shadow" style="width: 100%; max-width: 1200px;">
|
||||||
|
<CardHeader>
|
||||||
|
<h3 class="text-primary">Zarządzanie powiązaniami zamówień z DELFORami</h3>
|
||||||
|
</CardHeader>
|
||||||
|
<CardContent>
|
||||||
|
<SfGrid DataSource="@OrderTranslations"
|
||||||
|
AllowFiltering="true"
|
||||||
|
AllowPaging="true"
|
||||||
|
AllowSorting="true"
|
||||||
|
AllowSelection="true"
|
||||||
|
EnableAdaptiveUI="true"
|
||||||
|
EnablePersistence="true"
|
||||||
|
AdaptiveUIMode="AdaptiveMode.Both"
|
||||||
|
Toolbar="@(new List<string> { "Edit", "Delete", "Cancel", "Update" })">
|
||||||
|
<GridColumns>
|
||||||
|
<GridColumn Field=@nameof(EdiCustomerOrderTranslateDto.Id) AllowEditing="false" IsPrimaryKey="true" Visible="false" HeaderText="Id"
|
||||||
|
Width="100"></GridColumn>
|
||||||
|
<GridColumn Field=@nameof(EdiCustomerOrderTranslateDto.ScheduleOrderId) HeaderText="DELFOR Id" Width="150"></GridColumn>
|
||||||
|
<GridColumn Field=@nameof(EdiCustomerOrderTranslateDto.EdiCoCoNum) HeaderText="Numer zamówienia EDI" Width="150"></GridColumn>
|
||||||
|
<GridColumn Field=@nameof(EdiCustomerOrderTranslateDto.CoCoNum) HeaderText="Numer zamówienia SL" Width="200"></GridColumn>
|
||||||
|
<GridColumn Field=@nameof(EdiCustomerOrderTranslateDto.CreatedDate) AllowEditing="false" HeaderText="Data utworzenia"
|
||||||
|
Width="150"></GridColumn>
|
||||||
|
</GridColumns>
|
||||||
|
<GridEditSettings AllowDeleting="true"
|
||||||
|
ShowDeleteConfirmDialog="true"
|
||||||
|
AllowEditing="true">
|
||||||
|
</GridEditSettings>
|
||||||
|
<GridEvents OnActionBegin="OnActionBegin"
|
||||||
|
OnActionComplete="OnActionComplete"
|
||||||
|
TValue="EdiCustomerOrderTranslateDto">
|
||||||
|
</GridEvents>
|
||||||
|
<GridPageSettings PageSize="10"></GridPageSettings>
|
||||||
|
<GridFilterSettings Type="FilterType.Excel"/>
|
||||||
|
</SfGrid>
|
||||||
|
</CardContent>
|
||||||
|
<CardFooter>
|
||||||
|
<small class="text-muted">FA Krosno Manager © @(DateTime.Now.Year)</small>
|
||||||
|
</CardFooter>
|
||||||
|
</SfCard>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
private List<EdiCustomerOrderTranslateDto> OrderTranslations { get; set; } = new();
|
||||||
|
|
||||||
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||||
|
{
|
||||||
|
if (firstRender)
|
||||||
|
{
|
||||||
|
// ClaimsPrincipal currentUser = CustomAuthenticationStateProvider.GetCurrentUser();
|
||||||
|
//
|
||||||
|
// if (currentUser.Identity?.IsAuthenticated == false || currentUser.Identity?.Name != "pkus")
|
||||||
|
// {
|
||||||
|
// NavigationManager.NavigateTo("/Unauthorized");
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
await LoadTranslations();
|
||||||
|
StateHasChanged();
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task OnActionBegin(ActionEventArgs<EdiCustomerOrderTranslateDto> args)
|
||||||
|
{
|
||||||
|
if (args.RequestType.Equals(Action.Delete))
|
||||||
|
{
|
||||||
|
await EdiCustomerOrderTranslateService.DeleteEdiCustomerOrderTranslateAsync(args.Data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task LoadTranslations()
|
||||||
|
{
|
||||||
|
OrderTranslations = (await EdiCustomerOrderTranslateService.GetEdiCustomerOrdersTranslationsAsync() ?? Array.Empty<EdiCustomerOrderTranslateDto>()).OrderByDescending(x => x.CreatedDate).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task OnActionComplete(ActionEventArgs<EdiCustomerOrderTranslateDto> args)
|
||||||
|
{
|
||||||
|
switch (args.RequestType)
|
||||||
|
{
|
||||||
|
case Action.Delete:
|
||||||
|
await LoadTranslations();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,240 +1,228 @@
|
|||||||
@page "/EdiCustomerOrder/{CustomerOrderId:guid}"
|
@page "/Admin/PK/EdiCustomerOrder/{CustomerOrderId:guid}"
|
||||||
|
|
||||||
@inject EdiCustomerOrderService EdiCustomerOrderService
|
@inject EdiCustomerOrderService EdiCustomerOrderService
|
||||||
|
@inject NavigationManager NavigationManager
|
||||||
|
@inject CustomAuthenticationStateProvider CustomAuthenticationStateProvider
|
||||||
|
|
||||||
|
@using System.Security.Claims
|
||||||
|
@using Microsoft.AspNetCore.Authorization
|
||||||
@using SytelineSaAppEfDataModel.Dtos
|
@using SytelineSaAppEfDataModel.Dtos
|
||||||
|
@using Syncfusion.Blazor.Grids
|
||||||
|
@using Syncfusion.Blazor.Cards
|
||||||
|
|
||||||
@inherits LayoutComponentBase
|
@inherits LayoutComponentBase
|
||||||
|
|
||||||
<div class="row">
|
<div class="h-100 d-flex justify-content-center align-items-start">
|
||||||
<h3>Zamówienie Klienta EDI</h3>
|
<SfCard CssClass="shadow" style="width: 100%; max-width: 1200px;">
|
||||||
|
<CardHeader>
|
||||||
|
<h3 class="text-primary">Zamówienie klienta EDI nr @(EdiCustomerOrderDto?.CustomerOrderNumber ?? "Brak numeru")</h3>
|
||||||
|
</CardHeader>
|
||||||
|
<CardContent>
|
||||||
|
<SfCard CssClass="mb-4">
|
||||||
|
<CardContent>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col">
|
||||||
|
<u>Numer zamówienia EDI:</u> <b>@EdiCustomerOrderDto?.CustomerOrderNumber</b><br/>
|
||||||
|
<u>Numer zamówienia Klienta:</u> <b>@EdiCustomerOrderDto?.CustomerPoNumber</b><br/>
|
||||||
|
<u>Numer klienta:</u> <b>@EdiCustomerOrderDto?.CustomerNumber</b><br/>
|
||||||
|
<u>Klient:</u> <b>@EdiCustomerOrderDto?.CustomerName</b><br/>
|
||||||
|
<u>Numer odbiorcy:</u> <b>@(EdiCustomerOrderDto?.CustomerSequence?.ToString() ?? "N/A")</b><br/>
|
||||||
|
<u>Data otrzymania:</u> <b>@(EdiCustomerOrderDto?.RecivedDate?.ToString("dd.MM.yyyy") ?? "N/A")</b><br/>
|
||||||
|
<u>Wysłano do Syteline?:</u> <b>@((EdiCustomerOrderDto?.Posted?.ToString() ?? "0") == "0" ? "NIE" : "TAK")</b><br/>
|
||||||
|
<u>Data wysyłki do Syteline:</u> <b>@(EdiCustomerOrderDto?.PostedDate?.ToString("dd.MM.yyyy") ?? "N/A")</b><br/>
|
||||||
|
<u>Data zamówienia:</u> <b>@(EdiCustomerOrderDto?.OrderDate?.ToString("dd.MM.yyyy") ?? "N/A")</b><br/>
|
||||||
|
</div>
|
||||||
|
<div class="col">
|
||||||
|
<u>Cena:</u> <b>@(EdiCustomerOrderDto?.Price?.ToString("F2") ?? "N/A")</b><br/>
|
||||||
|
<u>Waga:</u> <b>@(EdiCustomerOrderDto?.Weight?.ToString("F2") ?? "N/A")</b><br/>
|
||||||
|
<u>Magazyn:</u> <b>@EdiCustomerOrderDto?.Warehouse</b><br/>
|
||||||
|
<u>Gate:</u> <b>@EdiCustomerOrderDto?.Gate</b><br/>
|
||||||
|
<u>Kod odbiorcy:</u> <b>@EdiCustomerOrderDto?.RecipientCode</b><br/>
|
||||||
|
<u>Kod wysyłającego:</u> <b>@EdiCustomerOrderDto?.SenderCode</b><br/>
|
||||||
|
<u>Kod sprzedawcy:</u> <b>@EdiCustomerOrderDto?.SellerCode</b><br/>
|
||||||
|
<u>Kod kupującego:</u> <b>@EdiCustomerOrderDto?.BuyerCode</b><br/>
|
||||||
|
<u>Typ dokumentu:</u> <b>@EdiCustomerOrderDto?.DocType</b><br/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</CardContent>
|
||||||
|
</SfCard>
|
||||||
|
|
||||||
|
<h5 class="text-primary mb-3">Indeksy</h5>
|
||||||
|
<SfGrid @ref="_ediCustomerOrderLinesGrid"
|
||||||
|
AllowFiltering="true"
|
||||||
|
AllowPaging="true"
|
||||||
|
AllowSorting="true"
|
||||||
|
AllowSelection="true"
|
||||||
|
TValue="EdiCustomerOrderLineDto"
|
||||||
|
DataSource="@_ediCustomerOrderLines"
|
||||||
|
EnableAdaptiveUI="true">
|
||||||
|
<GridTemplates>
|
||||||
|
<DetailTemplate>
|
||||||
|
@{
|
||||||
|
var order = context as EdiCustomerOrderLineDto;
|
||||||
|
<SfCard CssClass="mb-4">
|
||||||
|
<CardContent>
|
||||||
|
<div class="row">
|
||||||
|
<h6>Szczegóły</h6>
|
||||||
|
<div class="col">
|
||||||
|
<u>Numer zamówienia EDI:</u> <b>@order?.CustomerOrderNumber</b><br/>
|
||||||
|
<u>Linia:</u> <b>@order?.CustomerOrderLine</b><br/>
|
||||||
|
<u>Pozycja:</u> <b>@order?.Item</b><br/>
|
||||||
|
<u>Pozycja Klienta:</u> <b>@order?.CustomerItemNumber</b><br/>
|
||||||
|
<u>Opis:</u> <b>@order?.Description</b><br/>
|
||||||
|
<u>Łączna Ilość:</u> <b>@(order?.BlanketQty?.ToString("F2") ?? "N/A")</b><br/>
|
||||||
|
<u>Status:</u> <b>@order?.TranslatedStatus</b><br/>
|
||||||
|
</div>
|
||||||
|
<div class="col">
|
||||||
|
<u>Cena:</u> <b>@(order?.ContPrice?.ToString("F2") ?? "N/A")</b><br/>
|
||||||
|
<u>Ważne Od:</u> <b>@(order?.EffectiveDate?.ToString("dd.MM.yyyy") ?? "N/A")</b><br/>
|
||||||
|
<u>J/M:</u> <b>@order?.Uom</b><br/>
|
||||||
|
<u>BoxType:</u> <b>@order?.BoxType</b><br/>
|
||||||
|
<u>Address:</u> <b>@order?.Address</b><br/>
|
||||||
|
<u>FinalDestination:</u> <b>@order?.FinalDestination</b><br/>
|
||||||
|
<u>QtyPerBox:</u> <b>@(order?.QtyPerBox?.ToString() ?? "N/A")</b>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</CardContent>
|
||||||
|
</SfCard>
|
||||||
|
}
|
||||||
|
</DetailTemplate>
|
||||||
|
</GridTemplates>
|
||||||
|
<GridColumns>
|
||||||
|
<GridColumn Field=@nameof(EdiCustomerOrderLineDto.CustomerOrderLine) HeaderText="Linia" Width="70"></GridColumn>
|
||||||
|
<GridColumn Field=@nameof(EdiCustomerOrderLineDto.Item) HeaderText="Pozycja" Width="100"></GridColumn>
|
||||||
|
<GridColumn Field=@nameof(EdiCustomerOrderLineDto.CustomerItemNumber) HeaderText="Pozycja Klienta" Width="120"></GridColumn>
|
||||||
|
<GridColumn Field=@nameof(EdiCustomerOrderLineDto.Description) HeaderText="Opis" Width="200"></GridColumn>
|
||||||
|
<GridColumn Field=@nameof(EdiCustomerOrderLineDto.BlanketQty) HeaderText="Ilość" TextAlign="TextAlign.Right" Width="100"></GridColumn>
|
||||||
|
<GridColumn Field=@nameof(EdiCustomerOrderLineDto.Uom) HeaderText="J/M" Width="50"></GridColumn>
|
||||||
|
<GridColumn Field=@nameof(EdiCustomerOrderLineDto.ContPrice) HeaderText="Cena" Width="100"></GridColumn>
|
||||||
|
<GridColumn Field=@nameof(EdiCustomerOrderLineDto.TranslatedStatus) HeaderText="Status" Width="100"></GridColumn>
|
||||||
|
</GridColumns>
|
||||||
|
<GridFilterSettings Type="FilterType.Excel"/>
|
||||||
|
<GridPageSettings PageSize="10"/>
|
||||||
|
<GridSelectionSettings Mode="SelectionMode.Row" Type="SelectionType.Single"/>
|
||||||
|
<GridEvents TValue="EdiCustomerOrderLineDto" RowSelected="OnSelectedLineRow"></GridEvents>
|
||||||
|
</SfGrid>
|
||||||
|
|
||||||
|
@if (_isVisibleEdiCustomerOrderLine)
|
||||||
|
{
|
||||||
|
<h5 class="text-primary mb-3 mt-4">Harmonogramy</h5>
|
||||||
|
<SfGrid @ref="_ediCustomerOrderLineItemsGrid"
|
||||||
|
TValue="EdiCustomerOrderLineItemDto"
|
||||||
|
DataSource="@_ediCustomerOrderLineItems"
|
||||||
|
AllowFiltering="true"
|
||||||
|
AllowPaging="true"
|
||||||
|
AllowSelection="true"
|
||||||
|
AllowSorting="true"
|
||||||
|
SelectionMode="Syncfusion.Blazor.Grids.SelectionMode.Single"
|
||||||
|
SelectedItemsChanged="SelectedCustomerOrderLineItemChanged">
|
||||||
|
<GridTemplates>
|
||||||
|
<DetailTemplate>
|
||||||
|
@{
|
||||||
|
var detailLineItem = context as EdiCustomerOrderLineItemDto;
|
||||||
|
<SfCard CssClass="mb-4">
|
||||||
|
<CardContent>
|
||||||
|
<div class="row">
|
||||||
|
<h6>Szczegóły</h6>
|
||||||
|
<div class="col">
|
||||||
|
<u>Numer Zamówienia:</u> <b>@detailLineItem?.CustomerOrderNumber</b><br/>
|
||||||
|
<u>Linia:</u> <b>@detailLineItem?.CustomerOrderLine</b><br/>
|
||||||
|
<u>Zwolnienie:</u> <b>@detailLineItem?.CustomerOrderRelease</b><br/>
|
||||||
|
<u>Pozycja:</u> <b>@detailLineItem?.Item</b><br/>
|
||||||
|
<u>Pozycja Klienta:</u> <b>@detailLineItem?.CustomerItem</b><br/>
|
||||||
|
<u>Łączna Ilość Sztuk:</u> <b>@(detailLineItem?.QtyOrdered?.ToString("F2") ?? "N/A")</b><br/>
|
||||||
|
<u>Cena:</u> <b>@(detailLineItem?.Price?.ToString("F2") ?? "N/A")</b><br/>
|
||||||
|
<u>Data Wykonania:</u> <b>@(detailLineItem?.DueDate?.ToString("dd.MM.yyyy") ?? "N/A")</b><br/>
|
||||||
|
<u>Data Rejestracji:</u> <b>@(detailLineItem?.ReleaseDate?.ToString("dd.MM.yyyy") ?? "N/A")</b><br/>
|
||||||
|
<u>Magazyn:</u> <b>@detailLineItem?.Warehouse</b><br/>
|
||||||
|
<u>Typ Dokumentu:</u> <b>@detailLineItem?.DocumentType</b><br/>
|
||||||
|
</div>
|
||||||
|
<div class="col">
|
||||||
|
<u>Kod VAT:</u> <b>@detailLineItem?.TaxCodeOne</b><br/>
|
||||||
|
<u>J/M:</u> <b>@detailLineItem?.Uom</b><br/>
|
||||||
|
<u>Numer Klienta:</u> <b>@detailLineItem?.CustomerOrderCustomerNumber</b><br/>
|
||||||
|
<u>Opis:</u> <b>@detailLineItem?.Description</b><br/>
|
||||||
|
<u>Status:</u> <b>@detailLineItem?.TranslatedStatus</b><br/>
|
||||||
|
<u>RoutingCode:</u> <b>@detailLineItem?.RoutingCode</b><br/>
|
||||||
|
<u>DeliveryCallNumber:</u> <b>@detailLineItem?.DeliveryCallNumber</b><br/>
|
||||||
|
<u>UnloadingPoint:</u> <b>@detailLineItem?.UnloadingPoint</b><br/>
|
||||||
|
<u>DestinationPoint:</u> <b>@detailLineItem?.DestinationPoint</b><br/>
|
||||||
|
<u>PalletCode:</u> <b>@detailLineItem?.PalletCode</b><br/>
|
||||||
|
<u>PalletNumber:</u> <b>@detailLineItem?.PalletNumber</b>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</CardContent>
|
||||||
|
</SfCard>
|
||||||
|
}
|
||||||
|
</DetailTemplate>
|
||||||
|
</GridTemplates>
|
||||||
|
<Syncfusion.Blazor.Grids.GridColumns>
|
||||||
|
<Syncfusion.Blazor.Grids.GridColumn Field=@nameof(EdiCustomerOrderLineItemDto.CustomerOrderLine) HeaderText="Linia" Width="70"/>
|
||||||
|
<Syncfusion.Blazor.Grids.GridColumn Field=@nameof(EdiCustomerOrderLineItemDto.CustomerOrderRelease) HeaderText="Zwolnienie" Width="70"/>
|
||||||
|
<Syncfusion.Blazor.Grids.GridColumn Field=@nameof(EdiCustomerOrderLineItemDto.Item) HeaderText="Pozycja" Width="100"></Syncfusion.Blazor.Grids.GridColumn>
|
||||||
|
<Syncfusion.Blazor.Grids.GridColumn Field=@nameof(EdiCustomerOrderLineItemDto.CustomerItem) HeaderText="Pozycja Klienta" Width="100"></Syncfusion.Blazor.Grids.GridColumn>
|
||||||
|
<Syncfusion.Blazor.Grids.GridColumn Field=@nameof(EdiCustomerOrderLineItemDto.QtyOrdered) HeaderText="Łączna Ilość" TextAlign="TextAlign.Right" Width="120"></Syncfusion.Blazor.Grids.GridColumn>
|
||||||
|
<Syncfusion.Blazor.Grids.GridColumn Field=@nameof(EdiCustomerOrderLineItemDto.DueDate) HeaderText="Data Wykonania" Width="100"/>
|
||||||
|
<Syncfusion.Blazor.Grids.GridColumn Field=@nameof(EdiCustomerOrderLineItemDto.TranslatedStatus) HeaderText="Status" Width="100"></Syncfusion.Blazor.Grids.GridColumn>
|
||||||
|
</Syncfusion.Blazor.Grids.GridColumns>
|
||||||
|
<GridFilterSettings Type="FilterType.Excel"/>
|
||||||
|
<GridPageSettings PageSize="10"/>
|
||||||
|
<GridSelectionSettings Mode="SelectionMode.Row" Type="SelectionType.Single"/>
|
||||||
|
</SfGrid>
|
||||||
|
}
|
||||||
|
</CardContent>
|
||||||
|
<CardFooter>
|
||||||
|
<small class="text-muted">FA Krosno Manager © @(DateTime.Now.Year)</small>
|
||||||
|
</CardFooter>
|
||||||
|
</SfCard>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
|
||||||
<div class="col">
|
|
||||||
<SortableList TItem="EdiCustomerOrderDto" Data="_ediCustomerOrder">
|
|
||||||
<ItemTemplate>
|
|
||||||
<u>Numer zamówienia EDI:</u> <b>@context.CustomerOrderNumber</b><br />
|
|
||||||
<u>Numer zamówienia Klienta:</u> <b>@context.CustomerPoNumber</b><br />
|
|
||||||
<u>Numer klienta:</u> <b>@context.CustomerNumber</b><br />
|
|
||||||
<u>Klient:</u> <b>@context.CustomerName</b><br />
|
|
||||||
<u>Numer odbiorcy:</u> <b>@(context.CustomerSequence?.ToString() ?? "N/A")</b><br />
|
|
||||||
<u>Data otrzymania:</u> <b>@(context.RecivedDate?.ToString("dd.MM.yyyy") ?? "N/A")</b><br />
|
|
||||||
<u>Wysłano do Syteline?:</u> <b>@((context.Posted?.ToString() ?? "0") == "0" ? "NIE" : "TAK")</b><br />
|
|
||||||
<u>Data wysyłki do Syteline:</u> <b>@(context.PostedDate?.ToString("dd.MM.yyyy") ?? "N/A")</b><br />
|
|
||||||
<u>Data zamówienia:</u> <b>@(context.OrderDate?.ToString("dd.MM.yyyy") ?? "N/A")</b><br />
|
|
||||||
</ItemTemplate>
|
|
||||||
</SortableList>
|
|
||||||
</div>
|
|
||||||
<div class="col">
|
|
||||||
<SortableList TItem="EdiCustomerOrderDto" Data="_ediCustomerOrder" Class="bg-light">
|
|
||||||
<ItemTemplate>
|
|
||||||
<u>Cena:</u> <b>@(context.Price?.ToString("F2") ?? "N/A")</b><br />
|
|
||||||
<u>Waga:</u> <b>@(context.Weight?.ToString("F2") ?? "N/A")</b><br />
|
|
||||||
<u>Magazyn:</u> <b>@context.Warehouse</b><br />
|
|
||||||
<u>Gate:</u> <b>@context.Gate</b><br />
|
|
||||||
<u>Kod odbiorcy:</u> <b>@context.RecipientCode</b><br />
|
|
||||||
<u>Kod wysyłającego:</u> <b>@context.SenderCode</b><br />
|
|
||||||
<u>Kod sprzedawcy:</u> <b>@context.SellerCode</b><br />
|
|
||||||
<u>Kod kupującego:</u> <b>@context.BuyerCode</b><br />
|
|
||||||
<u>Typ dokumentu:</u> <b>@context.DocType</b><br />
|
|
||||||
</ItemTemplate>
|
|
||||||
</SortableList>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<br/>
|
|
||||||
<div class="row">
|
|
||||||
<h3>Indeksy</h3>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<Grid @ref="_ediCustomerOrderLinesGrid"
|
|
||||||
TItem="EdiCustomerOrderLineDto"
|
|
||||||
Class="table table-hover table-bordered table-striped"
|
|
||||||
Data="_ediCustomerOrderLines"
|
|
||||||
AllowFiltering="true"
|
|
||||||
Responsive="true"
|
|
||||||
AllowPaging="true"
|
|
||||||
PageSize="10"
|
|
||||||
AllowSelection="true"
|
|
||||||
AllowRowClick="true"
|
|
||||||
SelectionMode="GridSelectionMode.Single"
|
|
||||||
SelectedItemsChanged="SelectedEdiCustomerOrderLineChanged">
|
|
||||||
<GridColumns>
|
|
||||||
<GridColumn TItem="EdiCustomerOrderLineDto" HeaderText="Linia" PropertyName="CustomerOrderLine">
|
|
||||||
@context.CustomerOrderLine
|
|
||||||
</GridColumn>
|
|
||||||
<GridColumn TItem="EdiCustomerOrderLineDto" HeaderText="Pozycja" PropertyName="Item">
|
|
||||||
@context.Item
|
|
||||||
</GridColumn>
|
|
||||||
<GridColumn TItem="EdiCustomerOrderLineDto" HeaderText="Pozycja Klienta" PropertyName="CustomerItemNumber">
|
|
||||||
@context.CustomerItemNumber
|
|
||||||
</GridColumn>
|
|
||||||
<GridColumn TItem="EdiCustomerOrderLineDto" HeaderText="Opis" PropertyName="Description">
|
|
||||||
@context.Description
|
|
||||||
</GridColumn>
|
|
||||||
<GridColumn TItem="EdiCustomerOrderLineDto" HeaderText="Ilość" TextAlignment="Alignment.End" PropertyName="BlanketQty">
|
|
||||||
@context.BlanketQty
|
|
||||||
</GridColumn>
|
|
||||||
<GridColumn TItem="EdiCustomerOrderLineDto" HeaderText="J/M" PropertyName="Uom">
|
|
||||||
@context.Uom
|
|
||||||
</GridColumn>
|
|
||||||
<GridColumn TItem="EdiCustomerOrderLineDto" HeaderText="Cena" PropertyName="ContPrice">
|
|
||||||
@context.ContPrice
|
|
||||||
</GridColumn>
|
|
||||||
<GridColumn TItem="EdiCustomerOrderLineDto" HeaderText="Status" PropertyName="TranslatedStatus">
|
|
||||||
@context.TranslatedStatus
|
|
||||||
</GridColumn>
|
|
||||||
</GridColumns>
|
|
||||||
</Grid>
|
|
||||||
</div>
|
|
||||||
@if (_isVisibleEdiCustomerOrderLine)
|
|
||||||
{
|
|
||||||
<div class="row">
|
|
||||||
<h3>Szczegóły</h3>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col">
|
|
||||||
<SortableList TItem="EdiCustomerOrderLineDto" Data="_selectedEdiCustomerOrderLine">
|
|
||||||
<ItemTemplate>
|
|
||||||
<u>Numer zamówienia EDI:</u> <b>@context.CustomerOrderNumber</b><br />
|
|
||||||
<u>Linia:</u> <b>@context.CustomerOrderLine</b><br />
|
|
||||||
<u>Pozycja:</u> <b>@context.Item</b><br />
|
|
||||||
<u>Pozycja Klienta:</u> <b>@context.CustomerItemNumber</b><br />
|
|
||||||
<u>Opis:</u> <b>@context.Description</b><br />
|
|
||||||
<u>Łączna Ilość:</u> <b>@(context.BlanketQty?.ToString("F2") ?? "N/A")</b><br />
|
|
||||||
<u>Status:</u> <b>@context.TranslatedStatus</b><br />
|
|
||||||
</ItemTemplate>
|
|
||||||
</SortableList>
|
|
||||||
</div>
|
|
||||||
<div class="col">
|
|
||||||
<SortableList TItem="EdiCustomerOrderLineDto" Data="_selectedEdiCustomerOrderLine">
|
|
||||||
<ItemTemplate>
|
|
||||||
<u>Cena:</u> <b>@(context.ContPrice?.ToString("F2") ?? "N/A")</b><br />
|
|
||||||
<u>Ważne Od:</u> <b>@(context.EffectiveDate?.ToString("dd.MM.yyyy") ?? "N/A")</b><br />
|
|
||||||
<u>J/M:</u> <b>@context.Uom</b><br />
|
|
||||||
<u>BoxType:</u> <b>@context.BoxType</b><br/>
|
|
||||||
<u>Address:</u> <b>@context.Address</b><br/>
|
|
||||||
<u>FinalDestination:</u> <b>@context.FinalDestination</b><br/>
|
|
||||||
<u>QtyPerBox:</u> <b>@(context.QtyPerBox?.ToString() ?? "N/A")</b>
|
|
||||||
</ItemTemplate>
|
|
||||||
</SortableList>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<br />
|
|
||||||
<h3>Harmonogramy</h3>
|
|
||||||
<div class="row">
|
|
||||||
<Grid @ref="_ediCustomerOrderLineItemsGrid"
|
|
||||||
TItem="EdiCustomerOrderLineItemDto"
|
|
||||||
Class="table table-hover table-bordered table-striped"
|
|
||||||
Data="_ediCustomerOrderLineItems"
|
|
||||||
AllowFiltering="true"
|
|
||||||
Responsive="true"
|
|
||||||
AllowPaging="true"
|
|
||||||
PageSize="10"
|
|
||||||
AllowSelection="true"
|
|
||||||
AllowRowClick="true"
|
|
||||||
SelectionMode="GridSelectionMode.Single"
|
|
||||||
SelectedItemsChanged="SelectedEdiCustomerOrderLineItemChanged">
|
|
||||||
<GridColumns>
|
|
||||||
<GridColumn TItem="EdiCustomerOrderLineItemDto" HeaderText="Linia" PropertyName="CustomerOrderLine">
|
|
||||||
@context.CustomerOrderLine
|
|
||||||
</GridColumn>
|
|
||||||
<GridColumn TItem="EdiCustomerOrderLineItemDto" HeaderText="Zwolnienie" PropertyName="CustomerOrderRelease">
|
|
||||||
@context.CustomerOrderRelease
|
|
||||||
</GridColumn>
|
|
||||||
<GridColumn TItem="EdiCustomerOrderLineItemDto" HeaderText="Pozycja" PropertyName="Item">
|
|
||||||
@context.Item
|
|
||||||
</GridColumn>
|
|
||||||
<GridColumn TItem="EdiCustomerOrderLineItemDto" HeaderText="Pozycja" PropertyName="CustomerItem">
|
|
||||||
@context.CustomerItem
|
|
||||||
</GridColumn>
|
|
||||||
<GridColumn TItem="EdiCustomerOrderLineItemDto" HeaderText="Łączna Ilość" TextAlignment="Alignment.End" PropertyName="QtyOrdered">
|
|
||||||
@context.QtyOrdered
|
|
||||||
</GridColumn>
|
|
||||||
<GridColumn TItem="EdiCustomerOrderLineItemDto" HeaderText="Data Wykonania" PropertyName="DueDate">
|
|
||||||
@context.DueDate?.ToString("dd.MM.yyyy")
|
|
||||||
</GridColumn>
|
|
||||||
<GridColumn TItem="EdiCustomerOrderLineItemDto" HeaderText="Status" PropertyName="TranslatedStatus">
|
|
||||||
@context.TranslatedStatus
|
|
||||||
</GridColumn>
|
|
||||||
</GridColumns>
|
|
||||||
</Grid>
|
|
||||||
</div>
|
|
||||||
}@if (_isVisibleEdiCustomerOrderLineItem)
|
|
||||||
{
|
|
||||||
<div class="row">
|
|
||||||
<h3>Szczegóły</h3>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col">
|
|
||||||
<SortableList TItem="EdiCustomerOrderLineItemDto" Data="_selectedEdiCustomerOrderLineItem">
|
|
||||||
<ItemTemplate>
|
|
||||||
<u>Numer Zamówienia:</u> <b>@context.CustomerOrderNumber</b><br />
|
|
||||||
<u>Linia:</u> <b>@context.CustomerOrderLine</b><br />
|
|
||||||
<u>Zwolnienie:</u> <b>@context.CustomerOrderRelease</b><br />
|
|
||||||
<u>Pozycja:</u> <b>@context.Item</b><br />
|
|
||||||
<u>Pozycja Klienta:</u> <b>@context.CustomerItem</b><br />
|
|
||||||
<u>Łączna Ilość Sztuk:</u> <b>@(context.QtyOrdered?.ToString("F2") ?? "N/A")</b><br />
|
|
||||||
<u>Cena:</u> <b>@(context.Price?.ToString("F2") ?? "N/A")</b><br />
|
|
||||||
<u>Data Wykonania:</u> <b>@(context.DueDate?.ToString("dd.MM.yyyy") ?? "N/A")</b><br />
|
|
||||||
<u>Data Rejestracji:</u> <b>@(context.ReleaseDate?.ToString("dd.MM.yyyy") ?? "N/A")</b><br />
|
|
||||||
<u>Magazyn:</u> <b>@context.Warehouse</b><br />
|
|
||||||
<u>Typ Documentu:</u> <b>@context.DocumentType</b><br />
|
|
||||||
</ItemTemplate>
|
|
||||||
</SortableList>
|
|
||||||
</div>
|
|
||||||
<div class="col">
|
|
||||||
<SortableList TItem="EdiCustomerOrderLineItemDto" Data="_selectedEdiCustomerOrderLineItem">
|
|
||||||
<ItemTemplate>
|
|
||||||
<u>Kod VAT:</u> <b>@context.TaxCodeOne</b><br />
|
|
||||||
<u>J/M:</u> <b>@context.Uom</b><br />
|
|
||||||
<u>Numer Klienta:</u> <b>@context.CustomerOrderCustomerNumber</b><br />
|
|
||||||
<u>Opis:</u> <b>@context.Description</b><br />
|
|
||||||
<u>Status:</u> <b>@context.TranslatedStatus</b><br />
|
|
||||||
<u>RoutingCode:</u> <b>@context.RoutingCode</b><br />
|
|
||||||
<u>DeliveryCallNumber:</u> <b>@context.DeliveryCallNumber</b><br />
|
|
||||||
<u>UnloadingPoint:</u> <b>@context.UnloadingPoint</b><br />
|
|
||||||
<u>DestinationPoint:</u> <b>@context.DestinationPoint</b><br />
|
|
||||||
<u>PalletCode:</u> <b>@context.PalletCode</b><br />
|
|
||||||
<u>PalletNumber:</u> <b>@context.PalletNumber</b>
|
|
||||||
</ItemTemplate>
|
|
||||||
</SortableList>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
@code {
|
@code {
|
||||||
|
[Parameter] public Guid CustomerOrderId { get; set; }
|
||||||
|
|
||||||
[Parameter]
|
private EdiCustomerOrderDto? EdiCustomerOrderDto { get; set; }
|
||||||
public Guid CustomerOrderId { get; set; }
|
private List<EdiCustomerOrderLineDto> _ediCustomerOrderLines = [];
|
||||||
|
private List<EdiCustomerOrderLineItemDto> _ediCustomerOrderLineItems = [];
|
||||||
|
|
||||||
List<EdiCustomerOrderDto?>? _ediCustomerOrder;
|
EdiCustomerOrderLineDto? _selectedEdiCustomerOrderLine;
|
||||||
List<EdiCustomerOrderLineDto> _ediCustomerOrderLines = [];
|
|
||||||
List<EdiCustomerOrderLineItemDto> _ediCustomerOrderLineItems = [];
|
|
||||||
|
|
||||||
List<EdiCustomerOrderLineDto?> _selectedEdiCustomerOrderLine = [];
|
SfGrid<EdiCustomerOrderLineDto>? _ediCustomerOrderLinesGrid;
|
||||||
List<EdiCustomerOrderLineItemDto?> _selectedEdiCustomerOrderLineItem = [];
|
SfGrid<EdiCustomerOrderLineItemDto>? _ediCustomerOrderLineItemsGrid;
|
||||||
|
|
||||||
Grid<EdiCustomerOrderLineDto>? _ediCustomerOrderLinesGrid;
|
|
||||||
Grid<EdiCustomerOrderLineItemDto>? _ediCustomerOrderLineItemsGrid;
|
|
||||||
|
|
||||||
private bool _isVisibleEdiCustomerOrderLine;
|
private bool _isVisibleEdiCustomerOrderLine;
|
||||||
private bool _isVisibleEdiCustomerOrderLineItem;
|
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||||
{
|
{
|
||||||
EdiCustomerOrderDto? ediCustomerOrder = await EdiCustomerOrderService.GetEdiCustomerOrderAsync(CustomerOrderId);
|
if (firstRender)
|
||||||
|
{
|
||||||
|
// ClaimsPrincipal currentUser = CustomAuthenticationStateProvider.GetCurrentUser();
|
||||||
|
//
|
||||||
|
// if (currentUser.Identity?.IsAuthenticated == false)
|
||||||
|
// {
|
||||||
|
// NavigationManager.NavigateTo("/Unauthorized");
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
EdiCustomerOrderDto? ediCustomerOrder = await EdiCustomerOrderService.GetEdiCustomerOrderAsync(CustomerOrderId);
|
||||||
|
|
||||||
_ediCustomerOrder = [ediCustomerOrder];
|
EdiCustomerOrderDto = ediCustomerOrder;
|
||||||
_ediCustomerOrderLines = ediCustomerOrder?.EdiCustomerOrderLines.ToList() ?? [];
|
_ediCustomerOrderLines = ediCustomerOrder?.EdiCustomerOrderLines.ToList() ?? [];
|
||||||
|
StateHasChanged();
|
||||||
|
// }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SelectedEdiCustomerOrderLineChanged(HashSet<EdiCustomerOrderLineDto> obj)
|
private void OnSelectedLineRow<TValue>(RowSelectEventArgs<TValue> obj)
|
||||||
{
|
{
|
||||||
_isVisibleEdiCustomerOrderLine = obj.Any();
|
_isVisibleEdiCustomerOrderLine = obj.Data is not null;
|
||||||
_selectedEdiCustomerOrderLine = [obj.FirstOrDefault()];
|
_selectedEdiCustomerOrderLine = obj.Data as EdiCustomerOrderLineDto;
|
||||||
_ediCustomerOrderLineItems = obj.FirstOrDefault()?.EdiCustomerOrderLineItems.ToList() ?? [];
|
_ediCustomerOrderLineItems = _selectedEdiCustomerOrderLine?.EdiCustomerOrderLineItems.ToList() ?? [];
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SelectedEdiCustomerOrderLineItemChanged(HashSet<EdiCustomerOrderLineItemDto> obj)
|
|
||||||
{
|
|
||||||
_isVisibleEdiCustomerOrderLineItem = obj.Any();
|
|
||||||
_selectedEdiCustomerOrderLineItem = [obj.FirstOrDefault()];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,141 +1,178 @@
|
|||||||
@page "/EdiCustomerOrders"
|
@page "/Admin/PK/EdiCustomerOrders"
|
||||||
|
|
||||||
@inject EdiCustomerOrderService EdiCustomerOrderService
|
@inject EdiCustomerOrderService EdiCustomerOrderService
|
||||||
@inject NavigationManager NavigationManager
|
@inject NavigationManager NavigationManager
|
||||||
@using OrdersManagement.Dtos
|
@inject CustomAuthenticationStateProvider CustomAuthenticationStateProvider
|
||||||
|
@using System.Security.Claims
|
||||||
|
@using Microsoft.AspNetCore.Authorization
|
||||||
|
@using OrdersManagement.Models
|
||||||
@using SytelineSaAppEfDataModel.Dtos
|
@using SytelineSaAppEfDataModel.Dtos
|
||||||
|
@using Syncfusion.Blazor.Grids
|
||||||
|
@using Syncfusion.Blazor.Cards
|
||||||
|
@using Syncfusion.Blazor.Popups
|
||||||
|
@using Syncfusion.Blazor.Buttons
|
||||||
|
@using SelectionType = Syncfusion.Blazor.Grids.SelectionType
|
||||||
@inherits LayoutComponentBase
|
@inherits LayoutComponentBase
|
||||||
|
|
||||||
<div class="row">
|
<div class="h-100 d-flex justify-content-center align-items-start">
|
||||||
<h3>Zamówienia Klienta EDI</h3>
|
<SfCard CssClass="shadow" style="width: 100%; max-width: 1200px;">
|
||||||
</div>
|
<CardHeader>
|
||||||
<br />
|
<h3 class="text-primary">Zamówienia Klienta EDI</h3>
|
||||||
<div class="row">
|
</CardHeader>
|
||||||
<div class="col-md-12">
|
<CardContent>
|
||||||
<Switch ValueExpression="() => _filter" ValueChanged="FilterChanged" Label="Pokaż wszystkie" />
|
<div class="row mb-4">
|
||||||
</div>
|
<div class="col-md-12 d-flex align-items-center">
|
||||||
</div>
|
<label for="checked" style="padding: 10px 10px 10px 0">Pokaż wszystkie</label>
|
||||||
<br />
|
<SfSwitch @bind-Checked="_filter" ValueChange="FilterChanged" TChecked="bool?"
|
||||||
@if (_isVisible)
|
OnLabel="Pokaż tylko Wysłane do SL" OffLabel="Pokaż wszystkie"/>
|
||||||
{
|
</div>
|
||||||
<div class="row">
|
</div>
|
||||||
<div class="col-md-12">
|
|
||||||
<Button Color="ButtonColor.Primary" @onclick="SendOrderToSyteLine">@_text</Button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
<br />
|
|
||||||
<div class="row">
|
|
||||||
<Grid @ref="_grid"
|
|
||||||
TItem="EdiCustomerOrderDto"
|
|
||||||
Class="table table-hover table-bordered table-striped"
|
|
||||||
DataProvider="EdiCustomerOrdersDataProvider"
|
|
||||||
AllowFiltering="true"
|
|
||||||
Responsive="true"
|
|
||||||
AllowPaging="true"
|
|
||||||
PageSize="10"
|
|
||||||
AllowSelection="true"
|
|
||||||
AllowRowClick="true"
|
|
||||||
SelectionMode="GridSelectionMode.Multiple"
|
|
||||||
OnRowDoubleClick="OnRowDoubleClick"
|
|
||||||
SelectedItemsChanged="SelectedItemsChanged">
|
|
||||||
|
|
||||||
<GridColumns>
|
@if (_isVisible)
|
||||||
<GridColumn TItem="EdiCustomerOrderDto" HeaderText="Numer Zamówienia" PropertyName="CustomerOrderNumber">
|
{
|
||||||
@context.CustomerOrderNumber
|
<div class="row mb-4">
|
||||||
</GridColumn>
|
<div class="col-md-12">
|
||||||
<GridColumn TItem="EdiCustomerOrderDto" HeaderText="Zamówienie Klienta" PropertyName="CustomerPoNumber">
|
<SfButton CssClass="e-primary" IsPrimary="true" @onclick="SendOrderToSyteLine">@_text</SfButton>
|
||||||
@context.CustomerPoNumber
|
</div>
|
||||||
</GridColumn>
|
</div>
|
||||||
<GridColumn TItem="EdiCustomerOrderDto" HeaderText="Numer Klienta" PropertyName="CustomerNumber">
|
}
|
||||||
@context.CustomerNumber
|
|
||||||
</GridColumn>
|
|
||||||
<GridColumn TItem="EdiCustomerOrderDto" HeaderText="Klient" PropertyName="CustomerName">
|
|
||||||
@context.CustomerName
|
|
||||||
</GridColumn>
|
|
||||||
<GridColumn TItem="EdiCustomerOrderDto" HeaderText="Odbiorca" PropertyName="CustomerSequence">
|
|
||||||
@context.CustomerSequence
|
|
||||||
</GridColumn>
|
|
||||||
<GridColumn TItem="EdiCustomerOrderDto" HeaderText="Data Otrzymania" PropertyName="CreateDate">
|
|
||||||
@context.CreateDate
|
|
||||||
</GridColumn>
|
|
||||||
<GridColumn TItem="EdiCustomerOrderDto" HeaderText="Zamówienie SL" PropertyName="SlOrderNumber">
|
|
||||||
@context.SlOrderNumber
|
|
||||||
</GridColumn>
|
|
||||||
<GridColumn TItem="EdiCustomerOrderDto" HeaderText="Wysłane do SL" PropertyName="SentToSl">
|
|
||||||
@context.SentToSl
|
|
||||||
</GridColumn>
|
|
||||||
</GridColumns>
|
|
||||||
</Grid>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<Modal @ref="_modal" Title="@_text">
|
<SfGrid @ref="_grid"
|
||||||
<BodyTemplate>
|
AllowFiltering="true"
|
||||||
@if (_responses.Any(x => x.Status == 1))
|
AllowPaging="true"
|
||||||
{
|
AllowSorting="true"
|
||||||
foreach (ResponseDto response in _responses.Where(x => x.Status == 1))
|
AllowSelection="true"
|
||||||
{
|
TValue="EdiCustomerOrderDto"
|
||||||
<p>Zamówienie EDI @response.Identifier zostało poprawnie zaksięgowane w Zamówieniach klienta pod numerem '@response.ExternalIdentifier'</p>
|
DataSource="@_ediCustomerOrders"
|
||||||
}
|
EnableAdaptiveUI="true">
|
||||||
}
|
<GridTemplates>
|
||||||
@if (_responses.Any(x => x.Status == 0))
|
<DetailTemplate>
|
||||||
{
|
@{
|
||||||
foreach (ResponseDto response in _responses.Where(x => x.Status == 0))
|
var order = context as EdiCustomerOrderDto;
|
||||||
{
|
<SfCard CssClass="mb-4">
|
||||||
<p>Błąd: Zamówienie EDI @response.Identifier nie zostało poprawnie zaksięgowane w Zamówieniach klienta.<br/>Lista błędów:<br/>@response.Message</p>
|
<CardContent>
|
||||||
}
|
<div class="row">
|
||||||
}
|
<div class="col">
|
||||||
</BodyTemplate>
|
<u>Numer zamówienia EDI:</u> <b>@order?.CustomerOrderNumber</b><br/>
|
||||||
<FooterTemplate>
|
<u>Numer zamówienia Klienta:</u> <b>@order?.CustomerPoNumber</b><br/>
|
||||||
<Button Color="ButtonColor.Primary" @onclick="OnHideModalClick">OK</Button>
|
<u>Numer klienta:</u> <b>@order?.CustomerNumber</b><br/>
|
||||||
</FooterTemplate>
|
<u>Klient:</u> <b>@order?.CustomerName</b><br/>
|
||||||
</Modal>
|
<u>Numer odbiorcy:</u> <b>@(order?.CustomerSequence?.ToString() ?? "N/A")</b><br/>
|
||||||
|
<u>Data otrzymania:</u> <b>@(order?.RecivedDate?.ToString("dd.MM.yyyy") ?? "N/A")</b><br/>
|
||||||
|
<u>Wysłano do Syteline?:</u> <b>@((order?.Posted?.ToString() ?? "0") == "0" ? "NIE" : "TAK")</b><br/>
|
||||||
|
<u>Data wysyłki do Syteline:</u> <b>@(order?.PostedDate?.ToString("dd.MM.yyyy") ?? "N/A")</b><br/>
|
||||||
|
<u>Data zamówienia:</u> <b>@(order?.OrderDate?.ToString("dd.MM.yyyy") ?? "N/A")</b><br/>
|
||||||
|
</div>
|
||||||
|
<div class="col">
|
||||||
|
<u>Cena:</u> <b>@(order?.Price?.ToString("F2") ?? "N/A")</b><br/>
|
||||||
|
<u>Waga:</u> <b>@(order?.Weight?.ToString("F2") ?? "N/A")</b><br/>
|
||||||
|
<u>Magazyn:</u> <b>@order?.Warehouse</b><br/>
|
||||||
|
<u>Gate:</u> <b>@order?.Gate</b><br/>
|
||||||
|
<u>Kod odbiorcy:</u> <b>@order?.RecipientCode</b><br/>
|
||||||
|
<u>Kod wysyłającego:</u> <b>@order?.SenderCode</b><br/>
|
||||||
|
<u>Kod sprzedawcy:</u> <b>@order?.SellerCode</b><br/>
|
||||||
|
<u>Kod kupującego:</u> <b>@order?.BuyerCode</b><br/>
|
||||||
|
<u>Typ dokumentu:</u> <b>@order?.DocType</b><br/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</CardContent>
|
||||||
|
</SfCard>
|
||||||
|
}
|
||||||
|
</DetailTemplate>
|
||||||
|
</GridTemplates>
|
||||||
|
<GridColumns>
|
||||||
|
<GridColumn Field=@nameof(EdiCustomerOrderDto.CustomerOrderNumber) HeaderText="Numer Zamówienia" Width="110"></GridColumn>
|
||||||
|
<GridColumn Field=@nameof(EdiCustomerOrderDto.CustomerPoNumber) HeaderText="Zamówienie Klienta" Width="100"></GridColumn>
|
||||||
|
<GridColumn Field=@nameof(EdiCustomerOrderDto.CustomerNumber) HeaderText="Numer Klienta" Width="90"></GridColumn>
|
||||||
|
<GridColumn Field=@nameof(EdiCustomerOrderDto.CustomerSequence) HeaderText="Odbiorca" Width="80"></GridColumn>
|
||||||
|
<GridColumn Field=@nameof(EdiCustomerOrderDto.CreateDate) HeaderText="Data Otrzymania" TextAlign="TextAlign.Center" Width="110"></GridColumn>
|
||||||
|
<GridColumn Field=@nameof(EdiCustomerOrderDto.SlOrderNumber) HeaderText="Zamówienie SL" Width="100"></GridColumn>
|
||||||
|
<GridColumn Field=@nameof(EdiCustomerOrderDto.SentToSl) HeaderText="Wysłane do SL" TextAlign="TextAlign.Center" Width="80"></GridColumn>
|
||||||
|
</GridColumns>
|
||||||
|
<GridFilterSettings Type="FilterType.Excel"/>
|
||||||
|
<GridPageSettings PageSize="10"/>
|
||||||
|
<GridSelectionSettings Mode="SelectionMode.Row" Type="SelectionType.Multiple"/>
|
||||||
|
<GridEvents TValue="EdiCustomerOrderDto" OnRecordDoubleClick="OnRowDoubleClick" RowSelected="RowSelected"/>
|
||||||
|
</SfGrid>
|
||||||
|
|
||||||
|
<SfDialog Width="500px" Title="@_text" IsModal="true" @bind-Visible="Visibility" AllowPrerender="true">
|
||||||
|
<DialogTemplates>
|
||||||
|
<Content>
|
||||||
|
@if (_responses.Any(x => x.Status == 1))
|
||||||
|
{
|
||||||
|
foreach (ResponseModel? response in _responses.Where(x => x.Status == 1))
|
||||||
|
{
|
||||||
|
<p>Zamówienie EDI @response.Identifier zostało poprawnie zaksięgowane w Zamówieniach klienta pod numerem '@response.ExternalIdentifier'</p>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@if (_responses.Any(x => x.Status == 0))
|
||||||
|
{
|
||||||
|
foreach (ResponseModel? response in _responses.Where(x => x.Status == 0))
|
||||||
|
{
|
||||||
|
<p>Błąd: Zamówienie EDI @response.Identifier nie zostało poprawnie zaksięgowane w Zamówieniach klienta.<br/>Lista błędów:<br/>@response.Message</p>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</Content>
|
||||||
|
</DialogTemplates>
|
||||||
|
<DialogButtons>
|
||||||
|
<DialogButton Content="OK" IsPrimary="true" OnClick="@HideModal"/>
|
||||||
|
</DialogButtons>
|
||||||
|
</SfDialog>
|
||||||
|
</CardContent>
|
||||||
|
<CardFooter>
|
||||||
|
<small class="text-muted">FA Krosno Manager © @(DateTime.Now.Year)</small>
|
||||||
|
</CardFooter>
|
||||||
|
</SfCard>
|
||||||
|
</div>
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
Grid<EdiCustomerOrderDto>? _grid;
|
private bool Visibility { get; set; }
|
||||||
private List<EdiCustomerOrderDto> _ediCustomerOrders = new();
|
|
||||||
|
private SfGrid<EdiCustomerOrderDto>? _grid;
|
||||||
|
|
||||||
|
private IEnumerable<EdiCustomerOrderDto> _ediCustomerOrders = [];
|
||||||
private List<EdiCustomerOrderDto> _selectedEdiCustomerOrders = new();
|
private List<EdiCustomerOrderDto> _selectedEdiCustomerOrders = new();
|
||||||
|
|
||||||
private List<ResponseDto> _responses = new();
|
private List<ResponseModel?> _responses = new();
|
||||||
|
|
||||||
private Modal _modal = null!;
|
|
||||||
|
|
||||||
private bool _isVisible;
|
private bool _isVisible;
|
||||||
private bool _filter;
|
private bool? _filter = false;
|
||||||
|
|
||||||
private string _text = "Księguj bieżący";
|
private string _text = "Księguj bieżący";
|
||||||
|
|
||||||
private async Task<GridDataProviderResult<EdiCustomerOrderDto>> EdiCustomerOrdersDataProvider(GridDataProviderRequest<EdiCustomerOrderDto> request)
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||||
{
|
{
|
||||||
_ediCustomerOrders = (await EdiCustomerOrderService.GetEdiCustomerOrdersAsync() ?? new List<EdiCustomerOrderDto>()).ToList();
|
if (firstRender)
|
||||||
_ediCustomerOrders = _ediCustomerOrders.OrderByDescending(x => x.CreateDate).ToList();
|
|
||||||
|
|
||||||
if (!_filter)
|
|
||||||
{
|
{
|
||||||
_ediCustomerOrders = _ediCustomerOrders.Where(x => x.Posted == 0).ToList();
|
// ClaimsPrincipal currentUser = CustomAuthenticationStateProvider.GetCurrentUser();
|
||||||
|
//
|
||||||
|
// if (currentUser.Identity?.IsAuthenticated == false)
|
||||||
|
// {
|
||||||
|
// NavigationManager.NavigateTo("/Unauthorized");
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
await LoadData();
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
StateHasChanged();
|
|
||||||
|
|
||||||
return await Task.FromResult(request.ApplyTo(_ediCustomerOrders));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnRowDoubleClick(GridRowEventArgs<EdiCustomerOrderDto> obj)
|
private void OnRowDoubleClick(RecordDoubleClickEventArgs<EdiCustomerOrderDto> obj)
|
||||||
{
|
{
|
||||||
Guid customerOrderId = obj.Item.RowPointer;
|
Guid customerOrderId = obj.RowData.RowPointer;
|
||||||
|
|
||||||
NavigationManager.NavigateTo($"/EdiCustomerOrder/{customerOrderId}");
|
NavigationManager.NavigateTo($"/Admin/PK/EdiCustomerOrder/{customerOrderId}");
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<bool> SendOrderToSyteLine()
|
private async Task<bool> SendOrderToSyteLine()
|
||||||
{
|
{
|
||||||
if (!_selectedEdiCustomerOrders.Any()) return false;
|
if (!_selectedEdiCustomerOrders.Any()) return false;
|
||||||
|
|
||||||
_responses = new List<ResponseDto>();
|
_responses = new List<ResponseModel?>();
|
||||||
|
|
||||||
foreach (EdiCustomerOrderDto selectedEdiCustomerOrder in _selectedEdiCustomerOrders)
|
foreach (EdiCustomerOrderDto selectedEdiCustomerOrder in _selectedEdiCustomerOrders)
|
||||||
{
|
{
|
||||||
ResponseDto response = await EdiCustomerOrderService.SendOrderToSyteline(selectedEdiCustomerOrder.RowPointer, selectedEdiCustomerOrder.CustomerOrderNumber);
|
ResponseModel? response = await EdiCustomerOrderService.SendOrderToSyteline(selectedEdiCustomerOrder.RowPointer, selectedEdiCustomerOrder.CustomerOrderNumber);
|
||||||
|
|
||||||
if (response.Status == 1)
|
if (response.Status == 1)
|
||||||
{
|
{
|
||||||
@@ -145,31 +182,54 @@
|
|||||||
_responses.Add(response);
|
_responses.Add(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
await _modal.ShowAsync();
|
Visibility = true;
|
||||||
_grid?.RefreshDataAsync();
|
|
||||||
|
await LoadData();
|
||||||
|
|
||||||
|
_grid?.Refresh();
|
||||||
|
|
||||||
|
_isVisible = false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SelectedItemsChanged(HashSet<EdiCustomerOrderDto> obj)
|
private void HideModal()
|
||||||
{
|
{
|
||||||
|
Visibility = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task RowSelected(RowSelectEventArgs<EdiCustomerOrderDto> obj)
|
||||||
|
{
|
||||||
|
List<EdiCustomerOrderDto> selectedRecords = await _grid.GetSelectedRecordsAsync();
|
||||||
|
|
||||||
_isVisible = false;
|
_isVisible = false;
|
||||||
|
|
||||||
if (!obj.Any()) return;
|
if (!selectedRecords.Any()) return;
|
||||||
|
|
||||||
_selectedEdiCustomerOrders = obj.ToList();
|
_selectedEdiCustomerOrders = selectedRecords;
|
||||||
_isVisible = _selectedEdiCustomerOrders.Any(x => x.Posted == 0);
|
_isVisible = _selectedEdiCustomerOrders.Any(x => x.Posted == 0);
|
||||||
_text = obj.Count > 1 ? "Księguj zaznaczone" : "Księguj bieżący";
|
_text = selectedRecords.Count > 1 ? "Księguj zaznaczone" : "Księguj bieżący";
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task OnHideModalClick()
|
private async Task FilterChanged(ChangeEventArgs<bool?> obj)
|
||||||
{
|
{
|
||||||
await _modal.HideAsync();
|
_filter = obj.Checked;
|
||||||
|
await LoadData();
|
||||||
|
_grid?.Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FilterChanged(bool obj)
|
private async Task LoadData()
|
||||||
{
|
{
|
||||||
_filter = obj;
|
_ediCustomerOrders = await EdiCustomerOrderService.GetEdiCustomerOrdersAsync() ?? new List<EdiCustomerOrderDto>();
|
||||||
_grid?.RefreshDataAsync();
|
|
||||||
|
if (_filter == false)
|
||||||
|
{
|
||||||
|
_ediCustomerOrders = _ediCustomerOrders.Where(x => x.Posted == 0).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
_ediCustomerOrders = _ediCustomerOrders.OrderByDescending(x => x.CreateDate).ToList();
|
||||||
|
|
||||||
|
StateHasChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
163
OrdersManagement/Components/Pages/Login.razor
Normal file
163
OrdersManagement/Components/Pages/Login.razor
Normal file
@@ -0,0 +1,163 @@
|
|||||||
|
@page "/login"
|
||||||
|
|
||||||
|
@using Microsoft.AspNetCore.Authorization
|
||||||
|
@using OrdersManagement.Models
|
||||||
|
@using Syncfusion.Blazor.Inputs
|
||||||
|
@using Syncfusion.Blazor.Buttons
|
||||||
|
@using Syncfusion.Blazor.Cards
|
||||||
|
@inject UserService UserService
|
||||||
|
@inject NavigationManager NavigationManager
|
||||||
|
|
||||||
|
<div class="h-100 d-flex justify-content-center align-items-start">
|
||||||
|
<SfCard CssClass="text-center shadow" style="max-width: 500px;">
|
||||||
|
<CardHeader>
|
||||||
|
<h3 class="text-primary">Logowanie</h3>
|
||||||
|
</CardHeader>
|
||||||
|
<CardContent>
|
||||||
|
@if (!string.IsNullOrEmpty(TempPassword))
|
||||||
|
{
|
||||||
|
<div class="alert alert-info mb-3">
|
||||||
|
Twoje tymczasowe hasło to: <strong>@TempPassword</strong>. Użyj go do pierwszego logowania.
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
|
||||||
|
<EditForm Model="@LoginModel" FormName="LoginForm" OnValidSubmit="@HandleLogin">
|
||||||
|
<DataAnnotationsValidator/>
|
||||||
|
<ValidationSummary class="text-danger mb-3"/>
|
||||||
|
|
||||||
|
<div class="form-group mb-3">
|
||||||
|
<label for="login" class="d-block text-start">Login</label>
|
||||||
|
<SfTextBox ID="login" @bind-Value="LoginModel.Login" Placeholder="Wprowadź login" CssClass="e-outline"/>
|
||||||
|
<ValidationMessage For="@(() => LoginModel.Login)" ClassName="text-danger"/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group mb-3">
|
||||||
|
<label for="password" class="d-block text-start">Hasło</label>
|
||||||
|
<SfTextBox ID="password" Type="InputType.Password" @bind-Value="LoginModel.Password"
|
||||||
|
Placeholder="Wprowadź hasło" CssClass="e-outline"/>
|
||||||
|
<ValidationMessage For="@(() => LoginModel.Password)" ClassName="text-danger"/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group mt-3">
|
||||||
|
<SfButton CssClass="e-primary" IsPrimary="true" Type="submit">Zaloguj</SfButton>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@if (!string.IsNullOrEmpty(ErrorMessage))
|
||||||
|
{
|
||||||
|
<div class="alert alert-danger mt-3">@ErrorMessage</div>
|
||||||
|
}
|
||||||
|
</EditForm>
|
||||||
|
|
||||||
|
@if (ShowChangePassword)
|
||||||
|
{
|
||||||
|
<hr class="my-4"/>
|
||||||
|
<h5 class="text-success mb-3">Zmień hasło</h5>
|
||||||
|
<EditForm Model="@ChangePasswordModel" FormName="ChangePasswordForm" OnValidSubmit="@HandleChangePassword">
|
||||||
|
<DataAnnotationsValidator/>
|
||||||
|
<ValidationSummary class="text-danger mb-3"/>
|
||||||
|
|
||||||
|
<div class="form-group mb-3">
|
||||||
|
<label for="newPassword" class="d-block text-start">Nowe hasło</label>
|
||||||
|
<SfTextBox ID="newPassword" Type="InputType.Password" @bind-Value="ChangePasswordModel.NewPassword"
|
||||||
|
Placeholder="Wprowadź nowe hasło" CssClass="e-outline"/>
|
||||||
|
<ValidationMessage For="@(() => ChangePasswordModel.NewPassword)" ClassName="text-danger"/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group mb-3">
|
||||||
|
<label for="confirmPassword" class="d-block text-start">Potwierdź hasło</label>
|
||||||
|
<SfTextBox ID="confirmPassword" Type="InputType.Password" @bind-Value="ChangePasswordModel.ConfirmPassword"
|
||||||
|
Placeholder="Potwierdź nowe hasło" CssClass="e-outline"/>
|
||||||
|
<ValidationMessage For="@(() => ChangePasswordModel.ConfirmPassword)" ClassName="text-danger"/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group mt-3">
|
||||||
|
<SfButton CssClass="e-success" IsPrimary="true" Type="submit">Zmień hasło</SfButton>
|
||||||
|
</div>
|
||||||
|
</EditForm>
|
||||||
|
}
|
||||||
|
</CardContent>
|
||||||
|
<CardFooter>
|
||||||
|
<small class="text-muted">FA Krosno Manager © @(DateTime.Now.Year)</small>
|
||||||
|
</CardFooter>
|
||||||
|
</SfCard>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
private LoginModel LoginModel { get; set; } = new();
|
||||||
|
private ChangePasswordModel ChangePasswordModel { get; set; } = new();
|
||||||
|
private bool ShowChangePassword { get; set; }
|
||||||
|
private string TempPassword { get; set; }
|
||||||
|
private string ErrorMessage { get; set; }
|
||||||
|
|
||||||
|
protected override void OnInitialized()
|
||||||
|
{
|
||||||
|
TempPassword = NavigationManager.Uri.Split('?').Length > 1 ? Uri.UnescapeDataString(NavigationManager.Uri.Split('=')[1]) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task HandleLogin()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Próba logowania dla: {LoginModel.Login}");
|
||||||
|
var user = await UserService.AuthenticateUserAsync(LoginModel.Login, LoginModel.Password);
|
||||||
|
|
||||||
|
if (user != null)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Użytkownik {user.Login} znaleziony.");
|
||||||
|
if (user.IsTemporaryPassword)
|
||||||
|
{
|
||||||
|
ShowChangePassword = true;
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
NavigationManager.NavigateTo("/ScheduleOrders");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ErrorMessage = "Nieprawidłowy login lub hasło";
|
||||||
|
Console.WriteLine(ErrorMessage);
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
ErrorMessage = $"Błąd logowania: {ex.Message}";
|
||||||
|
Console.WriteLine(ErrorMessage);
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task HandleChangePassword()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (ChangePasswordModel.NewPassword == ChangePasswordModel.ConfirmPassword)
|
||||||
|
{
|
||||||
|
var user = await UserService.GetUserByUsernameAsync(LoginModel.Login);
|
||||||
|
if (user != null)
|
||||||
|
{
|
||||||
|
user.PasswordHash = BCrypt.Net.BCrypt.HashPassword(ChangePasswordModel.NewPassword);
|
||||||
|
user.IsTemporaryPassword = false;
|
||||||
|
await UserService.UpdateUserAsync(user);
|
||||||
|
ShowChangePassword = false;
|
||||||
|
LoginModel = new LoginModel();
|
||||||
|
StateHasChanged();
|
||||||
|
NavigationManager.NavigateTo("/login");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ErrorMessage = "Hasła nie są zgodne";
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
ErrorMessage = $"Błąd zmiany hasła: {ex.Message}";
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
19
OrdersManagement/Components/Pages/Main.razor
Normal file
19
OrdersManagement/Components/Pages/Main.razor
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
@page "/Main"
|
||||||
|
@using Microsoft.AspNetCore.Authorization
|
||||||
|
|
||||||
|
|
||||||
|
@inject CustomAuthenticationStateProvider CustomAuthenticationStateProvider
|
||||||
|
@inject NavigationManager NavigationManager
|
||||||
|
|
||||||
|
@code {
|
||||||
|
|
||||||
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||||
|
{
|
||||||
|
if (firstRender)
|
||||||
|
{
|
||||||
|
await CustomAuthenticationStateProvider.MarkUserAsLoggedOut();
|
||||||
|
NavigationManager.NavigateTo("/login");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,468 @@
|
|||||||
|
@page "/Warehouse/Marelli/PackList/{WzHeader:guid}"
|
||||||
|
|
||||||
|
@using OrdersManagement.Models
|
||||||
|
@using Syncfusion.Blazor.Cards
|
||||||
|
@using Syncfusion.Blazor.Grids
|
||||||
|
@using SytelineSaAppEfDataModel.Dtos
|
||||||
|
@using Syncfusion.Blazor.Navigations
|
||||||
|
@using Syncfusion.Blazor.Popups
|
||||||
|
@using Syncfusion.Blazor.Inputs
|
||||||
|
@using FilterType = Syncfusion.Blazor.Grids.FilterType
|
||||||
|
@using Syncfusion.Blazor.Buttons
|
||||||
|
@using SelectionType = Syncfusion.Blazor.Grids.SelectionType
|
||||||
|
|
||||||
|
@inject NavigationManager NavigationManager
|
||||||
|
@inject WarehouseService WarehouseService
|
||||||
|
|
||||||
|
<div class="h-100 d-flex justify-content-center align-items-start">
|
||||||
|
<SfCard CssClass="shadow" style="width: 100%; max-width: 1200px;">
|
||||||
|
<CardHeader>
|
||||||
|
<h3 class="text-primary">Packing List</h3>
|
||||||
|
</CardHeader>
|
||||||
|
<CardContent>
|
||||||
|
@* <SfCard CssClass="shadow" style="width: 100%; max-width: 1200px;"> *@
|
||||||
|
@* <CardContent> *@
|
||||||
|
@* <SfButton CssClass="e-primary" IsPrimary="true" @onclick="ChangeView">Zmień widok</SfButton> *@
|
||||||
|
@* </CardContent> *@
|
||||||
|
@* </SfCard> *@
|
||||||
|
<SfCard CssClass="shadow" style="width: 100%; max-width: 1200px;">
|
||||||
|
<CardContent>
|
||||||
|
<label for="textBox" class="form-label">Adresy Email do Wysyłki raportu:</label>
|
||||||
|
<SfTextBox ID="textBox" Placeholder="Wprowadź adresy..." @bind-Value="@EmailAddresses"
|
||||||
|
CssClass="e-outline"/>
|
||||||
|
</CardContent>
|
||||||
|
</SfCard>
|
||||||
|
<SfCard CssClass="shadow" style="width: 100%; max-width: 1200px;">
|
||||||
|
<CardContent>
|
||||||
|
<label for="textBox" class="form-label">Numer WZ:</label>
|
||||||
|
<SfTextBox ID="textBox" @bind-Value=@WzNumber CssClass="e-outline"/>
|
||||||
|
</CardContent>
|
||||||
|
</SfCard>
|
||||||
|
<SfCard CssClass="shadow" style="width: 100%; max-width: 1200px;">
|
||||||
|
<CardContent>
|
||||||
|
<label for="textBox" class="form-label">Wprowadź numer palety:</label>
|
||||||
|
<SfTextBox ID="palletNumber" Type="InputType.Number" @bind-Value="@PalletNumber"
|
||||||
|
CssClass="e-outline"/>
|
||||||
|
<label for="textBox" class="form-label">Zeskanowana wartość:</label>
|
||||||
|
<SfTextBox ID="scannedValue" ValueChange="ScanValue" @bind-Value="ScannedValue"
|
||||||
|
CssClass="e-outline" @ref="_scanner"/>
|
||||||
|
</CardContent>
|
||||||
|
</SfCard>
|
||||||
|
<SfGrid @ref="_grid"
|
||||||
|
AllowFiltering="true"
|
||||||
|
AllowPaging="true"
|
||||||
|
AllowSorting="true"
|
||||||
|
AllowSelection="true"
|
||||||
|
TValue="WzRowMarelliDto"
|
||||||
|
DataSource="@WzRowsMarelli"
|
||||||
|
EnableAdaptiveUI="true">
|
||||||
|
<SfToolbar>
|
||||||
|
<ToolbarItems>
|
||||||
|
<ToolbarItem Type="ItemType.Button" Text="Zapisz zmiany" Id="SaveButton"
|
||||||
|
PrefixIcon="e-icons e-save" OnClick="SaveChanges"/>
|
||||||
|
<ToolbarItem Type="ItemType.Button" Id="Generuj XLS i Wyślij" PrefixIcon="e-icons e-export-xls"
|
||||||
|
Text="Generuj XLS i Wyślij" OnClick="ExportXls"/>
|
||||||
|
</ToolbarItems>
|
||||||
|
</SfToolbar>
|
||||||
|
<GridColumns>
|
||||||
|
<GridColumn Field=@nameof(WzRowMarelliDto.ID) IsPrimaryKey="true" Visible="false" AllowEditing="false"
|
||||||
|
TextAlign="TextAlign.Center" HeaderText="ID" Width="70"></GridColumn>
|
||||||
|
<GridColumn Field=@nameof(WzRowMarelliDto.PalletNumber) AllowEditing="true"
|
||||||
|
TextAlign="TextAlign.Center" HeaderText="Nr Palety" Width="100"></GridColumn>
|
||||||
|
<GridColumn Field=@nameof(WzRowMarelliDto.ItemNumber) AllowEditing="false"
|
||||||
|
TextAlign="TextAlign.Center" HeaderText="Numer Indeksu Marelli"
|
||||||
|
Width="70"></GridColumn>
|
||||||
|
<GridColumn Field=@nameof(WzRowMarelliDto.EngineerNumber) AllowEditing="false" AllowFiltering="true"
|
||||||
|
TextAlign="TextAlign.Center" HeaderText="Numer Inżynieryjny" Width="100"></GridColumn>
|
||||||
|
<GridColumn Field=@nameof(WzRowMarelliDto.Quantity) AllowEditing="false" TextAlign="TextAlign.Center"
|
||||||
|
HeaderText="Ilość w Dostawie" Width="80"></GridColumn>
|
||||||
|
<GridColumn Field=@nameof(WzRowMarelliDto.OrderNumber) AllowEditing="true" TextAlign="TextAlign.Center"
|
||||||
|
HeaderText="Nr Zamówienia" Width="80"></GridColumn>
|
||||||
|
<GridColumn Field=@nameof(WzRowMarelliDto.WzNumber) AllowEditing="true" TextAlign="TextAlign.Center"
|
||||||
|
HeaderText="Nr WZ" Width="80"></GridColumn>
|
||||||
|
</GridColumns>
|
||||||
|
<GridEditSettings AllowDeleting="false"
|
||||||
|
AllowAdding="false"
|
||||||
|
AllowEditing="true"
|
||||||
|
AllowNextRowEdit="true"
|
||||||
|
AllowEditOnDblClick="true"
|
||||||
|
ShowConfirmDialog="false"
|
||||||
|
Mode="EditMode.Batch">
|
||||||
|
</GridEditSettings>
|
||||||
|
<GridFilterSettings Type="FilterType.Excel"/>
|
||||||
|
<GridPageSettings PageSize="10"/>
|
||||||
|
<GridSelectionSettings Mode="SelectionMode.Row" Type="SelectionType.Single"/>
|
||||||
|
<GridEvents RowSelected="OnRowSelected" OnBatchSave="OnBatchSave" TValue="WzRowMarelliDto"></GridEvents>
|
||||||
|
</SfGrid>
|
||||||
|
</CardContent>
|
||||||
|
|
||||||
|
<SfDialog Width="500px" Title="Informacja" IsModal="true" @bind-Visible="Visibility" AllowPrerender="true">
|
||||||
|
<DialogTemplates>
|
||||||
|
<Content>
|
||||||
|
@if (_isValid)
|
||||||
|
{
|
||||||
|
<p>Packing List został wygenerowany i wysłany!</p>
|
||||||
|
}
|
||||||
|
else if (string.IsNullOrWhiteSpace(EmailAddresses))
|
||||||
|
{
|
||||||
|
<p>Błąd: Proszę wprowadzić przynajmniej jeden <b>ADRES EMAIL</b> do wysyłki raportu!</p>
|
||||||
|
}
|
||||||
|
else if (!_isValid)
|
||||||
|
{
|
||||||
|
<p>Błąd: Nie Wszystkie linie mają wypełniony <b>NUMER PALETY</b>.<br/>Packing List nie zostanie
|
||||||
|
wygenerowany!</p>
|
||||||
|
}
|
||||||
|
</Content>
|
||||||
|
</DialogTemplates>
|
||||||
|
<DialogButtons>
|
||||||
|
<DialogButton Content="OK" IsPrimary="true" OnClick="@HideModal"/>
|
||||||
|
</DialogButtons>
|
||||||
|
</SfDialog>
|
||||||
|
|
||||||
|
<SfDialog Width="500px" Title="Błąd" IsModal="true" @bind-Visible="VisibilityPalletNumber"
|
||||||
|
AllowPrerender="true">
|
||||||
|
<DialogTemplates>
|
||||||
|
<Content>
|
||||||
|
<p>Błąd skanowania! <b>Wybierz NUMER PALETY większy niż 0</b> (Aktualnie '@PalletNumber'):</p>
|
||||||
|
</Content>
|
||||||
|
</DialogTemplates>
|
||||||
|
<DialogButtons>
|
||||||
|
<DialogButton Content="OK" IsPrimary="true" OnClick="@HideModal"/>
|
||||||
|
</DialogButtons>
|
||||||
|
</SfDialog>
|
||||||
|
|
||||||
|
<SfDialog Width="500px" Title="Błąd" IsModal="true" @bind-Visible="VisibilityIndexQty"
|
||||||
|
AllowPrerender="true">
|
||||||
|
<DialogTemplates>
|
||||||
|
<Content>
|
||||||
|
<p>Nie znaleziono indeksu z ilością sztuk ('<b>@IndexWithQty</b>') odpowiadającemu skanowanym wartościom!</p>
|
||||||
|
<p>Znaleziono indeks, który ma ilość sztuk: '<b>@IndexQty</b>'!</p>
|
||||||
|
<p><b>Uzupełnij numer palety ręcznie i kliknij 'Zapisz'!</b></p>
|
||||||
|
</Content>
|
||||||
|
</DialogTemplates>
|
||||||
|
<DialogButtons>
|
||||||
|
<DialogButton Content="OK" IsPrimary="true" OnClick="@HideModal"/>
|
||||||
|
</DialogButtons>
|
||||||
|
</SfDialog>
|
||||||
|
|
||||||
|
<SfDialog Width="500px" Title="Błąd" IsModal="true" @bind-Visible="VisibilityNotFound"
|
||||||
|
AllowPrerender="true">
|
||||||
|
<DialogTemplates>
|
||||||
|
<Content>
|
||||||
|
<p>Na liście nie znaleziono skanowanego numeru partii '<b>@NotFoundItem</b>'!</p>
|
||||||
|
</Content>
|
||||||
|
</DialogTemplates>
|
||||||
|
<DialogButtons>
|
||||||
|
<DialogButton Content="OK" IsPrimary="true" OnClick="@HideModal"/>
|
||||||
|
</DialogButtons>
|
||||||
|
</SfDialog>
|
||||||
|
<CardFooter>
|
||||||
|
<small class="text-muted">FA Krosno Manager © @(DateTime.Now.Year)</small>
|
||||||
|
</CardFooter>
|
||||||
|
</SfCard>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
[Parameter] public Guid WzHeader { get; set; }
|
||||||
|
|
||||||
|
private SfGrid<WzRowMarelliDto> _grid;
|
||||||
|
private List<WzRowMarelliDto> WzRowsMarelli { get; set; } = new();
|
||||||
|
private IDictionary<string, List<TransactionModel>> TransactionModelsByPartNumber { get; set; } = new Dictionary<string, List<TransactionModel>>();
|
||||||
|
private List<WzRowMarelliDto> ChangedRecords = new();
|
||||||
|
private WzHeaderDto _wzHeader;
|
||||||
|
private SfTextBox _scanner;
|
||||||
|
|
||||||
|
private WzRowMarelliDto? SelectedRow { get; set; }
|
||||||
|
private List<WzRowMarelliDto> SelectedRows { get; set; } = new();
|
||||||
|
|
||||||
|
private string WzNumber { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
private bool _isValid;
|
||||||
|
|
||||||
|
private bool Visibility { get; set; }
|
||||||
|
private bool VisibilityPalletNumber { get; set; }
|
||||||
|
private bool VisibilityIndexQty { get; set; }
|
||||||
|
private bool VisibilityNotFound { get; set; }
|
||||||
|
|
||||||
|
private string? EmailAddresses { get; set; } = string.Empty;
|
||||||
|
private string PalletNumber { get; set; } = "0";
|
||||||
|
|
||||||
|
private string LastScannedValue { get; set; } = string.Empty;
|
||||||
|
private string ScannedValue { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
private bool IsDisabled => SelectedRow == null;
|
||||||
|
|
||||||
|
private string IndexWithQty { get; set; } = string.Empty;
|
||||||
|
private string IndexQty { get; set; } = string.Empty;
|
||||||
|
private string NotFoundItem { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
private void HideModal()
|
||||||
|
{
|
||||||
|
Visibility = false;
|
||||||
|
VisibilityPalletNumber = false;
|
||||||
|
VisibilityIndexQty = false;
|
||||||
|
VisibilityNotFound = false;
|
||||||
|
|
||||||
|
LastScannedValue = ScannedValue;
|
||||||
|
ScannedValue = string.Empty;
|
||||||
|
IndexQty = string.Empty;
|
||||||
|
IndexWithQty = string.Empty;
|
||||||
|
NotFoundItem = string.Empty;
|
||||||
|
|
||||||
|
_scanner.FocusAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||||
|
{
|
||||||
|
if (firstRender)
|
||||||
|
{
|
||||||
|
_wzHeader = await WarehouseService.GetWzHeaderByIdAsync(WzHeader);
|
||||||
|
WzRowsMarelli = (await WarehouseService.GetWzRowsMarelliByWzHeaderId(WzHeader)).ToList();
|
||||||
|
|
||||||
|
TransactionModelsByPartNumber = await GetTransactionModels();
|
||||||
|
|
||||||
|
EmailAddresses = _wzHeader.EmailAddresses;
|
||||||
|
|
||||||
|
WzNumber = _wzHeader.WzNumbers ?? string.Empty;
|
||||||
|
|
||||||
|
await _scanner.FocusAsync();
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task SaveChanges()
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrWhiteSpace(EmailAddresses))
|
||||||
|
{
|
||||||
|
await WarehouseService.AddEmailsToWzHeaderAsync(WzHeader, EmailAddresses);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ChangedRecords.Any())
|
||||||
|
{
|
||||||
|
await UpdateRows(ChangedRecords);
|
||||||
|
}
|
||||||
|
|
||||||
|
await _grid.EndEditAsync();
|
||||||
|
await _grid.ClearSelectionAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task OnBatchSave(BeforeBatchSaveArgs<WzRowMarelliDto> obj)
|
||||||
|
{
|
||||||
|
var changes = obj.BatchChanges;
|
||||||
|
List<WzRowMarelliDto> changedRecords = changes.ChangedRecords;
|
||||||
|
|
||||||
|
if (!changedRecords.Any()) return;
|
||||||
|
|
||||||
|
await UpdateRows(changedRecords);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task ExportXls()
|
||||||
|
{
|
||||||
|
int count = WzRowsMarelli.Count(x => x.PalletNumber == null);
|
||||||
|
_isValid = count == 0;
|
||||||
|
_isValid = _isValid && !string.IsNullOrWhiteSpace(EmailAddresses);
|
||||||
|
|
||||||
|
if (_isValid)
|
||||||
|
{
|
||||||
|
await WarehouseService.AddEmailsToWzHeaderAsync(WzHeader, EmailAddresses);
|
||||||
|
await WarehouseService.GenerateXlsForMarelliAsync(WzHeader);
|
||||||
|
}
|
||||||
|
|
||||||
|
Visibility = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ScanValue(ChangedEventArgs obj)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(obj.Value)) return;
|
||||||
|
if (int.Parse(PalletNumber) <= 0)
|
||||||
|
{
|
||||||
|
VisibilityPalletNumber = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ScannedValue = obj.Value.Trim();
|
||||||
|
|
||||||
|
StateHasChanged();
|
||||||
|
|
||||||
|
TransactionModelsByPartNumber.TryGetValue(obj.Value.Trim(), out List<TransactionModel>? materialTransactionsByPartNumber);
|
||||||
|
TransactionModel? materialTransactionByPartNumber = materialTransactionsByPartNumber?.FirstOrDefault();
|
||||||
|
|
||||||
|
_grid.Query = null;
|
||||||
|
_grid.ClearFilteringAsync();
|
||||||
|
|
||||||
|
if (materialTransactionByPartNumber != null)
|
||||||
|
{
|
||||||
|
SelectedRows.Clear();
|
||||||
|
FillPalletNumber(materialTransactionByPartNumber, obj.Value.Trim());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
NotFoundItem = ScannedValue;
|
||||||
|
VisibilityNotFound = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
LastScannedValue = ScannedValue;
|
||||||
|
ScannedValue = string.Empty;
|
||||||
|
|
||||||
|
_scanner.FocusAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task FillPalletNumber(TransactionModel materialTransactionByPartNumber, string scannedValue)
|
||||||
|
{
|
||||||
|
await _grid.ClearSelectionAsync();
|
||||||
|
await _grid.Refresh();
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
|
||||||
|
List<int> selectedIndices = new List<int>();
|
||||||
|
int palletNumber = int.Parse(PalletNumber);
|
||||||
|
int rowIndex = WzRowsMarelli.FindIndex(x => x.FaIndex == materialTransactionByPartNumber.ItemNumber && x.Quantity == materialTransactionByPartNumber.Quantity);
|
||||||
|
|
||||||
|
switch (rowIndex)
|
||||||
|
{
|
||||||
|
case -1:
|
||||||
|
{
|
||||||
|
SelectedRows = WzRowsMarelli.Where(x => x.FaIndex == materialTransactionByPartNumber.ItemNumber).ToList();
|
||||||
|
|
||||||
|
rowIndex = WzRowsMarelli.FindIndex(x => x.FaIndex == SelectedRows.First().FaIndex && x.Quantity == SelectedRows.First().Quantity);
|
||||||
|
|
||||||
|
var validCombinations = FindCombinations(SelectedRows, (int?)materialTransactionByPartNumber.Quantity ?? 0);
|
||||||
|
|
||||||
|
if (!validCombinations.Any() && SelectedRows.Count > 0)
|
||||||
|
{
|
||||||
|
IndexWithQty = $"{materialTransactionByPartNumber.ItemNumber}, Qty = {materialTransactionByPartNumber.Quantity}";
|
||||||
|
IndexQty = SelectedRows.First().Quantity.ToString() ?? "0";
|
||||||
|
VisibilityIndexQty = true;
|
||||||
|
|
||||||
|
await ApplyFilter(SelectedRows);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var combination in validCombinations)
|
||||||
|
{
|
||||||
|
foreach (var record in combination)
|
||||||
|
{
|
||||||
|
record.PalletNumber = palletNumber;
|
||||||
|
ChangedRecords.Add(record);
|
||||||
|
|
||||||
|
int index = WzRowsMarelli.IndexOf(record);
|
||||||
|
|
||||||
|
if (index >= 0)
|
||||||
|
{
|
||||||
|
selectedIndices.Add(index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SelectedRows.Clear();
|
||||||
|
SelectedRows.AddRange(ChangedRecords);
|
||||||
|
|
||||||
|
SelectedRow = SelectedRows.FirstOrDefault();
|
||||||
|
|
||||||
|
await ApplyFilter(ChangedRecords);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
SelectedRow = WzRowsMarelli[rowIndex];
|
||||||
|
selectedIndices.Add(rowIndex);
|
||||||
|
|
||||||
|
SelectedRow.PalletNumber = palletNumber;
|
||||||
|
|
||||||
|
if (ChangedRecords.All(x => x.TransactionNumber != SelectedRow.TransactionNumber))
|
||||||
|
{
|
||||||
|
ChangedRecords.Add(SelectedRow);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
await SaveChanges();
|
||||||
|
ChangedRecords.Clear();
|
||||||
|
|
||||||
|
if (selectedIndices.Any())
|
||||||
|
{
|
||||||
|
await _grid.SelectRowsAsync(selectedIndices.ToArray());
|
||||||
|
}
|
||||||
|
|
||||||
|
await _grid.Refresh();
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
|
||||||
|
FocusGridRow(rowIndex);
|
||||||
|
await _scanner.FocusAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FocusGridRow(int rowIndex)
|
||||||
|
{
|
||||||
|
if (_grid.AllowPaging)
|
||||||
|
{
|
||||||
|
int pageSize = _grid.PageSettings.PageSize;
|
||||||
|
int targetPage = (rowIndex / pageSize) + 1;
|
||||||
|
_grid.GoToPageAsync(targetPage);
|
||||||
|
|
||||||
|
rowIndex %= pageSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
_grid.SelectRowAsync(rowIndex);
|
||||||
|
_grid.ScrollIntoViewAsync(rowIndex: rowIndex);
|
||||||
|
_grid.FocusAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task<IDictionary<string, List<TransactionModel>>> GetTransactionModels()
|
||||||
|
{
|
||||||
|
return await WarehouseService.GetTransactionsModels();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task UpdateRows(IList<WzRowMarelliDto> changedRecords)
|
||||||
|
{
|
||||||
|
await WarehouseService.UpdateWzRowsMarelliAsync(changedRecords);
|
||||||
|
|
||||||
|
WzRowsMarelli = (await WarehouseService.GetWzRowsMarelliByWzHeaderId(WzHeader)).ToList();
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
await _grid.Refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnRowSelected(RowSelectEventArgs<WzRowMarelliDto> obj)
|
||||||
|
{
|
||||||
|
SelectedRow = obj.Data;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<List<WzRowMarelliDto>> FindCombinations(List<WzRowMarelliDto> records, int targetSum)
|
||||||
|
{
|
||||||
|
var result = new List<List<WzRowMarelliDto>>();
|
||||||
|
var currentCombination = new List<WzRowMarelliDto>();
|
||||||
|
|
||||||
|
void Backtrack(int start, int currentSum)
|
||||||
|
{
|
||||||
|
if (currentSum == targetSum)
|
||||||
|
{
|
||||||
|
result.Add([..currentCombination]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = start; i < records.Count; i++)
|
||||||
|
{
|
||||||
|
if (currentSum + records[i].Quantity <= targetSum)
|
||||||
|
{
|
||||||
|
currentCombination.Add(records[i]);
|
||||||
|
Backtrack(i + 1, currentSum + records[i].Quantity ?? 0);
|
||||||
|
currentCombination.RemoveAt(currentCombination.Count - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Backtrack(0, 0);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task ApplyFilter(IList<WzRowMarelliDto> selectedRecords)
|
||||||
|
{
|
||||||
|
await _grid.FilterByColumnAsync(nameof(WzRowMarelliDto.ItemNumber), "equal", selectedRecords.First().ItemNumber);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ChangeView()
|
||||||
|
{
|
||||||
|
NavigationManager.NavigateTo($"/Warehouse/Marelli/PackList/{WzHeader}/Simple");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,316 @@
|
|||||||
|
@page "/Warehouse/Marelli/PackList/{WzHeader:guid}/Simple"
|
||||||
|
@using OrdersManagement.Models
|
||||||
|
@using Syncfusion.Blazor.Cards
|
||||||
|
@using SytelineSaAppEfDataModel.Dtos
|
||||||
|
@using Syncfusion.Blazor.Popups
|
||||||
|
@using Syncfusion.Blazor.Inputs
|
||||||
|
@using Syncfusion.Blazor.Buttons
|
||||||
|
|
||||||
|
@inject NavigationManager NavigationManager
|
||||||
|
@inject WarehouseService WarehouseService
|
||||||
|
|
||||||
|
<div class="h-100 d-flex justify-content-center align-items-start">
|
||||||
|
<SfCard CssClass="shadow" style="width: 100%; max-width: 1200px;">
|
||||||
|
<CardHeader>
|
||||||
|
<h3 class="text-primary">Packing List</h3>
|
||||||
|
</CardHeader>
|
||||||
|
<CardContent>
|
||||||
|
<SfCard CssClass="shadow" style="width: 100%; max-width: 1200px;" Orientation="CardOrientation.Horizontal">
|
||||||
|
<CardContent>
|
||||||
|
<SfButton CssClass="e-primary" IsPrimary="true" @onclick="ChangeView">Zmień widok</SfButton>
|
||||||
|
<SfButton CssClass="e-primary" IsPrimary="true" @onclick="ExportXls">Generuj XLS i Wyślij</SfButton>
|
||||||
|
</CardContent>
|
||||||
|
</SfCard>
|
||||||
|
<SfCard CssClass="shadow" style="width: 100%; max-width: 1200px;">
|
||||||
|
<CardContent>
|
||||||
|
<label for="textBox" class="form-label">Adresy Email do Wysyłki raportu:</label>
|
||||||
|
<SfTextBox ID="textBox" Placeholder="Wprowadź adresy..." @bind-Value="@EmailAddresses"
|
||||||
|
CssClass="e-outline"/>
|
||||||
|
</CardContent>
|
||||||
|
</SfCard>
|
||||||
|
<SfCard CssClass="shadow" style="width: 100%; max-width: 1200px;">
|
||||||
|
<CardContent>
|
||||||
|
<label for="textBox" class="form-label">Numer WZ:</label>
|
||||||
|
<SfTextBox ID="textBox" @bind-Value=@WzNumber CssClass="e-outline"/>
|
||||||
|
</CardContent>
|
||||||
|
</SfCard>
|
||||||
|
<SfCard CssClass="shadow" style="width: 100%; max-width: 1200px;">
|
||||||
|
<CardContent>
|
||||||
|
<label for="textBox" class="form-label">Wprowadź numer palety:</label>
|
||||||
|
<SfTextBox ID="palletNumber" Type="InputType.Number" @bind-Value="@PalletNumber"
|
||||||
|
CssClass="e-outline"/>
|
||||||
|
<label for="textBox" class="form-label">Zeskanowana wartość:</label>
|
||||||
|
<SfTextBox ID="scannedValue" ValueChange="ScanValue" @bind-Value="ScannedValue"
|
||||||
|
CssClass="e-outline" @ref="_scanner"/>
|
||||||
|
</CardContent>
|
||||||
|
</SfCard>
|
||||||
|
<SfCard CssClass="shadow" style="width: 100%; max-width: 1200px;">
|
||||||
|
<CardContent>
|
||||||
|
<label for="textBox" class="form-label">Numer Indeksu FA:</label>
|
||||||
|
<SfTextBox ID="itemNumber" @bind-Value="@ItemNumber"
|
||||||
|
CssClass="e-outline" Readonly="true"/>
|
||||||
|
<label for="textBox" class="form-label">Ilość w Dostawie:</label>
|
||||||
|
<SfTextBox ID="qty" Type="InputType.Number" @bind-Value="@Qty"
|
||||||
|
CssClass="e-outline" Readonly="true"/>
|
||||||
|
<label for="textBox" class="form-label">Numer Palety:</label>
|
||||||
|
<SfTextBox ID="palletNumberOutput" Type="InputType.Number" @bind-Value="@PalletNumberOutput"
|
||||||
|
CssClass="e-outline" Readonly="true"/>
|
||||||
|
</CardContent>
|
||||||
|
</SfCard>
|
||||||
|
</CardContent>
|
||||||
|
|
||||||
|
<SfDialog Width="500px" Title="Informacja" IsModal="true" @bind-Visible="Visibility" AllowPrerender="true">
|
||||||
|
<DialogTemplates>
|
||||||
|
<Content>
|
||||||
|
@if (_isValid)
|
||||||
|
{
|
||||||
|
<p>Packing List został wygenerowany i wysłany!</p>
|
||||||
|
}
|
||||||
|
else if (string.IsNullOrWhiteSpace(EmailAddresses))
|
||||||
|
{
|
||||||
|
<p>Błąd: Proszę wprowadzić przynajmniej jeden <b>ADRES EMAIL</b> do wysyłki raportu!</p>
|
||||||
|
}
|
||||||
|
else if (!_isValid)
|
||||||
|
{
|
||||||
|
<p>Błąd: Nie Wszystkie linie mają wypełniony <b>NUMER PALETY</b>.<br/>Packing List nie zostanie
|
||||||
|
wygenerowany!</p>
|
||||||
|
}
|
||||||
|
</Content>
|
||||||
|
</DialogTemplates>
|
||||||
|
<DialogButtons>
|
||||||
|
<DialogButton Content="OK" IsPrimary="true" OnClick="@HideModal"/>
|
||||||
|
</DialogButtons>
|
||||||
|
</SfDialog>
|
||||||
|
|
||||||
|
<SfDialog Width="500px" Title="Błąd" IsModal="true" @bind-Visible="VisibilityPalletNumber"
|
||||||
|
AllowPrerender="true">
|
||||||
|
<DialogTemplates>
|
||||||
|
<Content>
|
||||||
|
<p>Błąd skanowania! <b>Wybierz NUMER PALETY większy niż 0</b> (Aktualnie '@PalletNumber'):</p>
|
||||||
|
</Content>
|
||||||
|
</DialogTemplates>
|
||||||
|
<DialogButtons>
|
||||||
|
<DialogButton Content="OK" IsPrimary="true" OnClick="@HideModal"/>
|
||||||
|
</DialogButtons>
|
||||||
|
</SfDialog>
|
||||||
|
|
||||||
|
<CardFooter>
|
||||||
|
<small class="text-muted">FA Krosno Manager © @(DateTime.Now.Year)</small>
|
||||||
|
</CardFooter>
|
||||||
|
</SfCard>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
[Parameter] public Guid WzHeader { get; set; }
|
||||||
|
|
||||||
|
private List<WzRowMarelliDto> WzRowsMarelli { get; set; } = new();
|
||||||
|
private IDictionary<string, List<TransactionModel>> TransactionModelsByPartNumber { get; set; } = new Dictionary<string, List<TransactionModel>>();
|
||||||
|
private List<WzRowMarelliDto> ChangedRecords = new();
|
||||||
|
private WzHeaderDto _wzHeader;
|
||||||
|
private SfTextBox _scanner;
|
||||||
|
|
||||||
|
private string ItemNumber { get; set; } = string.Empty;
|
||||||
|
private string Qty { get; set; } = "0";
|
||||||
|
private string PalletNumberOutput { get; set; } = "0";
|
||||||
|
|
||||||
|
private string WzNumber { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
private WzRowMarelliDto? SelectedRow { get; set; }
|
||||||
|
private List<WzRowMarelliDto> SelectedRows { get; set; } = new();
|
||||||
|
|
||||||
|
private bool _isValid;
|
||||||
|
|
||||||
|
public bool Visibility { get; set; }
|
||||||
|
public bool VisibilityPalletNumber { get; set; }
|
||||||
|
|
||||||
|
private string? EmailAddresses { get; set; } = string.Empty;
|
||||||
|
private string PalletNumber { get; set; } = "0";
|
||||||
|
|
||||||
|
private string LastScannedValue { get; set; } = string.Empty;
|
||||||
|
private string ScannedValue { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
private void HideModal()
|
||||||
|
{
|
||||||
|
VisibilityPalletNumber = false;
|
||||||
|
Visibility = false;
|
||||||
|
|
||||||
|
LastScannedValue = ScannedValue;
|
||||||
|
ScannedValue = string.Empty;
|
||||||
|
|
||||||
|
_scanner.FocusAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||||
|
{
|
||||||
|
if (firstRender)
|
||||||
|
{
|
||||||
|
_wzHeader = await WarehouseService.GetWzHeaderByIdAsync(WzHeader);
|
||||||
|
WzRowsMarelli = (await WarehouseService.GetWzRowsMarelliByWzHeaderId(WzHeader)).ToList();
|
||||||
|
|
||||||
|
TransactionModelsByPartNumber = await GetTransactionModels();
|
||||||
|
|
||||||
|
EmailAddresses = _wzHeader.EmailAddresses;
|
||||||
|
|
||||||
|
WzNumber = _wzHeader.WzNumbers ?? string.Empty;
|
||||||
|
|
||||||
|
await _scanner.FocusAsync();
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task SaveChanges()
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrWhiteSpace(EmailAddresses))
|
||||||
|
{
|
||||||
|
await WarehouseService.AddEmailsToWzHeaderAsync(WzHeader, EmailAddresses);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ChangedRecords.Any())
|
||||||
|
{
|
||||||
|
await UpdateRows(ChangedRecords);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task ExportXls()
|
||||||
|
{
|
||||||
|
int count = WzRowsMarelli.Count(x => x.PalletNumber == null);
|
||||||
|
|
||||||
|
_isValid = count == 0;
|
||||||
|
_isValid = _isValid && !string.IsNullOrWhiteSpace(EmailAddresses);
|
||||||
|
|
||||||
|
if (_isValid)
|
||||||
|
{
|
||||||
|
await WarehouseService.AddEmailsToWzHeaderAsync(WzHeader, EmailAddresses);
|
||||||
|
await WarehouseService.GenerateXlsForMarelliAsync(WzHeader);
|
||||||
|
}
|
||||||
|
|
||||||
|
Visibility = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ScanValue(ChangedEventArgs obj)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(obj.Value)) return;
|
||||||
|
if (int.Parse(PalletNumber) <= 0)
|
||||||
|
{
|
||||||
|
VisibilityPalletNumber = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ScannedValue = obj.Value.Trim();
|
||||||
|
|
||||||
|
StateHasChanged();
|
||||||
|
|
||||||
|
TransactionModelsByPartNumber.TryGetValue(obj.Value.Trim(), out List<TransactionModel>? materialTransactionsByPartNumber);
|
||||||
|
TransactionModel? materialTransactionByPartNumber = materialTransactionsByPartNumber?.FirstOrDefault();
|
||||||
|
|
||||||
|
if (materialTransactionByPartNumber != null)
|
||||||
|
{
|
||||||
|
FillPalletNumber(materialTransactionByPartNumber, obj.Value.Trim());
|
||||||
|
}
|
||||||
|
|
||||||
|
LastScannedValue = ScannedValue;
|
||||||
|
ScannedValue = string.Empty;
|
||||||
|
|
||||||
|
_scanner.FocusAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task FillPalletNumber(TransactionModel materialTransactionByPartNumber, string scannedValue)
|
||||||
|
{
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
|
||||||
|
int palletNumber = int.Parse(PalletNumber);
|
||||||
|
int rowIndex = WzRowsMarelli.FindIndex(x => x.FaIndex == materialTransactionByPartNumber.ItemNumber && x.Quantity == materialTransactionByPartNumber.Quantity);
|
||||||
|
|
||||||
|
switch (rowIndex)
|
||||||
|
{
|
||||||
|
case -1:
|
||||||
|
{
|
||||||
|
SelectedRows = WzRowsMarelli.Where(x => x.FaIndex == materialTransactionByPartNumber.ItemNumber).ToList();
|
||||||
|
|
||||||
|
var validCombinations = FindCombinations(SelectedRows, (int?)materialTransactionByPartNumber.Quantity ?? 0);
|
||||||
|
|
||||||
|
foreach (var combination in validCombinations)
|
||||||
|
{
|
||||||
|
foreach (var record in combination)
|
||||||
|
{
|
||||||
|
record.PalletNumber = palletNumber;
|
||||||
|
ChangedRecords.Add(record);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SelectedRows.Clear();
|
||||||
|
SelectedRows.AddRange(ChangedRecords);
|
||||||
|
|
||||||
|
SelectedRow = SelectedRows.FirstOrDefault();
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
SelectedRow = WzRowsMarelli[rowIndex];
|
||||||
|
|
||||||
|
SelectedRow.PalletNumber = palletNumber;
|
||||||
|
|
||||||
|
if (ChangedRecords.All(x => x.TransactionNumber != SelectedRow.TransactionNumber))
|
||||||
|
{
|
||||||
|
ChangedRecords.Add(SelectedRow);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
await SaveChanges();
|
||||||
|
ChangedRecords.Clear();
|
||||||
|
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
|
||||||
|
await _scanner.FocusAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task<IDictionary<string, List<TransactionModel>>> GetTransactionModels()
|
||||||
|
{
|
||||||
|
return await WarehouseService.GetTransactionsModels();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task UpdateRows(IList<WzRowMarelliDto> changedRecords)
|
||||||
|
{
|
||||||
|
await WarehouseService.UpdateWzRowsMarelliAsync(changedRecords);
|
||||||
|
|
||||||
|
WzRowsMarelli = (await WarehouseService.GetWzRowsMarelliByWzHeaderId(WzHeader)).ToList();
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<List<WzRowMarelliDto>> FindCombinations(List<WzRowMarelliDto> records, int targetSum)
|
||||||
|
{
|
||||||
|
var result = new List<List<WzRowMarelliDto>>();
|
||||||
|
var currentCombination = new List<WzRowMarelliDto>();
|
||||||
|
|
||||||
|
void Backtrack(int start, int currentSum)
|
||||||
|
{
|
||||||
|
if (currentSum == targetSum)
|
||||||
|
{
|
||||||
|
result.Add(new List<WzRowMarelliDto>(currentCombination));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = start; i < records.Count; i++)
|
||||||
|
{
|
||||||
|
if (currentSum + records[i].Quantity <= targetSum)
|
||||||
|
{
|
||||||
|
currentCombination.Add(records[i]);
|
||||||
|
Backtrack(i + 1, currentSum + records[i].Quantity ?? 0);
|
||||||
|
currentCombination.RemoveAt(currentCombination.Count - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Backtrack(0, 0);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ChangeView()
|
||||||
|
{
|
||||||
|
NavigationManager.NavigateTo($"/Warehouse/Marelli/PackList/{WzHeader}");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,568 @@
|
|||||||
|
@page "/Warehouse/Meyle/PackList/{WzHeader:guid}"
|
||||||
|
|
||||||
|
@using OrdersManagement.Models
|
||||||
|
@using Syncfusion.Blazor.Cards
|
||||||
|
@using Syncfusion.Blazor.Grids
|
||||||
|
@using SytelineSaAppEfDataModel.Dtos
|
||||||
|
@using Syncfusion.Blazor.Navigations
|
||||||
|
@using Syncfusion.Blazor.Popups
|
||||||
|
@using Syncfusion.Blazor.Inputs
|
||||||
|
@using FilterType = Syncfusion.Blazor.Grids.FilterType
|
||||||
|
@using Syncfusion.Blazor.Buttons
|
||||||
|
@using SelectionType = Syncfusion.Blazor.Grids.SelectionType
|
||||||
|
|
||||||
|
@inject NavigationManager NavigationManager
|
||||||
|
@inject WarehouseService WarehouseService
|
||||||
|
|
||||||
|
<div class="h-100 d-flex justify-content-center align-items-start">
|
||||||
|
<SfCard CssClass="shadow" style="width: 100%; max-width: 1200px;">
|
||||||
|
<CardHeader>
|
||||||
|
<h3 class="text-primary">Packing List</h3>
|
||||||
|
</CardHeader>
|
||||||
|
<CardContent>
|
||||||
|
<SfCard CssClass="shadow" style="width: 100%; max-width: 1200px;">
|
||||||
|
<CardContent>
|
||||||
|
<SfButton CssClass="e-primary" IsPrimary="true" @onclick="ChangeView">Zmień widok</SfButton>
|
||||||
|
</CardContent>
|
||||||
|
</SfCard>
|
||||||
|
<SfCard CssClass="shadow" style="width: 100%; max-width: 1200px;">
|
||||||
|
<CardContent>
|
||||||
|
<label for="textBox" class="form-label">Adresy Email do Wysyłki raportu:</label>
|
||||||
|
<SfTextBox ID="textBox" Placeholder="Wprowadź adresy..." @bind-Value="@EmailAddresses"
|
||||||
|
CssClass="e-outline"/>
|
||||||
|
</CardContent>
|
||||||
|
</SfCard>
|
||||||
|
<SfCard CssClass="shadow" style="width: 100%; max-width: 1200px;">
|
||||||
|
<CardContent>
|
||||||
|
<label for="textBox" class="form-label">Numer WZ:</label>
|
||||||
|
<SfTextBox ID="textBox" @bind-Value=@WzNumber CssClass="e-outline"/>
|
||||||
|
</CardContent>
|
||||||
|
</SfCard>
|
||||||
|
<SfCard CssClass="shadow" style="width: 100%; max-width: 1200px;">
|
||||||
|
<CardContent>
|
||||||
|
<label for="textBox" class="form-label">Wprowadź numer palety:</label>
|
||||||
|
<SfTextBox ID="palletNumber" Type="InputType.Number" @bind-Value="@PalletNumber"
|
||||||
|
CssClass="e-outline"/>
|
||||||
|
<label for="textBox" class="form-label">Zeskanowana wartość:</label>
|
||||||
|
<SfTextBox ID="scannedValue" ValueChange="ScanValue" @bind-Value="ScannedValue"
|
||||||
|
CssClass="e-outline" @ref="_scanner"/>
|
||||||
|
</CardContent>
|
||||||
|
</SfCard>
|
||||||
|
<SfGrid @ref="_grid"
|
||||||
|
AllowFiltering="true"
|
||||||
|
AllowPaging="true"
|
||||||
|
AllowSorting="true"
|
||||||
|
AllowSelection="true"
|
||||||
|
TValue="WzRowMeyleDto"
|
||||||
|
DataSource="@WzRowsMeyle"
|
||||||
|
EnableAdaptiveUI="true">
|
||||||
|
<SfToolbar>
|
||||||
|
<ToolbarItems>
|
||||||
|
<ToolbarItem Type="ItemType.Button" Text="Zapisz zmiany" Id="SaveButton"
|
||||||
|
PrefixIcon="e-icons e-save" OnClick="SaveChanges"/>
|
||||||
|
<ToolbarItem Type="ItemType.Button" Text="Podziel Linię" Id="SplitLineButton"
|
||||||
|
PrefixIcon="e-icons e-split-horizontal" OnClick="ShowSplitDialog"
|
||||||
|
Disabled="IsDisabled"/>
|
||||||
|
<ToolbarItem Type="ItemType.Button" Id="Generuj XLS i Wyślij" PrefixIcon="e-icons e-export-xls"
|
||||||
|
Text="Generuj XLS i Wyślij" OnClick="ExportXls"/>
|
||||||
|
</ToolbarItems>
|
||||||
|
</SfToolbar>
|
||||||
|
<GridColumns>
|
||||||
|
<GridColumn Field=@nameof(WzRowMeyleDto.ID) IsPrimaryKey="true" Visible="false" AllowEditing="false"
|
||||||
|
TextAlign="TextAlign.Center" HeaderText="ID" Width="70"></GridColumn>
|
||||||
|
<GridColumn Field=@nameof(WzRowMeyleDto.OrderNumber) AllowEditing="false"
|
||||||
|
TextAlign="TextAlign.Center" HeaderText="Numer Zamówienia Meyle"
|
||||||
|
Width="70"></GridColumn>
|
||||||
|
<GridColumn Field=@nameof(WzRowMeyleDto.FaIndex) AllowEditing="false" AllowFiltering="true"
|
||||||
|
TextAlign="TextAlign.Center" HeaderText="Numer Indeksu FA" Width="100"></GridColumn>
|
||||||
|
<GridColumn Field=@nameof(WzRowMeyleDto.ItemNumber) AllowEditing="false"
|
||||||
|
TextAlign="TextAlign.Center" HeaderText="Numer Indeksu Meyle" Width="100"></GridColumn>
|
||||||
|
<GridColumn Field=@nameof(WzRowMeyleDto.Quantity) AllowEditing="false" TextAlign="TextAlign.Center"
|
||||||
|
HeaderText="Ilość w Dostawie" Width="80"></GridColumn>
|
||||||
|
<GridColumn Field=@nameof(WzRowMeyleDto.PalletNumber) AllowEditing="true"
|
||||||
|
TextAlign="TextAlign.Center" HeaderText="Nr Palety" Width="100"></GridColumn>
|
||||||
|
<GridColumn Field=@nameof(WzRowMeyleDto.PartNumberSl) AllowEditing="true"
|
||||||
|
TextAlign="TextAlign.Center"
|
||||||
|
HeaderText="Nr Partii SL" Width="80"></GridColumn>
|
||||||
|
<GridColumn Field=@nameof(WzRowMeyleDto.PartNumber) AllowEditing="true" TextAlign="TextAlign.Center"
|
||||||
|
HeaderText="Nr Partii Meyle" Width="80"></GridColumn>
|
||||||
|
</GridColumns>
|
||||||
|
<GridEditSettings AllowDeleting="false"
|
||||||
|
AllowAdding="false"
|
||||||
|
AllowEditing="true"
|
||||||
|
AllowNextRowEdit="true"
|
||||||
|
AllowEditOnDblClick="true"
|
||||||
|
ShowConfirmDialog="false"
|
||||||
|
Mode="EditMode.Batch">
|
||||||
|
</GridEditSettings>
|
||||||
|
<GridFilterSettings Type="FilterType.Excel"/>
|
||||||
|
<GridPageSettings PageSize="10"/>
|
||||||
|
<GridSelectionSettings Mode="SelectionMode.Row" Type="SelectionType.Single"/>
|
||||||
|
<GridEvents RowSelected="OnRowSelected" OnBatchSave="OnBatchSave" TValue="WzRowMeyleDto"></GridEvents>
|
||||||
|
</SfGrid>
|
||||||
|
</CardContent>
|
||||||
|
|
||||||
|
<SfDialog Width="500px" Title="Informacja" IsModal="true" @bind-Visible="Visibility" AllowPrerender="true">
|
||||||
|
<DialogTemplates>
|
||||||
|
<Content>
|
||||||
|
@if (_isValid)
|
||||||
|
{
|
||||||
|
<p>Packing List został wygenerowany i wysłany!</p>
|
||||||
|
}
|
||||||
|
else if (string.IsNullOrWhiteSpace(EmailAddresses))
|
||||||
|
{
|
||||||
|
<p>Błąd: Proszę wprowadzić przynajmniej jeden <b>ADRES EMAIL</b> do wysyłki raportu!</p>
|
||||||
|
}
|
||||||
|
else if (!_isValid)
|
||||||
|
{
|
||||||
|
<p>Błąd: Nie Wszystkie linie mają wypełniony <b>NUMER PALETY</b>.<br/>Packing List nie zostanie
|
||||||
|
wygenerowany!</p>
|
||||||
|
}
|
||||||
|
</Content>
|
||||||
|
</DialogTemplates>
|
||||||
|
<DialogButtons>
|
||||||
|
<DialogButton Content="OK" IsPrimary="true" OnClick="@HideModal"/>
|
||||||
|
</DialogButtons>
|
||||||
|
</SfDialog>
|
||||||
|
|
||||||
|
<SfDialog Width="500px" Title="Błąd" IsModal="true" @bind-Visible="VisibilityValidation" AllowPrerender="true">
|
||||||
|
<DialogTemplates>
|
||||||
|
<Content>
|
||||||
|
<p>Błąd skanowania! Wystąpił jeden z wyjątków (Zeskanowana wartość '<b>@ScannedValue</b>'):</p>
|
||||||
|
<ul>
|
||||||
|
<li><p>Zeskanowano niepoprawny Numer Partii SL (nieistniejący w tabeli)</p></li>
|
||||||
|
<li><p>Zeskanowano niepoprawny numer Partii Meyle (niezaczynający się od
|
||||||
|
<b>@($"{DateTime.Now.Year - 2000}X")</b>)</p></li>
|
||||||
|
<li><p>Numer Palety nie jest większy niż 0 (aktualnie wybrany numer palety:
|
||||||
|
'<b>@PalletNumber</b>')</p></li>
|
||||||
|
</ul>
|
||||||
|
</Content>
|
||||||
|
</DialogTemplates>
|
||||||
|
<DialogButtons>
|
||||||
|
<DialogButton Content="OK" IsPrimary="true" OnClick="@HideModal"/>
|
||||||
|
</DialogButtons>
|
||||||
|
</SfDialog>
|
||||||
|
|
||||||
|
<SfDialog Width="500px" Title="Błąd" IsModal="true" @bind-Visible="VisibilityPalletNumber"
|
||||||
|
AllowPrerender="true">
|
||||||
|
<DialogTemplates>
|
||||||
|
<Content>
|
||||||
|
<p>Błąd skanowania! <b>Wybierz NUMER PALETY większy niż 0</b> (Aktualnie '@PalletNumber'):</p>
|
||||||
|
</Content>
|
||||||
|
</DialogTemplates>
|
||||||
|
<DialogButtons>
|
||||||
|
<DialogButton Content="OK" IsPrimary="true" OnClick="@HideModal"/>
|
||||||
|
</DialogButtons>
|
||||||
|
</SfDialog>
|
||||||
|
|
||||||
|
<SfDialog Width="500px" Title="Podziel Linię" IsModal="true" @bind-Visible="VisibilityLineSplitter"
|
||||||
|
AllowPrerender="true">
|
||||||
|
<DialogTemplates>
|
||||||
|
<Content>
|
||||||
|
<label for="textBox" class="form-label">Podziel linię <b>@SelectedRow?.FaIndex</b> podając ilość
|
||||||
|
sztuk dla nowej linii:</label>
|
||||||
|
<SfTextBox ID="newQuantity" Type="InputType.Number" @bind-Value="@NewQuantity"
|
||||||
|
CssClass="e-outline"/>
|
||||||
|
</Content>
|
||||||
|
</DialogTemplates>
|
||||||
|
<DialogButtons>
|
||||||
|
<DialogButton Content="Zapisz" IsPrimary="true" OnClick="@SplitLine"/>
|
||||||
|
<DialogButton Content="Anuluj" OnClick="@HideModal"></DialogButton>
|
||||||
|
</DialogButtons>
|
||||||
|
</SfDialog>
|
||||||
|
|
||||||
|
<CardFooter>
|
||||||
|
<small class="text-muted">FA Krosno Manager © @(DateTime.Now.Year)</small>
|
||||||
|
</CardFooter>
|
||||||
|
</SfCard>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
[Parameter] public Guid WzHeader { get; set; }
|
||||||
|
|
||||||
|
private SfGrid<WzRowMeyleDto> _grid;
|
||||||
|
private List<WzRowMeyleDto> WzRowsMeyle { get; set; } = new();
|
||||||
|
private IDictionary<string, List<TransactionModel>> TransactionModelsByPartNumber { get; set; } = new Dictionary<string, List<TransactionModel>>();
|
||||||
|
private List<WzRowMeyleDto> ChangedRecords = new();
|
||||||
|
private WzHeaderDto _wzHeader;
|
||||||
|
private SfTextBox _scanner;
|
||||||
|
|
||||||
|
private WzRowMeyleDto? SelectedRow { get; set; }
|
||||||
|
private List<WzRowMeyleDto> SelectedRows { get; set; } = new();
|
||||||
|
|
||||||
|
private string WzNumber { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
private bool _isValid;
|
||||||
|
|
||||||
|
private bool Visibility { get; set; }
|
||||||
|
private bool VisibilityValidation { get; set; }
|
||||||
|
private bool VisibilityLineSplitter { get; set; }
|
||||||
|
public bool VisibilityPalletNumber { get; set; }
|
||||||
|
|
||||||
|
private string? EmailAddresses { get; set; } = string.Empty;
|
||||||
|
private string PalletNumber { get; set; } = "0";
|
||||||
|
|
||||||
|
private string LastScannedValue { get; set; } = string.Empty;
|
||||||
|
private string ScannedValue { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
private string NewQuantity { get; set; } = "0";
|
||||||
|
|
||||||
|
private bool IsDisabled => SelectedRow == null;
|
||||||
|
|
||||||
|
private void HideModal()
|
||||||
|
{
|
||||||
|
Visibility = false;
|
||||||
|
VisibilityValidation = false;
|
||||||
|
VisibilityLineSplitter = false;
|
||||||
|
VisibilityPalletNumber = false;
|
||||||
|
|
||||||
|
LastScannedValue = ScannedValue;
|
||||||
|
ScannedValue = string.Empty;
|
||||||
|
|
||||||
|
_scanner.FocusAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||||
|
{
|
||||||
|
if (firstRender)
|
||||||
|
{
|
||||||
|
_wzHeader = await WarehouseService.GetWzHeaderByIdAsync(WzHeader);
|
||||||
|
WzRowsMeyle = (await WarehouseService.GetWzRowsMeyleByWzHeaderId(WzHeader)).ToList();
|
||||||
|
|
||||||
|
TransactionModelsByPartNumber = await GetTransactionModels();
|
||||||
|
|
||||||
|
EmailAddresses = _wzHeader.EmailAddresses;
|
||||||
|
|
||||||
|
WzNumber = _wzHeader.WzNumbers ?? string.Empty;
|
||||||
|
|
||||||
|
await _scanner.FocusAsync();
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task SaveChanges()
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrWhiteSpace(EmailAddresses))
|
||||||
|
{
|
||||||
|
await WarehouseService.AddEmailsToWzHeaderAsync(WzHeader, EmailAddresses);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ChangedRecords.Any())
|
||||||
|
{
|
||||||
|
await UpdateRows(ChangedRecords);
|
||||||
|
}
|
||||||
|
|
||||||
|
await _grid.EndEditAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task OnBatchSave(BeforeBatchSaveArgs<WzRowMeyleDto> obj)
|
||||||
|
{
|
||||||
|
var changes = obj.BatchChanges;
|
||||||
|
List<WzRowMeyleDto> changedRecords = changes.ChangedRecords;
|
||||||
|
|
||||||
|
if (!changedRecords.Any()) return;
|
||||||
|
|
||||||
|
await UpdateRows(changedRecords);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task ExportXls()
|
||||||
|
{
|
||||||
|
int count = WzRowsMeyle.Count(x => x.PalletNumber == null);
|
||||||
|
|
||||||
|
_isValid = count == 0;
|
||||||
|
_isValid = _isValid && !string.IsNullOrWhiteSpace(EmailAddresses);
|
||||||
|
|
||||||
|
if (_isValid)
|
||||||
|
{
|
||||||
|
await WarehouseService.AddEmailsToWzHeaderAsync(WzHeader, EmailAddresses);
|
||||||
|
await WarehouseService.GenerateXlsForMeyleAsync(WzHeader);
|
||||||
|
}
|
||||||
|
|
||||||
|
Visibility = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ScanValue(ChangedEventArgs obj)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(obj.Value)) return;
|
||||||
|
if (int.Parse(PalletNumber) <= 0)
|
||||||
|
{
|
||||||
|
VisibilityPalletNumber = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ScannedValue = obj.Value.Trim();
|
||||||
|
|
||||||
|
StateHasChanged();
|
||||||
|
|
||||||
|
TransactionModelsByPartNumber.TryGetValue(obj.Value.Trim(), out List<TransactionModel>? materialTransactionsByPartNumber);
|
||||||
|
TransactionModel? materialTransactionByPartNumber = materialTransactionsByPartNumber?.FirstOrDefault();
|
||||||
|
|
||||||
|
if (materialTransactionByPartNumber == null && IsValidScannedValue(obj.Value))
|
||||||
|
{
|
||||||
|
FillMeylePartNumber(ScannedValue);
|
||||||
|
|
||||||
|
LastScannedValue = ScannedValue;
|
||||||
|
ScannedValue = string.Empty;
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_grid.Query = null;
|
||||||
|
_grid.ClearFilteringAsync();
|
||||||
|
|
||||||
|
if (materialTransactionByPartNumber != null)
|
||||||
|
{
|
||||||
|
SelectedRows.Clear();
|
||||||
|
FillFaPartNumberAndPalletNumber(materialTransactionByPartNumber, obj.Value.Trim());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (materialTransactionByPartNumber == null)
|
||||||
|
{
|
||||||
|
ShowValidationMessage();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
LastScannedValue = ScannedValue;
|
||||||
|
ScannedValue = string.Empty;
|
||||||
|
|
||||||
|
_scanner.FocusAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool IsValidScannedValue(string scannedValue)
|
||||||
|
{
|
||||||
|
int year = DateTime.Now.Year - 2000;
|
||||||
|
|
||||||
|
string format = $"{year}X";
|
||||||
|
|
||||||
|
return scannedValue.StartsWith(format);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task FillMeylePartNumber(string scannedValue)
|
||||||
|
{
|
||||||
|
var rowIndex = WzRowsMeyle.FindIndex(x => x.FaIndex == SelectedRow?.FaIndex && x.Quantity == SelectedRow?.Quantity);
|
||||||
|
|
||||||
|
if (SelectedRow != null && !SelectedRows.Any())
|
||||||
|
{
|
||||||
|
SelectedRow.PartNumber = scannedValue;
|
||||||
|
ChangedRecords.Add(SelectedRow);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (WzRowMeyleDto wzRowMeyleDto in SelectedRows)
|
||||||
|
{
|
||||||
|
wzRowMeyleDto.PartNumber = scannedValue;
|
||||||
|
ChangedRecords.Add(wzRowMeyleDto);
|
||||||
|
}
|
||||||
|
|
||||||
|
await SaveChanges();
|
||||||
|
|
||||||
|
ChangedRecords.Clear();
|
||||||
|
SelectedRows.Clear();
|
||||||
|
|
||||||
|
FocusGridRow(rowIndex);
|
||||||
|
await _scanner.FocusAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task FillFaPartNumberAndPalletNumber(TransactionModel materialTransactionByPartNumber, string scannedValue)
|
||||||
|
{
|
||||||
|
await _grid.ClearSelectionAsync();
|
||||||
|
await _grid.Refresh();
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
|
||||||
|
List<int> selectedIndices = new List<int>();
|
||||||
|
int palletNumber = int.Parse(PalletNumber);
|
||||||
|
int rowIndex = WzRowsMeyle.FindIndex(x => x.FaIndex == materialTransactionByPartNumber.ItemNumber && x.Quantity == materialTransactionByPartNumber.Quantity);
|
||||||
|
|
||||||
|
switch (rowIndex)
|
||||||
|
{
|
||||||
|
case -1:
|
||||||
|
{
|
||||||
|
SelectedRows = WzRowsMeyle.Where(x => x.FaIndex == materialTransactionByPartNumber.ItemNumber).ToList();
|
||||||
|
|
||||||
|
if (SelectedRows.Count == 0)
|
||||||
|
{
|
||||||
|
ShowValidationMessage();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
rowIndex = WzRowsMeyle.FindIndex(x => x.FaIndex == SelectedRows.First().FaIndex && x.Quantity == SelectedRows.First().Quantity);
|
||||||
|
|
||||||
|
var validCombinations = FindCombinations(SelectedRows, (int?)materialTransactionByPartNumber.Quantity ?? 0);
|
||||||
|
|
||||||
|
foreach (var combination in validCombinations)
|
||||||
|
{
|
||||||
|
foreach (var record in combination)
|
||||||
|
{
|
||||||
|
record.PartNumberSl = scannedValue;
|
||||||
|
record.PalletNumber = palletNumber;
|
||||||
|
ChangedRecords.Add(record);
|
||||||
|
|
||||||
|
int index = WzRowsMeyle.IndexOf(record);
|
||||||
|
|
||||||
|
if (index >= 0)
|
||||||
|
{
|
||||||
|
selectedIndices.Add(index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SelectedRows.Clear();
|
||||||
|
SelectedRows.AddRange(ChangedRecords);
|
||||||
|
|
||||||
|
SelectedRow = SelectedRows.FirstOrDefault();
|
||||||
|
|
||||||
|
await ApplyFilter(ChangedRecords);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
SelectedRow = WzRowsMeyle[rowIndex];
|
||||||
|
selectedIndices.Add(rowIndex);
|
||||||
|
|
||||||
|
SelectedRow.PartNumberSl = scannedValue;
|
||||||
|
SelectedRow.PalletNumber = palletNumber;
|
||||||
|
|
||||||
|
if (ChangedRecords.All(x => x.TransactionNumber != SelectedRow.TransactionNumber))
|
||||||
|
{
|
||||||
|
ChangedRecords.Add(SelectedRow);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
await SaveChanges();
|
||||||
|
ChangedRecords.Clear();
|
||||||
|
|
||||||
|
if (selectedIndices.Any())
|
||||||
|
{
|
||||||
|
await _grid.SelectRowsAsync(selectedIndices.ToArray());
|
||||||
|
}
|
||||||
|
|
||||||
|
await _grid.Refresh();
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
|
||||||
|
FocusGridRow(rowIndex);
|
||||||
|
await _scanner.FocusAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FocusGridRow(int rowIndex)
|
||||||
|
{
|
||||||
|
if (_grid.AllowPaging)
|
||||||
|
{
|
||||||
|
int pageSize = _grid.PageSettings.PageSize;
|
||||||
|
int targetPage = (rowIndex / pageSize) + 1;
|
||||||
|
_grid.GoToPageAsync(targetPage);
|
||||||
|
|
||||||
|
rowIndex %= pageSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
_grid.SelectRowAsync(rowIndex);
|
||||||
|
_grid.ScrollIntoViewAsync(rowIndex: rowIndex);
|
||||||
|
_grid.FocusAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ShowValidationMessage()
|
||||||
|
{
|
||||||
|
VisibilityValidation = true;
|
||||||
|
|
||||||
|
ChangedRecords.Clear();
|
||||||
|
_scanner.FocusAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task<IDictionary<string, List<TransactionModel>>> GetTransactionModels()
|
||||||
|
{
|
||||||
|
return await WarehouseService.GetTransactionsModels();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task UpdateRows(IList<WzRowMeyleDto> changedRecords)
|
||||||
|
{
|
||||||
|
await WarehouseService.UpdateWzRowsMeyleAsync(changedRecords);
|
||||||
|
|
||||||
|
WzRowsMeyle = (await WarehouseService.GetWzRowsMeyleByWzHeaderId(WzHeader)).ToList();
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
await _grid.Refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task SplitLine(MouseEventArgs arg)
|
||||||
|
{
|
||||||
|
int newQuantity = int.Parse(NewQuantity);
|
||||||
|
|
||||||
|
if (newQuantity > 0 && SelectedRow != null)
|
||||||
|
{
|
||||||
|
WzRowMeyleDto splitRow = new WzRowMeyleDto
|
||||||
|
{
|
||||||
|
ID = Guid.NewGuid(),
|
||||||
|
FK_Header = SelectedRow.FK_Header,
|
||||||
|
Quantity = newQuantity,
|
||||||
|
FaIndex = SelectedRow.FaIndex,
|
||||||
|
ItemNumber = SelectedRow.ItemNumber,
|
||||||
|
OrderNumber = SelectedRow.OrderNumber,
|
||||||
|
PalletNumber = SelectedRow.PalletNumber,
|
||||||
|
WzNumber = SelectedRow.WzNumber,
|
||||||
|
TransactionNumber = SelectedRow.TransactionNumber += 10000,
|
||||||
|
PartNumberSl = SelectedRow.PartNumberSl,
|
||||||
|
PartNumber = SelectedRow.PartNumber
|
||||||
|
};
|
||||||
|
|
||||||
|
WzRowsMeyle.Add(splitRow);
|
||||||
|
SelectedRow.Quantity -= newQuantity;
|
||||||
|
|
||||||
|
ChangedRecords.Add(SelectedRow);
|
||||||
|
|
||||||
|
await WarehouseService.CreateWzRowsMeyleAsync(new List<WzRowMeyleDto> { splitRow });
|
||||||
|
await UpdateRows(ChangedRecords);
|
||||||
|
}
|
||||||
|
|
||||||
|
VisibilityLineSplitter = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ShowSplitDialog(ClickEventArgs obj)
|
||||||
|
{
|
||||||
|
VisibilityLineSplitter = true;
|
||||||
|
NewQuantity = "0";
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnRowSelected(RowSelectEventArgs<WzRowMeyleDto> obj)
|
||||||
|
{
|
||||||
|
SelectedRow = obj.Data;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<List<WzRowMeyleDto>> FindCombinations(List<WzRowMeyleDto> records, int targetSum)
|
||||||
|
{
|
||||||
|
var result = new List<List<WzRowMeyleDto>>();
|
||||||
|
var currentCombination = new List<WzRowMeyleDto>();
|
||||||
|
|
||||||
|
void Backtrack(int start, int currentSum)
|
||||||
|
{
|
||||||
|
if (currentSum == targetSum)
|
||||||
|
{
|
||||||
|
result.Add(new List<WzRowMeyleDto>(currentCombination));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = start; i < records.Count; i++)
|
||||||
|
{
|
||||||
|
if (currentSum + records[i].Quantity <= targetSum)
|
||||||
|
{
|
||||||
|
currentCombination.Add(records[i]);
|
||||||
|
Backtrack(i + 1, currentSum + records[i].Quantity ?? 0);
|
||||||
|
currentCombination.RemoveAt(currentCombination.Count - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Backtrack(0, 0);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task ApplyFilter(IList<WzRowMeyleDto> selectedRecords)
|
||||||
|
{
|
||||||
|
await _grid.FilterByColumnAsync(nameof(WzRowMeyleDto.FaIndex), "equal", selectedRecords.First().FaIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ChangeView()
|
||||||
|
{
|
||||||
|
NavigationManager.NavigateTo($"/Warehouse/Meyle/PackList/{WzHeader}/Simple");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,424 @@
|
|||||||
|
@page "/Warehouse/Meyle/PackList/{WzHeader:guid}/Simple"
|
||||||
|
@using OrdersManagement.Models
|
||||||
|
@using Syncfusion.Blazor.Cards
|
||||||
|
@using Syncfusion.Blazor.Grids
|
||||||
|
@using SytelineSaAppEfDataModel.Dtos
|
||||||
|
@using Syncfusion.Blazor.Popups
|
||||||
|
@using Syncfusion.Blazor.Inputs
|
||||||
|
@using Syncfusion.Blazor.Buttons
|
||||||
|
|
||||||
|
@inject NavigationManager NavigationManager
|
||||||
|
@inject WarehouseService WarehouseService
|
||||||
|
|
||||||
|
<div class="h-100 d-flex justify-content-center align-items-start">
|
||||||
|
<SfCard CssClass="shadow" style="width: 100%; max-width: 1200px;">
|
||||||
|
<CardHeader>
|
||||||
|
<h3 class="text-primary">Packing List</h3>
|
||||||
|
</CardHeader>
|
||||||
|
<CardContent>
|
||||||
|
<SfCard CssClass="shadow" style="width: 100%; max-width: 1200px;" Orientation="CardOrientation.Horizontal">
|
||||||
|
<CardContent>
|
||||||
|
<SfButton CssClass="e-primary" IsPrimary="true" @onclick="ChangeView">Zmień widok</SfButton>
|
||||||
|
<SfButton CssClass="e-primary" IsPrimary="true" @onclick="ExportXls">Generuj XLS i Wyślij</SfButton>
|
||||||
|
</CardContent>
|
||||||
|
</SfCard>
|
||||||
|
<SfCard CssClass="shadow" style="width: 100%; max-width: 1200px;">
|
||||||
|
<CardContent>
|
||||||
|
<label for="textBox" class="form-label">Adresy Email do Wysyłki raportu:</label>
|
||||||
|
<SfTextBox ID="textBox" Placeholder="Wprowadź adresy..." @bind-Value="@EmailAddresses"
|
||||||
|
CssClass="e-outline"/>
|
||||||
|
</CardContent>
|
||||||
|
</SfCard>
|
||||||
|
<SfCard CssClass="shadow" style="width: 100%; max-width: 1200px;">
|
||||||
|
<CardContent>
|
||||||
|
<label for="textBox" class="form-label">Numer WZ:</label>
|
||||||
|
<SfTextBox ID="textBox" @bind-Value=@WzNumber CssClass="e-outline"/>
|
||||||
|
</CardContent>
|
||||||
|
</SfCard>
|
||||||
|
<SfCard CssClass="shadow" style="width: 100%; max-width: 1200px;">
|
||||||
|
<CardContent>
|
||||||
|
<label for="textBox" class="form-label">Wprowadź numer palety:</label>
|
||||||
|
<SfTextBox ID="palletNumber" Type="InputType.Number" @bind-Value="@PalletNumber"
|
||||||
|
CssClass="e-outline"/>
|
||||||
|
<label for="textBox" class="form-label">Zeskanowana wartość:</label>
|
||||||
|
<SfTextBox ID="scannedValue" ValueChange="ScanValue" @bind-Value="ScannedValue"
|
||||||
|
CssClass="e-outline" @ref="_scanner"/>
|
||||||
|
</CardContent>
|
||||||
|
</SfCard>
|
||||||
|
<SfCard CssClass="shadow" style="width: 100%; max-width: 1200px;">
|
||||||
|
<CardContent>
|
||||||
|
<label for="textBox" class="form-label">Numer Indeksu FA:</label>
|
||||||
|
<SfTextBox ID="itemNumber" @bind-Value="@ItemNumber"
|
||||||
|
CssClass="e-outline" Readonly="true"/>
|
||||||
|
<label for="textBox" class="form-label">Ilość w Dostawie:</label>
|
||||||
|
<SfTextBox ID="qty" Type="InputType.Number" @bind-Value="@Qty"
|
||||||
|
CssClass="e-outline" Readonly="true"/>
|
||||||
|
<label for="textBox" class="form-label">Numer Palety:</label>
|
||||||
|
<SfTextBox ID="palletNumberOutput" Type="InputType.Number" @bind-Value="@PalletNumberOutput"
|
||||||
|
CssClass="e-outline" Readonly="true"/>
|
||||||
|
<label for="textBox" class="form-label">Nr Partii SL:</label>
|
||||||
|
<SfTextBox ID="partNumberSl" @bind-Value="@PartNumberSl"
|
||||||
|
CssClass="e-outline" Readonly="true"/>
|
||||||
|
<label for="textBox" class="form-label">Numer Partii Meyle:</label>
|
||||||
|
<SfTextBox ID="partNumberMeyle" @bind-Value="@PartNumberMeyle"
|
||||||
|
CssClass="e-outline" Readonly="true"/>
|
||||||
|
</CardContent>
|
||||||
|
</SfCard>
|
||||||
|
</CardContent>
|
||||||
|
|
||||||
|
<SfDialog Width="500px" Title="Informacja" IsModal="true" @bind-Visible="Visibility" AllowPrerender="true">
|
||||||
|
<DialogTemplates>
|
||||||
|
<Content>
|
||||||
|
@if (_isValid)
|
||||||
|
{
|
||||||
|
<p>Packing List został wygenerowany i wysłany!</p>
|
||||||
|
}
|
||||||
|
else if (string.IsNullOrWhiteSpace(EmailAddresses))
|
||||||
|
{
|
||||||
|
<p>Błąd: Proszę wprowadzić przynajmniej jeden <b>ADRES EMAIL</b> do wysyłki raportu!</p>
|
||||||
|
}
|
||||||
|
else if (!_isValid)
|
||||||
|
{
|
||||||
|
<p>Błąd: Nie Wszystkie linie mają wypełniony <b>NUMER PALETY</b>.<br/>Packing List nie zostanie
|
||||||
|
wygenerowany!</p>
|
||||||
|
}
|
||||||
|
</Content>
|
||||||
|
</DialogTemplates>
|
||||||
|
<DialogButtons>
|
||||||
|
<DialogButton Content="OK" IsPrimary="true" OnClick="@HideModal"/>
|
||||||
|
</DialogButtons>
|
||||||
|
</SfDialog>
|
||||||
|
|
||||||
|
<SfDialog Width="500px" Title="Błąd" IsModal="true" @bind-Visible="VisibilityValidation" AllowPrerender="true">
|
||||||
|
<DialogTemplates>
|
||||||
|
<Content>
|
||||||
|
<p>Błąd skanowania! Wystąpił jeden z wyjątków (Zeskanowana wartość '<b>@ScannedValue</b>'):</p>
|
||||||
|
<ul>
|
||||||
|
<li><p>Zeskanowano niepoprawny Numer Partii SL (nieistniejący w tabeli)</p></li>
|
||||||
|
<li><p>Zeskanowano niepoprawny numer Partii Meyle (niezaczynający się od
|
||||||
|
<b>@($"{DateTime.Now.Year - 2000}X")</b>)</p></li>
|
||||||
|
<li><p>Numer Palety nie jest większy niż 0 (aktualnie wybrany numer palety:
|
||||||
|
'<b>@PalletNumber</b>')</p></li>
|
||||||
|
</ul>
|
||||||
|
</Content>
|
||||||
|
</DialogTemplates>
|
||||||
|
<DialogButtons>
|
||||||
|
<DialogButton Content="OK" IsPrimary="true" OnClick="@HideModal"/>
|
||||||
|
</DialogButtons>
|
||||||
|
</SfDialog>
|
||||||
|
|
||||||
|
<SfDialog Width="500px" Title="Błąd" IsModal="true" @bind-Visible="VisibilityPalletNumber"
|
||||||
|
AllowPrerender="true">
|
||||||
|
<DialogTemplates>
|
||||||
|
<Content>
|
||||||
|
<p>Błąd skanowania! <b>Wybierz NUMER PALETY większy niż 0</b> (Aktualnie '@PalletNumber'):</p>
|
||||||
|
</Content>
|
||||||
|
</DialogTemplates>
|
||||||
|
<DialogButtons>
|
||||||
|
<DialogButton Content="OK" IsPrimary="true" OnClick="@HideModal"/>
|
||||||
|
</DialogButtons>
|
||||||
|
</SfDialog>
|
||||||
|
|
||||||
|
<CardFooter>
|
||||||
|
<small class="text-muted">FA Krosno Manager © @(DateTime.Now.Year)</small>
|
||||||
|
</CardFooter>
|
||||||
|
</SfCard>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
[Parameter] public Guid WzHeader { get; set; }
|
||||||
|
|
||||||
|
private List<WzRowMeyleDto> WzRowsMeyle { get; set; } = new();
|
||||||
|
private IDictionary<string, List<TransactionModel>> TransactionModelsByPartNumber { get; set; } = new Dictionary<string, List<TransactionModel>>();
|
||||||
|
private List<WzRowMeyleDto> ChangedRecords = new();
|
||||||
|
private WzHeaderDto _wzHeader;
|
||||||
|
private SfTextBox _scanner;
|
||||||
|
|
||||||
|
private string ItemNumber { get; set; } = string.Empty;
|
||||||
|
private string Qty { get; set; } = "0";
|
||||||
|
private string PalletNumberOutput { get; set; } = "0";
|
||||||
|
private string PartNumberSl { get; set; } = string.Empty;
|
||||||
|
private string PartNumberMeyle { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
private string WzNumber { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
private WzRowMeyleDto? SelectedRow { get; set; }
|
||||||
|
private List<WzRowMeyleDto> SelectedRows { get; set; } = new();
|
||||||
|
|
||||||
|
private bool _isValid;
|
||||||
|
|
||||||
|
private bool Visibility { get; set; }
|
||||||
|
private bool VisibilityValidation { get; set; }
|
||||||
|
private bool VisibilityLineSplitter { get; set; }
|
||||||
|
public bool VisibilityPalletNumber { get; set; }
|
||||||
|
|
||||||
|
private string? EmailAddresses { get; set; } = string.Empty;
|
||||||
|
private string PalletNumber { get; set; } = "0";
|
||||||
|
|
||||||
|
private string LastScannedValue { get; set; } = string.Empty;
|
||||||
|
private string ScannedValue { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
private void HideModal()
|
||||||
|
{
|
||||||
|
Visibility = false;
|
||||||
|
VisibilityValidation = false;
|
||||||
|
VisibilityLineSplitter = false;
|
||||||
|
VisibilityPalletNumber = false;
|
||||||
|
|
||||||
|
LastScannedValue = ScannedValue;
|
||||||
|
ScannedValue = string.Empty;
|
||||||
|
|
||||||
|
_scanner.FocusAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||||
|
{
|
||||||
|
if (firstRender)
|
||||||
|
{
|
||||||
|
_wzHeader = await WarehouseService.GetWzHeaderByIdAsync(WzHeader);
|
||||||
|
WzRowsMeyle = (await WarehouseService.GetWzRowsMeyleByWzHeaderId(WzHeader)).ToList();
|
||||||
|
|
||||||
|
TransactionModelsByPartNumber = await GetTransactionModels();
|
||||||
|
|
||||||
|
EmailAddresses = _wzHeader.EmailAddresses;
|
||||||
|
|
||||||
|
WzNumber = _wzHeader.WzNumbers ?? string.Empty;
|
||||||
|
|
||||||
|
await _scanner.FocusAsync();
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task SaveChanges()
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrWhiteSpace(EmailAddresses))
|
||||||
|
{
|
||||||
|
await WarehouseService.AddEmailsToWzHeaderAsync(WzHeader, EmailAddresses);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ChangedRecords.Any())
|
||||||
|
{
|
||||||
|
await UpdateRows(ChangedRecords);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task OnBatchSave(BeforeBatchSaveArgs<WzRowMeyleDto> obj)
|
||||||
|
{
|
||||||
|
var changes = obj.BatchChanges;
|
||||||
|
List<WzRowMeyleDto> changedRecords = changes.ChangedRecords;
|
||||||
|
|
||||||
|
if (!changedRecords.Any()) return;
|
||||||
|
|
||||||
|
await UpdateRows(changedRecords);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task ExportXls()
|
||||||
|
{
|
||||||
|
int count = WzRowsMeyle.Count(x => x.PalletNumber == null);
|
||||||
|
|
||||||
|
_isValid = count == 0;
|
||||||
|
_isValid = _isValid && !string.IsNullOrWhiteSpace(EmailAddresses);
|
||||||
|
|
||||||
|
if (_isValid)
|
||||||
|
{
|
||||||
|
await WarehouseService.AddEmailsToWzHeaderAsync(WzHeader, EmailAddresses);
|
||||||
|
await WarehouseService.GenerateXlsForMeyleAsync(WzHeader);
|
||||||
|
}
|
||||||
|
|
||||||
|
Visibility = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ScanValue(ChangedEventArgs obj)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(obj.Value)) return;
|
||||||
|
if (int.Parse(PalletNumber) <= 0)
|
||||||
|
{
|
||||||
|
VisibilityPalletNumber = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ScannedValue = obj.Value.Trim();
|
||||||
|
|
||||||
|
StateHasChanged();
|
||||||
|
|
||||||
|
TransactionModelsByPartNumber.TryGetValue(obj.Value.Trim(), out List<TransactionModel>? materialTransactionsByPartNumber);
|
||||||
|
TransactionModel? materialTransactionByPartNumber = materialTransactionsByPartNumber?.FirstOrDefault();
|
||||||
|
|
||||||
|
if (materialTransactionByPartNumber == null && IsValidScannedValue(obj.Value))
|
||||||
|
{
|
||||||
|
FillMeylePartNumber(ScannedValue);
|
||||||
|
|
||||||
|
LastScannedValue = ScannedValue;
|
||||||
|
ScannedValue = string.Empty;
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (materialTransactionByPartNumber != null)
|
||||||
|
{
|
||||||
|
FillFaPartNumberAndPalletNumber(materialTransactionByPartNumber, obj.Value.Trim());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (materialTransactionByPartNumber == null)
|
||||||
|
{
|
||||||
|
ShowValidationMessage();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
LastScannedValue = ScannedValue;
|
||||||
|
ScannedValue = string.Empty;
|
||||||
|
|
||||||
|
_scanner.FocusAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool IsValidScannedValue(string scannedValue)
|
||||||
|
{
|
||||||
|
int year = DateTime.Now.Year - 2000;
|
||||||
|
|
||||||
|
string format = $"{year}X";
|
||||||
|
|
||||||
|
return scannedValue.StartsWith(format);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task FillMeylePartNumber(string scannedValue)
|
||||||
|
{
|
||||||
|
if (SelectedRow != null && !SelectedRows.Any())
|
||||||
|
{
|
||||||
|
SelectedRow.PartNumber = scannedValue;
|
||||||
|
ChangedRecords.Add(SelectedRow);
|
||||||
|
|
||||||
|
PartNumberMeyle = scannedValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (WzRowMeyleDto wzRowMeyleDto in SelectedRows)
|
||||||
|
{
|
||||||
|
wzRowMeyleDto.PartNumber = scannedValue;
|
||||||
|
ChangedRecords.Add(wzRowMeyleDto);
|
||||||
|
}
|
||||||
|
|
||||||
|
await SaveChanges();
|
||||||
|
|
||||||
|
ChangedRecords.Clear();
|
||||||
|
SelectedRows.Clear();
|
||||||
|
|
||||||
|
await _scanner.FocusAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task FillFaPartNumberAndPalletNumber(TransactionModel materialTransactionByPartNumber, string scannedValue)
|
||||||
|
{
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
|
||||||
|
int palletNumber = int.Parse(PalletNumber);
|
||||||
|
int rowIndex = WzRowsMeyle.FindIndex(x => x.FaIndex == materialTransactionByPartNumber.ItemNumber && x.Quantity == materialTransactionByPartNumber.Quantity);
|
||||||
|
|
||||||
|
switch (rowIndex)
|
||||||
|
{
|
||||||
|
case -1:
|
||||||
|
{
|
||||||
|
SelectedRows = WzRowsMeyle.Where(x => x.FaIndex == materialTransactionByPartNumber.ItemNumber).ToList();
|
||||||
|
|
||||||
|
if (SelectedRows.Count == 0)
|
||||||
|
{
|
||||||
|
ShowValidationMessage();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var validCombinations = FindCombinations(SelectedRows, (int?)materialTransactionByPartNumber.Quantity ?? 0);
|
||||||
|
|
||||||
|
foreach (var combination in validCombinations)
|
||||||
|
{
|
||||||
|
foreach (var record in combination)
|
||||||
|
{
|
||||||
|
record.PartNumberSl = scannedValue;
|
||||||
|
record.PalletNumber = palletNumber;
|
||||||
|
ChangedRecords.Add(record);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SelectedRows.Clear();
|
||||||
|
SelectedRows.AddRange(ChangedRecords);
|
||||||
|
|
||||||
|
SelectedRow = SelectedRows.FirstOrDefault();
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
SelectedRow = WzRowsMeyle[rowIndex];
|
||||||
|
|
||||||
|
SelectedRow.PartNumberSl = scannedValue;
|
||||||
|
SelectedRow.PalletNumber = palletNumber;
|
||||||
|
|
||||||
|
if (ChangedRecords.All(x => x.TransactionNumber != SelectedRow.TransactionNumber))
|
||||||
|
{
|
||||||
|
ChangedRecords.Add(SelectedRow);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
PartNumberSl = SelectedRow?.PartNumberSl ?? string.Empty;
|
||||||
|
PalletNumberOutput = SelectedRow?.PalletNumber.ToString() ?? "0";
|
||||||
|
ItemNumber = SelectedRow?.FaIndex ?? string.Empty;
|
||||||
|
Qty = SelectedRow?.Quantity.ToString() ?? "0";
|
||||||
|
|
||||||
|
await SaveChanges();
|
||||||
|
ChangedRecords.Clear();
|
||||||
|
await _scanner.FocusAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ShowValidationMessage()
|
||||||
|
{
|
||||||
|
VisibilityValidation = true;
|
||||||
|
|
||||||
|
ChangedRecords.Clear();
|
||||||
|
_scanner.FocusAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task<IDictionary<string, List<TransactionModel>>> GetTransactionModels()
|
||||||
|
{
|
||||||
|
return await WarehouseService.GetTransactionsModels();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task UpdateRows(IList<WzRowMeyleDto> changedRecords)
|
||||||
|
{
|
||||||
|
await WarehouseService.UpdateWzRowsMeyleAsync(changedRecords);
|
||||||
|
|
||||||
|
WzRowsMeyle = (await WarehouseService.GetWzRowsMeyleByWzHeaderId(WzHeader)).ToList();
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<List<WzRowMeyleDto>> FindCombinations(List<WzRowMeyleDto> records, int targetSum)
|
||||||
|
{
|
||||||
|
var result = new List<List<WzRowMeyleDto>>();
|
||||||
|
var currentCombination = new List<WzRowMeyleDto>();
|
||||||
|
|
||||||
|
void Backtrack(int start, int currentSum)
|
||||||
|
{
|
||||||
|
if (currentSum == targetSum)
|
||||||
|
{
|
||||||
|
result.Add(new List<WzRowMeyleDto>(currentCombination));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = start; i < records.Count; i++)
|
||||||
|
{
|
||||||
|
if (currentSum + records[i].Quantity <= targetSum)
|
||||||
|
{
|
||||||
|
currentCombination.Add(records[i]);
|
||||||
|
Backtrack(i + 1, currentSum + records[i].Quantity ?? 0);
|
||||||
|
currentCombination.RemoveAt(currentCombination.Count - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Backtrack(0, 0);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ChangeView()
|
||||||
|
{
|
||||||
|
NavigationManager.NavigateTo($"/Warehouse/Meyle/PackList/{WzHeader}");
|
||||||
|
}
|
||||||
|
}
|
||||||
76
OrdersManagement/Components/Pages/Products.razor
Normal file
76
OrdersManagement/Components/Pages/Products.razor
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
@page "/Products"
|
||||||
|
|
||||||
|
@using Syncfusion.Blazor.Grids
|
||||||
|
@using Syncfusion.Blazor.Cards
|
||||||
|
@using Action = Syncfusion.Blazor.Grids.Action
|
||||||
|
@inject ProductService ProductService
|
||||||
|
@inject CustomAuthenticationStateProvider CustomAuthenticationStateProvider
|
||||||
|
|
||||||
|
<div class="h-100 d-flex justify-content-center align-items-start">
|
||||||
|
<SfCard CssClass="shadow" style="width: 100%; max-width: 1200px;">
|
||||||
|
<CardHeader>
|
||||||
|
<h3 class="text-primary">Zarządzanie Indeksami</h3>
|
||||||
|
</CardHeader>
|
||||||
|
<CardContent>
|
||||||
|
<SfGrid DataSource="@_products"
|
||||||
|
AllowPaging="true"
|
||||||
|
ShowColumnMenu="true"
|
||||||
|
Toolbar="@(new List<string> { "Update" })">
|
||||||
|
<GridColumns>
|
||||||
|
<GridColumn Field="@nameof(ProductDto.ID)" AllowEditing="false" IsPrimaryKey="true" HeaderText="ID" Width="70"></GridColumn>
|
||||||
|
<GridColumn Field="@nameof(ProductDto.RecipientName)" AllowEditing="false" HeaderText="Odbiorca" Width="100"></GridColumn>
|
||||||
|
<GridColumn Field="@nameof(ProductDto.RecipientIdx)" AllowEditing="false" HeaderText="Indeks odbiorcy" Width="100"></GridColumn>
|
||||||
|
<GridColumn Field="@nameof(ProductDto.FaIdx)" HeaderText="Kod FA" Width="100"></GridColumn>
|
||||||
|
</GridColumns>
|
||||||
|
<GridEditSettings AllowEditing="true">
|
||||||
|
</GridEditSettings>
|
||||||
|
<GridEvents OnActionComplete="UserActionComplete"
|
||||||
|
TValue="ProductDto">
|
||||||
|
</GridEvents>
|
||||||
|
<GridPageSettings PageSize="10"></GridPageSettings>
|
||||||
|
</SfGrid>
|
||||||
|
</CardContent>
|
||||||
|
<CardFooter>
|
||||||
|
<small class="text-muted">FA Krosno Manager © @(DateTime.Now.Year)</small>
|
||||||
|
</CardFooter>
|
||||||
|
</SfCard>
|
||||||
|
</div>
|
||||||
|
@code {
|
||||||
|
private IEnumerable<ProductDto>? _products { get; set; }
|
||||||
|
|
||||||
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||||
|
{
|
||||||
|
if (firstRender)
|
||||||
|
{
|
||||||
|
// ClaimsPrincipal currentUser = CustomAuthenticationStateProvider.GetCurrentUser();
|
||||||
|
//
|
||||||
|
// if (currentUser.Identity?.IsAuthenticated == false)
|
||||||
|
// {
|
||||||
|
// NavigationManager.NavigateTo("/Unauthorized");
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
await GetProducts();
|
||||||
|
|
||||||
|
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task UserActionComplete(ActionEventArgs<ProductDto> args)
|
||||||
|
{
|
||||||
|
switch (args.RequestType)
|
||||||
|
{
|
||||||
|
case Action.Save:
|
||||||
|
await ProductService.UpdateProductAsync(args.Data);
|
||||||
|
await GetProducts();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task GetProducts()
|
||||||
|
{
|
||||||
|
_products = await ProductService.GetProductsByIndexAsync("Uzupelnij") ?? new List<ProductDto>();
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
87
OrdersManagement/Components/Pages/Register.razor
Normal file
87
OrdersManagement/Components/Pages/Register.razor
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
@page "/register"
|
||||||
|
@using OrdersManagement.Models
|
||||||
|
@using OrdersManagementDataModel.Dtos
|
||||||
|
@using Syncfusion.Blazor.Inputs
|
||||||
|
@using Syncfusion.Blazor.Buttons
|
||||||
|
@using Syncfusion.Blazor.Cards
|
||||||
|
|
||||||
|
@inject UserService UserService
|
||||||
|
@inject NavigationManager NavigationManager
|
||||||
|
|
||||||
|
<div class="h-100 d-flex flex-column">
|
||||||
|
<h5>Rejestracja</h5>
|
||||||
|
<br/>
|
||||||
|
<SfCard>
|
||||||
|
<CardHeader Title="Zarejestruj się"/>
|
||||||
|
<CardContent>
|
||||||
|
<EditForm Model="@RegisterModel" OnValidSubmit="HandleRegister">
|
||||||
|
<DataAnnotationsValidator/>
|
||||||
|
<ValidationSummary/>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="login">Login</label>
|
||||||
|
<SfTextBox ID="login" @bind-Value="RegisterModel.Login" Placeholder="Wprowadź login"
|
||||||
|
CssClass="e-outline"/>
|
||||||
|
<ValidationMessage For="@(() => RegisterModel.Login)"/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="email">Email</label>
|
||||||
|
<SfTextBox ID="email" @bind-Value="RegisterModel.Email" Placeholder="Wprowadź email"
|
||||||
|
CssClass="e-outline"/>
|
||||||
|
<ValidationMessage For="@(() => RegisterModel.Email)"/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="firstName">Imię</label>
|
||||||
|
<SfTextBox ID="firstName" @bind-Value="RegisterModel.FirstName" Placeholder="Wprowadź imię"
|
||||||
|
CssClass="e-outline"/>
|
||||||
|
<ValidationMessage For="@(() => RegisterModel.FirstName)"/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="lastName">Nazwisko</label>
|
||||||
|
<SfTextBox ID="lastName" @bind-Value="RegisterModel.LastName" Placeholder="Wprowadź nazwisko"
|
||||||
|
CssClass="e-outline"/>
|
||||||
|
<ValidationMessage For="@(() => RegisterModel.LastName)"/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group mt-3">
|
||||||
|
<SfButton CssClass="e-primary" IsPrimary="true" Type="submit">Zarejestruj</SfButton>
|
||||||
|
</div>
|
||||||
|
</EditForm>
|
||||||
|
</CardContent>
|
||||||
|
</SfCard>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
private RegisterModel RegisterModel { get; set; } = new();
|
||||||
|
|
||||||
|
private async Task HandleRegister()
|
||||||
|
{
|
||||||
|
var temporaryPassword = Guid.NewGuid().ToString().Substring(0, 8);
|
||||||
|
var passwordHash = BCrypt.Net.BCrypt.HashPassword(temporaryPassword);
|
||||||
|
|
||||||
|
var user = new UserDto
|
||||||
|
{
|
||||||
|
Login = RegisterModel.Login,
|
||||||
|
PasswordHash = passwordHash,
|
||||||
|
IsTemporaryPassword = true,
|
||||||
|
IsActive = true,
|
||||||
|
ActiveFrom = DateTime.Now,
|
||||||
|
Email = RegisterModel.Email,
|
||||||
|
FirstName = RegisterModel.FirstName,
|
||||||
|
LastName = RegisterModel.LastName,
|
||||||
|
CreatedDate = DateTime.Now,
|
||||||
|
RowPointer = Guid.NewGuid()
|
||||||
|
};
|
||||||
|
|
||||||
|
var result = await UserService.AddUserAsync(user);
|
||||||
|
|
||||||
|
if (result.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
NavigationManager.NavigateTo($"/login?tempPassword={Uri.EscapeDataString(temporaryPassword)}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,137 +1,166 @@
|
|||||||
@page "/ScheduleOrder/{ScheduleOrderId:int}"
|
@page "/ScheduleOrder/{ScheduleOrderId:int}"
|
||||||
|
|
||||||
@inject ScheduleOrderDetailsService ScheduleOrderDetailsService
|
@using System.Security.Claims
|
||||||
|
@using Microsoft.AspNetCore.Authorization
|
||||||
|
@using Syncfusion.Blazor.Grids
|
||||||
|
@using Syncfusion.Blazor.Lists
|
||||||
|
@using Syncfusion.Blazor.Cards
|
||||||
|
@inject ScheduleOrderService ScheduleOrderService
|
||||||
|
@inject NavigationManager NavigationManager
|
||||||
|
@inject CustomAuthenticationStateProvider CustomAuthenticationStateProvider
|
||||||
|
|
||||||
<div class="row">
|
<div class="h-100 d-flex justify-content-center align-items-start">
|
||||||
<h3>Indeksy</h3>
|
<SfCard CssClass="shadow" style="width: 100%; max-width: 1200px;">
|
||||||
</div>
|
<CardHeader>
|
||||||
<div class="row">
|
<h3 class="text-primary">Zamówienie DELFOR nr @(ScheduleOrderDto?.PONum ?? "Brak numeru") (ID: @ScheduleOrderDto?.ID)</h3>
|
||||||
<Grid @ref="_grid"
|
</CardHeader>
|
||||||
TItem="ScheduleOrderDetailDto"
|
<CardContent>
|
||||||
Class="table table-hover table-bordered table-striped"
|
<SfListView Id="ScheduleOrderMiscs"
|
||||||
DataProvider="ScheduleOrderDetailsDataProvider"
|
DataSource="@ScheduleOrderDto?.ScheduleOrderMiscs"
|
||||||
AllowFiltering="true"
|
ShowHeader="false"
|
||||||
Responsive="true"
|
CssClass="e-list-template mb-4">
|
||||||
AllowPaging="true"
|
<ListViewFieldSettings TValue="ScheduleOrderMiscDto" Id="ScheduleOrderMiscListId" Text="Text"></ListViewFieldSettings>
|
||||||
PageSize="20"
|
<ListViewTemplates Context="item" TValue="ScheduleOrderMiscDto">
|
||||||
AllowSelection="true"
|
<Template>
|
||||||
AllowRowClick="true"
|
<span class="e-list-content"><b>@item.Label:</b> @item.Value</span>
|
||||||
SelectionMode="GridSelectionMode.Single"
|
</Template>
|
||||||
SelectedItemsChanged="SelectedItemChanged">
|
</ListViewTemplates>
|
||||||
<GridColumns>
|
</SfListView>
|
||||||
<GridColumn TItem="ScheduleOrderDetailDto" HeaderText="Pozycja"
|
|
||||||
PropertyName="SalesChannelProductCode">
|
<h5 class="text-primary mb-3">Indeksy</h5>
|
||||||
@context.Sc_productCode
|
<SfGrid AllowFiltering="true"
|
||||||
</GridColumn>
|
AllowPaging="true"
|
||||||
<GridColumn TItem="ScheduleOrderDetailDto" HeaderText="Pozycja Klienta"
|
AllowSorting="true"
|
||||||
PropertyName="ShipperProductCode">
|
AllowSelection="true"
|
||||||
@context.Sh_productCode
|
TValue="ScheduleOrderDetailDto"
|
||||||
</GridColumn>
|
DataSource="@_scheduleOrderDetails"
|
||||||
<GridColumn TItem="ScheduleOrderDetailDto" HeaderText="Cena" PropertyName="Price">
|
EnableAdaptiveUI="true">
|
||||||
@context.Price
|
<GridTemplates>
|
||||||
</GridColumn>
|
<DetailTemplate>
|
||||||
</GridColumns>
|
@{
|
||||||
</Grid>
|
IList<ScheduleOrderDetailMiscDto>? scheduleOrderDetailMiscs = (@context as ScheduleOrderDetailDto)?.ScheduleOrderDetailMiscs;
|
||||||
</div>
|
IList<ScheduleOrderDetailDetailDto>? scheduleOrderDetailDetails = (@context as ScheduleOrderDetailDto)?.ScheduleOrderDetailDetails;
|
||||||
@if (_isVisible)
|
|
||||||
{
|
<SfListView Id="ScheduleOrderDetailMiscs"
|
||||||
<div class="row">
|
DataSource="@scheduleOrderDetailMiscs"
|
||||||
<h2>Dodatkowe informacje</h2>
|
ShowHeader="false"
|
||||||
</div>
|
CssClass="e-list-template mb-4">
|
||||||
<div class="row">
|
<ListViewFieldSettings TValue="ScheduleOrderDetailMiscDto" Id="ScheduleOrderDetailMiscListId" Text="Text"></ListViewFieldSettings>
|
||||||
<SortableList TItem="ScheduleOrderDetailMiscDto" Data="_scheduleOrderDetailMiscs">
|
<ListViewTemplates Context="item" TValue="ScheduleOrderDetailMiscDto">
|
||||||
<ItemTemplate>
|
<Template>
|
||||||
<u>@context.Label:</u> <b>@context.Value</b>
|
<span class="e-list-content"><b>@item.Label:</b> @item.Value</span>
|
||||||
</ItemTemplate>
|
</Template>
|
||||||
</SortableList>
|
</ListViewTemplates>
|
||||||
</div>
|
</SfListView>
|
||||||
<br/>
|
|
||||||
<div class="row">
|
<h5 class="text-primary mb-3">Harmonogramy</h5>
|
||||||
<h3>Harmonogramy</h3>
|
<SfGrid AllowFiltering="true"
|
||||||
</div>
|
AllowPaging="true"
|
||||||
<div class="row">
|
AllowSorting="true"
|
||||||
<Grid @ref="_detailDetailsGrid"
|
AllowSelection="true"
|
||||||
TItem="ScheduleOrderDetailDetailDto"
|
TValue="ScheduleOrderDetailDetailDto"
|
||||||
Data="_scheduleOrderDetailsDetails"
|
DataSource="@scheduleOrderDetailDetails"
|
||||||
Class="table table-hover table-bordered table-striped"
|
EnableAdaptiveUI="true"
|
||||||
AllowFiltering="true"
|
AdaptiveUIMode="AdaptiveMode.Both">
|
||||||
Responsive="true"
|
<GridEvents TValue="ScheduleOrderDetailDetailDto" RowDataBound="OnRowDataBound"/>
|
||||||
AllowPaging="true"
|
<GridTemplates Context="detailDetail">
|
||||||
PageSize="20"
|
<DetailTemplate>
|
||||||
AllowSelection="true"
|
@{
|
||||||
SelectionMode="GridSelectionMode.Single"
|
IList<ScheduleOrderDetailDetailMiscDto>? scheduleOrderDetailDetailMiscs = (@detailDetail as ScheduleOrderDetailDetailDto)?.ScheduleOrderDetailDetailMiscs;
|
||||||
SelectedItemsChanged="SelectedDetailDetailChanged">
|
|
||||||
|
<SfListView Id="ScheduleOrderDetailDetailMiscs"
|
||||||
|
DataSource="@scheduleOrderDetailDetailMiscs"
|
||||||
|
ShowHeader="false"
|
||||||
|
CssClass="e-list-template mb-4">
|
||||||
|
<ListViewFieldSettings TValue="ScheduleOrderDetailDetailMiscDto" Id="ScheduleOrderDetailDetailMiscListId" Text="Text"></ListViewFieldSettings>
|
||||||
|
<ListViewTemplates Context="item" TValue="ScheduleOrderDetailDetailMiscDto">
|
||||||
|
<Template>
|
||||||
|
<span class="e-list-content"><b>@item.Label:</b> @item.Value</span>
|
||||||
|
</Template>
|
||||||
|
</ListViewTemplates>
|
||||||
|
</SfListView>
|
||||||
|
}
|
||||||
|
</DetailTemplate>
|
||||||
|
</GridTemplates>
|
||||||
|
<GridColumns>
|
||||||
|
<GridColumn Field=@nameof(ScheduleOrderDetailDetailDto.DateFrom) HeaderText="Data Od" Width="100"></GridColumn>
|
||||||
|
<GridColumn Field=@nameof(ScheduleOrderDetailDetailDto.DateTo) HeaderText="Data Do" Width="100"></GridColumn>
|
||||||
|
<GridColumn Field=@nameof(ScheduleOrderDetailDetailDto.Qty) TextAlign="TextAlign.Right" HeaderText="Ilość Sztuk" Width="50"></GridColumn>
|
||||||
|
<GridColumn Field=@nameof(ScheduleOrderDetailDetailDto.QtyType) TextAlign="TextAlign.Right" HeaderText="Typ Qty" Width="50"></GridColumn>
|
||||||
|
<GridColumn Field=@nameof(ScheduleOrderDetailDetailDto.QtyDesc) HeaderText="Opis Typu" Width="100"></GridColumn>
|
||||||
|
</GridColumns>
|
||||||
|
<GridFilterSettings Type="FilterType.Excel"/>
|
||||||
|
<GridPageSettings PageSize="10"/>
|
||||||
|
<GridSelectionSettings Mode="SelectionMode.Row" Type="SelectionType.Single"/>
|
||||||
|
</SfGrid>
|
||||||
|
}
|
||||||
|
</DetailTemplate>
|
||||||
|
</GridTemplates>
|
||||||
|
<GridColumns>
|
||||||
|
<GridColumn Field=@nameof(ScheduleOrderDetailDto.OrderNumber) HeaderText="Numer Zamówienia" Width="100"></GridColumn>
|
||||||
|
<GridColumn Field=@nameof(ScheduleOrderDetailDto.PurchaserName) HeaderText="Klient" Width="100"></GridColumn>
|
||||||
|
<GridColumn Field=@nameof(ScheduleOrderDetailDto.RecipientName) HeaderText="Odbiorca" Width="100"></GridColumn>
|
||||||
|
<GridColumn Field=@nameof(ScheduleOrderDetailDto.RecipientCode) HeaderText="Kod odbiorcy" Width="100" AllowFiltering="true"></GridColumn>
|
||||||
|
<GridColumn Field=@nameof(ScheduleOrderDetailDto.Sh_productCode) HeaderText="Pozycja" Width="100"></GridColumn>
|
||||||
|
<GridColumn Field=@nameof(ScheduleOrderDetailDto.Sc_productCode) HeaderText="Pozycja Klienta" Width="100"></GridColumn>
|
||||||
|
</GridColumns>
|
||||||
|
<GridFilterSettings Type="FilterType.Excel"/>
|
||||||
|
<GridPageSettings PageSize="10"/>
|
||||||
|
<GridSelectionSettings Mode="SelectionMode.Row" Type="SelectionType.Single"/>
|
||||||
|
</SfGrid>
|
||||||
|
</CardContent>
|
||||||
|
<CardFooter>
|
||||||
|
<small class="text-muted">FA Krosno Manager © @(DateTime.Now.Year)</small>
|
||||||
|
</CardFooter>
|
||||||
|
</SfCard>
|
||||||
|
</div>
|
||||||
|
|
||||||
<GridColumns>
|
|
||||||
<GridColumn TItem="ScheduleOrderDetailDetailDto" HeaderText="Id" PropertyName="Id">
|
|
||||||
@context.ID
|
|
||||||
</GridColumn>
|
|
||||||
<GridColumn TItem="ScheduleOrderDetailDetailDto" HeaderText="Data Od" PropertyName="DateFrom">
|
|
||||||
@context.DateFrom.ToString("dd.MM.yyyy")
|
|
||||||
</GridColumn>
|
|
||||||
<GridColumn TItem="ScheduleOrderDetailDetailDto" HeaderText="Data Do" PropertyName="DateTo">
|
|
||||||
@context.DateTo.ToString("dd.MM.yyyy")
|
|
||||||
</GridColumn>
|
|
||||||
<GridColumn TItem="ScheduleOrderDetailDetailDto" HeaderText="Ilość Sztuk" PropertyName="Qty">
|
|
||||||
@context.Qty
|
|
||||||
</GridColumn>
|
|
||||||
<GridColumn TItem="ScheduleOrderDetailDetailDto" HeaderText="Typ Qty" PropertyName="QtyType">
|
|
||||||
@context.QtyType
|
|
||||||
</GridColumn>
|
|
||||||
<GridColumn TItem="ScheduleOrderDetailDetailDto" HeaderText="Opis Typu" PropertyName="QtyDesc">
|
|
||||||
@context.QtyDesc
|
|
||||||
</GridColumn>
|
|
||||||
</GridColumns>
|
|
||||||
</Grid>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
@if (_isVisibleDetailDetail)
|
|
||||||
{
|
|
||||||
<div class="row">
|
|
||||||
<h2>Dodatkowe informacje</h2>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<SortableList TItem="ScheduleOrderDetailDetailMiscDto" Data="_scheduleOrderDetailDetailMiscs">
|
|
||||||
<ItemTemplate>
|
|
||||||
<u>@context.Label:</u> <b>@context.Value</b>
|
|
||||||
</ItemTemplate>
|
|
||||||
</SortableList>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
[Parameter] public int ScheduleOrderId { get; set; }
|
[Parameter] public int ScheduleOrderId { get; set; }
|
||||||
private bool _isVisible;
|
|
||||||
private bool _isVisibleDetailDetail;
|
|
||||||
|
|
||||||
Grid<ScheduleOrderDetailDto>? _grid;
|
|
||||||
Grid<ScheduleOrderDetailDetailDto>? _detailDetailsGrid;
|
|
||||||
|
|
||||||
private IEnumerable<ScheduleOrderDetailDto>? _scheduleOrderDetails;
|
private IEnumerable<ScheduleOrderDetailDto>? _scheduleOrderDetails;
|
||||||
private IEnumerable<ScheduleOrderDetailDetailDto>? _scheduleOrderDetailsDetails;
|
|
||||||
|
|
||||||
private List<ScheduleOrderDetailMiscDto>? _scheduleOrderDetailMiscs;
|
private ScheduleOrderDto? ScheduleOrderDto { get; set; }
|
||||||
private List<ScheduleOrderDetailDetailMiscDto>? _scheduleOrderDetailDetailMiscs;
|
|
||||||
|
|
||||||
private async Task<GridDataProviderResult<ScheduleOrderDetailDto>> ScheduleOrderDetailsDataProvider(GridDataProviderRequest<ScheduleOrderDetailDto> request)
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||||
{
|
{
|
||||||
_scheduleOrderDetails = await ScheduleOrderDetailsService.GetScheduleOrderDetails(ScheduleOrderId) ?? new List<ScheduleOrderDetailDto>();
|
if (firstRender)
|
||||||
StateHasChanged();
|
{
|
||||||
|
// ClaimsPrincipal currentUser = CustomAuthenticationStateProvider.GetCurrentUser();
|
||||||
|
//
|
||||||
|
// if (currentUser.Identity?.IsAuthenticated == false)
|
||||||
|
// {
|
||||||
|
// NavigationManager.NavigateTo("/Unauthorized");
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
ScheduleOrderDto = await ScheduleOrderService.GetScheduleOrderAsync(ScheduleOrderId);
|
||||||
|
|
||||||
return await Task.FromResult(request.ApplyTo(_scheduleOrderDetails));
|
_scheduleOrderDetails = ScheduleOrderDto?.ScheduleOrderDetails;
|
||||||
|
|
||||||
|
if (ScheduleOrderDto is not null && _scheduleOrderDetails is not null)
|
||||||
|
{
|
||||||
|
foreach (ScheduleOrderDetailDto scheduleOrderDetailDto in _scheduleOrderDetails)
|
||||||
|
{
|
||||||
|
scheduleOrderDetailDto.OrderNumber = ScheduleOrderDto?.PONum;
|
||||||
|
scheduleOrderDetailDto.RecipientCode = ScheduleOrderDto?.RecipientCode;
|
||||||
|
scheduleOrderDetailDto.RecipientName = ScheduleOrderDto?.RecipientName;
|
||||||
|
scheduleOrderDetailDto.PurchaserName = ScheduleOrderDto?.PurchaserCode;
|
||||||
|
}
|
||||||
|
// }
|
||||||
|
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SelectedItemChanged(HashSet<ScheduleOrderDetailDto> obj)
|
private void OnRowDataBound(RowDataBoundEventArgs<ScheduleOrderDetailDetailDto> args)
|
||||||
{
|
{
|
||||||
_isVisible = obj.Any();
|
if (args.Data.QtyType == "83" || args.Data.QtyType == "84")
|
||||||
_scheduleOrderDetailMiscs = obj.FirstOrDefault()?.ScheduleOrderDetailMiscs.ToList();
|
{
|
||||||
_scheduleOrderDetailsDetails = obj.FirstOrDefault()?.ScheduleOrderDetailDetails.ToList();
|
args.Row.AddClass(["highlight-red"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SelectedDetailDetailChanged(HashSet<ScheduleOrderDetailDetailDto> obj)
|
|
||||||
{
|
|
||||||
_isVisibleDetailDetail = obj.Any();
|
|
||||||
_scheduleOrderDetailDetailMiscs = obj.FirstOrDefault()?.ScheduleOrderDetailDetailMiscs.ToList();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,30 +1,54 @@
|
|||||||
@page "/"
|
@page "/"
|
||||||
|
|
||||||
|
@using System.Security.Claims
|
||||||
|
@using Microsoft.AspNetCore.Authorization
|
||||||
@using OrdersManagement.Components.Pages.Shared
|
@using OrdersManagement.Components.Pages.Shared
|
||||||
@inject ScheduleOrderService ScheduleOrderService
|
@using Syncfusion.Blazor.Grids
|
||||||
@inherits LayoutComponentBase
|
|
||||||
|
|
||||||
<div class="row">
|
@inject ScheduleOrderService ScheduleOrderService
|
||||||
<h3>Zamówienia DELFOR </h3>
|
@inject CustomAuthenticationStateProvider CustomAuthenticationStateProvider
|
||||||
</div>
|
@inject NavigationManager NavigationManager;
|
||||||
<br />
|
|
||||||
<ScheduleOrdersGrid PageSize="20" PassGridRef="SetGridRef" DataProvider="ScheduleOrdersDataProvider"></ScheduleOrdersGrid>
|
<ScheduleOrdersGrid PageSize="20" @ref="_grid" PassGridRef="SetGridRef" GridData="_scheduleOrders" />
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
private IEnumerable<ScheduleOrderDto>? _scheduleOrders;
|
private IEnumerable<ScheduleOrderDto> _scheduleOrders = [];
|
||||||
|
|
||||||
private Grid<ScheduleOrderDto> _gridRef;
|
private ScheduleOrdersGrid _grid { get; set; }
|
||||||
|
|
||||||
private async Task<GridDataProviderResult<ScheduleOrderDto>> ScheduleOrdersDataProvider(GridDataProviderRequest<ScheduleOrderDto> request)
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||||
|
{
|
||||||
|
if (firstRender)
|
||||||
|
{
|
||||||
|
// ClaimsPrincipal currentUser = CustomAuthenticationStateProvider.GetCurrentUser();
|
||||||
|
//
|
||||||
|
// if (currentUser.Identity?.IsAuthenticated == false)
|
||||||
|
// {
|
||||||
|
// NavigationManager.NavigateTo("/Unauthorized");
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
_scheduleOrders = await FetchScheduleOrdersAsync();
|
||||||
|
StateHasChanged();
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await _grid.RestoreFilterFromLocalStorage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task<IEnumerable<ScheduleOrderDto>> FetchScheduleOrdersAsync()
|
||||||
{
|
{
|
||||||
_scheduleOrders = await ScheduleOrderService.GetScheduleOrdersAsync() ?? new List<ScheduleOrderDto>();
|
_scheduleOrders = await ScheduleOrderService.GetScheduleOrdersAsync() ?? new List<ScheduleOrderDto>();
|
||||||
_scheduleOrders = _scheduleOrders.OrderByDescending(x => x.LastUpdateDate).ToList();
|
_scheduleOrders = _scheduleOrders.OrderByDescending(x => x.LastUpdateDate).ToList();
|
||||||
StateHasChanged();
|
return _scheduleOrders;
|
||||||
|
|
||||||
return await Task.FromResult(request.ApplyTo(_scheduleOrders));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task SetGridRef(Grid<ScheduleOrderDto> grid)
|
private SfGrid<ScheduleOrderDto> _gridRef;
|
||||||
|
|
||||||
|
private async Task SetGridRef(SfGrid<ScheduleOrderDto> grid)
|
||||||
{
|
{
|
||||||
_gridRef = grid;
|
_gridRef = grid;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,71 +1,286 @@
|
|||||||
@inject NavigationManager NavigationManager
|
@inject NavigationManager NavigationManager
|
||||||
|
@using System.Text.Json
|
||||||
|
@using Syncfusion.Blazor.Grids
|
||||||
|
@using Syncfusion.Blazor.Cards
|
||||||
|
@using Syncfusion.Blazor.Data
|
||||||
|
@using FilterType = Syncfusion.Blazor.Grids.FilterType
|
||||||
|
@using Syncfusion.Blazor.Navigations
|
||||||
@inherits LayoutComponentBase
|
@inherits LayoutComponentBase
|
||||||
|
|
||||||
<div class="row">
|
@inject ScheduleOrderService ScheduleOrderService
|
||||||
<Grid @ref="_grid"
|
@inject IJSRuntime JSRuntime
|
||||||
TItem="ScheduleOrderDto"
|
|
||||||
Class="table table-hover table-bordered table-striped"
|
|
||||||
AllowFiltering="true"
|
|
||||||
Responsive="true"
|
|
||||||
AllowPaging="true"
|
|
||||||
PageSize="@PageSize"
|
|
||||||
AllowSelection="true"
|
|
||||||
AllowRowClick="true"
|
|
||||||
DataProvider="LoadData"
|
|
||||||
OnRowDoubleClick="OnRowDoubleClick">
|
|
||||||
|
|
||||||
<GridColumns>
|
<div class="h-100 d-flex justify-content-center align-items-start">
|
||||||
<GridColumn TItem="ScheduleOrderDto" HeaderText="Zamówienie" PropertyName="OrderID">
|
<SfCard CssClass="shadow" style="width: 100%; max-width: 1200px;">
|
||||||
@context.OrderID
|
<CardHeader>
|
||||||
</GridColumn>
|
<h3 class="text-primary">Zamówienia DELFOR</h3>
|
||||||
<GridColumn TItem="ScheduleOrderDto" HeaderText="Zamówienie Klienta" PropertyName="PONum">
|
</CardHeader>
|
||||||
@context.PONum
|
<CardContent>
|
||||||
</GridColumn>
|
<SfGrid @ref="Grid"
|
||||||
<GridColumn TItem="ScheduleOrderDto" HeaderText="Odbiorca" PropertyName="RecipientCode">
|
TValue="ScheduleOrderDto"
|
||||||
@context.RecipientCode
|
AllowFiltering="true"
|
||||||
</GridColumn>
|
AllowPaging="true"
|
||||||
<GridColumn TItem="ScheduleOrderDto" HeaderText="Klient" PropertyName="PurchaserCode">
|
AllowSorting="true"
|
||||||
@context.PurchaserCode
|
AllowSelection="true"
|
||||||
</GridColumn>
|
DataSource="@_dataSource"
|
||||||
<GridColumn TItem="ScheduleOrderDto" HeaderText="Data Utworzenia" PropertyName="LastUpdateDate">
|
EnableAdaptiveUI="true"
|
||||||
@context.LastUpdateDate
|
EnablePersistence="true"
|
||||||
</GridColumn>
|
AdaptiveUIMode="AdaptiveMode.Both"
|
||||||
<GridColumn TItem="ScheduleOrderDto" HeaderText="Typ Dokumentu" PropertyName="DocType">
|
AllowRowClick="true"
|
||||||
@context.DocType
|
SelectionMode="GridSelectionMode.Single"
|
||||||
</GridColumn>
|
QueryCellInfo="OnQueryCellInfo"
|
||||||
</GridColumns>
|
RowSelected="OnRowSelected">
|
||||||
</Grid>
|
<SfToolbar>
|
||||||
|
<ToolbarItems>
|
||||||
|
<ToolbarItem Type="ItemType.Button" Text="Zapisz Filtry" Id="SaveButton"
|
||||||
|
PrefixIcon="e-icons e-save" OnClick="SaveFilters"/>
|
||||||
|
<ToolbarItem Type="ItemType.Button" Id="DeleteButton" PrefixIcon="e-icons e-delete"
|
||||||
|
Text="Usuń Zapisane Filtry" OnClick="DeleteFilters"/>
|
||||||
|
</ToolbarItems>
|
||||||
|
</SfToolbar>
|
||||||
|
<GridColumns>
|
||||||
|
<GridColumn Field=@nameof(ScheduleOrderDto.PONum) HeaderText="Zamówienie Klienta" Width="120" AllowResizing="true"
|
||||||
|
AllowFiltering="true"></GridColumn>
|
||||||
|
<GridColumn Field=@nameof(ScheduleOrderDto.PurchaserCode) HeaderText="Klient" Width="100" AllowResizing="true"
|
||||||
|
AllowFiltering="true"></GridColumn>
|
||||||
|
<GridColumn Field=@nameof(ScheduleOrderDto.RecipientName) HeaderText="Odbiorca" Width="150" AllowResizing="true"
|
||||||
|
AllowFiltering="true"></GridColumn>
|
||||||
|
<GridColumn Field=@nameof(ScheduleOrderDto.RecipientCode) HeaderText="Kod odbiorcy" Width="120" AllowResizing="true"
|
||||||
|
AllowFiltering="true"></GridColumn>
|
||||||
|
<GridColumn Field=@nameof(ScheduleOrderDto.LastUpdateDate) HeaderText="Data" Format="d"
|
||||||
|
Type="ColumnType.Date" Width="80" AllowResizing="true" AllowFiltering="true"></GridColumn>
|
||||||
|
<GridColumn Field=@nameof(ScheduleOrderDto.DocType) HeaderText="Typ Dokumentu" Width="100" AllowResizing="true"
|
||||||
|
AllowFiltering="true"></GridColumn>
|
||||||
|
</GridColumns>
|
||||||
|
<GridTemplates>
|
||||||
|
<DetailTemplate>
|
||||||
|
@{
|
||||||
|
IList<ScheduleOrderDetailDto>? scheduleOrderDetails = (@context as ScheduleOrderDto)?.ScheduleOrderDetails;
|
||||||
|
<SfGrid AllowFiltering="true"
|
||||||
|
AllowPaging="true"
|
||||||
|
AllowSorting="true"
|
||||||
|
AllowSelection="true"
|
||||||
|
TValue="ScheduleOrderDetailDto"
|
||||||
|
DataSource="@scheduleOrderDetails"
|
||||||
|
EnablePersistence="true"
|
||||||
|
EnableAdaptiveUI="true"
|
||||||
|
AdaptiveUIMode="AdaptiveMode.Both">
|
||||||
|
<GridColumns>
|
||||||
|
<GridColumn Field=@nameof(ScheduleOrderDetailDto.OrderNumber)
|
||||||
|
HeaderText="Numer Zamówienia" Width="100" AllowResizing="true"></GridColumn>
|
||||||
|
<GridColumn Field=@nameof(ScheduleOrderDetailDto.PurchaserName) HeaderText="Klient"
|
||||||
|
Width="100" AllowResizing="true"></GridColumn>
|
||||||
|
<GridColumn Field=@nameof(ScheduleOrderDetailDto.RecipientName)
|
||||||
|
HeaderText="Odbiorca" Width="100" AllowResizing="true"></GridColumn>
|
||||||
|
<GridColumn Field=@nameof(ScheduleOrderDetailDto.RecipientCode)
|
||||||
|
HeaderText="Kod odbiorcy" Width="100"
|
||||||
|
AllowFiltering="true" AllowResizing="true"></GridColumn>
|
||||||
|
<GridColumn Field=@nameof(ScheduleOrderDetailDto.Sc_productCode)
|
||||||
|
HeaderText="Pozycja Klienta" Width="100" AllowResizing="true"></GridColumn>
|
||||||
|
<GridColumn Field=@nameof(ScheduleOrderDetailDto.Sh_productCode)
|
||||||
|
HeaderText="Pozycja" Width="100" AllowResizing="true"></GridColumn>
|
||||||
|
</GridColumns>
|
||||||
|
<GridTemplates>
|
||||||
|
<DetailTemplate Context="detail">
|
||||||
|
@{
|
||||||
|
IList<ScheduleOrderDetailDetailDto>? scheduleOrderDetailsDetails = (@detail as ScheduleOrderDetailDto)?.ScheduleOrderDetailDetails;
|
||||||
|
<SfGrid AllowFiltering="true"
|
||||||
|
AllowPaging="true"
|
||||||
|
AllowSorting="true"
|
||||||
|
AllowSelection="true"
|
||||||
|
TValue="ScheduleOrderDetailDetailDto"
|
||||||
|
DataSource="@scheduleOrderDetailsDetails"
|
||||||
|
EnableAdaptiveUI="true"
|
||||||
|
AdaptiveUIMode="AdaptiveMode.Both">
|
||||||
|
<GridColumns>
|
||||||
|
<GridColumn Field=@nameof(ScheduleOrderDetailDetailDto.DateFrom)
|
||||||
|
HeaderText="Data Od" Width="100" AllowResizing="true"></GridColumn>
|
||||||
|
<GridColumn Field=@nameof(ScheduleOrderDetailDetailDto.DateTo)
|
||||||
|
HeaderText="Data Do" Width="100" AllowResizing="true"></GridColumn>
|
||||||
|
<GridColumn Field=@nameof(ScheduleOrderDetailDetailDto.Qty)
|
||||||
|
TextAlign="TextAlign.Right" HeaderText="Ilość Sztuk"
|
||||||
|
Width="50" AllowResizing="true"></GridColumn>
|
||||||
|
<GridColumn Field=@nameof(ScheduleOrderDetailDetailDto.QtyType)
|
||||||
|
TextAlign="TextAlign.Right" HeaderText="Typ Qty"
|
||||||
|
Width="50" AllowResizing="true"></GridColumn>
|
||||||
|
<GridColumn Field=@nameof(ScheduleOrderDetailDetailDto.QtyDesc)
|
||||||
|
HeaderText="Opis Typu" Width="100" AllowResizing="true"></GridColumn>
|
||||||
|
</GridColumns>
|
||||||
|
<GridFilterSettings Type="FilterType.Excel"/>
|
||||||
|
<GridPageSettings PageSize="10"/>
|
||||||
|
<GridSelectionSettings Mode="SelectionMode.Row"
|
||||||
|
Type="SelectionType.Single"/>
|
||||||
|
<GridEvents TValue="ScheduleOrderDetailDetailDto"
|
||||||
|
OnRecordDoubleClick="OnScheduleOrderDetailDetailRowDoubleClick"
|
||||||
|
RowDataBound="OnRowDataBound"/>
|
||||||
|
</SfGrid>
|
||||||
|
}
|
||||||
|
</DetailTemplate>
|
||||||
|
</GridTemplates>
|
||||||
|
<GridFilterSettings Type="FilterType.Excel"/>
|
||||||
|
<GridPageSettings PageSize="10"/>
|
||||||
|
<GridSelectionSettings Mode="SelectionMode.Row" Type="SelectionType.Single"/>
|
||||||
|
<GridEvents TValue="ScheduleOrderDetailDto"
|
||||||
|
OnRecordDoubleClick="OnScheduleOrderDetailRowDoubleClick"/>
|
||||||
|
</SfGrid>
|
||||||
|
}
|
||||||
|
</DetailTemplate>
|
||||||
|
</GridTemplates>
|
||||||
|
<GridEvents TValue="ScheduleOrderDto" OnRecordDoubleClick="OnScheduleOrderRowDoubleClick" DetailsExpanding="OnDetailsExpanding"/>
|
||||||
|
<GridFilterSettings Type="FilterType.Excel"/>
|
||||||
|
<GridPageSettings PageSize="@PageSize"/>
|
||||||
|
</SfGrid>
|
||||||
|
</CardContent>
|
||||||
|
<CardFooter>
|
||||||
|
<small class="text-muted">FA Krosno Manager © @(DateTime.Now.Year)</small>
|
||||||
|
</CardFooter>
|
||||||
|
</SfCard>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
[Parameter]
|
[Parameter] public required IEnumerable<ScheduleOrderDto> GridData { get; set; }
|
||||||
public required Func<GridDataProviderRequest<ScheduleOrderDto>, Task<GridDataProviderResult<ScheduleOrderDto>>> DataProvider { get; set; }
|
|
||||||
|
|
||||||
[Parameter]
|
[Parameter] public required Func<SfGrid<ScheduleOrderDto>, Task> PassGridRef { get; set; }
|
||||||
public required Func<Grid<ScheduleOrderDto>, Task> PassGridRef { get; set; }
|
|
||||||
|
|
||||||
[Parameter]
|
[Parameter] public required int PageSize { get; set; }
|
||||||
public required int PageSize { get; set; }
|
|
||||||
|
|
||||||
private Grid<ScheduleOrderDto> _grid { get; set; }
|
private ScheduleOrderDto? ScheduleOrderDto { get; set; }
|
||||||
|
|
||||||
|
private SfGrid<ScheduleOrderDto>? Grid { get; set; }
|
||||||
|
|
||||||
|
private IEnumerable<ScheduleOrderDto> _dataSource = [];
|
||||||
|
|
||||||
|
protected override void OnParametersSet()
|
||||||
|
{
|
||||||
|
_dataSource = GridData;
|
||||||
|
}
|
||||||
|
|
||||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||||
{
|
{
|
||||||
if (firstRender)
|
if (firstRender && Grid != null)
|
||||||
{
|
{
|
||||||
await PassGridRef(_grid);
|
await PassGridRef(Grid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<GridDataProviderResult<ScheduleOrderDto>> LoadData(GridDataProviderRequest<ScheduleOrderDto> request)
|
private void OnScheduleOrderRowDoubleClick(RecordDoubleClickEventArgs<ScheduleOrderDto> obj)
|
||||||
{
|
{
|
||||||
return await DataProvider.Invoke(request);
|
int scheduleOrderId = obj.RowData.ID;
|
||||||
}
|
|
||||||
|
|
||||||
private void OnRowDoubleClick(GridRowEventArgs<ScheduleOrderDto> obj)
|
|
||||||
{
|
|
||||||
int scheduleOrderId = obj.Item.ID;
|
|
||||||
|
|
||||||
NavigationManager.NavigateTo($"/ScheduleOrder/{scheduleOrderId}");
|
NavigationManager.NavigateTo($"/ScheduleOrder/{scheduleOrderId}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnScheduleOrderDetailRowDoubleClick(RecordDoubleClickEventArgs<ScheduleOrderDetailDto> obj)
|
||||||
|
{
|
||||||
|
int? scheduleOrderId = ScheduleOrderDto?.ID;
|
||||||
|
|
||||||
|
if (scheduleOrderId is not null)
|
||||||
|
{
|
||||||
|
NavigationManager.NavigateTo($"/ScheduleOrder/{scheduleOrderId}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnScheduleOrderDetailDetailRowDoubleClick(RecordDoubleClickEventArgs<ScheduleOrderDetailDetailDto> obj)
|
||||||
|
{
|
||||||
|
int? scheduleOrderId = ScheduleOrderDto?.ID;
|
||||||
|
|
||||||
|
if (scheduleOrderId is not null)
|
||||||
|
{
|
||||||
|
NavigationManager.NavigateTo($"/ScheduleOrder/{scheduleOrderId}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task OnDetailsExpanding(DetailsExpandingEventArgs<ScheduleOrderDto> obj)
|
||||||
|
{
|
||||||
|
ScheduleOrderDto = obj.Data;
|
||||||
|
|
||||||
|
if (ScheduleOrderDto != null)
|
||||||
|
{
|
||||||
|
ScheduleOrderDto? scheduleOrder = await ScheduleOrderService.GetScheduleOrderAsync(ScheduleOrderDto.ID);
|
||||||
|
ScheduleOrderDto.ScheduleOrderDetails = scheduleOrder?.ScheduleOrderDetails ?? [];
|
||||||
|
|
||||||
|
foreach (ScheduleOrderDetailDto scheduleOrderDetailDto in ScheduleOrderDto.ScheduleOrderDetails)
|
||||||
|
{
|
||||||
|
scheduleOrderDetailDto.OrderNumber = scheduleOrder?.PONum;
|
||||||
|
scheduleOrderDetailDto.RecipientCode = scheduleOrder?.RecipientCode;
|
||||||
|
scheduleOrderDetailDto.RecipientName = scheduleOrder?.RecipientName;
|
||||||
|
scheduleOrderDetailDto.PurchaserName = scheduleOrder?.PurchaserCode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnRowDataBound(RowDataBoundEventArgs<ScheduleOrderDetailDetailDto> args)
|
||||||
|
{
|
||||||
|
if (new[] { "54", "83", "84" }.Any(x => x == args.Data.QtyType))
|
||||||
|
{
|
||||||
|
args.Row.AddClass(["highlight-red"]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task RestoreFilterFromLocalStorage()
|
||||||
|
{
|
||||||
|
var filterJson = await JSRuntime.InvokeAsync<string>("localStorage.getItem", "gridFilter");
|
||||||
|
if (!string.IsNullOrEmpty(filterJson))
|
||||||
|
{
|
||||||
|
var options = new JsonSerializerOptions
|
||||||
|
{
|
||||||
|
PropertyNameCaseInsensitive = true
|
||||||
|
};
|
||||||
|
var filters = JsonSerializer.Deserialize<List<WhereFilter>>(filterJson, options);
|
||||||
|
|
||||||
|
await Grid.ClearFilteringAsync();
|
||||||
|
|
||||||
|
if (filters != null && filters.Any())
|
||||||
|
{
|
||||||
|
foreach (var filter in filters.GroupBy(x => x.Field))
|
||||||
|
{
|
||||||
|
IList<object> values = filter.Select(x => GetValueFromJsonElement((JsonElement)x.value)).ToList();
|
||||||
|
|
||||||
|
await Grid.FilterByColumnAsync(filter.Key, filter.First().Operator.ToLower(), values);
|
||||||
|
}
|
||||||
|
|
||||||
|
await Grid.Refresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private object GetValueFromJsonElement(JsonElement element)
|
||||||
|
{
|
||||||
|
switch (element.ValueKind)
|
||||||
|
{
|
||||||
|
case JsonValueKind.String:
|
||||||
|
return element.GetString();
|
||||||
|
case JsonValueKind.Number:
|
||||||
|
if (element.TryGetInt32(out int intValue)) return intValue;
|
||||||
|
if (element.TryGetDouble(out double doubleValue)) return doubleValue;
|
||||||
|
break;
|
||||||
|
case JsonValueKind.True:
|
||||||
|
return true;
|
||||||
|
case JsonValueKind.False:
|
||||||
|
return false;
|
||||||
|
case JsonValueKind.Null:
|
||||||
|
return null;
|
||||||
|
default:
|
||||||
|
Console.WriteLine($"Nieobsługiwany typ JsonElement: {element.ValueKind}");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task SaveFilters()
|
||||||
|
{
|
||||||
|
var filterSettings = Grid.FilterSettings.Columns;
|
||||||
|
if (filterSettings != null && filterSettings.Any())
|
||||||
|
{
|
||||||
|
string filterJson = JsonSerializer.Serialize(filterSettings);
|
||||||
|
await JSRuntime.InvokeVoidAsync("localStorage.setItem", "gridFilter", filterJson);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task DeleteFilters()
|
||||||
|
{
|
||||||
|
await JSRuntime.InvokeVoidAsync("localStorage.removeItem", "gridFilter");
|
||||||
|
await Grid.ClearFilteringAsync();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
33
OrdersManagement/Components/Pages/Unauthorized.razor
Normal file
33
OrdersManagement/Components/Pages/Unauthorized.razor
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
@page "/Unauthorized"
|
||||||
|
@using Microsoft.AspNetCore.Authorization
|
||||||
|
|
||||||
|
@using Syncfusion.Blazor.Cards
|
||||||
|
@using Syncfusion.Blazor.Buttons
|
||||||
|
|
||||||
|
@inject NavigationManager NavigationManager
|
||||||
|
|
||||||
|
<div class="h-100 d-flex justify-content-center align-items-start pt-5">
|
||||||
|
<SfCard CssClass="text-center shadow" style="max-width: 500px;">
|
||||||
|
<CardHeader>
|
||||||
|
<h3 class="text-warning">Brak autoryzacji</h3>
|
||||||
|
</CardHeader>
|
||||||
|
<CardContent>
|
||||||
|
<p class="text-muted mb-4">
|
||||||
|
Ups! Wygląda na to, że nie masz dostępu do tej strony. Aby kontynuować, zaloguj się do swojego konta.
|
||||||
|
</p>
|
||||||
|
<SfButton CssClass="e-primary" IsPrimary="true" @onclick="NavigateToLogin">
|
||||||
|
Przejdź do logowania
|
||||||
|
</SfButton>
|
||||||
|
</CardContent>
|
||||||
|
<CardFooter>
|
||||||
|
<small class="text-muted">FA Krosno Manager © @(DateTime.Now.Year)</small>
|
||||||
|
</CardFooter>
|
||||||
|
</SfCard>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
private void NavigateToLogin()
|
||||||
|
{
|
||||||
|
NavigationManager.NavigateTo("/login");
|
||||||
|
}
|
||||||
|
}
|
||||||
280
OrdersManagement/Components/Pages/Warehouse.razor
Normal file
280
OrdersManagement/Components/Pages/Warehouse.razor
Normal file
@@ -0,0 +1,280 @@
|
|||||||
|
@page "/Warehouse"
|
||||||
|
|
||||||
|
@using Blazored.LocalStorage
|
||||||
|
@using Syncfusion.Blazor.Cards
|
||||||
|
@using Syncfusion.Blazor.Grids
|
||||||
|
@using SytelineSaAppEfDataModel.Dtos
|
||||||
|
@using Syncfusion.Blazor.DropDowns
|
||||||
|
@using FilterType = Syncfusion.Blazor.Grids.FilterType
|
||||||
|
@using SelectionMode = Syncfusion.Blazor.Grids.SelectionMode
|
||||||
|
@using Syncfusion.Blazor.Navigations
|
||||||
|
@using Syncfusion.Blazor.Popups
|
||||||
|
|
||||||
|
@inject WarehouseService WarehouseService
|
||||||
|
@inject NavigationManager NavigationManager
|
||||||
|
@inject ILocalStorageService LocalStorage
|
||||||
|
|
||||||
|
<div class="h-100 d-flex justify-content-center align-items-start">
|
||||||
|
<SfCard CssClass="shadow" style="width: 100%; max-width: 1200px;">
|
||||||
|
<CardHeader>
|
||||||
|
<h3 class="text-primary">Dokumenty WZ na Magazynie</h3>
|
||||||
|
</CardHeader>
|
||||||
|
<CardContent>
|
||||||
|
<h5 class="text-primary mb-3">Klient</h5>
|
||||||
|
<SfDropDownList @ref="_dropdown" TValue="Guid?" TItem="WzClientDto" DataSource="@_clients" Placeholder="Wybierz Klienta">
|
||||||
|
<DropDownListFieldSettings Value="ID" Text="Name"/>
|
||||||
|
<DropDownListEvents TValue="Guid?" TItem="WzClientDto" ValueChange="OnValueChange"/>
|
||||||
|
</SfDropDownList>
|
||||||
|
@if (_isVisible)
|
||||||
|
{
|
||||||
|
<SfCard CssClass="shadow" style="width: 100%; max-width: 1200px;">
|
||||||
|
<CardHeader>
|
||||||
|
<h5 class="text-primary mb-3">Dokumenty WZ</h5>
|
||||||
|
</CardHeader>
|
||||||
|
<CardContent>
|
||||||
|
<SfGrid @ref="_grid"
|
||||||
|
AllowFiltering="true"
|
||||||
|
AllowPaging="true"
|
||||||
|
AllowSorting="true"
|
||||||
|
AllowSelection="true"
|
||||||
|
TValue="MaterialTransactionDto"
|
||||||
|
DataSource="@_dataSource"
|
||||||
|
EnableAdaptiveUI="true">
|
||||||
|
<GridColumns>
|
||||||
|
<GridColumn Field=@nameof(MaterialTransactionDto.MTGroupNum) HeaderText="Numer WZ" TextAlign="TextAlign.Center" Width="110"></GridColumn>
|
||||||
|
<GridColumn Field=@nameof(MaterialTransactionDto.CreateDate) HeaderText="Data utworzenia" TextAlign="TextAlign.Center" Width="100"></GridColumn>
|
||||||
|
<GridColumn Field=@nameof(MaterialTransactionDto.RefNum) HeaderText="Numer zamówienia" TextAlign="TextAlign.Center" Width="110"></GridColumn>
|
||||||
|
</GridColumns>
|
||||||
|
<SfToolbar>
|
||||||
|
<ToolbarItems>
|
||||||
|
<ToolbarItem Type="ItemType.Button" Text="Utwórz Packing List" Id="CreatePackingList"
|
||||||
|
PrefixIcon="e-icons e-save" OnClick="CreatePackingList"/>
|
||||||
|
</ToolbarItems>
|
||||||
|
</SfToolbar>
|
||||||
|
<GridFilterSettings Type="FilterType.Excel"/>
|
||||||
|
<GridPageSettings PageSize="5"/>
|
||||||
|
<GridSelectionSettings Mode="SelectionMode.Row" Type="SelectionType.Multiple"/>
|
||||||
|
</SfGrid>
|
||||||
|
</CardContent>
|
||||||
|
</SfCard>
|
||||||
|
<SfCard CssClass="shadow" style="width: 100%; max-width: 1200px;">
|
||||||
|
<CardHeader>
|
||||||
|
<h5 class="text-primary mb-3">Packling Listy</h5>
|
||||||
|
</CardHeader>
|
||||||
|
<CardContent>
|
||||||
|
<SfGrid AllowFiltering="true"
|
||||||
|
AllowPaging="true"
|
||||||
|
AllowSorting="true"
|
||||||
|
AllowSelection="true"
|
||||||
|
TValue="WzHeaderDto"
|
||||||
|
DataSource="@_wzHeaders"
|
||||||
|
EnableAdaptiveUI="true">
|
||||||
|
<GridColumns>
|
||||||
|
<GridColumn Field=@nameof(WzHeaderDto.ID) HeaderText="ID" TextAlign="TextAlign.Center" Width="110"></GridColumn>
|
||||||
|
<GridColumn Field=@nameof(WzHeaderDto.WzNumbers) HeaderText="Numery WZ" TextAlign="TextAlign.Center" Width="100"></GridColumn>
|
||||||
|
<GridColumn Field=@nameof(WzHeaderDto.CreatedDate) HeaderText="Data utworzenia" TextAlign="TextAlign.Center" Width="100"></GridColumn>
|
||||||
|
</GridColumns>
|
||||||
|
<GridFilterSettings Type="FilterType.Excel"/>
|
||||||
|
<GridPageSettings PageSize="5"/>
|
||||||
|
<GridSelectionSettings Mode="SelectionMode.Row" Type="SelectionType.Single"/>
|
||||||
|
<GridEvents TValue="WzHeaderDto" OnRecordDoubleClick="OnRowDoubleClick"/>
|
||||||
|
</SfGrid>
|
||||||
|
</CardContent>
|
||||||
|
</SfCard>
|
||||||
|
}
|
||||||
|
</CardContent>
|
||||||
|
|
||||||
|
<SfDialog Width="500px" Title="Informacja" IsModal="true" @bind-Visible="Visibility" AllowPrerender="true">
|
||||||
|
<DialogTemplates>
|
||||||
|
<Content>
|
||||||
|
<p>Błąd: Zaznacz przynajmniej jeden rekord, żeby wygenerowac Pack List!</p>
|
||||||
|
</Content>
|
||||||
|
</DialogTemplates>
|
||||||
|
<DialogButtons>
|
||||||
|
<DialogButton Content="OK" IsPrimary="true" OnClick="@HideModal"/>
|
||||||
|
</DialogButtons>
|
||||||
|
</SfDialog>
|
||||||
|
|
||||||
|
<SfDialog Width="500px" Title="Błąd" IsModal="true" @bind-Visible="VisibilityError" AllowPrerender="true">
|
||||||
|
<DialogTemplates>
|
||||||
|
<Content>
|
||||||
|
<p>Błąd: Dla zaznaczonego rekordu istnieje już PackingList!</p>
|
||||||
|
</Content>
|
||||||
|
</DialogTemplates>
|
||||||
|
<DialogButtons>
|
||||||
|
<DialogButton Content="OK" IsPrimary="true" OnClick="@HideModal"/>
|
||||||
|
</DialogButtons>
|
||||||
|
</SfDialog>
|
||||||
|
|
||||||
|
<CardFooter>
|
||||||
|
<small class="text-muted">FA Krosno Manager © @(DateTime.Now.Year)</small>
|
||||||
|
</CardFooter>
|
||||||
|
</SfCard>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
private SfGrid<MaterialTransactionDto> _grid;
|
||||||
|
private IEnumerable<WzClientDto> _clients = new List<WzClientDto>();
|
||||||
|
private IEnumerable<MaterialTransactionDto> _materialTransactions = new List<MaterialTransactionDto>();
|
||||||
|
private IEnumerable<MaterialTransactionDto> _dataSource = new List<MaterialTransactionDto>();
|
||||||
|
private IEnumerable<WzHeaderDto> _wzHeaders = new List<WzHeaderDto>();
|
||||||
|
|
||||||
|
private WzClientDto? _selectedClient;
|
||||||
|
|
||||||
|
private WzHeaderDto? _selectedHeader;
|
||||||
|
private SfDropDownList<Guid?, WzClientDto> _dropdown;
|
||||||
|
private bool _isVisible;
|
||||||
|
|
||||||
|
private bool Visibility { get; set; }
|
||||||
|
private bool VisibilityError { get; set; }
|
||||||
|
|
||||||
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||||
|
{
|
||||||
|
if (firstRender)
|
||||||
|
{
|
||||||
|
_clients = await WarehouseService.GetAllClientsAsync();
|
||||||
|
_clients = _clients.Where(x => new[] { "MAGNETI MARELLI", "MEYLE" }.Any(y => y.Equals(x.Name, StringComparison.OrdinalIgnoreCase))).ToList();
|
||||||
|
|
||||||
|
StateHasChanged();
|
||||||
|
|
||||||
|
var savedClientId = await LocalStorage.GetItemAsync<Guid?>("SelectedClientId");
|
||||||
|
|
||||||
|
if (savedClientId != null && _clients.FirstOrDefault(c => c.ID == savedClientId) is {} savedClient)
|
||||||
|
{
|
||||||
|
await OnValueChange(new ChangeEventArgs<Guid?, WzClientDto>() { Value = savedClient.ID });
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task OnValueChange(ChangeEventArgs<Guid?, WzClientDto> args)
|
||||||
|
{
|
||||||
|
if (args.Value.HasValue)
|
||||||
|
{
|
||||||
|
_selectedClient = args.ItemData ?? _clients.FirstOrDefault(x => x.ID == args.Value);
|
||||||
|
|
||||||
|
if (_selectedClient == null) { return; }
|
||||||
|
|
||||||
|
_isVisible = true;
|
||||||
|
_materialTransactions = await WarehouseService.GetAllClientWzsAsync(_selectedClient.CustomerNumber, _selectedClient.CustomerSequence ?? 0);
|
||||||
|
_dataSource = _materialTransactions.GroupBy(x => x.MTGroupNum).Select(x => x.First()).ToList();
|
||||||
|
_wzHeaders = await WarehouseService.GetAllClientWzHeadersAsync(_selectedClient.CustomerNumber, _selectedClient.CustomerSequence ?? 0);
|
||||||
|
|
||||||
|
await LocalStorage.SetItemAsync("SelectedClientId", _selectedClient.ID);
|
||||||
|
|
||||||
|
_dropdown.Value = _selectedClient.ID;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_selectedClient = null;
|
||||||
|
_isVisible = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnRowDoubleClick(RecordDoubleClickEventArgs<WzHeaderDto> obj)
|
||||||
|
{
|
||||||
|
if (_selectedClient is null) return;
|
||||||
|
|
||||||
|
Guid headerId = obj.RowData.ID;
|
||||||
|
|
||||||
|
NavigationManager.NavigateTo($"/Warehouse/{_selectedClient.ShortName}/PackList/" + headerId);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task CreatePackingList()
|
||||||
|
{
|
||||||
|
var selectedRecords = await _grid.GetSelectedRecordsAsync();
|
||||||
|
|
||||||
|
if (!selectedRecords.Any())
|
||||||
|
{
|
||||||
|
Visibility = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
string wzNumbers = string.Join(", ",selectedRecords.Select(x => x.MTGroupNum).Distinct());
|
||||||
|
|
||||||
|
if (_wzHeaders.Any(x => x.WzNumbers == wzNumbers))
|
||||||
|
{
|
||||||
|
VisibilityError = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
WzHeaderDto wzHeader = new WzHeaderDto
|
||||||
|
{
|
||||||
|
ID = Guid.NewGuid(),
|
||||||
|
FK_Client = _selectedClient?.ID,
|
||||||
|
CreatedDate = DateTime.Now,
|
||||||
|
WzNumbers = wzNumbers
|
||||||
|
};
|
||||||
|
|
||||||
|
await WarehouseService.CreateWzHeaderAsync(wzHeader);
|
||||||
|
|
||||||
|
switch (_selectedClient?.ShortName.ToUpper())
|
||||||
|
{
|
||||||
|
case "MEYLE":
|
||||||
|
IList<WzRowMeyleDto> meyleRows = new List<WzRowMeyleDto>();
|
||||||
|
IList<MaterialTransactionDto> meyleMaterialTransactions = _materialTransactions.Where(x => selectedRecords.Any(y => y.MTGroupNum == x.MTGroupNum)).ToList();
|
||||||
|
|
||||||
|
foreach (MaterialTransactionDto materialTransactionDto in meyleMaterialTransactions)
|
||||||
|
{
|
||||||
|
CustomerOrderDto customerOrder = await WarehouseService.GetCustomerOrder(materialTransactionDto.RefNum ?? string.Empty);
|
||||||
|
ItemCustDto item = await WarehouseService.GetItem(materialTransactionDto.Item ?? string.Empty, customerOrder.CustNum);
|
||||||
|
|
||||||
|
meyleRows.Add(new WzRowMeyleDto
|
||||||
|
{
|
||||||
|
ID = Guid.NewGuid(),
|
||||||
|
Quantity = Math.Abs((int?)materialTransactionDto.Qty ?? 0),
|
||||||
|
ItemNumber = item.CustItem,
|
||||||
|
OrderNumber = customerOrder.CustPo,
|
||||||
|
WzNumber = materialTransactionDto.MTGroupNum ?? string.Empty,
|
||||||
|
FK_Header = wzHeader.ID,
|
||||||
|
TransactionNumber = (int?)materialTransactionDto.TransNum ?? 0,
|
||||||
|
PartNumberSl = materialTransactionDto.NR_KARTY_KONTROLNEJ,
|
||||||
|
FaIndex = item.Item
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
await WarehouseService.CreateWzRowsMeyleAsync(meyleRows);
|
||||||
|
|
||||||
|
NavigationManager.NavigateTo("/Warehouse/Meyle/PackList/" + wzHeader.ID);
|
||||||
|
|
||||||
|
break;
|
||||||
|
case "MARELLI":
|
||||||
|
IList<WzRowMarelliDto> marelliRows = new List<WzRowMarelliDto>();
|
||||||
|
IList<MaterialTransactionDto> marelliMaterialTransactions = _materialTransactions.Where(x => selectedRecords.Any(y => y.MTGroupNum == x.MTGroupNum)).ToList();
|
||||||
|
|
||||||
|
foreach (MaterialTransactionDto materialTransactionDto in marelliMaterialTransactions)
|
||||||
|
{
|
||||||
|
CustomerOrderDto customerOrder = await WarehouseService.GetCustomerOrder(materialTransactionDto.RefNum ?? string.Empty);
|
||||||
|
ItemCustDto item = await WarehouseService.GetItem(materialTransactionDto.Item ?? string.Empty, customerOrder.CustNum);
|
||||||
|
|
||||||
|
marelliRows.Add(new WzRowMarelliDto
|
||||||
|
{
|
||||||
|
ID = Guid.NewGuid(),
|
||||||
|
Quantity = Math.Abs((int?)materialTransactionDto.Qty ?? 0),
|
||||||
|
ItemNumber = item.CustItem,
|
||||||
|
OrderNumber = customerOrder.CustPo,
|
||||||
|
WzNumber = materialTransactionDto.MTGroupNum ?? string.Empty,
|
||||||
|
FKHeader = wzHeader.ID,
|
||||||
|
TransactionNumber = (int?)materialTransactionDto.TransNum ?? 0,
|
||||||
|
Type = "MIX",
|
||||||
|
FaIndex = item.Item,
|
||||||
|
EngineerNumber = item.Uf_FKR_CustItem2
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
await WarehouseService.CreateWzRowsMarelliAsync(marelliRows);
|
||||||
|
|
||||||
|
NavigationManager.NavigateTo("/Warehouse/Marelli/PackList/" + wzHeader.ID);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void HideModal()
|
||||||
|
{
|
||||||
|
Visibility = false;
|
||||||
|
VisibilityError = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
@using OrdersManagement.Components.Layout
|
<Router AppAssembly="@typeof(Program).Assembly">
|
||||||
<Router AppAssembly="@typeof(Program).Assembly">
|
|
||||||
<Found Context="routeData">
|
<Found Context="routeData">
|
||||||
<RouteView RouteData="@routeData" DefaultLayout="@typeof(Layout.MainLayout)" />
|
<RouteView RouteData="@routeData" DefaultLayout="@typeof(Layout.MainLayout)" />
|
||||||
<FocusOnNavigate RouteData="@routeData" Selector="h1" />
|
<FocusOnNavigate RouteData="@routeData" Selector="h1" />
|
||||||
|
|||||||
@@ -6,6 +6,5 @@
|
|||||||
@using static Microsoft.AspNetCore.Components.Web.RenderMode
|
@using static Microsoft.AspNetCore.Components.Web.RenderMode
|
||||||
@using Microsoft.AspNetCore.Components.Web.Virtualization
|
@using Microsoft.AspNetCore.Components.Web.Virtualization
|
||||||
@using Microsoft.JSInterop
|
@using Microsoft.JSInterop
|
||||||
@using BlazorBootstrap;
|
|
||||||
@using FaKrosnoEfDataModel.Dtos
|
@using FaKrosnoEfDataModel.Dtos
|
||||||
@using OrdersManagement.Services
|
@using OrdersManagement.Services
|
||||||
|
|||||||
51
OrdersManagement/CustomAuthenticationStateProvider.cs
Normal file
51
OrdersManagement/CustomAuthenticationStateProvider.cs
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
using System.IdentityModel.Tokens.Jwt;
|
||||||
|
using System.Security.Claims;
|
||||||
|
using Blazored.LocalStorage;
|
||||||
|
using Microsoft.AspNetCore.Components.Authorization;
|
||||||
|
|
||||||
|
namespace OrdersManagement;
|
||||||
|
|
||||||
|
public class CustomAuthenticationStateProvider(ILocalStorageService localStorage) : AuthenticationStateProvider
|
||||||
|
{
|
||||||
|
private string? _token;
|
||||||
|
private ClaimsPrincipal _currentUser = new(new ClaimsIdentity());
|
||||||
|
|
||||||
|
public override async Task<AuthenticationState> GetAuthenticationStateAsync()
|
||||||
|
{
|
||||||
|
_token = await localStorage.GetItemAsync<string>("authToken");
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(_token))
|
||||||
|
{
|
||||||
|
return await Task.FromResult(new AuthenticationState(new ClaimsPrincipal(new ClaimsIdentity())));
|
||||||
|
}
|
||||||
|
|
||||||
|
var handler = new JwtSecurityTokenHandler();
|
||||||
|
var jwtToken = handler.ReadJwtToken(_token);
|
||||||
|
var identity = new ClaimsIdentity(jwtToken.Claims, "jwt", JwtRegisteredClaimNames.Sub, null);
|
||||||
|
_currentUser = new ClaimsPrincipal(identity);
|
||||||
|
return await Task.FromResult(new AuthenticationState(_currentUser));
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task MarkUserAsAuthenticated(string? token)
|
||||||
|
{
|
||||||
|
_token = token;
|
||||||
|
await localStorage.SetItemAsync("authToken", token);
|
||||||
|
var handler = new JwtSecurityTokenHandler();
|
||||||
|
var jwtToken = handler.ReadJwtToken(token);
|
||||||
|
var identity = new ClaimsIdentity(jwtToken.Claims, "jwt", JwtRegisteredClaimNames.Sub, null);
|
||||||
|
_currentUser = new ClaimsPrincipal(identity);
|
||||||
|
NotifyAuthenticationStateChanged(Task.FromResult(new AuthenticationState(_currentUser)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task MarkUserAsLoggedOut()
|
||||||
|
{
|
||||||
|
_token = null;
|
||||||
|
await localStorage.RemoveItemAsync("authToken");
|
||||||
|
_currentUser = new ClaimsPrincipal(new ClaimsIdentity());
|
||||||
|
NotifyAuthenticationStateChanged(Task.FromResult(new AuthenticationState(_currentUser)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public string? GetToken() => _token;
|
||||||
|
public ClaimsPrincipal GetCurrentUser() => _currentUser;
|
||||||
|
}
|
||||||
|
|
||||||
14
OrdersManagement/Models/ChangePasswordModel.cs
Normal file
14
OrdersManagement/Models/ChangePasswordModel.cs
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace OrdersManagement.Models;
|
||||||
|
|
||||||
|
public class ChangePasswordModel
|
||||||
|
{
|
||||||
|
[Required(ErrorMessage = "Nowe hasło jest wymagane")]
|
||||||
|
[StringLength(100, MinimumLength = 6, ErrorMessage = "Hasło musi mieć od 6 do 100 znaków")]
|
||||||
|
public string NewPassword { get; set; }
|
||||||
|
|
||||||
|
[Required(ErrorMessage = "Potwierdzenie hasła jest wymagane")]
|
||||||
|
[Compare("NewPassword", ErrorMessage = "Hasła muszą się zgadzać")]
|
||||||
|
public string ConfirmPassword { get; set; }
|
||||||
|
}
|
||||||
12
OrdersManagement/Models/LoginModel.cs
Normal file
12
OrdersManagement/Models/LoginModel.cs
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace OrdersManagement.Models;
|
||||||
|
|
||||||
|
public class LoginModel
|
||||||
|
{
|
||||||
|
[Required(ErrorMessage = "Login jest wymagany")]
|
||||||
|
public string Login { get; set; }
|
||||||
|
|
||||||
|
[Required(ErrorMessage = "Hasło jest wymagane")]
|
||||||
|
public string Password { get; set; }
|
||||||
|
}
|
||||||
7
OrdersManagement/Models/LoginResponseDto.cs
Normal file
7
OrdersManagement/Models/LoginResponseDto.cs
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
namespace OrdersManagement.Models;
|
||||||
|
|
||||||
|
public class LoginResponseDto
|
||||||
|
{
|
||||||
|
public string? Token { get; set; }
|
||||||
|
public DateTime Expires { get; set; }
|
||||||
|
}
|
||||||
21
OrdersManagement/Models/RegisterModel.cs
Normal file
21
OrdersManagement/Models/RegisterModel.cs
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace OrdersManagement.Models;
|
||||||
|
|
||||||
|
public class RegisterModel
|
||||||
|
{
|
||||||
|
[Required(ErrorMessage = "Login jest wymagany")]
|
||||||
|
[StringLength(50, ErrorMessage = "Login może mieć maksymalnie 50 znaków")]
|
||||||
|
public string Login { get; set; }
|
||||||
|
|
||||||
|
[Required(ErrorMessage = "Email jest wymagany")]
|
||||||
|
[EmailAddress(ErrorMessage = "Nieprawidłowy format email")]
|
||||||
|
[StringLength(100, ErrorMessage = "Email może mieć maksymalnie 100 znaków")]
|
||||||
|
public string Email { get; set; }
|
||||||
|
|
||||||
|
[StringLength(50, ErrorMessage = "Imię może mieć maksymalnie 50 znaków")]
|
||||||
|
public string FirstName { get; set; }
|
||||||
|
|
||||||
|
[StringLength(50, ErrorMessage = "Nazwisko może mieć maksymalnie 50 znaków")]
|
||||||
|
public string LastName { get; set; }
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
namespace OrdersManagement.Dtos
|
namespace OrdersManagement.Models
|
||||||
{
|
{
|
||||||
public class ResponseDto(int status, string identifier, string? message, string? externalIdentifier)
|
public class ResponseModel(int status, string identifier, string? message, string? externalIdentifier)
|
||||||
{
|
{
|
||||||
public int Status { get; set; } = status;
|
public int Status { get; set; } = status;
|
||||||
public string Identifier { get; set; } = identifier;
|
public string Identifier { get; set; } = identifier;
|
||||||
29
OrdersManagement/Models/RowMeyleModel.cs
Normal file
29
OrdersManagement/Models/RowMeyleModel.cs
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
namespace OrdersManagement.Models;
|
||||||
|
|
||||||
|
public class RowMeyleModel : IEquatable<RowMeyleModel>
|
||||||
|
{
|
||||||
|
public string ItemNumber {get; set;} = string.Empty;
|
||||||
|
public string WzNumber { get; set; } = string.Empty;
|
||||||
|
public string? PartNumberSl { get; set; }
|
||||||
|
public int? TransactionNumber { get; set; }
|
||||||
|
|
||||||
|
public bool Equals(RowMeyleModel? other)
|
||||||
|
{
|
||||||
|
if (other is null) return false;
|
||||||
|
if (ReferenceEquals(this, other)) return true;
|
||||||
|
return ItemNumber == other.ItemNumber && WzNumber == other.WzNumber && PartNumberSl == other.PartNumberSl && TransactionNumber == other.TransactionNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool Equals(object? obj)
|
||||||
|
{
|
||||||
|
if (obj is null) return false;
|
||||||
|
if (ReferenceEquals(this, obj)) return true;
|
||||||
|
if (obj.GetType() != GetType()) return false;
|
||||||
|
return Equals((RowMeyleModel)obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override int GetHashCode()
|
||||||
|
{
|
||||||
|
return HashCode.Combine(ItemNumber, WzNumber, PartNumberSl, TransactionNumber);
|
||||||
|
}
|
||||||
|
}
|
||||||
29
OrdersManagement/Models/TransactionModel.cs
Normal file
29
OrdersManagement/Models/TransactionModel.cs
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
namespace OrdersManagement.Models;
|
||||||
|
|
||||||
|
public class TransactionModel : IEquatable<TransactionModel>
|
||||||
|
{
|
||||||
|
public string? PartNumber { get; set; }
|
||||||
|
public string? ItemNumber { get; set; }
|
||||||
|
public decimal? Quantity { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
public bool Equals(TransactionModel? other)
|
||||||
|
{
|
||||||
|
if (other is null) return false;
|
||||||
|
if (ReferenceEquals(this, other)) return true;
|
||||||
|
return PartNumber == other.PartNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool Equals(object? obj)
|
||||||
|
{
|
||||||
|
if (obj is null) return false;
|
||||||
|
if (ReferenceEquals(this, obj)) return true;
|
||||||
|
if (obj.GetType() != GetType()) return false;
|
||||||
|
return Equals((TransactionModel)obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override int GetHashCode()
|
||||||
|
{
|
||||||
|
return PartNumber.GetHashCode();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,11 +7,24 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Blazor.Bootstrap" Version="3.2.0" />
|
<PackageReference Include="BCrypt.Net-Core" Version="1.6.0" />
|
||||||
|
<PackageReference Include="Blazored.LocalStorage" Version="4.5.0" />
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.11" />
|
||||||
|
<PackageReference Include="Microsoft.IdentityModel.Protocols" Version="8.6.1" />
|
||||||
|
<PackageReference Include="Microsoft.IdentityModel.Protocols.OpenIdConnect" Version="8.6.1" />
|
||||||
|
<PackageReference Include="Syncfusion.Blazor.Buttons" Version="28.2.3" />
|
||||||
|
<PackageReference Include="Syncfusion.Blazor.Cards" Version="28.2.3" />
|
||||||
|
<PackageReference Include="Syncfusion.Blazor.Core" Version="28.2.3" />
|
||||||
|
<PackageReference Include="Syncfusion.Blazor.Grid" Version="28.2.3" />
|
||||||
|
<PackageReference Include="Syncfusion.Blazor.Navigations" Version="28.2.3" />
|
||||||
|
<PackageReference Include="Syncfusion.Blazor.SplitButtons" Version="28.2.3" />
|
||||||
|
<PackageReference Include="Syncfusion.Blazor.Themes" Version="28.2.3" />
|
||||||
|
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="8.6.1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\FaKrosnoEfDataModel\FaKrosnoEfDataModel.csproj" />
|
<ProjectReference Include="..\FaKrosnoEfDataModel\FaKrosnoEfDataModel.csproj" />
|
||||||
|
<ProjectReference Include="..\OrdersManagementDataModel\OrdersManagementDataModel.csproj" />
|
||||||
<ProjectReference Include="..\SytelineSaAppEfDataModel\SytelineSaAppEfDataModel.csproj" />
|
<ProjectReference Include="..\SytelineSaAppEfDataModel\SytelineSaAppEfDataModel.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -1,39 +1,79 @@
|
|||||||
using Microsoft.AspNetCore.Routing.Constraints;
|
using Blazored.LocalStorage;
|
||||||
|
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||||
|
using Microsoft.AspNetCore.Components.Authorization;
|
||||||
|
using Microsoft.IdentityModel.Tokens;
|
||||||
|
using OrdersManagement;
|
||||||
using OrdersManagement.Components;
|
using OrdersManagement.Components;
|
||||||
using OrdersManagement.Services;
|
using OrdersManagement.Services;
|
||||||
|
using Syncfusion.Blazor;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
builder.Services.AddBlazorBootstrap();
|
string faKrosnoApiUrl = builder.Configuration["FaKrosnoApiUrl"] ?? "http://localhost:5001";
|
||||||
|
|
||||||
string apiUrl = builder.Configuration["ApiUrl"] ?? "http://localhost:5555"; // Ustawienie na adres twojego API
|
builder.Services.AddSyncfusionBlazor();
|
||||||
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(apiUrl) });
|
builder.Services.AddBlazoredLocalStorage();
|
||||||
|
|
||||||
// Add services to the container.
|
builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
|
||||||
|
.AddJwtBearer(options =>
|
||||||
|
{
|
||||||
|
options.TokenValidationParameters = new TokenValidationParameters
|
||||||
|
{
|
||||||
|
ValidateIssuer = true,
|
||||||
|
ValidateAudience = true,
|
||||||
|
ValidateLifetime = true,
|
||||||
|
ValidateIssuerSigningKey = true,
|
||||||
|
ValidIssuer = builder.Configuration["Jwt:Issuer"],
|
||||||
|
ValidAudience = builder.Configuration["Jwt:Audience"],
|
||||||
|
IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(builder.Configuration["Jwt:Key"] ?? string.Empty)),
|
||||||
|
NameClaimType = "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier"
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
builder.Services.AddAuthorizationCore();
|
||||||
|
builder.Services.AddScoped<CustomAuthenticationStateProvider>();
|
||||||
|
|
||||||
|
builder.Services.AddHttpClient("FaKrosnoApi", client =>
|
||||||
|
{
|
||||||
|
client.BaseAddress = new Uri(faKrosnoApiUrl);
|
||||||
|
client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
|
||||||
|
});
|
||||||
builder.Services.AddRazorComponents()
|
builder.Services.AddRazorComponents()
|
||||||
.AddInteractiveServerComponents();
|
.AddInteractiveServerComponents();
|
||||||
|
|
||||||
builder.Services.AddScoped<ScheduleOrderService>();
|
builder.Services.AddScoped<ScheduleOrderService>();
|
||||||
builder.Services.AddScoped<ScheduleOrderDetailsService>();
|
|
||||||
builder.Services.AddScoped<EdiCustomerOrderService>();
|
builder.Services.AddScoped<EdiCustomerOrderService>();
|
||||||
|
builder.Services.AddScoped<EdiCustomerOrderTranslateService>();
|
||||||
builder.Services.AddScoped<CustomerOrderService>();
|
builder.Services.AddScoped<CustomerOrderService>();
|
||||||
|
builder.Services.AddScoped<HangfireService>();
|
||||||
|
builder.Services.AddScoped<RoleService>();
|
||||||
|
builder.Services.AddScoped<FunctionService>();
|
||||||
|
builder.Services.AddScoped<UserService>();
|
||||||
|
builder.Services.AddScoped<ErrorLogService>();
|
||||||
|
builder.Services.AddScoped<ProductService>();
|
||||||
|
builder.Services.AddScoped<WarehouseService>();
|
||||||
|
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
|
||||||
// Configure the HTTP request pipeline.
|
|
||||||
if (!app.Environment.IsDevelopment())
|
if (!app.Environment.IsDevelopment())
|
||||||
{
|
{
|
||||||
app.UseExceptionHandler("/Error", createScopeForErrors: true);
|
app.UseExceptionHandler("/Error", createScopeForErrors: true);
|
||||||
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
|
|
||||||
app.UseHsts();
|
app.UseHsts();
|
||||||
}
|
}
|
||||||
|
|
||||||
app.UseHttpsRedirection();
|
app.UseHttpsRedirection();
|
||||||
|
|
||||||
app.UseStaticFiles();
|
app.UseStaticFiles();
|
||||||
|
app.UseRouting();
|
||||||
|
|
||||||
|
app.UseAuthentication();
|
||||||
|
app.UseAuthorization();
|
||||||
|
|
||||||
app.UseAntiforgery();
|
app.UseAntiforgery();
|
||||||
|
|
||||||
app.MapRazorComponents<App>()
|
app.MapRazorComponents<App>()
|
||||||
.AddInteractiveServerRenderMode();
|
.AddInteractiveServerRenderMode();
|
||||||
|
|
||||||
|
Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense("Ngo9BigBOggjHTQxAR8/V1NMaF5cXmBCf1FpRmJGdld5fUVHYVZUTXxaS00DNHVRdkdmWX1ec3VWQmNYV01wWUE=");
|
||||||
|
|
||||||
app.Run();
|
app.Run();
|
||||||
@@ -1,17 +1,36 @@
|
|||||||
|
using Microsoft.AspNetCore.Components.Authorization;
|
||||||
using SytelineSaAppEfDataModel.Dtos;
|
using SytelineSaAppEfDataModel.Dtos;
|
||||||
|
|
||||||
namespace OrdersManagement.Services;
|
namespace OrdersManagement.Services;
|
||||||
|
|
||||||
public class CustomerOrderService(HttpClient httpClient)
|
public class CustomerOrderService(
|
||||||
|
IHttpClientFactory httpClientFactory,
|
||||||
|
CustomAuthenticationStateProvider authenticationStateProvider)
|
||||||
|
: ServiceBase<CustomerOrderDto>(httpClientFactory, authenticationStateProvider)
|
||||||
{
|
{
|
||||||
public async Task<IEnumerable<CustomerOrderDto>?> GetCustomerOrdersAsync()
|
public async Task<IEnumerable<CustomerOrderDto>?> GetCustomerOrdersAsync()
|
||||||
{
|
{
|
||||||
return await httpClient.GetFromJsonAsync<IEnumerable<CustomerOrderDto>>("api/CustomerOrders");
|
try
|
||||||
|
{
|
||||||
|
return await GetListAsync("api/CustomerOrders");
|
||||||
|
}
|
||||||
|
catch (HttpRequestException ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Błąd HTTP w GetCustomerOrdersAsync: {ex.Message}");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<CustomerOrderDto?> GetCustomerOrderAsync(Guid customerOrderNumber)
|
public async Task<CustomerOrderDto?> GetCustomerOrderAsync(Guid customerOrderNumber)
|
||||||
{
|
{
|
||||||
return await httpClient.GetFromJsonAsync<CustomerOrderDto>(
|
try
|
||||||
$"api/CustomerOrders/by-order-number/?customerOrderNumber={customerOrderNumber}");
|
{
|
||||||
|
return await GetEntityAsync($"api/CustomerOrders/by-order-number/?customerOrderNumber={customerOrderNumber}");
|
||||||
|
}
|
||||||
|
catch (HttpRequestException ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Błąd HTTP w GetScheduleOrderAsync: {ex.Message}");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,41 +1,63 @@
|
|||||||
using OrdersManagement.Dtos;
|
using Microsoft.AspNetCore.Components.Authorization;
|
||||||
|
using OrdersManagement.Models;
|
||||||
using SytelineSaAppEfDataModel.Dtos;
|
using SytelineSaAppEfDataModel.Dtos;
|
||||||
|
|
||||||
namespace OrdersManagement.Services
|
namespace OrdersManagement.Services
|
||||||
{
|
{
|
||||||
public class EdiCustomerOrderService(HttpClient httpClient)
|
public class EdiCustomerOrderService(IHttpClientFactory httpClientFactory, CustomAuthenticationStateProvider authenticationStateProvider, ErrorLogService errorLogService) : ServiceBase<EdiCustomerOrderDto>(httpClientFactory, authenticationStateProvider)
|
||||||
{
|
{
|
||||||
public async Task<IEnumerable<EdiCustomerOrderDto>?> GetEdiCustomerOrdersAsync()
|
public async Task<IEnumerable<EdiCustomerOrderDto>?> GetEdiCustomerOrdersAsync()
|
||||||
{
|
{
|
||||||
return await httpClient.GetFromJsonAsync<IEnumerable<EdiCustomerOrderDto>>("api/EdiCustomerOrders");
|
try
|
||||||
|
{
|
||||||
|
return await GetListAsync("api/EdiCustomerOrders");
|
||||||
|
}
|
||||||
|
catch (HttpRequestException ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Błąd HTTP w GetEdiCustomerOrdersAsync: {ex.Message}");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<EdiCustomerOrderDto?> GetEdiCustomerOrderAsync(Guid customerOrderNumber)
|
public async Task<EdiCustomerOrderDto?> GetEdiCustomerOrderAsync(Guid customerOrderNumber)
|
||||||
{
|
{
|
||||||
return await httpClient.GetFromJsonAsync<EdiCustomerOrderDto>(
|
try
|
||||||
$"api/EdiCustomerOrders/by-order-number/?customerOrderNumber={customerOrderNumber}");
|
{
|
||||||
|
return await GetEntityAsync($"api/EdiCustomerOrders/by-order-number/?customerOrderNumber={customerOrderNumber}");
|
||||||
|
}
|
||||||
|
catch (HttpRequestException ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Błąd HTTP w GetEdiCustomerOrdersAsync: {ex.Message}");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<ResponseDto> SendOrderToSyteline(Guid customerOrderNumber, string orderNumber)
|
public async Task<ResponseModel?> SendOrderToSyteline(Guid customerOrderNumber, string orderNumber)
|
||||||
{
|
{
|
||||||
HttpResponseMessage responseMessage = await httpClient.PostAsync(
|
try
|
||||||
$"api/EdiCustomerOrders/send-to-syteline?customerOrderNumber={customerOrderNumber}", null);
|
|
||||||
|
|
||||||
if (responseMessage.IsSuccessStatusCode)
|
|
||||||
{
|
{
|
||||||
return new ResponseDto(1, orderNumber, null, null);
|
HttpResponseMessage responseMessage = await PostAsync($"api/EdiCustomerOrders/send-to-syteline?customerOrderNumber={customerOrderNumber}");
|
||||||
|
|
||||||
|
if (responseMessage.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
return new ResponseModel(1, orderNumber, null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
string? errorMessage = null;
|
||||||
|
IEnumerable<ErrorLogDto>? logs = await errorLogService.GetErrorLogsAsync(customerOrderNumber);
|
||||||
|
|
||||||
|
if (logs != null)
|
||||||
|
{
|
||||||
|
errorMessage = string.Join("\r\n", logs.Select(x => x.ErrMsg));
|
||||||
|
}
|
||||||
|
|
||||||
|
return new ResponseModel(0, orderNumber, errorMessage, null);
|
||||||
}
|
}
|
||||||
|
catch (HttpRequestException ex)
|
||||||
string? errorMessage = null;
|
|
||||||
IEnumerable<ErrorLogDto>? logs = await httpClient.GetFromJsonAsync<IEnumerable<ErrorLogDto>>(
|
|
||||||
$"api/ErrorLog/by-order-number/?customerOrderNumber={customerOrderNumber}");
|
|
||||||
|
|
||||||
if (logs != null)
|
|
||||||
{
|
{
|
||||||
errorMessage = string.Join("\r\n", logs.Select(x => x.ErrMsg));
|
Console.WriteLine($"Błąd HTTP w GetEdiCustomerOrdersAsync: {ex.Message}");
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ResponseDto(0, orderNumber, errorMessage, null);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
using SytelineSaAppEfDataModel.Dtos;
|
||||||
|
|
||||||
|
namespace OrdersManagement.Services;
|
||||||
|
|
||||||
|
public class EdiCustomerOrderTranslateService(
|
||||||
|
IHttpClientFactory httpClientFactory,
|
||||||
|
CustomAuthenticationStateProvider authenticationStateProvider)
|
||||||
|
: ServiceBase<EdiCustomerOrderTranslateDto>(httpClientFactory, authenticationStateProvider)
|
||||||
|
{
|
||||||
|
public async Task<IEnumerable<EdiCustomerOrderTranslateDto>?> GetEdiCustomerOrdersTranslationsAsync()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return await GetListAsync("api/EdiCustomerOrdersTranslations");
|
||||||
|
}
|
||||||
|
catch (HttpRequestException ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Błąd HTTP w GetEdiCustomerOrdersTranslationsAsync: {ex.Message}");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<int> DeleteEdiCustomerOrderTranslateAsync(EdiCustomerOrderTranslateDto ediCustomerOrderTranslateDto)
|
||||||
|
{
|
||||||
|
HttpResponseMessage responseMessage =
|
||||||
|
await DeleteAsync($"api/EdiCustomerOrdersTranslations/?id={ediCustomerOrderTranslateDto.Id}");
|
||||||
|
return responseMessage.IsSuccessStatusCode ? 1 : 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
23
OrdersManagement/Services/ErrorLogService.cs
Normal file
23
OrdersManagement/Services/ErrorLogService.cs
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
using Microsoft.AspNetCore.Components.Authorization;
|
||||||
|
using SytelineSaAppEfDataModel.Dtos;
|
||||||
|
|
||||||
|
namespace OrdersManagement.Services;
|
||||||
|
|
||||||
|
public class ErrorLogService(
|
||||||
|
IHttpClientFactory httpClientFactory,
|
||||||
|
CustomAuthenticationStateProvider authenticationStateProvider)
|
||||||
|
: ServiceBase<ErrorLogDto>(httpClientFactory, authenticationStateProvider)
|
||||||
|
{
|
||||||
|
public async Task<IEnumerable<ErrorLogDto>?> GetErrorLogsAsync(Guid customerOrderNumber)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return await GetListAsync($"api/CustomerOrders/by-order-number/?customerOrderNumber={customerOrderNumber}");
|
||||||
|
}
|
||||||
|
catch (HttpRequestException ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Błąd HTTP w GetCustomerOrdersAsync: {ex.Message}");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
36
OrdersManagement/Services/FunctionService.cs
Normal file
36
OrdersManagement/Services/FunctionService.cs
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
using OrdersManagementDataModel.Dtos;
|
||||||
|
|
||||||
|
namespace OrdersManagement.Services;
|
||||||
|
|
||||||
|
public class FunctionService(HttpClient httpClient)
|
||||||
|
{
|
||||||
|
public async Task<IEnumerable<FunctionDto>?> GetFunctionsAsync()
|
||||||
|
{
|
||||||
|
return await httpClient.GetFromJsonAsync<IEnumerable<FunctionDto>>("api/Functions");
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<FunctionDto?> GetFunctionAsync(Guid functionId)
|
||||||
|
{
|
||||||
|
return await httpClient.GetFromJsonAsync<FunctionDto>($"api/Functions/by-id/?id={functionId}");
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<FunctionDto?> GetFunctionByNameAsync(string functionName)
|
||||||
|
{
|
||||||
|
return await httpClient.GetFromJsonAsync<FunctionDto>($"api/Functions/by-name/?name={functionName}");
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task AddFunctionAsync(FunctionDto function)
|
||||||
|
{
|
||||||
|
await httpClient.PostAsJsonAsync("api/Functions", function);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task UpdateFunctionAsync(FunctionDto function)
|
||||||
|
{
|
||||||
|
await httpClient.PutAsJsonAsync("api/Functions", function);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task DeleteFunctionAsync(Guid functionId)
|
||||||
|
{
|
||||||
|
await httpClient.DeleteAsync($"api/Functions/?id={functionId}");
|
||||||
|
}
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user