Merge branch 'feature/PaginaODL' into develop
This commit is contained in:
@@ -6,6 +6,8 @@ using System.Threading.Tasks;
|
||||
using System.Configuration;
|
||||
using NLog;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Data.SqlClient;
|
||||
|
||||
namespace MP.Data.Controllers
|
||||
{
|
||||
@@ -138,18 +140,31 @@ namespace MP.Data.Controllers
|
||||
/// <summary>
|
||||
/// Elenco tabella scarti da filtro
|
||||
/// </summary>
|
||||
/// <param name="numRecord"></param>
|
||||
/// <param name="searchVal"></param>
|
||||
/// <param name="DataStart"></param>
|
||||
/// <param name="DataEnd"></param>
|
||||
/// <param name="IdxMacchina"></param>
|
||||
/// <param name="DataEnd"></param>
|
||||
/// <returns></returns>
|
||||
public List<DatabaseModels.ResScarti> StatScartiGetAll(int numRecord, string searchVal = "")
|
||||
public List<DatabaseModels.ResScarti> StatScartiGetAll(DateTime DataStart, DateTime DataEnd, string IdxMacchina, int IdxODL, string KeyRichiesta, string CodArticolo)
|
||||
{
|
||||
List<DatabaseModels.ResScarti> dbResult = new List<DatabaseModels.ResScarti>();
|
||||
//dbResult = dbCtx
|
||||
// .DbSetScarti
|
||||
// .Where(x => x.KeyRichiesta.Contains(searchVal) || x.Descrizione.Contains(searchVal) || x.CodArticolo.Contains(searchVal) || string.IsNullOrEmpty(searchVal))
|
||||
// .OrderByDescending(x => x.DataOraRif)
|
||||
// .Take(numRecord)
|
||||
// .ToList();
|
||||
|
||||
var dataFrom = new SqlParameter("@dataFrom", DataStart);
|
||||
var dataTo = new SqlParameter("@dataTo", DataEnd);
|
||||
var idxMacchina = new SqlParameter("@idxMacchina", IdxMacchina);
|
||||
var idxODL = new SqlParameter("@IdxODL", IdxODL);
|
||||
var keyRichiesta = new SqlParameter("@KeyRichiesta", KeyRichiesta);
|
||||
var codArticolo = new SqlParameter("@CodArticolo", CodArticolo);
|
||||
|
||||
dbResult = dbCtx
|
||||
.DbSetScarti
|
||||
.Where(x => x.KeyRichiesta.Contains(searchVal) || x.Descrizione.Contains(searchVal) || x.CodArticolo.Contains(searchVal) || string.IsNullOrEmpty(searchVal))
|
||||
.OrderByDescending(x => x.DataOraRif)
|
||||
.Take(numRecord)
|
||||
.FromSqlRaw("EXEC stp_UI_RS_GetByFilter @dataFrom,@dataTo,@idxMacchina,@IdxODL,@KeyRichiesta,@CodArticolo", dataFrom, dataTo, idxMacchina, idxODL, keyRichiesta, codArticolo)
|
||||
.ToList();
|
||||
|
||||
return dbResult;
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.AspNetCore.Components.Forms;
|
||||
using Microsoft.AspNetCore.Components.Rendering;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MP.Stats.Components
|
||||
{
|
||||
public class InputDateTime<TValue> : InputDate<TValue>
|
||||
{
|
||||
#region Private Fields
|
||||
|
||||
private const string DateFormat = "yyyy-MM-ddTHH:mm";
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private static bool TryParseDateTime(string value, out TValue result)
|
||||
{
|
||||
var success = BindConverter.TryConvertToDateTime(value, CultureInfo.InvariantCulture, DateFormat, out var parsedValue);
|
||||
if (success)
|
||||
{
|
||||
result = (TValue)(object)parsedValue;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = default;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static bool TryParseDateTimeOffset(string value, out TValue result)
|
||||
{
|
||||
var success = BindConverter.TryConvertToDateTimeOffset(value, CultureInfo.InvariantCulture, DateFormat, out var parsedValue);
|
||||
if (success)
|
||||
{
|
||||
result = (TValue)(object)parsedValue;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = default;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void BuildRenderTree(RenderTreeBuilder builder)
|
||||
{
|
||||
builder.OpenElement(0, "input");
|
||||
builder.AddMultipleAttributes(1, AdditionalAttributes);
|
||||
builder.AddAttribute(2, "type", "datetime-local");
|
||||
builder.AddAttribute(3, "class", CssClass);
|
||||
builder.AddAttribute(4, "value", BindConverter.FormatValue(CurrentValueAsString));
|
||||
builder.AddAttribute(5, "onchange", EventCallback.Factory.CreateBinder<string>(this, __value => CurrentValueAsString = __value, CurrentValueAsString));
|
||||
builder.CloseElement();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override string FormatValueAsString(TValue value)
|
||||
{
|
||||
switch (value)
|
||||
{
|
||||
case DateTime dateTimeValue:
|
||||
return BindConverter.FormatValue(dateTimeValue, DateFormat, CultureInfo.InvariantCulture);
|
||||
|
||||
case DateTimeOffset dateTimeOffsetValue:
|
||||
return BindConverter.FormatValue(dateTimeOffsetValue, DateFormat, CultureInfo.InvariantCulture);
|
||||
|
||||
default:
|
||||
return string.Empty; // Handles null for Nullable<DateTime>, etc.
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override bool TryParseValueFromString(string value, out TValue result, out string validationErrorMessage)
|
||||
{
|
||||
// Unwrap nullable types. We don't have to deal with receiving empty values for nullable
|
||||
// types here, because the underlying InputBase already covers that.
|
||||
var targetType = Nullable.GetUnderlyingType(typeof(TValue)) ?? typeof(TValue);
|
||||
|
||||
bool success;
|
||||
if (targetType == typeof(DateTime))
|
||||
{
|
||||
success = TryParseDateTime(value, out result);
|
||||
}
|
||||
else if (targetType == typeof(DateTimeOffset))
|
||||
{
|
||||
success = TryParseDateTimeOffset(value, out result);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new InvalidOperationException($"The type '{targetType}' is not a supported date type.");
|
||||
}
|
||||
|
||||
if (success)
|
||||
{
|
||||
validationErrorMessage = null;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
validationErrorMessage = string.Format(ParsingErrorMessage, FieldIdentifier.FieldName);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<EditForm Model="@SelFilter">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="form-group">
|
||||
<label for="dtInizio" class="small">inizio:</label>
|
||||
<InputDateTime id="dtInizio" class="form-control form-control-sm" @bind-Value="@DateStart"></InputDateTime>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="form-group">
|
||||
<label for="dtFine" class="small">fine:</label>
|
||||
<InputDateTime id="dtFine" class="form-control form-control-sm" @bind-Value="@DateEnd"></InputDateTime>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="form-group">
|
||||
<label for="idxMacc" class="small">macchina:</label>
|
||||
<input id="idxMacc" class="form-control form-control-sm" @bind="@IdxMacchina" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="form-group">
|
||||
<label for="keyRich" class="small">commessa:</label>
|
||||
<input id="keyRich" class="form-control form-control-sm" @bind="@KeyRichiesta" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
|
||||
<div class="form-group">
|
||||
<label for="CodArt" class="small">articolo:</label>
|
||||
<input id="CodArt" class="form-control form-control-sm" @bind="@CodArticolo" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</EditForm>
|
||||
@@ -0,0 +1,121 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using MP.Stats.Components;
|
||||
using MP.Stats.Data;
|
||||
|
||||
namespace MP.Stats.Components
|
||||
{
|
||||
public partial class SelectionFilter
|
||||
{
|
||||
#region Protected Properties
|
||||
|
||||
protected string CodArticolo
|
||||
{
|
||||
get
|
||||
{
|
||||
return SelFilter.CodArticolo;
|
||||
}
|
||||
set
|
||||
{
|
||||
bool doReport = (!SelFilter.CodArticolo.Equals(value));
|
||||
SelFilter.CodArticolo = value;
|
||||
if (doReport)
|
||||
{
|
||||
reportChange();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected DateTime DateEnd
|
||||
{
|
||||
get
|
||||
{
|
||||
return SelFilter.DateEnd;
|
||||
}
|
||||
set
|
||||
{
|
||||
bool doReport = (!SelFilter.DateEnd.Equals(value));
|
||||
SelFilter.DateEnd = value;
|
||||
if (doReport)
|
||||
{
|
||||
reportChange();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected DateTime DateStart
|
||||
{
|
||||
get
|
||||
{
|
||||
return SelFilter.DateStart;
|
||||
}
|
||||
set
|
||||
{
|
||||
bool doReport = (!SelFilter.DateStart.Equals(value));
|
||||
SelFilter.DateStart = value;
|
||||
if (doReport)
|
||||
{
|
||||
reportChange();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected string IdxMacchina
|
||||
{
|
||||
get
|
||||
{
|
||||
return SelFilter.IdxMacchina;
|
||||
}
|
||||
set
|
||||
{
|
||||
bool doReport = (!SelFilter.IdxMacchina.Equals(value));
|
||||
SelFilter.IdxMacchina = value;
|
||||
if (doReport)
|
||||
{
|
||||
reportChange();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected string KeyRichiesta
|
||||
{
|
||||
get
|
||||
{
|
||||
return SelFilter.KeyRichiesta;
|
||||
}
|
||||
set
|
||||
{
|
||||
bool doReport = (!SelFilter.KeyRichiesta.Equals(value));
|
||||
SelFilter.KeyRichiesta = value;
|
||||
if (doReport)
|
||||
{
|
||||
reportChange();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
#region Public Properties
|
||||
|
||||
[Parameter]
|
||||
public EventCallback<SelectData> filterChanged { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public SelectData SelFilter { get; set; }
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private void reportChange()
|
||||
{
|
||||
filterChanged.InvokeAsync(SelFilter);
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
}
|
||||
}
|
||||
@@ -84,9 +84,10 @@ namespace MP.Stats.Data
|
||||
return Task.FromResult(dbController.StatOdlGetAll(numRecord, searchVal).ToArray());
|
||||
}
|
||||
|
||||
public Task<MP.Data.DatabaseModels.ResScarti[]> StatScartiGetAll(int numRecord, string searchVal = "")
|
||||
public Task<MP.Data.DatabaseModels.ResScarti[]> StatScartiGetAll(DateTime DataStart, DateTime DataEnd, string IdxMacchina, int IdxODL, string KeyRichiesta, string CodArticolo, int numRecord, string searchVal = "")
|
||||
{
|
||||
return Task.FromResult(dbController.StatScartiGetAll(numRecord, searchVal).ToArray());
|
||||
// filtra e restituisce SOLO i primi record...
|
||||
return Task.FromResult(dbController.StatScartiGetAll(DataStart, DataEnd, IdxMacchina, IdxODL, KeyRichiesta, CodArticolo).Take(numRecord).ToArray());
|
||||
}
|
||||
|
||||
public Task<MP.Data.DatabaseModels.UserActionLog[]> StatUserLogGetAll(int numRecord, string searchVal = "")
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MP.Stats.Data
|
||||
{
|
||||
public class SelectData
|
||||
{
|
||||
#region Public Properties
|
||||
|
||||
public string CodArticolo { get; set; } = "*";
|
||||
public DateTime DateEnd { get; set; } = DateTime.Now.AddMinutes(1);
|
||||
public DateTime DateStart { get; set; } = DateTime.Now.AddDays(-7);
|
||||
public string IdxMacchina { get; set; } = "*";
|
||||
public int IdxOdl { get; set; } = -999;
|
||||
public string KeyRichiesta { get; set; } = "*";
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (!(obj is SelectData item))
|
||||
return false;
|
||||
|
||||
if (CodArticolo != item.CodArticolo)
|
||||
return false;
|
||||
if (DateEnd != item.DateEnd)
|
||||
return false;
|
||||
if (DateStart != item.DateStart)
|
||||
return false;
|
||||
if (IdxMacchina != item.IdxMacchina)
|
||||
return false;
|
||||
if (IdxOdl != item.IdxOdl)
|
||||
return false;
|
||||
if (KeyRichiesta != item.KeyRichiesta)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return base.GetHashCode();
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
}
|
||||
}
|
||||
@@ -25,10 +25,6 @@
|
||||
<ProjectReference Include="..\MP.Data\MP.Data.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Components\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="compilerconfig.json" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -26,9 +26,9 @@
|
||||
<div class="card">
|
||||
<div class="card-header table-primary h1">Main Topics</div>
|
||||
<div class="card-body">
|
||||
<HomeButton NavLink="reportodl" Icon="oi oi-book" Descript="ODL" />
|
||||
<HomeButton NavLink="produzione" Icon="oi oi-book" Descript="Produzione" />
|
||||
<HomeButton NavLink="userlog" Icon="oi oi-document" Descript="User Log" />
|
||||
<HomeButton NavLink="reportodl" Icon="oi oi-book" Descript="Report ODL" />
|
||||
<HomeButton NavLink="produzione" Icon="oi oi-clipboard" Descript="Diario Produzione" />
|
||||
<HomeButton NavLink="userlog" Icon="oi oi-document" Descript="User ActionLog" />
|
||||
<HomeButton NavLink="controlli" Icon="oi oi-beaker" Descript="Controlli" />
|
||||
<HomeButton NavLink="scarti" Icon="oi oi-warning" Descript="Scarti" />
|
||||
@*<HomeButton NavLink="resources" Icon="oi oi-puzzle-piece" Descript="Risorse" />*@
|
||||
|
||||
@@ -77,7 +77,7 @@ namespace MP.Stats.Pages
|
||||
{
|
||||
try
|
||||
{
|
||||
answ = (currRecord.IdxODL == IdxODL) ? "table-info" : "";
|
||||
answ = (currRecord.IdxOdl == IdxODL) ? "table-info" : "";
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
|
||||
@@ -4,7 +4,14 @@
|
||||
@using MP.Stats.Data
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header table-primary h1">Scarti</div>
|
||||
<div class="card-header table-primary">
|
||||
<div class="row">
|
||||
<div class="col-6 col-lg-2 h1">Scarti</div>
|
||||
<div class="col-6 col-lg-10">
|
||||
<SelectionFilter SelFilter="currFilter" filterChanged="DoFilter"></SelectionFilter>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
@if (currRecord != null)
|
||||
{
|
||||
|
||||
@@ -18,6 +18,7 @@ namespace MP.Stats.Pages
|
||||
|
||||
#region Private Properties
|
||||
|
||||
private SelectData currFilter { get; set; }
|
||||
private int numRecord { get; set; } = 10;
|
||||
|
||||
#endregion Private Properties
|
||||
@@ -38,20 +39,36 @@ namespace MP.Stats.Pages
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private async Task reloadData()
|
||||
{
|
||||
ListRecords = await StatService.StatScartiGetAll(currFilter.DateStart, currFilter.DateEnd, currFilter.IdxMacchina, currFilter.IdxOdl, currFilter.KeyRichiesta, currFilter.CodArticolo, numRecord, MessageService.SearchVal);
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
protected async Task DoFilter(SelectData newFilter)
|
||||
{
|
||||
currFilter = newFilter;
|
||||
await reloadData();
|
||||
}
|
||||
|
||||
protected async Task ForceReload(int newNum)
|
||||
{
|
||||
numRecord = newNum;
|
||||
ListRecords = await StatService.StatScartiGetAll(numRecord, MessageService.SearchVal);
|
||||
await reloadData();
|
||||
}
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
numRecord = 10;
|
||||
currFilter = new SelectData();
|
||||
MessageService.ShowSearch = true;
|
||||
MessageService.EA_SearchUpdated += OnSeachUpdated;
|
||||
ListRecords = await StatService.StatScartiGetAll(numRecord, MessageService.SearchVal);
|
||||
await reloadData();
|
||||
}
|
||||
|
||||
protected void ResetData()
|
||||
@@ -63,7 +80,7 @@ namespace MP.Stats.Pages
|
||||
protected async Task UpdateData()
|
||||
{
|
||||
currRecord = null;
|
||||
ListRecords = await StatService.StatScartiGetAll(numRecord, MessageService.SearchVal);
|
||||
await reloadData();
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
@@ -14,12 +14,12 @@
|
||||
</li>
|
||||
<li class="nav-item px-3">
|
||||
<NavLink class="nav-link" href="ReportODL">
|
||||
<span class="oi oi-book" aria-hidden="true" title="Dati di Produzione ODL"></span> Diario ODL
|
||||
<span class="oi oi-book" aria-hidden="true" title="Dati di Produzione ODL"></span> Report ODL
|
||||
</NavLink>
|
||||
</li>
|
||||
<li class="nav-item px-3">
|
||||
<NavLink class="nav-link" href="diario">
|
||||
<span class="oi oi-book" aria-hidden="true" title="Dettaglio dati di Produzione"></span> Dettaglio Produzione
|
||||
<span class="oi oi-clipboard" aria-hidden="true" title="Dettaglio dati di Produzione"></span> Diario Produzione
|
||||
</NavLink>
|
||||
</li>
|
||||
<li class="nav-item px-3">
|
||||
|
||||
Reference in New Issue
Block a user