+
@PageName
-
+
@if (ShowSearch)
{
-
+
+
+
}
+
diff --git a/MagMan.UI/Components/CmpTop.razor.cs b/MagMan.UI/Components/CmpTop.razor.cs
index 12f1112..34d5c9a 100644
--- a/MagMan.UI/Components/CmpTop.razor.cs
+++ b/MagMan.UI/Components/CmpTop.razor.cs
@@ -41,11 +41,6 @@ namespace MagMan.UI.Components
AppMessages.EA_PageUpdated += OnPageUpdate;
}
- protected override async Task OnInitializedAsync()
- {
- await Task.Delay(0);
- }
-
#endregion Protected Methods
#region Private Properties
@@ -57,6 +52,8 @@ namespace MagMan.UI.Components
[CascadingParameter(Name = "ShowSearch")]
private bool ShowSearch { get; set; } = false;
+
+
#endregion Private Properties
}
}
\ No newline at end of file
diff --git a/MagMan.UI/Components/ProjectMan.razor b/MagMan.UI/Components/ProjectMan.razor
new file mode 100644
index 0000000..97e3073
--- /dev/null
+++ b/MagMan.UI/Components/ProjectMan.razor
@@ -0,0 +1,148 @@
+
+
+
+ @if (ListRecords == null || isLoading)
+ {
+
+ }
+ else if (totalCount == 0)
+ {
+
Nessun record trovato
+ }
+ else
+ {
+
+
+
+ |
+
+ |
+ ID |
+ Descr. |
+ Filename |
+ @if (ProjDbId == 0)
+ {
+ Macchina |
+ }
+ Creato |
+ Previsione |
+ Prod |
+ @* Arch | *@
+ Time |
+ @* | *@
+
+
+
+ @foreach (var item in ListRecords)
+ {
+
+ |
+
+ @* *@
+ |
+
+
+ @if (item.PType == Enums.BWType.BEAM)
+ {
+
+
+
+ }
+ else
+ {
+
+
+
+ }
+ @item.ProjExtId
+
+ |
+
+ @item.ProjDescription
+ |
+
+ @item.BTLFileName
+ |
+ @if (ProjDbId == 0)
+ {
+
+ @item.Machine
+ |
+ }
+
+ @($"{item.DtCreated:yyyy-MM-dd}")
+ |
+
+ @($"{item.DtSchedule:yyyy-MM-dd}")
+ |
+
+ @if (item.DtStartProd > DateTime.MinValue)
+ {
+ @($"{item.DtStartProd:yyyy-MM-dd}")
+ }
+ else
+ {
+ n.a.
+ }
+ |
+ @*
+ @item.IsArchived
+ | *@
+
+ @if (item.ProcTimeReal > 0)
+ {
+ @($"{item.ProcTimeReal:N1}") min
+ }
+ else
+ {
+ @($"{item.ProcTimeEst:N1}") min
+ }
+ |
+
+ }
+
+
+ }
+
+
+
+
+
+
diff --git a/MagMan.UI/Components/ProjectMan.razor.cs b/MagMan.UI/Components/ProjectMan.razor.cs
new file mode 100644
index 0000000..f2e1a82
--- /dev/null
+++ b/MagMan.UI/Components/ProjectMan.razor.cs
@@ -0,0 +1,417 @@
+using EgwCoreLib.Razor;
+using MagMan.Core.Services;
+using MagMan.Data.Tenant.DbModels;
+using MagMan.Data.Tenant.Services;
+using Microsoft.AspNetCore.Components;
+using Microsoft.JSInterop;
+
+namespace MagMan.UI.Components
+{
+ public partial class ProjectMan
+ {
+ #region Public Properties
+
+ [Parameter]
+ public int CustomerId { get; set; } = 0;
+
+ [Parameter]
+ public EventCallback
E_ProjSel { get; set; }
+
+ [Parameter]
+ public int KeyNum { get; set; } = 0;
+
+ #endregion Public Properties
+
+ #region Protected Properties
+
+ [Inject]
+ protected MessageService AppMService { get; set; } = null!;
+
+ [Inject]
+ protected IConfiguration Configuration { get; set; } = null!;
+
+ [Inject]
+ protected IJSRuntime JSRuntime { get; set; } = null!;
+
+ protected int totalCount { get; set; } = 0;
+
+ [Inject]
+ protected TenantService TService { get; set; } = null!;
+
+ #endregion Protected Properties
+
+ #region Protected Methods
+
+ protected string CheckSel(ProjModel curItem)
+ {
+ string answ = "";
+ if (CurrItem != null)
+ {
+ answ = curItem.ProjDbId == CurrItem.ProjDbId ? "table-info" : "";
+ }
+ else
+ {
+ answ = curItem.ProjDbId == ProjDbId ? "table-info" : "";
+ }
+ return answ;
+ }
+
+
+
+ protected async Task DeleteRecord(ProjModel selItem)
+ {
+ if (!await JSRuntime.InvokeAsync("confirm", "Sicuro di voler eliminare il record?"))
+ return;
+ await TService.ProjectDelete(KeyNum, selItem);
+ await ReloadData();
+ }
+
+#if false
+ protected void DoEdit(ProjModel? selItem)
+ {
+ CurrItem = selItem;
+ if (selItem == null)
+ {
+ DoSelect(null);
+ }
+ }
+#endif
+
+ protected void DoSelect(ProjModel? selItem)
+ {
+ if (selItem != null)
+ {
+ ProjDbId = selItem.ProjDbId;
+ }
+ else
+ {
+ ProjDbId = 0;
+ }
+ E_ProjSel.InvokeAsync(selItem);
+ }
+
+ protected async Task ForceReload(bool force)
+ {
+ CurrItem = null;
+ await ReloadData();
+ }
+
+ protected override void OnInitialized()
+ {
+ currSearch = "";
+ AppMService.EA_SearchUpdated += AppMService_EA_SearchUpdated;
+ }
+
+ protected override async Task OnParametersSetAsync()
+ {
+ await ReloadData();
+ }
+
+ protected void SetNumRec(int newNum)
+ {
+ numRecord = newNum;
+ currPage = 1;
+ InvokeAsync(ReloadData);
+ }
+
+ protected void SetPage(int newNum)
+ {
+ currPage = newNum;
+ DoSelect(null);
+ InvokeAsync(ReloadData);
+ }
+
+ protected async Task SortRequested(Sorter.SortCallBack e)
+ {
+ sortField = e.ParamName;
+ sortAsc = e.IsAscending;
+ await ReloadData();
+ }
+
+ #endregion Protected Methods
+
+ #region Private Fields
+
+ private ProjModel? CurrItem = null;
+ private string currSearch = "";
+ private int filtType = 0;
+ private List? ListRecords = null;
+ private int ProjDbId = 0;
+ private List? SearchRecords = null;
+
+ private bool sortAsc = true;
+
+ private string sortField = "";
+
+ #endregion Private Fields
+
+ #region Private Properties
+
+ private int currPage { get; set; } = 1;
+
+ private int FiltType
+ {
+ get => filtType;
+ set
+ {
+ if (filtType != value)
+ {
+ filtType = value;
+ InvokeAsync(ReloadData);
+ InvokeAsync(StateHasChanged);
+ }
+ }
+ }
+
+ private bool isLoading { get; set; } = false;
+
+ private int numRecord { get; set; } = 10;
+
+ #endregion Private Properties
+
+ #region Private Methods
+
+ private async void AppMService_EA_SearchUpdated()
+ {
+ currSearch = AppMService.SearchVal;
+ await ReloadData();
+ }
+
+ private async Task ReloadData()
+ {
+ isLoading = true;
+ //await InvokeAsync(StateHasChanged);
+ ListRecords = null;
+ SearchRecords = await TService.ProjectGetByMachine(KeyNum, 0);
+#if false
+ // verifico se filtrare x beam/wall
+ if (FiltType > 0)
+ {
+ SearchRecords = SearchRecords.Where(x => (x.IsBeam && FiltType == 1) || (x.IsWall && FiltType == 2)).ToList();
+ }
+#endif
+ // verifico filtro per ricerca
+ if (!string.IsNullOrEmpty(currSearch))
+ {
+ SearchRecords = SearchRecords.Where(x => x.ProjDescription.Contains(currSearch, StringComparison.InvariantCultureIgnoreCase) || x.BTLFileName.Contains(currSearch, StringComparison.InvariantCultureIgnoreCase)).ToList();
+ }
+ totalCount = SearchRecords.Count;
+ SortTable();
+ isLoading = false;
+ await InvokeAsync(StateHasChanged);
+ }
+
+ private void SortTable()
+ {
+ if (SearchRecords != null)
+ {
+ // se ho ordinamento riordino...
+ if (!string.IsNullOrEmpty(sortField))
+ {
+ switch (sortField)
+ {
+ case "ID":
+ if (sortAsc)
+ {
+ SearchRecords = SearchRecords.OrderBy(x => x.ProjExtId).ToList();
+ }
+ else
+ {
+ SearchRecords = SearchRecords.OrderByDescending(x => x.ProjExtId).ToList();
+ }
+ break;
+
+#if false
+ case "MachineID":
+ if (sortAsc)
+ {
+ SearchRecords = SearchRecords.OrderBy(x => x.MachineID).ToList();
+ }
+ else
+ {
+ SearchRecords = SearchRecords.OrderByDescending(x => x.MachineID).ToList();
+ }
+ break;
+
+ case "ProjExtDbId":
+ if (sortAsc)
+ {
+ SearchRecords = SearchRecords.OrderBy(x => x.ProjExtDbId).ToList();
+ }
+ else
+ {
+ SearchRecords = SearchRecords.OrderByDescending(x => x.ProjExtDbId).ToList();
+ }
+ break;
+
+ case "ProjExtId":
+ if (sortAsc)
+ {
+ SearchRecords = SearchRecords.OrderBy(x => x.ProjExtId).ToList();
+ }
+ else
+ {
+ SearchRecords = SearchRecords.OrderByDescending(x => x.ProjExtId).ToList();
+ }
+ break;
+
+ case "BTLFileName":
+ if (sortAsc)
+ {
+ SearchRecords = SearchRecords.OrderBy(x => x.BTLFileName).ToList();
+ }
+ else
+ {
+ SearchRecords = SearchRecords.OrderByDescending(x => x.BTLFileName).ToList();
+ }
+ break;
+#endif
+
+ case "ProjDescription":
+ if (sortAsc)
+ {
+ SearchRecords = SearchRecords.OrderBy(x => x.ProjDescription).ToList();
+ }
+ else
+ {
+ SearchRecords = SearchRecords.OrderByDescending(x => x.ProjDescription).ToList();
+ }
+ break;
+
+#if false
+ case "PType":
+ if (sortAsc)
+ {
+ SearchRecords = SearchRecords.OrderBy(x => x.PType).ToList();
+ }
+ else
+ {
+ SearchRecords = SearchRecords.OrderByDescending(x => x.PType).ToList();
+ }
+ break;
+#endif
+
+ case "Machine":
+ if (sortAsc)
+ {
+ SearchRecords = SearchRecords.OrderBy(x => x.Machine).ToList();
+ }
+ else
+ {
+ SearchRecords = SearchRecords.OrderByDescending(x => x.Machine).ToList();
+ }
+ break;
+
+ case "DtCreated":
+ if (sortAsc)
+ {
+ SearchRecords = SearchRecords.OrderBy(x => x.DtCreated).ToList();
+ }
+ else
+ {
+ SearchRecords = SearchRecords.OrderByDescending(x => x.DtCreated).ToList();
+ }
+ break;
+
+ case "DtSchedule":
+ if (sortAsc)
+ {
+ SearchRecords = SearchRecords.OrderBy(x => x.DtSchedule).ToList();
+ }
+ else
+ {
+ SearchRecords = SearchRecords.OrderByDescending(x => x.DtSchedule).ToList();
+ }
+ break;
+
+ case "DtStartProd":
+ if (sortAsc)
+ {
+ SearchRecords = SearchRecords.OrderBy(x => x.DtStartProd).ToList();
+ }
+ else
+ {
+ SearchRecords = SearchRecords.OrderByDescending(x => x.DtStartProd).ToList();
+ }
+ break;
+
+ case "DtLastAction":
+ if (sortAsc)
+ {
+ SearchRecords = SearchRecords.OrderBy(x => x.DtLastAction).ToList();
+ }
+ else
+ {
+ SearchRecords = SearchRecords.OrderByDescending(x => x.DtLastAction).ToList();
+ }
+ break;
+
+ case "ListName":
+ if (sortAsc)
+ {
+ SearchRecords = SearchRecords.OrderBy(x => x.ListName).ToList();
+ }
+ else
+ {
+ SearchRecords = SearchRecords.OrderByDescending(x => x.ListName).ToList();
+ }
+ break;
+
+ case "IsActive":
+ if (sortAsc)
+ {
+ SearchRecords = SearchRecords.OrderBy(x => x.IsActive).ToList();
+ }
+ else
+ {
+ SearchRecords = SearchRecords.OrderByDescending(x => x.IsActive).ToList();
+ }
+ break;
+
+ case "IsArchived":
+ if (sortAsc)
+ {
+ SearchRecords = SearchRecords.OrderBy(x => x.IsArchived).ToList();
+ }
+ else
+ {
+ SearchRecords = SearchRecords.OrderByDescending(x => x.IsArchived).ToList();
+ }
+ break;
+
+ case "ProcTimeEst":
+ if (sortAsc)
+ {
+ SearchRecords = SearchRecords.OrderBy(x => x.ProcTimeEst).ToList();
+ }
+ else
+ {
+ SearchRecords = SearchRecords.OrderByDescending(x => x.ProcTimeEst).ToList();
+ }
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ // filtro x display
+ ListRecords = SearchRecords
+ .Skip(numRecord * (currPage - 1))
+ .Take(numRecord)
+ .ToList();
+ }
+ else
+ {
+ ListRecords = new List();
+ }
+ }
+
+ private string textCss(bool isActive)
+ {
+ return isActive ? "text-dark" : "text-secondary text-decoration-line-through";
+ }
+
+ #endregion Private Methods
+ }
+}
\ No newline at end of file
diff --git a/MagMan.UI/Controllers/ResourcesController.cs b/MagMan.UI/Controllers/ResourcesController.cs
index af8f3b3..1d7a2c1 100644
--- a/MagMan.UI/Controllers/ResourcesController.cs
+++ b/MagMan.UI/Controllers/ResourcesController.cs
@@ -61,13 +61,21 @@ namespace MagMan.UI.Controllers
/// Elenco Macchine dato RestToken
///
/// Rest Token cliente
- /// Chiave associata ai progetti
+ /// ID progetto
+ /// true = ultima stima attiva / false = consumi effettivi
///
// GET api/Machines/2cba60c7-7be4-40b1-aa0d-52e7c71fc1a7
[HttpGet("{id}")]
- public async Task> Get(string id, int KeyNum)
+ public async Task> Get(string id, int projDbId, bool isEstim)
{
- var ListRecords = await MTAdmService.MachineGetByToken(id);
+ List ListRecords = new List();
+ // verifico ci sia valore
+ if (!string.IsNullOrEmpty(id))
+ {
+ // in primis recupero codice chiave da token...
+ int nKey = await MTAdmService.MainKeyByToken(id);
+ ListRecords = await TService.ResourcesGetByProject(nKey, projDbId, isEstim);
+ }
return ListRecords;
}
@@ -89,24 +97,36 @@ namespace MagMan.UI.Controllers
int nKey = await MTAdmService.MainKeyByToken(id);
if (nKey > 0)
{
-#if false
- // creo oggetti materiale da lista ricevuta
- List matList = item2Consume.ItemList.Select(jpl => TService.ItemFromDto(jpl, true)).ToList();
-
- foreach (var item in matList)
+ // in primis registro il record RequestPlan...
+ var recPlan = new RequestPlanModel()
{
- try
+ DtRequest = DateTime.Now,
+ IsActive = true,
+ ReqState = projectData.ReqState,
+ ProjDbId = projectData.ProjDbId
+ };
+
+ int reqId = await TService.ReqPlanUpdate(nKey, recPlan);
+
+ // per ogni riga risorsa registro le info relative...
+ List listRes = new List();
+ if (projectData.ResourceList != null)
+ {
+ listRes = projectData.ResourceList.Select(x => TService.ResourceFromDto(x, reqId)).ToList();
+ foreach (var item in listRes)
{
- await TService.ItemUpdate(nKey, item);
- fatto = true;
+ try
+ {
+ await TService.ResourceUpdate(nKey, item);
+ fatto = true;
+ }
+ catch (Exception exc)
+ {
+ Log.Error($"InventoryController.upsert | Errore in fase salvataggio ResourceDto{Environment.NewLine}{exc}");
+ fatto = false;
+ }
}
- catch (Exception exc)
- {
- Log.Error($"InventoryController.upsert | Errore in fase salvataggio ItemDto{Environment.NewLine}{exc}");
- fatto = false;
- }
- }
-#endif
+ }
// resetto cache redis
await MTAdmService.FlushRedisCache();
}
diff --git a/MagMan.UI/MagMan.UI.csproj b/MagMan.UI/MagMan.UI.csproj
index edce482..ce88386 100644
--- a/MagMan.UI/MagMan.UI.csproj
+++ b/MagMan.UI/MagMan.UI.csproj
@@ -2,7 +2,7 @@
net6.0
- 1.0.2401.2309
+ 1.0.2401.2418
enable
enable
true
diff --git a/MagMan.UI/Pages/AdminArea.razor b/MagMan.UI/Pages/AdminArea.razor
index d925cba..4a4a699 100644
--- a/MagMan.UI/Pages/AdminArea.razor
+++ b/MagMan.UI/Pages/AdminArea.razor
@@ -19,16 +19,14 @@