From 0aad827655f50a9ea87a6b8c2f7e40b1750bdcc4 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Tue, 23 Jan 2024 09:22:30 +0100 Subject: [PATCH 01/13] Update deploy SDK --- .gitlab-ci.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6939d2c..3a9e0e3 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -204,8 +204,7 @@ EgwProxy.MagMan:release: - *nuspec-fix script: - dotnet build "$env:APP_NAME\$env:APP_NAME.csproj" - #- '& "$env:MSBUILD_PATH" "$env:APP_NAME\$env:APP_NAME.csproj" -target:Build /p:Configuration=$env:CONFIG /p:Platform="Any CPU" /p:OutputPath=bin/$env:CONFIG /verbosity:minimal /m' - '& Remove-Item *.nupkg' - - '& $env:NUGET_PATH pack "$env:APP_NAME.Debug.nuspec"' + - '& $env:NUGET_PATH pack "$env:APP_NAME.Reelase.nuspec"' - '& "$env:NUGET_PATH" setapikey $NUGET_API_KEY -source http://nexus.steamware.net/repository/nuget-hosted' - '& "$env:NUGET_PATH" push *$env:NUM_DEB.nupkg -Source http://nexus.steamware.net/repository/nuget-hosted' \ No newline at end of file From 7221b56c8753de26980e534684588a2bc554ea96 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Tue, 23 Jan 2024 09:23:34 +0100 Subject: [PATCH 02/13] Fix sdk CI/CD --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3a9e0e3..e896e55 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -205,6 +205,6 @@ EgwProxy.MagMan:release: script: - dotnet build "$env:APP_NAME\$env:APP_NAME.csproj" - '& Remove-Item *.nupkg' - - '& $env:NUGET_PATH pack "$env:APP_NAME.Reelase.nuspec"' + - '& $env:NUGET_PATH pack "$env:APP_NAME.Relase.nuspec"' - '& "$env:NUGET_PATH" setapikey $NUGET_API_KEY -source http://nexus.steamware.net/repository/nuget-hosted' - '& "$env:NUGET_PATH" push *$env:NUM_DEB.nupkg -Source http://nexus.steamware.net/repository/nuget-hosted' \ No newline at end of file From d34290bf6382ec5dfa81de8f1aa12e5ab5d1d207 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Tue, 23 Jan 2024 09:25:53 +0100 Subject: [PATCH 03/13] Ancora typo CI/CD --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e896e55..dce4c25 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -205,6 +205,6 @@ EgwProxy.MagMan:release: script: - dotnet build "$env:APP_NAME\$env:APP_NAME.csproj" - '& Remove-Item *.nupkg' - - '& $env:NUGET_PATH pack "$env:APP_NAME.Relase.nuspec"' + - '& $env:NUGET_PATH pack "$env:APP_NAME.Release.nuspec"' - '& "$env:NUGET_PATH" setapikey $NUGET_API_KEY -source http://nexus.steamware.net/repository/nuget-hosted' - '& "$env:NUGET_PATH" push *$env:NUM_DEB.nupkg -Source http://nexus.steamware.net/repository/nuget-hosted' \ No newline at end of file From 311da2987edadf858f11be1439a0dc9ca0690e90 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Tue, 23 Jan 2024 09:27:23 +0100 Subject: [PATCH 04/13] Ancora fix deploy nuget stabile --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index dce4c25..039088c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -207,4 +207,4 @@ EgwProxy.MagMan:release: - '& Remove-Item *.nupkg' - '& $env:NUGET_PATH pack "$env:APP_NAME.Release.nuspec"' - '& "$env:NUGET_PATH" setapikey $NUGET_API_KEY -source http://nexus.steamware.net/repository/nuget-hosted' - - '& "$env:NUGET_PATH" push *$env:NUM_DEB.nupkg -Source http://nexus.steamware.net/repository/nuget-hosted' \ No newline at end of file + - '& "$env:NUGET_PATH" push *$env:NUM_REL.nupkg -Source http://nexus.steamware.net/repository/nuget-hosted' \ No newline at end of file From 13242fffb149665b856675d77bc1a10bbd3ffcaf Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Tue, 23 Jan 2024 12:03:47 +0100 Subject: [PATCH 05/13] spostamento grafico x sel clienti in CmpTop --- MagMan.Core/Services/MessageService.cs | 16 ++++++++++++++++ MagMan.UI/Components/CmpSelCliente.razor | 2 +- MagMan.UI/Components/CmpTop.razor | 17 +++++++++++++---- MagMan.UI/Components/CmpTop.razor.cs | 7 +++++++ MagMan.UI/Components/ProjectMan.razor | 5 +++++ MagMan.UI/MagMan.UI.csproj | 2 +- MagMan.UI/Pages/ProjectsStatus.razor | 7 +++++++ MagMan.UI/Pages/ProjectsStatus.razor.cs | 9 +++++++++ MagMan.UI/Shared/MainLayout.razor | 2 +- MagMan.UI/Shared/MainLayout.razor.css | 6 +++--- Resources/ChangeLog.html | 2 +- Resources/VersNum.txt | 2 +- Resources/manifest.xml | 2 +- TestWinFormVB/Form1.vb | 14 +++++++------- TestWinFormVB/TestWinFormVB.vbproj | 2 +- TestWinFormVB/packages.config | 2 +- 16 files changed, 75 insertions(+), 22 deletions(-) create mode 100644 MagMan.UI/Components/ProjectMan.razor create mode 100644 MagMan.UI/Pages/ProjectsStatus.razor create mode 100644 MagMan.UI/Pages/ProjectsStatus.razor.cs diff --git a/MagMan.Core/Services/MessageService.cs b/MagMan.Core/Services/MessageService.cs index a3dc8dc..49751aa 100644 --- a/MagMan.Core/Services/MessageService.cs +++ b/MagMan.Core/Services/MessageService.cs @@ -1,5 +1,6 @@ using Blazored.LocalStorage; using Blazored.SessionStorage; +using Microsoft.AspNetCore.Components; using NLog; using StackExchange.Redis; using System.Diagnostics; @@ -33,6 +34,7 @@ namespace MagMan.Core.Services public event Action EA_SearchUpdated = null!; public event Action EA_ShowSearch = null!; + public EventCallback EC_CustomerSel { get; set; } #endregion Public Events @@ -102,6 +104,19 @@ namespace MagMan.Core.Services } } + public int CustomerID + { + get => _customerID; + set + { + if (_customerID != value) + { + _customerID = value; + EC_CustomerSel.InvokeAsync(value); + } + } + } + public string SelOrderCode { get; set; } = ""; public string SelPlantId { get; set; } = "0"; @@ -488,6 +503,7 @@ namespace MagMan.Core.Services private string _pageIcon = ""; private string _pageName = ""; private string _searchVal = ""; + private int _customerID = -1; private bool _showSearch = false; private Logger Log = LogManager.GetCurrentClassLogger(); diff --git a/MagMan.UI/Components/CmpSelCliente.razor b/MagMan.UI/Components/CmpSelCliente.razor index c236799..0bf9d7f 100644 --- a/MagMan.UI/Components/CmpSelCliente.razor +++ b/MagMan.UI/Components/CmpSelCliente.razor @@ -1,4 +1,4 @@ -
+
+ + + + +
+
+ + + + @if (CurrItem != null) + { +
+ + } + +
+ @if (ListRecords == null || isLoading) + { + + } + else if (totalCount == 0) + { +
Nessun record trovato
+ } + else + { + + + + + + + + + + @* *@ + @* *@ + + + + @foreach (var item in ListRecords) + { + + + + + + + + @* *@ + @* *@ + + } + +
+ + ID Mat.Code Descr. W (mm) H (mm) L (mm)
+ + + + @if (item.IsBeam) + { + + + + } + else if (@item.IsWall) + { + + + + } +  @item.MatId + + @item.MatCode + + @item.MatDesc + + @if (item.IsBeam) + { + @($"{item.WMm:N2}") + } + else + { + - + } + + @($"{item.HMm:N2}") + + @($"{item.LMm:N2}") + + +
+ } + +
+ + -@code { -} diff --git a/MagMan.UI/Components/ProjectMan.razor.cs b/MagMan.UI/Components/ProjectMan.razor.cs new file mode 100644 index 0000000..7bc34d3 --- /dev/null +++ b/MagMan.UI/Components/ProjectMan.razor.cs @@ -0,0 +1,307 @@ +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_MaterialSel { 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(MaterialModel curItem) + { + string answ = ""; + if (CurrItem != null) + { + answ = curItem.MatId == CurrItem.MatId ? "table-info" : ""; + } + else + { + answ = curItem.MatId == MaterialId ? "table-info" : ""; + } + return answ; + } + + protected async Task CreateNew() + { + CurrItem = new MaterialModel() + { + MatCode = "Mat_unique_code", + MatDesc = "Material Description" + }; + await InvokeAsync(StateHasChanged); + } + + protected async Task DeleteRecord(MaterialModel selItem) + { + if (!await JSRuntime.InvokeAsync("confirm", "Sicuro di voler eliminare il record?")) + return; + await TService.MaterialDelete(KeyNum, selItem); + await ReloadData(); + } + + protected void DoEdit(MaterialModel? selItem) + { + CurrItem = selItem; + if (selItem == null) + { + DoSelect(null); + } + } + + protected void DoSelect(MaterialModel? selItem) + { + if (selItem != null) + { + MaterialId = selItem.MatId; + } + else + { + MaterialId = 0; + } + E_MaterialSel.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 MaterialModel? CurrItem = null; + private string currSearch = ""; + private int filtType = 0; + private List? ListRecords = null; + private int MaterialId = 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.MaterialGetAll(KeyNum, false); + // verifico se filtrare x beam/wall + if (FiltType > 0) + { + SearchRecords = SearchRecords.Where(x => (x.IsBeam && FiltType == 1) || (x.IsWall && FiltType == 2)).ToList(); + } + // verifico filtro per ricerca + if (!string.IsNullOrEmpty(currSearch)) + { + SearchRecords = SearchRecords.Where(x => x.MatCode.Contains(currSearch, StringComparison.InvariantCultureIgnoreCase) || x.MatDesc.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 "RawItemId": + if (sortAsc) + { + SearchRecords = SearchRecords.OrderBy(x => x.MatId).ThenBy(x => x.MatCode).ToList(); + } + else + { + SearchRecords = SearchRecords.OrderByDescending(x => x.MatId).ThenByDescending(x => x.MatCode).ToList(); + } + break; + + case "MatCode": + if (sortAsc) + { + SearchRecords = SearchRecords.OrderBy(x => x.MatCode).ToList(); + } + else + { + SearchRecords = SearchRecords.OrderByDescending(x => x.MatCode).ToList(); + } + break; + + case "MatDesc": + if (sortAsc) + { + SearchRecords = SearchRecords.OrderBy(x => x.MatDesc).ToList(); + } + else + { + SearchRecords = SearchRecords.OrderByDescending(x => x.MatDesc).ToList(); + } + break; + + case "W": + if (sortAsc) + { + SearchRecords = SearchRecords.OrderBy(x => x.WMm).ToList(); + } + else + { + SearchRecords = SearchRecords.OrderByDescending(x => x.WMm).ToList(); + } + break; + + case "H": + if (sortAsc) + { + SearchRecords = SearchRecords.OrderBy(x => x.HMm).ToList(); + } + else + { + SearchRecords = SearchRecords.OrderByDescending(x => x.HMm).ToList(); + } + break; + + case "L": + if (sortAsc) + { + SearchRecords = SearchRecords.OrderBy(x => x.LMm).ToList(); + } + else + { + SearchRecords = SearchRecords.OrderByDescending(x => x.LMm).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/Pages/AdminArea.razor.cs b/MagMan.UI/Pages/AdminArea.razor.cs index c2b76b5..d27e5d3 100644 --- a/MagMan.UI/Pages/AdminArea.razor.cs +++ b/MagMan.UI/Pages/AdminArea.razor.cs @@ -45,7 +45,6 @@ namespace MagMan.UI.Pages { var actMode = currMode; currMode = CtMode.Loading; - await InvokeAsync(StateHasChanged); CustomerID = AppMService.CustomerID; await Task.Delay(50); currMode = actMode; diff --git a/MagMan.UI/Pages/MachineStatus.razor.cs b/MagMan.UI/Pages/MachineStatus.razor.cs index 2fd7a4b..c91e795 100644 --- a/MagMan.UI/Pages/MachineStatus.razor.cs +++ b/MagMan.UI/Pages/MachineStatus.razor.cs @@ -1,9 +1,86 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. +// Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this +// file to you under the MIT license. +using MagMan.Core.Services; +using MagMan.Data.Admin.Services; +using MagMan.Data.Tenant.DbModels; +using Microsoft.AspNetCore.Components; + namespace MagMan.UI.Pages { public partial class MachineStatus { + #region Protected Fields + protected int nKey = 0; + + #endregion Protected Fields + + #region Protected Properties + + [Inject] + protected MessageService AppMService { get; set; } = null!; + + protected string mainCss + { + get => MaterialSel == null ? "col-12" : "col-6 small"; + } + + [Inject] + protected MTAdminService MTService { get; set; } = null!; + + #endregion Protected Properties + + #region Protected Methods + + protected override async Task OnInitializedAsync() + { + AppMService.ShowSearch = true; + AppMService.PageName = "Dati Macchine"; + AppMService.PageIcon = "fa-solid fa-screwdriver-wrench pr-2"; + AppMService.EA_CustomerSel += AppMService_EA_CustomerSel; + CustomerID = AppMService.CustomerID; + // rileggo dati + await ReloadData(); + } + + protected void SaveMat(MaterialModel? newMat) + { + MaterialSel = newMat; + } + + #endregion Protected Methods + + #region Private Fields + + private int KeyNum = 0; + private MaterialModel? MaterialSel = null; + + #endregion Private Fields + + #region Private Properties + + private int CustomerID { get; set; } = 0; + private bool isLoading { get; set; } = false; + + #endregion Private Properties + + #region Private Methods + + private async void AppMService_EA_CustomerSel() + { + CustomerID = AppMService.CustomerID; + await Task.Delay(10); + await ReloadData(); + await InvokeAsync(StateHasChanged); + } + + private async Task ReloadData() + { + isLoading = true; + nKey = await MTService.MainKeyByCustomer(CustomerID); + isLoading = false; + } + + #endregion Private Methods } } \ No newline at end of file diff --git a/MagMan.UI/Pages/ProjectsStatus.razor b/MagMan.UI/Pages/ProjectsStatus.razor index 0fc3132..bbb8cc7 100644 --- a/MagMan.UI/Pages/ProjectsStatus.razor +++ b/MagMan.UI/Pages/ProjectsStatus.razor @@ -1,7 +1,26 @@ @page "/ProjectsStatus" -

ProjectsStatus

- - -Work In Progress +Projects Status +@if (isLoading) +{ + +} +else if (CustomerID == 0) +{ + +} +else +{ +
+
+ +
+ @if (MaterialSel != null) + { +
+ +
+ } +
+} \ No newline at end of file diff --git a/MagMan.UI/Pages/ProjectsStatus.razor.cs b/MagMan.UI/Pages/ProjectsStatus.razor.cs index 8b14bad..1b990ee 100644 --- a/MagMan.UI/Pages/ProjectsStatus.razor.cs +++ b/MagMan.UI/Pages/ProjectsStatus.razor.cs @@ -1,9 +1,84 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. +using MagMan.Core.Services; +using MagMan.Data.Admin.Services; +using MagMan.Data.Tenant.DbModels; +using Microsoft.AspNetCore.Components; + namespace MagMan.UI.Pages { public partial class ProjectsStatus { + #region Protected Fields + protected int nKey = 0; + + #endregion Protected Fields + + #region Protected Properties + + [Inject] + protected MessageService AppMService { get; set; } = null!; + + protected string mainCss + { + get => MaterialSel == null ? "col-12" : "col-6 small"; + } + + [Inject] + protected MTAdminService MTService { get; set; } = null!; + + #endregion Protected Properties + + #region Protected Methods + + protected override async Task OnInitializedAsync() + { + AppMService.ShowSearch = true; + AppMService.PageName = "Progetti"; + AppMService.PageIcon = "fa-solid fa-chart-gantt pr-2"; + AppMService.EA_CustomerSel += AppMService_EA_CustomerSel; + CustomerID = AppMService.CustomerID; + // rileggo dati + await ReloadData(); + } + + protected void SaveMat(MaterialModel? newMat) + { + MaterialSel = newMat; + } + + #endregion Protected Methods + + #region Private Fields + + private int KeyNum = 0; + private MaterialModel? MaterialSel = null; + + #endregion Private Fields + + #region Private Properties + + private int CustomerID { get; set; } = 0; + private bool isLoading { get; set; } = false; + + #endregion Private Properties + + #region Private Methods + + private async void AppMService_EA_CustomerSel() + { + CustomerID = AppMService.CustomerID; + await Task.Delay(10); + await ReloadData(); + await InvokeAsync(StateHasChanged); + } + + private async Task ReloadData() + { + isLoading = true; + nKey = await MTService.MainKeyByCustomer(CustomerID); + isLoading = false; + } + + #endregion Private Methods } } \ No newline at end of file diff --git a/MagMan.UI/Pages/WareHouse.razor b/MagMan.UI/Pages/WareHouse.razor index 857c4d7..a7760c0 100644 --- a/MagMan.UI/Pages/WareHouse.razor +++ b/MagMan.UI/Pages/WareHouse.razor @@ -2,14 +2,13 @@ WareHouse Area -@if (CustomerID == 0) +@if (isLoading) { -
-
- Customer Undef -
- Prego selezionare Cliente per visualizzare dati Magazzino -
+ +} +else if (CustomerID == 0) +{ + } else { diff --git a/MagMan.UI/Pages/WareHouse.razor.cs b/MagMan.UI/Pages/WareHouse.razor.cs index 2cc1435..e7d7e0d 100644 --- a/MagMan.UI/Pages/WareHouse.razor.cs +++ b/MagMan.UI/Pages/WareHouse.razor.cs @@ -35,7 +35,7 @@ namespace MagMan.UI.Pages protected override async Task OnInitializedAsync() { AppMService.ShowSearch = true; - AppMService.PageName = "Warehouse Area"; + AppMService.PageName = "Magazzino"; AppMService.PageIcon = "fa-solid fa-warehouse pr-2"; AppMService.EA_CustomerSel += AppMService_EA_CustomerSel; CustomerID = AppMService.CustomerID; @@ -71,6 +71,7 @@ namespace MagMan.UI.Pages CustomerID = AppMService.CustomerID; await Task.Delay(10); await ReloadData(); + await InvokeAsync(StateHasChanged); } private async Task ReloadData() From 6375ec8bd11d0b62d33d060e0133b9e3486c0620 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Wed, 24 Jan 2024 12:46:31 +0100 Subject: [PATCH 10/13] Bozza display progetti --- .../Controllers/TenantController.cs | 8 +- MagMan.Data.Tenant/Services/TenantService.cs | 14 +- MagMan.UI/Components/ProjectMan.razor | 100 +++++---- MagMan.UI/Components/ProjectMan.razor.cs | 204 ++++++++++++++---- MagMan.UI/MagMan.UI.csproj | 2 +- MagMan.UI/Pages/ProjectsStatus.razor | 6 +- MagMan.UI/Pages/ProjectsStatus.razor.cs | 10 +- Resources/ChangeLog.html | 2 +- Resources/VersNum.txt | 2 +- Resources/manifest.xml | 2 +- 10 files changed, 234 insertions(+), 116 deletions(-) diff --git a/MagMan.Data.Tenant/Controllers/TenantController.cs b/MagMan.Data.Tenant/Controllers/TenantController.cs index 44fe134..937fb5c 100644 --- a/MagMan.Data.Tenant/Controllers/TenantController.cs +++ b/MagMan.Data.Tenant/Controllers/TenantController.cs @@ -278,7 +278,7 @@ namespace MagMan.Data.Tenant.Controllers } /// /// Elenco Materiali gestiti a magazzino Stringa - /// connessione (variabile x cliente) Materiale richiesto, 0 + /// connessione (variabile x cliente) Materiale richiesto, 0 /// = tutti Se true allora include record child /// (Items) public List MaterialGetFilt(string connString, int matID, bool withChild) @@ -420,16 +420,16 @@ namespace MagMan.Data.Tenant.Controllers /// Elenco Items gestiti a magazzino dato Materiale /// /// Stringa connessione (variabile x cliente) - /// ID del materiale x cui filtrare, 0 = tutti + /// ID macchina, 0 = tutti /// - public List ProjectGetByNumKey(string connString, int numKey) + public List ProjectGetByMachine(string connString, int machineID) { List dbResult = new List(); using (MagManContext dbCtx = new MagManContext(connString)) { dbResult = dbCtx .DbSetProjects - .Where(x => numKey == 0 || x.KeyNum == numKey) + .Where(x => machineID == 0 || x.MachineID == machineID) .OrderBy(x => x.DtCreated) .ToList(); } diff --git a/MagMan.Data.Tenant/Services/TenantService.cs b/MagMan.Data.Tenant/Services/TenantService.cs index 177061e..7c1e83d 100644 --- a/MagMan.Data.Tenant/Services/TenantService.cs +++ b/MagMan.Data.Tenant/Services/TenantService.cs @@ -545,19 +545,19 @@ namespace MagMan.Data.Tenant.Services } /// - /// Lista Items gestiti a magazzino x materiale + /// Lista progetti x macchina /// /// Key di riferimento - /// ID del materiale x cui filtrare, 0 = tutti + /// ID macchina, 0 = tutti /// - public async Task> ProjectGetByNumKey(int nKey, int numKey) + public async Task> ProjectGetByMachine(int nKey, int machineId) { string source = "DB"; string cString = ConnString(nKey); List? dbResult = new List(); try { - string currKey = $"{Const.rKeyConfig}:{nKey}:ProjList:{numKey}"; + string currKey = $"{Const.rKeyConfig}:{nKey}:ProjList:{machineId}"; Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); string? rawData = await redisDb.StringGetAsync(currKey); @@ -576,7 +576,7 @@ namespace MagMan.Data.Tenant.Services } else { - dbResult = dbController.ProjectGetByNumKey(cString, numKey); + dbResult = dbController.ProjectGetByMachine(cString, machineId); rawData = JsonConvert.SerializeObject(dbResult, JSSettings); await redisDb.StringSetAsync(currKey, rawData, LongCache); } @@ -586,11 +586,11 @@ namespace MagMan.Data.Tenant.Services } stopWatch.Stop(); TimeSpan ts = stopWatch.Elapsed; - Log.Debug($"ProjectGetByNumKey | {source} in: {ts.TotalMilliseconds} ms"); + Log.Debug($"ProjectGetByMachine | {source} in: {ts.TotalMilliseconds} ms"); } catch (Exception exc) { - Log.Error($"Error during ProjectGetByNumKey:{Environment.NewLine}{exc}"); + Log.Error($"Error during ProjectGetByMachine:{Environment.NewLine}{exc}"); } return dbResult; } diff --git a/MagMan.UI/Components/ProjectMan.razor b/MagMan.UI/Components/ProjectMan.razor index 4130b17..752838c 100644 --- a/MagMan.UI/Components/ProjectMan.razor +++ b/MagMan.UI/Components/ProjectMan.razor @@ -2,37 +2,37 @@
-

Materiali

+

Progetti

-
- @if (CurrItem == null) - { - - } - else - { - - } -
-
-
- Tipo Mat. - -
+ @*
+ @if (CurrItem == null) + { + + } + else + { + + } +
*@ + @*
+
+ Tipo Mat. +
+
*@
@if (CurrItem != null) { -
- + @*
+ *@ }
@@ -50,14 +50,16 @@ - + - ID - Mat.Code - Descr. - W (mm) - H (mm) - @* L (mm) *@ + ID + Descr. + Macchina + Creat + Sched + Prod + Arch + Time @* *@ @@ -67,48 +69,52 @@ - + @* *@ - @if (item.IsBeam) + @if (item.PType == Enums.BWType.BEAM) { } - else if (@item.IsWall) + else { } -  @item.MatId +  @item.ProjExtId (@item.ProjExtDbId) - @item.MatCode + @item.ProjDescription +
@item.BTLFileName
- @item.MatDesc + @item.Machine - @if (item.IsBeam) + @($"{item.DtCreated:yyyy-MM-dd HH:mm}") + + + @($"{item.DtSchedule:yyyy-MM-dd HH:mm}") + + + @($"{item.DtStartProd:yyyy-MM-dd HH:mm}") + + + @item.IsArchived + + + @if (item.ProcTimeReal > 0) { - @($"{item.WMm:N2}") + @($"{item.ProcTimeReal:N1}") min } else { - - + @($"{item.ProcTimeEst:N1}") min } - - @($"{item.HMm:N2}") - - @* - @($"{item.LMm:N2}") - *@ - @* - - *@ } diff --git a/MagMan.UI/Components/ProjectMan.razor.cs b/MagMan.UI/Components/ProjectMan.razor.cs index 7bc34d3..f2e1a82 100644 --- a/MagMan.UI/Components/ProjectMan.razor.cs +++ b/MagMan.UI/Components/ProjectMan.razor.cs @@ -15,7 +15,7 @@ namespace MagMan.UI.Components public int CustomerId { get; set; } = 0; [Parameter] - public EventCallback E_MaterialSel { get; set; } + public EventCallback E_ProjSel { get; set; } [Parameter] public int KeyNum { get; set; } = 0; @@ -42,58 +42,52 @@ namespace MagMan.UI.Components #region Protected Methods - protected string CheckSel(MaterialModel curItem) + protected string CheckSel(ProjModel curItem) { string answ = ""; if (CurrItem != null) { - answ = curItem.MatId == CurrItem.MatId ? "table-info" : ""; + answ = curItem.ProjDbId == CurrItem.ProjDbId ? "table-info" : ""; } else { - answ = curItem.MatId == MaterialId ? "table-info" : ""; + answ = curItem.ProjDbId == ProjDbId ? "table-info" : ""; } return answ; } - protected async Task CreateNew() - { - CurrItem = new MaterialModel() - { - MatCode = "Mat_unique_code", - MatDesc = "Material Description" - }; - await InvokeAsync(StateHasChanged); - } - protected async Task DeleteRecord(MaterialModel selItem) + + protected async Task DeleteRecord(ProjModel selItem) { if (!await JSRuntime.InvokeAsync("confirm", "Sicuro di voler eliminare il record?")) return; - await TService.MaterialDelete(KeyNum, selItem); + await TService.ProjectDelete(KeyNum, selItem); await ReloadData(); } - protected void DoEdit(MaterialModel? selItem) +#if false + protected void DoEdit(ProjModel? selItem) { CurrItem = selItem; if (selItem == null) { DoSelect(null); } - } + } +#endif - protected void DoSelect(MaterialModel? selItem) + protected void DoSelect(ProjModel? selItem) { if (selItem != null) { - MaterialId = selItem.MatId; + ProjDbId = selItem.ProjDbId; } else { - MaterialId = 0; + ProjDbId = 0; } - E_MaterialSel.InvokeAsync(selItem); + E_ProjSel.InvokeAsync(selItem); } protected async Task ForceReload(bool force) @@ -138,12 +132,12 @@ namespace MagMan.UI.Components #region Private Fields - private MaterialModel? CurrItem = null; + private ProjModel? CurrItem = null; private string currSearch = ""; private int filtType = 0; - private List? ListRecords = null; - private int MaterialId = 0; - private List? SearchRecords = null; + private List? ListRecords = null; + private int ProjDbId = 0; + private List? SearchRecords = null; private bool sortAsc = true; @@ -186,18 +180,20 @@ namespace MagMan.UI.Components private async Task ReloadData() { isLoading = true; - await InvokeAsync(StateHasChanged); + //await InvokeAsync(StateHasChanged); ListRecords = null; - SearchRecords = await TService.MaterialGetAll(KeyNum, false); + 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.MatCode.Contains(currSearch, StringComparison.InvariantCultureIgnoreCase) || x.MatDesc.Contains(currSearch, StringComparison.InvariantCultureIgnoreCase)).ToList(); + SearchRecords = SearchRecords.Where(x => x.ProjDescription.Contains(currSearch, StringComparison.InvariantCultureIgnoreCase) || x.BTLFileName.Contains(currSearch, StringComparison.InvariantCultureIgnoreCase)).ToList(); } totalCount = SearchRecords.Count; SortTable(); @@ -214,69 +210,183 @@ namespace MagMan.UI.Components { switch (sortField) { - case "RawItemId": + case "ID": if (sortAsc) { - SearchRecords = SearchRecords.OrderBy(x => x.MatId).ThenBy(x => x.MatCode).ToList(); + SearchRecords = SearchRecords.OrderBy(x => x.ProjExtId).ToList(); } else { - SearchRecords = SearchRecords.OrderByDescending(x => x.MatId).ThenByDescending(x => x.MatCode).ToList(); + SearchRecords = SearchRecords.OrderByDescending(x => x.ProjExtId).ToList(); } break; - case "MatCode": +#if false + case "MachineID": if (sortAsc) { - SearchRecords = SearchRecords.OrderBy(x => x.MatCode).ToList(); + SearchRecords = SearchRecords.OrderBy(x => x.MachineID).ToList(); } else { - SearchRecords = SearchRecords.OrderByDescending(x => x.MatCode).ToList(); + SearchRecords = SearchRecords.OrderByDescending(x => x.MachineID).ToList(); } break; - case "MatDesc": + case "ProjExtDbId": if (sortAsc) { - SearchRecords = SearchRecords.OrderBy(x => x.MatDesc).ToList(); + SearchRecords = SearchRecords.OrderBy(x => x.ProjExtDbId).ToList(); } else { - SearchRecords = SearchRecords.OrderByDescending(x => x.MatDesc).ToList(); + SearchRecords = SearchRecords.OrderByDescending(x => x.ProjExtDbId).ToList(); } break; - case "W": + case "ProjExtId": if (sortAsc) { - SearchRecords = SearchRecords.OrderBy(x => x.WMm).ToList(); + SearchRecords = SearchRecords.OrderBy(x => x.ProjExtId).ToList(); } else { - SearchRecords = SearchRecords.OrderByDescending(x => x.WMm).ToList(); + 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; - case "H": +#if false + case "PType": if (sortAsc) { - SearchRecords = SearchRecords.OrderBy(x => x.HMm).ToList(); + SearchRecords = SearchRecords.OrderBy(x => x.PType).ToList(); } else { - SearchRecords = SearchRecords.OrderByDescending(x => x.HMm).ToList(); + 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 "L": + case "DtCreated": if (sortAsc) { - SearchRecords = SearchRecords.OrderBy(x => x.LMm).ToList(); + SearchRecords = SearchRecords.OrderBy(x => x.DtCreated).ToList(); } else { - SearchRecords = SearchRecords.OrderByDescending(x => x.LMm).ToList(); + 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; @@ -293,7 +403,7 @@ namespace MagMan.UI.Components } else { - ListRecords = new List(); + ListRecords = new List(); } } diff --git a/MagMan.UI/MagMan.UI.csproj b/MagMan.UI/MagMan.UI.csproj index b52df31..d802375 100644 --- a/MagMan.UI/MagMan.UI.csproj +++ b/MagMan.UI/MagMan.UI.csproj @@ -2,7 +2,7 @@ net6.0 - 1.0.2401.2410 + 1.0.2401.2412 enable enable true diff --git a/MagMan.UI/Pages/ProjectsStatus.razor b/MagMan.UI/Pages/ProjectsStatus.razor index bbb8cc7..38886fd 100644 --- a/MagMan.UI/Pages/ProjectsStatus.razor +++ b/MagMan.UI/Pages/ProjectsStatus.razor @@ -14,12 +14,12 @@ else {
- +
- @if (MaterialSel != null) + @if (ProjSel != null) {
- + @* *@
}
diff --git a/MagMan.UI/Pages/ProjectsStatus.razor.cs b/MagMan.UI/Pages/ProjectsStatus.razor.cs index 1b990ee..3703c1e 100644 --- a/MagMan.UI/Pages/ProjectsStatus.razor.cs +++ b/MagMan.UI/Pages/ProjectsStatus.razor.cs @@ -20,7 +20,7 @@ namespace MagMan.UI.Pages protected string mainCss { - get => MaterialSel == null ? "col-12" : "col-6 small"; + get => ProjSel == null ? "col-12" : "col-6 small"; } [Inject] @@ -41,9 +41,10 @@ namespace MagMan.UI.Pages await ReloadData(); } - protected void SaveMat(MaterialModel? newMat) + + protected void SaveProj(ProjModel? newMat) { - MaterialSel = newMat; + ProjSel = newMat; } #endregion Protected Methods @@ -51,7 +52,8 @@ namespace MagMan.UI.Pages #region Private Fields private int KeyNum = 0; - private MaterialModel? MaterialSel = null; + + private ProjModel? ProjSel = null; #endregion Private Fields diff --git a/Resources/ChangeLog.html b/Resources/ChangeLog.html index bf6dea8..2c06a87 100644 --- a/Resources/ChangeLog.html +++ b/Resources/ChangeLog.html @@ -1,6 +1,6 @@ MagMan - Wood Warehouse Management System -

Versione: 1.0.2401.2410

+

Versione: 1.0.2401.2412


Note di rilascio:
  • diff --git a/Resources/VersNum.txt b/Resources/VersNum.txt index d5b0131..d91b4c8 100644 --- a/Resources/VersNum.txt +++ b/Resources/VersNum.txt @@ -1 +1 @@ -1.0.2401.2410 +1.0.2401.2412 diff --git a/Resources/manifest.xml b/Resources/manifest.xml index f9355cf..39cc060 100644 --- a/Resources/manifest.xml +++ b/Resources/manifest.xml @@ -1,6 +1,6 @@ - 1.0.2401.2410 + 1.0.2401.2412 http://nexus.steamware.net/repository/SWS/MagMan/stable/0/MagMan.UI.zip http://nexus.steamware.net/repository/SWS/MagMan/stable/0/ChangeLog.html false From 437e23b30cf7f5d9cc00995af0e52bf518b48385 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Wed, 24 Jan 2024 15:25:43 +0100 Subject: [PATCH 11/13] OK display stato proj --- MagMan.UI/Components/ProjectMan.razor | 56 +++++++++++++++++---------- 1 file changed, 36 insertions(+), 20 deletions(-) diff --git a/MagMan.UI/Components/ProjectMan.razor b/MagMan.UI/Components/ProjectMan.razor index 752838c..7c30e54 100644 --- a/MagMan.UI/Components/ProjectMan.razor +++ b/MagMan.UI/Components/ProjectMan.razor @@ -32,7 +32,7 @@ @if (CurrItem != null) { @*
    - *@ + *@ }
