Warehouses #1
@@ -16,155 +16,155 @@ public class HangfireJobsController(
|
||||
IRecurringJobManager recurringJobManager,
|
||||
ITaskSchedulerService service) : Controller
|
||||
{
|
||||
[HttpGet("GetJobsToRun")]
|
||||
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.");
|
||||
}
|
||||
|
||||
[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}");
|
||||
}
|
||||
}
|
||||
// [HttpGet("GetJobsToRun")]
|
||||
// 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.");
|
||||
// }
|
||||
//
|
||||
// [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}");
|
||||
// }
|
||||
// }
|
||||
}
|
||||
@@ -23,4 +23,16 @@ public class WzHeaderController(IWzHeaderService service, IMaterialTransactionSe
|
||||
await materialTransactionService.GetByCustomerNumber(customerNumber, customerSequence);
|
||||
return Ok(materialTransactions);
|
||||
}
|
||||
|
||||
[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);
|
||||
}
|
||||
}
|
||||
29
FaKrosnoApi/Controllers/WzRowMeyleController.cs
Normal file
29
FaKrosnoApi/Controllers/WzRowMeyleController.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SytelineSaAppEfDataModel.Dtos;
|
||||
using SytelineSaAppEfDataModel.Services;
|
||||
|
||||
namespace FaKrosnoApi.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("api/[controller]")]
|
||||
public class WzRowMeyleController(IWzRowMeyleService service) : 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);
|
||||
}
|
||||
}
|
||||
@@ -103,6 +103,7 @@ 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.AddHostedService<TimedHostedService>();
|
||||
|
||||
|
||||
@@ -35,14 +35,14 @@
|
||||
<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>
|
||||
@* <MenuItem Text="Zamówienia klienta EDI" Url="/EdiCustomerOrders" IconCss="fa-solid fa-list-check"></MenuItem> *@
|
||||
@* <MenuItem Text="Zamówienia klienta" Url="/CustomerOrders" IconCss="fa-solid fa-database"></MenuItem> *@
|
||||
@if (UserName == "pkus")
|
||||
@if (IsAdminRoute())
|
||||
{
|
||||
<MenuItem Text="Admin" IconCss="fa-solid fa-screwdriver-wrench">
|
||||
<MenuItem Text="Administracja" Url="/Admin/PK" IconCss="fa-solid fa-screwdriver-wrench">
|
||||
<MenuItems>
|
||||
<MenuItem Text = "Użytkownicy" Url = "/Admin/UsersManager" IconCss="fa-solid fa-user-tie"></MenuItem>
|
||||
<MenuItem Text= "Scheduler" Url = "/Admin/Scheduler" IconCss="fa-solid fa-calendar-week"></MenuItem>
|
||||
<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>
|
||||
}
|
||||
@@ -64,6 +64,12 @@
|
||||
private bool IsAuthenticated { get; set; }
|
||||
private string UserName { get; set; } = string.Empty;
|
||||
|
||||
private bool IsAdminRoute()
|
||||
{
|
||||
var path = new Uri(NavigationManager.Uri).AbsolutePath;
|
||||
return path.StartsWith("/admin", StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
// ClaimsPrincipal currentUser = AuthenticationStateProvider.GetCurrentUser();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
@page "/Admin/Scheduler"
|
||||
@page "/Admin/PK/Scheduler"
|
||||
|
||||
@using System.Security.Claims
|
||||
@using Microsoft.AspNetCore.Authorization
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
@page "/admin/UsersManager"
|
||||
@page "/Admin/PK/UsersManager"
|
||||
|
||||
@using System.Security.Claims
|
||||
@using Microsoft.AspNetCore.Authorization
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
@page "/CustomerOrder/{CustomerOrderId:guid}"
|
||||
@page "/Admin/PK/CustomerOrder/{CustomerOrderId:guid}"
|
||||
|
||||
@inject CustomerOrderService CustomerOrderService
|
||||
@inject ScheduleOrderService ScheduleOrderService
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
@page "/CustomerOrders"
|
||||
@page "/Admin/PK/CustomerOrders"
|
||||
|
||||
@inject CustomerOrderService CustomerOrderService
|
||||
@inject NavigationManager NavigationManager
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
@page "/CustomerOrdersTranslations"
|
||||
@page "/admin"
|
||||
|
||||
@using SytelineSaAppEfDataModel.Dtos
|
||||
@using Syncfusion.Blazor.Cards
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
@page "/EdiCustomerOrder/{CustomerOrderId:guid}"
|
||||
@page "/Admin/PK/EdiCustomerOrder/{CustomerOrderId:guid}"
|
||||
|
||||
@inject EdiCustomerOrderService EdiCustomerOrderService
|
||||
@inject NavigationManager NavigationManager
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
@page "/EdiCustomerOrders"
|
||||
@page "/Admin/PK/EdiCustomerOrders"
|
||||
|
||||
@inject EdiCustomerOrderService EdiCustomerOrderService
|
||||
@inject NavigationManager NavigationManager
|
||||
|
||||
@@ -3,6 +3,10 @@
|
||||
@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
|
||||
|
||||
@inject WarehouseService WarehouseService
|
||||
|
||||
@@ -12,34 +16,41 @@
|
||||
<h3 class="text-primary">Dokumenty WZ na Magazynie</h3>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
@* <SfGrid @ref="" *@
|
||||
@* AllowFiltering="true" *@
|
||||
@* AllowPaging="true" *@
|
||||
@* AllowSorting="true" *@
|
||||
@* AllowSelection="true" *@
|
||||
@* TValue="" *@
|
||||
@* DataSource="" *@
|
||||
@* EnableAdaptiveUI="true"> *@
|
||||
@* <GridTemplates> *@
|
||||
@* <DetailTemplate> *@
|
||||
@* @{ *@
|
||||
@* } *@
|
||||
@* </DetailTemplate> *@
|
||||
@* </GridTemplates> *@
|
||||
@* <GridColumns> *@
|
||||
@* $1$ <GridColumn Field=@nameof(EdiCustomerOrderDto.CustomerOrderNumber) HeaderText="Numer Zamówienia" Width="110"></GridColumn> #1# *@
|
||||
@* $1$ <GridColumn Field=@nameof(EdiCustomerOrderDto.CustomerPoNumber) HeaderText="Zamówienie Klienta" Width="100"></GridColumn> #1# *@
|
||||
@* $1$ <GridColumn Field=@nameof(EdiCustomerOrderDto.CustomerNumber) HeaderText="Numer Klienta" Width="90"></GridColumn> #1# *@
|
||||
@* $1$ <GridColumn Field=@nameof(EdiCustomerOrderDto.CustomerSequence) HeaderText="Odbiorca" Width="80"></GridColumn> #1# *@
|
||||
@* $1$ <GridColumn Field=@nameof(EdiCustomerOrderDto.CreateDate) HeaderText="Data Otrzymania" TextAlign="TextAlign.Center" Width="110"></GridColumn> #1# *@
|
||||
@* $1$ <GridColumn Field=@nameof(EdiCustomerOrderDto.SlOrderNumber) HeaderText="Zamówienie SL" Width="100"></GridColumn> #1# *@
|
||||
@* $1$ <GridColumn Field=@nameof(EdiCustomerOrderDto.SentToSl) HeaderText="Wysłane do SL" TextAlign="TextAlign.Center" Width="80"></GridColumn> #1# *@
|
||||
@* </GridColumns> *@
|
||||
@* <GridFilterSettings Type="FilterType.Excel"/> *@
|
||||
@* <GridPageSettings PageSize="10"/> *@
|
||||
@* <GridSelectionSettings Mode="SelectionMode.Row" Type="SelectionType.Multiple"/> *@
|
||||
@* $1$ <GridEvents TValue="EdiCustomerOrderDto" OnRecordDoubleClick="OnRowDoubleClick" RowSelected="RowSelected"/> #1# *@
|
||||
@* </SfGrid> *@
|
||||
<h5 class="text-primary mb-3">Klient</h5>
|
||||
<SfDropDownList TValue="Guid?" TItem="WzClientDto" DataSource="@_clients" Placeholder="Wybierz Klienta">
|
||||
<DropDownListFieldSettings Value="ID" Text="Name"/>
|
||||
<DropDownListEvents TValue="Guid?" TItem="WzClientDto" ValueChange="OnValueChange"/>
|
||||
</SfDropDownList>
|
||||
@if (_isVisible)
|
||||
{
|
||||
<h5 class="text-primary mb-3">Dokumenty WZ</h5>
|
||||
<SfGrid @ref="_grid"
|
||||
AllowFiltering="true"
|
||||
AllowPaging="true"
|
||||
AllowSorting="true"
|
||||
AllowSelection="true"
|
||||
TValue="MaterialTransactionDto"
|
||||
DataSource="@_materialTransactions"
|
||||
EnableAdaptiveUI="true">
|
||||
<GridColumns>
|
||||
<GridColumn Field=@nameof(MaterialTransactionDto.MTGroupNum) HeaderText="Numer WZ" TextAlign="TextAlign.Center" Width="110"></GridColumn>
|
||||
<GridColumn Field=@nameof(MaterialTransactionDto.Item) HeaderText="Indeks" TextAlign="TextAlign.Center" Width="80"></GridColumn>
|
||||
<GridColumn Field=@nameof(MaterialTransactionDto.Qty) HeaderText="Ilość sztuk" TextAlign="TextAlign.Right" Width="90"></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="10" PageSizes="@(new[] { 10, 20, 50, 100 })"/>
|
||||
<GridSelectionSettings Mode="SelectionMode.Row" Type="SelectionType.Multiple"/>
|
||||
@* <GridEvents TValue="EdiCustomerOrderDto" OnRecordDoubleClick="OnRowDoubleClick" RowSelected="RowSelected"/> *@
|
||||
</SfGrid>
|
||||
}
|
||||
</CardContent>
|
||||
<CardFooter>
|
||||
<small class="text-muted">FA Krosno Manager © @(DateTime.Now.Year)</small>
|
||||
@@ -48,11 +59,68 @@
|
||||
</div>
|
||||
|
||||
@code {
|
||||
private SfGrid<MaterialTransactionDto> _grid;
|
||||
IEnumerable<WzClientDto> _clients = new List<WzClientDto>();
|
||||
IEnumerable<MaterialTransactionDto> _materialTransactions = new List<MaterialTransactionDto>();
|
||||
|
||||
WzClientDto? _selectedClient;
|
||||
|
||||
bool _isVisible = false;
|
||||
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||
{
|
||||
if (firstRender)
|
||||
{
|
||||
IEnumerable<MaterialTransactionDto> task = await WarehouseService.GetAllClientWzsAsync("K005531", 0);
|
||||
_clients = await WarehouseService.GetAllClientsAsync();
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
|
||||
private async Task OnValueChange(ChangeEventArgs<Guid?, WzClientDto> args)
|
||||
{
|
||||
if (args.Value.HasValue)
|
||||
{
|
||||
_selectedClient = args.ItemData;
|
||||
_isVisible = true;
|
||||
_materialTransactions = await WarehouseService.GetAllClientWzsAsync(_selectedClient.CustomerNumber, _selectedClient.CustomerSequence ?? 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
_selectedClient = null;
|
||||
_isVisible = false;
|
||||
}
|
||||
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
private async Task CreatePackingList()
|
||||
{
|
||||
var selectedRecords = await _grid.GetSelectedRecordsAsync();
|
||||
if (selectedRecords.Any())
|
||||
{
|
||||
WzHeaderDto wzHeader = new WzHeaderDto
|
||||
{
|
||||
ID = Guid.NewGuid(),
|
||||
FK_Client = _selectedClient?.ID
|
||||
};
|
||||
|
||||
await WarehouseService.CreateWzHeaderAsync(wzHeader);
|
||||
|
||||
switch (_selectedClient?.Name.ToUpper())
|
||||
{
|
||||
case "MEYLE":
|
||||
IList<WzRowMeyleDto> rows = new List<WzRowMeyleDto>();
|
||||
foreach (MaterialTransactionDto materialTransactionDto in selectedRecords)
|
||||
{
|
||||
rows.Add(new WzRowMeyleDto
|
||||
{
|
||||
ID = Guid.NewGuid(),
|
||||
Quantity = Math.Abs((int?)materialTransactionDto.Qty ?? 0),
|
||||
//ItemNumber =
|
||||
});
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
@page "/Warehouse/PackList"
|
||||
|
||||
<h3>WarehousePackList</h3>
|
||||
|
||||
@code {
|
||||
|
||||
}
|
||||
@@ -2,13 +2,15 @@ using SytelineSaAppEfDataModel.Dtos;
|
||||
|
||||
namespace OrdersManagement.Services;
|
||||
|
||||
public class WarehouseService
|
||||
public class WarehouseService(IHttpClientFactory httpClientFactory)
|
||||
{
|
||||
private readonly HttpClient _httpClient;
|
||||
private readonly HttpClient _httpClient = httpClientFactory.CreateClient("FaKrosnoApi");
|
||||
|
||||
public WarehouseService(IHttpClientFactory httpClientFactory)
|
||||
public async Task<IEnumerable<WzClientDto>> GetAllClientsAsync()
|
||||
{
|
||||
_httpClient = httpClientFactory.CreateClient("FaKrosnoApi");
|
||||
var response = await _httpClient.GetAsync($"api/WzClient");
|
||||
response.EnsureSuccessStatusCode();
|
||||
return await response.Content.ReadFromJsonAsync<IEnumerable<WzClientDto>>();
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<MaterialTransactionDto>> GetAllClientWzsAsync(string customerNumber, int customerSequence)
|
||||
@@ -18,4 +20,24 @@ public class WarehouseService
|
||||
response.EnsureSuccessStatusCode();
|
||||
return await response.Content.ReadFromJsonAsync<IEnumerable<MaterialTransactionDto>>();
|
||||
}
|
||||
|
||||
public async Task CreateWzHeaderAsync(WzHeaderDto wzHeader)
|
||||
{
|
||||
var response = await _httpClient.PostAsJsonAsync("api/WzHeader", wzHeader);
|
||||
response.EnsureSuccessStatusCode();
|
||||
if (response.StatusCode != System.Net.HttpStatusCode.Created)
|
||||
{
|
||||
throw new Exception("Failed to create WzHeader");
|
||||
}
|
||||
}
|
||||
|
||||
public async Task CreateWzRowMeyleAsync(IEnumerable<WzRowMeyleDto> wzRowMeyles)
|
||||
{
|
||||
var response = await _httpClient.PostAsJsonAsync("api/WzRowMeyle", wzRowMeyles);
|
||||
response.EnsureSuccessStatusCode();
|
||||
if (response.StatusCode != System.Net.HttpStatusCode.Created)
|
||||
{
|
||||
throw new Exception("Failed to create WzRowMeyle");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,4 +6,5 @@ public class WzClientDto
|
||||
public string CustomerNumber { get; set; }
|
||||
public int? CustomerSequence { get; set; }
|
||||
public DateTime CreatedDate { get; set; }
|
||||
public string Name { get; set; }
|
||||
}
|
||||
13
SytelineSaAppEfDataModel/Dtos/WzRowMeyleDto.cs
Normal file
13
SytelineSaAppEfDataModel/Dtos/WzRowMeyleDto.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
namespace SytelineSaAppEfDataModel.Dtos;
|
||||
|
||||
public class WzRowMeyleDto
|
||||
{
|
||||
public Guid ID { get; set; }
|
||||
public Guid? FK_Header { get; set; }
|
||||
public string OrderNumber { get; set; }
|
||||
public string ItemNumber { get; set; }
|
||||
public int? Quantity { get; set; }
|
||||
public int? PalletNumber { get; set; }
|
||||
public string WzNumber { get; set; }
|
||||
public string PartNumber { get; set; }
|
||||
}
|
||||
@@ -6,4 +6,5 @@ public class WzClient
|
||||
public string CustomerNumber { get; set; }
|
||||
public int? CustomerSequence { get; set; }
|
||||
public DateTime CreatedDate { get; set; }
|
||||
public string Name { get; set; }
|
||||
}
|
||||
16
SytelineSaAppEfDataModel/Entities/WzRowMeyle.cs
Normal file
16
SytelineSaAppEfDataModel/Entities/WzRowMeyle.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
namespace SytelineSaAppEfDataModel.Entities;
|
||||
|
||||
public class WzRowMeyle
|
||||
{
|
||||
public Guid ID { get; set; }
|
||||
public Guid? FK_Header { get; set; }
|
||||
public string OrderNumber { get; set; }
|
||||
public string ItemNumber { get; set; }
|
||||
public int? Quantity { get; set; }
|
||||
public int? PalletNumber { get; set; }
|
||||
public string WzNumber { get; set; }
|
||||
public string PartNumber { get; set; }
|
||||
|
||||
// Navigation property
|
||||
public WzHeader Header { get; set; }
|
||||
}
|
||||
@@ -21,6 +21,8 @@ namespace SytelineSaAppEfDataModel
|
||||
CreateMap<EdiUser, EdiUserDto>().ReverseMap();
|
||||
CreateMap<MaterialTransaction, MaterialTransactionDto>().ReverseMap();
|
||||
CreateMap<WzClient, WzClientDto>().ReverseMap();
|
||||
CreateMap<WzHeader, WzHeaderDto>().ReverseMap();
|
||||
CreateMap<WzRowMeyle, WzRowMeyleDto>().ReverseMap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,4 +5,5 @@ namespace SytelineSaAppEfDataModel.Services;
|
||||
public interface IWzHeaderService
|
||||
{
|
||||
Task<IEnumerable<WzHeaderDto>> GetAll();
|
||||
Task CreateHeader(WzHeaderDto wzHeader);
|
||||
}
|
||||
9
SytelineSaAppEfDataModel/Services/IWzRowMeyleService.cs
Normal file
9
SytelineSaAppEfDataModel/Services/IWzRowMeyleService.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
using SytelineSaAppEfDataModel.Dtos;
|
||||
|
||||
namespace SytelineSaAppEfDataModel.Services;
|
||||
|
||||
public interface IWzRowMeyleService
|
||||
{
|
||||
Task<IEnumerable<WzRowMeyleDto>> GetAll();
|
||||
Task CreateRows(IEnumerable<WzRowMeyleDto> rows);
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
using AutoMapper;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using SytelineSaAppEfDataModel.Dtos;
|
||||
using SytelineSaAppEfDataModel.Entities;
|
||||
|
||||
namespace SytelineSaAppEfDataModel.Services;
|
||||
|
||||
@@ -10,4 +11,11 @@ public class WzHeaderService(SytelineSaAppDbContext context, IMapper mapper) : I
|
||||
{
|
||||
return await context.WzHeaders.Select(x => mapper.Map<WzHeaderDto>(x)).ToListAsync();
|
||||
}
|
||||
|
||||
public async Task CreateHeader(WzHeaderDto wzHeader)
|
||||
{
|
||||
var entity = mapper.Map<WzHeader>(wzHeader);
|
||||
await context.WzHeaders.AddAsync(entity);
|
||||
await context.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
21
SytelineSaAppEfDataModel/Services/WzRowMeyleService.cs
Normal file
21
SytelineSaAppEfDataModel/Services/WzRowMeyleService.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using AutoMapper;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using SytelineSaAppEfDataModel.Dtos;
|
||||
using SytelineSaAppEfDataModel.Entities;
|
||||
|
||||
namespace SytelineSaAppEfDataModel.Services;
|
||||
|
||||
public class WzRowMeyleService(SytelineSaAppDbContext context, IMapper mapper) : IWzRowMeyleService
|
||||
{
|
||||
public async Task<IEnumerable<WzRowMeyleDto>> GetAll()
|
||||
{
|
||||
return await context.WzRowsMeyle.Select(x => mapper.Map<WzRowMeyleDto>(x)).ToListAsync();
|
||||
}
|
||||
|
||||
public async Task CreateRows(IEnumerable<WzRowMeyleDto> rows)
|
||||
{
|
||||
var entities = mapper.Map<IEnumerable<WzRowMeyle>>(rows);
|
||||
await context.WzRowsMeyle.AddRangeAsync(entities);
|
||||
await context.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,7 @@ namespace SytelineSaAppEfDataModel
|
||||
public DbSet<WzClient> WzClients { get; set; }
|
||||
public DbSet<WzHeader> WzHeaders { get; set; }
|
||||
|
||||
public DbSet<WzRowMeyle> WzRowsMeyle { get; set; }
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
var configuration = new ConfigurationBuilder()
|
||||
@@ -799,7 +800,7 @@ namespace SytelineSaAppEfDataModel
|
||||
entity.Property(e => e.WhseSplit)
|
||||
.HasColumnName("WhseSplit")
|
||||
.HasColumnType("tinyint")
|
||||
.IsRequired(false);;
|
||||
.IsRequired(false);
|
||||
|
||||
entity.Property(e => e.VariableId)
|
||||
.HasColumnName("VariableId")
|
||||
@@ -930,6 +931,64 @@ namespace SytelineSaAppEfDataModel
|
||||
.HasColumnName("CreatedDate")
|
||||
.HasColumnType("timestamp")
|
||||
.IsRowVersion();
|
||||
|
||||
entity.Property(e => e.Name)
|
||||
.HasColumnName("Name")
|
||||
.HasMaxLength(255)
|
||||
.IsRequired(false);
|
||||
});
|
||||
|
||||
modelBuilder.Entity<WzRowMeyle>(entity =>
|
||||
{
|
||||
entity.ToTable("wz_row_meyle");
|
||||
|
||||
entity.HasKey(e => e.ID);
|
||||
|
||||
entity.Property(e => e.ID)
|
||||
.HasColumnName("ID")
|
||||
.HasColumnType("uniqueidentifier")
|
||||
.HasDefaultValueSql("newid()");
|
||||
|
||||
entity.Property(e => e.FK_Header)
|
||||
.HasColumnName("FK_Header")
|
||||
.HasColumnType("uniqueidentifier")
|
||||
.IsRequired(false);
|
||||
|
||||
entity.Property(e => e.OrderNumber)
|
||||
.HasColumnName("order_number")
|
||||
.HasMaxLength(100)
|
||||
.IsRequired(false);
|
||||
|
||||
entity.Property(e => e.ItemNumber)
|
||||
.HasColumnName("item_number")
|
||||
.HasMaxLength(100)
|
||||
.IsRequired(false);
|
||||
|
||||
entity.Property(e => e.Quantity)
|
||||
.HasColumnName("quantity")
|
||||
.HasColumnType("int")
|
||||
.IsRequired(false);
|
||||
|
||||
entity.Property(e => e.PalletNumber)
|
||||
.HasColumnName("pallet_number")
|
||||
.HasColumnType("int")
|
||||
.IsRequired(false);
|
||||
|
||||
entity.Property(e => e.WzNumber)
|
||||
.HasColumnName("wz_number")
|
||||
.HasMaxLength(100)
|
||||
.IsRequired(false);
|
||||
|
||||
entity.Property(e => e.PartNumber)
|
||||
.HasColumnName("part_number")
|
||||
.HasMaxLength(100)
|
||||
.IsRequired(false);
|
||||
|
||||
// Relationship
|
||||
entity.HasOne(e => e.Header)
|
||||
.WithMany()
|
||||
.HasForeignKey(e => e.FK_Header)
|
||||
.HasConstraintName("wz_rows_meyle_wz_header_ID_fk");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user