@@ -54,11 +54,15 @@ ID Descr. - Macchina - Creat - Sched + Filename + @if (ProjDbId == 0) + { + Macchina + } + Creato + Previsione Prod - Arch + @* Arch *@ Time @* *@ @@ -88,31 +92,43 @@ @item.ProjDescription -
@item.BTLFileName
- @item.Machine + @item.BTLFileName + + @if (ProjDbId == 0) + { + + @item.Machine + + } + + @($"{item.DtCreated:yyyy-MM-dd}") - @($"{item.DtCreated:yyyy-MM-dd HH:mm}") + @($"{item.DtSchedule:yyyy-MM-dd}") - @($"{item.DtSchedule:yyyy-MM-dd HH:mm}") - - - @($"{item.DtStartProd:yyyy-MM-dd HH:mm}") - - - @item.IsArchived - - - @if (item.ProcTimeReal > 0) + @if (item.DtStartProd > DateTime.MinValue) { - @($"{item.ProcTimeReal:N1}") min + @($"{item.DtStartProd:yyyy-MM-dd}") } else { - @($"{item.ProcTimeEst:N1}") min + n.a. + } + + @* + @item.IsArchived + *@ + + @if (item.ProcTimeReal > 0) + { + @($"{item.ProcTimeReal:N1}") min + } + else + { + @($"{item.ProcTimeEst:N1}") min } From db087b52e1cf41366d6e6cbd775f3a04317e79ae Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Wed, 24 Jan 2024 16:09:17 +0100 Subject: [PATCH 12/13] Aggiunto controllo export dati risorse (get) --- MagMan.Data.Admin/Services/MTAdminService.cs | 2 +- .../Controllers/TenantController.cs | 34 +++++++++++- MagMan.Data.Tenant/Services/TenantService.cs | 52 +++++++++++++++++++ MagMan.UI/Components/ProjectMan.razor | 4 +- MagMan.UI/Controllers/ResourcesController.cs | 14 +++-- MagMan.UI/MagMan.UI.csproj | 2 +- Resources/ChangeLog.html | 2 +- Resources/VersNum.txt | 2 +- Resources/manifest.xml | 2 +- 9 files changed, 104 insertions(+), 10 deletions(-) diff --git a/MagMan.Data.Admin/Services/MTAdminService.cs b/MagMan.Data.Admin/Services/MTAdminService.cs index f1b4d1f..cb48abf 100644 --- a/MagMan.Data.Admin/Services/MTAdminService.cs +++ b/MagMan.Data.Admin/Services/MTAdminService.cs @@ -443,7 +443,7 @@ namespace MagMan.Data.Admin.Services { CustMKeyList.Add(CustID, answ); } - catch + catch { } Log.Info($"TokenMKeyList: added {CustID} --> {answ}"); } diff --git a/MagMan.Data.Tenant/Controllers/TenantController.cs b/MagMan.Data.Tenant/Controllers/TenantController.cs index 937fb5c..6e7d5a8 100644 --- a/MagMan.Data.Tenant/Controllers/TenantController.cs +++ b/MagMan.Data.Tenant/Controllers/TenantController.cs @@ -278,7 +278,7 @@ namespace MagMan.Data.Tenant.Controllers } /// /// Elenco Materiali gestiti a magazzino Stringa - /// connessione (variabile x cliente) Materiale richiesto, 0 + /// connessione (variabile x cliente) Materiale richiesto, 0 /// = tutti Se true allora include record child /// (Items) public List MaterialGetFilt(string connString, int matID, bool withChild) @@ -523,6 +523,38 @@ namespace MagMan.Data.Tenant.Controllers return done; } + /// + /// Elenco risorse dato progetto e stato + /// + /// Stringa connessione (variabile x cliente) + /// ID progetto + /// true = ultima stima attiva / false = consumi effettivi + /// + public List ResourcesGetByProject(string connString, int projDbId, bool isEstim) + { + List dbResult = new List(); + using (MagManContext dbCtx = new MagManContext(connString)) + { + if (isEstim) + { + dbResult = dbCtx + .DbSetResources + .Where(x => x.RequestNav.ProjDbId == projDbId && x.RequestNav.IsActive && x.RequestNav.ReqState > Core.Enums.ProjResState.ND) + .OrderBy(x => x.ResourceId) + .ToList(); + } + else + { + dbResult = dbCtx + .DbSetResources + .Where(x => x.RequestNav.ProjDbId == projDbId && x.RequestNav.IsActive && x.RequestNav.ReqState == Core.Enums.ProjResState.Consumed) + .OrderBy(x => x.ResourceId) + .ToList(); + } + } + return dbResult; + } + #endregion Public Methods #region Private Fields diff --git a/MagMan.Data.Tenant/Services/TenantService.cs b/MagMan.Data.Tenant/Services/TenantService.cs index 7c1e83d..eaa155d 100644 --- a/MagMan.Data.Tenant/Services/TenantService.cs +++ b/MagMan.Data.Tenant/Services/TenantService.cs @@ -622,6 +622,58 @@ namespace MagMan.Data.Tenant.Services #endregion Public Methods + /// + /// Elenco risorse dato progetto e stato + /// + /// Key di riferimento + /// ID progetto + /// true = ultima stima attiva / false = consumi effettivi + /// + public async Task> ResourcesGetByProject(int nKey, int projDbId, bool isEstim) + { + string source = "DB"; + string cString = ConnString(nKey); + List? dbResult = new List(); + try + { + string currKey = $"{Const.rKeyConfig}:{nKey}:ResList:{projDbId}:{isEstim}"; + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + string? rawData = await redisDb.StringGetAsync(currKey); + if (!string.IsNullOrEmpty(rawData)) + { + source = "REDIS"; + var tempResult = JsonConvert.DeserializeObject>(rawData); + if (tempResult == null) + { + dbResult = new List(); + } + else + { + dbResult = tempResult; + } + } + else + { + dbResult = dbController.ResourcesGetByProject(cString, projDbId, isEstim); + rawData = JsonConvert.SerializeObject(dbResult, JSSettings); + await redisDb.StringSetAsync(currKey, rawData, FastCache); + } + if (dbResult == null) + { + dbResult = new List(); + } + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Debug($"ResourcesGetByProject | {source} in: {ts.TotalMilliseconds} ms"); + } + catch (Exception exc) + { + Log.Error($"Error during ResourcesGetByProject:{Environment.NewLine}{exc}"); + } + return dbResult; + } + #region Private Fields private static JsonSerializerSettings? JSSettings; diff --git a/MagMan.UI/Components/ProjectMan.razor b/MagMan.UI/Components/ProjectMan.razor index 7c30e54..97e3073 100644 --- a/MagMan.UI/Components/ProjectMan.razor +++ b/MagMan.UI/Components/ProjectMan.razor @@ -76,6 +76,7 @@ @* *@ + @if (item.PType == Enums.BWType.BEAM) { @@ -88,7 +89,8 @@ } -  @item.ProjExtId (@item.ProjExtDbId) +  @item.ProjExtId + @item.ProjDescription diff --git a/MagMan.UI/Controllers/ResourcesController.cs b/MagMan.UI/Controllers/ResourcesController.cs index af8f3b3..7416b35 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; } diff --git a/MagMan.UI/MagMan.UI.csproj b/MagMan.UI/MagMan.UI.csproj index d802375..b93188e 100644 --- a/MagMan.UI/MagMan.UI.csproj +++ b/MagMan.UI/MagMan.UI.csproj @@ -2,7 +2,7 @@ net6.0 - 1.0.2401.2412 + 1.0.2401.2416 enable enable true diff --git a/Resources/ChangeLog.html b/Resources/ChangeLog.html index 2c06a87..5c2f4c8 100644 --- a/Resources/ChangeLog.html +++ b/Resources/ChangeLog.html @@ -1,6 +1,6 @@ MagMan - Wood Warehouse Management System -

Versione: 1.0.2401.2412

+

Versione: 1.0.2401.2416


Note di rilascio:
  • diff --git a/Resources/VersNum.txt b/Resources/VersNum.txt index d91b4c8..e3a31d5 100644 --- a/Resources/VersNum.txt +++ b/Resources/VersNum.txt @@ -1 +1 @@ -1.0.2401.2412 +1.0.2401.2416 diff --git a/Resources/manifest.xml b/Resources/manifest.xml index 39cc060..97c0692 100644 --- a/Resources/manifest.xml +++ b/Resources/manifest.xml @@ -1,6 +1,6 @@ - 1.0.2401.2412 + 1.0.2401.2416 http://nexus.steamware.net/repository/SWS/MagMan/stable/0/MagMan.UI.zip http://nexus.steamware.net/repository/SWS/MagMan/stable/0/ChangeLog.html false From 7dbc84fe453f5b2b4f434f55f4427c2cc336dcaf Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Wed, 24 Jan 2024 18:34:16 +0100 Subject: [PATCH 13/13] Aggiunta post risorse (stima + consumo) - da testare --- .../Controllers/TenantController.cs | 110 ++++++++++++++++++ MagMan.Data.Tenant/Services/TenantService.cs | 70 ++++++++++- MagMan.UI/Controllers/ResourcesController.cs | 42 ++++--- MagMan.UI/MagMan.UI.csproj | 2 +- Resources/ChangeLog.html | 2 +- Resources/VersNum.txt | 2 +- Resources/manifest.xml | 2 +- 7 files changed, 210 insertions(+), 20 deletions(-) diff --git a/MagMan.Data.Tenant/Controllers/TenantController.cs b/MagMan.Data.Tenant/Controllers/TenantController.cs index 6e7d5a8..ee48284 100644 --- a/MagMan.Data.Tenant/Controllers/TenantController.cs +++ b/MagMan.Data.Tenant/Controllers/TenantController.cs @@ -555,6 +555,116 @@ namespace MagMan.Data.Tenant.Controllers return dbResult; } + /// + /// Aggiunge/Modifica un record ReqPlan + /// + /// Stringa connessione (variabile x cliente) + /// Record da aggiungere/aggiornare + /// + public int ReqPlanUpdate(string connString, RequestPlanModel rec2upd) + { + int newId = 0; + using (MagManContext dbCtx = new MagManContext(connString)) + { + try + { + /* + * Ricerca x Id corrispondente + * */ + var currData = dbCtx + .DbSetReqPlan + .Where(x => x.RequestId == rec2upd.RequestId) + .FirstOrDefault(); + + // aggiorno + if (currData != null) + { + currData.ProjDbId = rec2upd.ProjDbId; + currData.DtRequest = rec2upd.DtRequest; + currData.ReqState = rec2upd.ReqState; + currData.IsActive = rec2upd.IsActive; + dbCtx.Entry(currData).State = EntityState.Modified; + } + else + { + // se NON di consumo prima rendo disattivi altri.... + if (rec2upd.ReqState > Core.Enums.ProjResState.Consumed) + { + var rec2disable = dbCtx + .DbSetReqPlan + .Where(x => x.IsActive && x.ProjDbId == rec2upd.ProjDbId && x.ReqState > Core.Enums.ProjResState.Consumed) + .ToList(); + if (rec2disable != null) + { + foreach (var recAct in rec2disable) + { + recAct.IsActive = false; + dbCtx.Entry(recAct).State = EntityState.Modified; + } + } + } + // aggiungo record + dbCtx + .DbSetReqPlan + .Add(rec2upd); + } + dbCtx.SaveChanges(); + newId = rec2upd.RequestId; + } + catch (Exception exc) + { + Log.Error($"Eccezione in ReqPlanUpdate{Environment.NewLine}{exc}"); + } + } + return newId; + } + + /// + /// Aggiunge/Modifica un record Resource + /// + /// Stringa connessione (variabile x cliente) + /// Record da aggiungere/aggiornare + /// + public int ResourceUpdate(string connString, ResourceModel rec2upd) + { + int newId = 0; + using (MagManContext dbCtx = new MagManContext(connString)) + { + try + { + /* + * Ricerca x Id corrispondente + * */ + var currData = dbCtx + .DbSetResources + .Where(x => x.ResourceId == rec2upd.ResourceId) + .FirstOrDefault(); + + // aggiorno + if (currData != null) + { + currData.Qty = rec2upd.Qty; + currData.RawItemId = rec2upd.RawItemId; + dbCtx.Entry(currData).State = EntityState.Modified; + } + else + { + // aggiungo record + dbCtx + .DbSetResources + .Add(rec2upd); + } + dbCtx.SaveChanges(); + newId = rec2upd.RequestId; + } + catch (Exception exc) + { + Log.Error($"Eccezione in ResourceUpdate{Environment.NewLine}{exc}"); + } + } + return newId; + } + #endregion Public Methods #region Private Fields diff --git a/MagMan.Data.Tenant/Services/TenantService.cs b/MagMan.Data.Tenant/Services/TenantService.cs index eaa155d..a39a7d2 100644 --- a/MagMan.Data.Tenant/Services/TenantService.cs +++ b/MagMan.Data.Tenant/Services/TenantService.cs @@ -620,7 +620,48 @@ namespace MagMan.Data.Tenant.Services return fatto; } - #endregion Public Methods + /// + /// Aggiunge/Modifica un record ReqPlan + /// + /// Key di riferimento + /// Record da aggiungere/aggiornare + /// + public async Task ReqPlanUpdate(int nKey, RequestPlanModel currItem) + { + int newId = 0; + string cString = ConnString(nKey); + try + { + newId = dbController.ReqPlanUpdate(cString, currItem); + if (newId > 0) + { + await FlushRedisCache(); + } + } + catch (Exception exc) + { + Log.Error($"Error during ReqPlanUpdate:{Environment.NewLine}{exc}"); + } + return newId; + } + + /// + /// Converte il DTO in ResourceModel + /// + /// DTO di partenza + /// + public ResourceModel ResourceFromDto(ResourceDTO origItem, int reqId) + { + ResourceModel answ = new ResourceModel() + { + Qty = origItem.Qty, + RawItemId = origItem.RawItemId, + RequestId = reqId, + ResourceId = 0 + }; + + return answ; + } /// /// Elenco risorse dato progetto e stato @@ -674,6 +715,33 @@ namespace MagMan.Data.Tenant.Services return dbResult; } + /// + /// Aggiunge/Modifica un record Resource + /// + /// Key di riferimento + /// Record da aggiungere/aggiornare + /// + public async Task ResourceUpdate(int nKey, ResourceModel currItem) + { + int newId = 0; + string cString = ConnString(nKey); + try + { + newId = dbController.ResourceUpdate(cString, currItem); + if (newId > 0) + { + await FlushRedisCache(); + } + } + catch (Exception exc) + { + Log.Error($"Error during ResourceUpdate:{Environment.NewLine}{exc}"); + } + return newId; + } + + #endregion Public Methods + #region Private Fields private static JsonSerializerSettings? JSSettings; diff --git a/MagMan.UI/Controllers/ResourcesController.cs b/MagMan.UI/Controllers/ResourcesController.cs index 7416b35..1d7a2c1 100644 --- a/MagMan.UI/Controllers/ResourcesController.cs +++ b/MagMan.UI/Controllers/ResourcesController.cs @@ -97,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 b93188e..ce88386 100644 --- a/MagMan.UI/MagMan.UI.csproj +++ b/MagMan.UI/MagMan.UI.csproj @@ -2,7 +2,7 @@ net6.0 - 1.0.2401.2416 + 1.0.2401.2418 enable enable true diff --git a/Resources/ChangeLog.html b/Resources/ChangeLog.html index 5c2f4c8..cae6966 100644 --- a/Resources/ChangeLog.html +++ b/Resources/ChangeLog.html @@ -1,6 +1,6 @@ MagMan - Wood Warehouse Management System -

    Versione: 1.0.2401.2416

    +

    Versione: 1.0.2401.2418


    Note di rilascio:
    • diff --git a/Resources/VersNum.txt b/Resources/VersNum.txt index e3a31d5..112a2c7 100644 --- a/Resources/VersNum.txt +++ b/Resources/VersNum.txt @@ -1 +1 @@ -1.0.2401.2416 +1.0.2401.2418 diff --git a/Resources/manifest.xml b/Resources/manifest.xml index 97c0692..8ea9ceb 100644 --- a/Resources/manifest.xml +++ b/Resources/manifest.xml @@ -1,6 +1,6 @@ - 1.0.2401.2416 + 1.0.2401.2418 http://nexus.steamware.net/repository/SWS/MagMan/stable/0/MagMan.UI.zip http://nexus.steamware.net/repository/SWS/MagMan/stable/0/ChangeLog.html false