diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6939d2c..039088c 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.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 diff --git a/MagMan.Core/Services/MessageService.cs b/MagMan.Core/Services/MessageService.cs index a3dc8dc..53e12ad 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; @@ -25,14 +26,11 @@ namespace MagMan.Core.Services #region Public Events public event Action EA_FilterUpdated = null!; - public event Action EA_HideSearch = null!; - public event Action EA_PageUpdated = null!; - public event Action EA_SearchUpdated = null!; - public event Action EA_ShowSearch = null!; + public event Action EA_CustomerSel = null!; #endregion Public Events @@ -93,7 +91,6 @@ namespace MagMan.Core.Services if (_searchVal != value) { _searchVal = value; - if (EA_SearchUpdated != null) { EA_SearchUpdated?.Invoke(); @@ -101,6 +98,21 @@ namespace MagMan.Core.Services } } } + public int CustomerID + { + get => _customerID; + set + { + if (_customerID != value) + { + _customerID = value; + if (EA_CustomerSel != null) + { + EA_CustomerSel?.Invoke(); + } + } + } + } public string SelOrderCode { get; set; } = ""; public string SelPlantId { get; set; } = "0"; @@ -488,6 +500,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.Data.Admin/Services/MTAdminService.cs b/MagMan.Data.Admin/Services/MTAdminService.cs index 70eac3e..cb48abf 100644 --- a/MagMan.Data.Admin/Services/MTAdminService.cs +++ b/MagMan.Data.Admin/Services/MTAdminService.cs @@ -439,7 +439,12 @@ namespace MagMan.Data.Admin.Services if (custRow != null) { answ = custRow.MainKey; - CustMKeyList.Add(CustID, answ); + try + { + CustMKeyList.Add(CustID, answ); + } + catch + { } Log.Info($"TokenMKeyList: added {CustID} --> {answ}"); } } diff --git a/MagMan.Data.Tenant/Controllers/TenantController.cs b/MagMan.Data.Tenant/Controllers/TenantController.cs index 44fe134..ee48284 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(); } @@ -523,6 +523,148 @@ 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; + } + + /// + /// 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 177061e..a39a7d2 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; } @@ -620,6 +620,126 @@ namespace MagMan.Data.Tenant.Services return fatto; } + /// + /// 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 + /// + /// 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; + } + + /// + /// 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 diff --git a/MagMan.UI/Components/CmpCustomerUndef.razor b/MagMan.UI/Components/CmpCustomerUndef.razor new file mode 100644 index 0000000..bbcbf3b --- /dev/null +++ b/MagMan.UI/Components/CmpCustomerUndef.razor @@ -0,0 +1,10 @@ +
+
+ Customer Undef +
+ Prego selezionare Cliente per visualizzare i dati relativi +
+ +@code { + +} 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 + { + + + + + + + + @if (ProjDbId == 0) + { + + } + + + + @* *@ + + @* *@ + + + + @foreach (var item in ListRecords) + { + + + + + + @if (ProjDbId == 0) + { + + } + + + + @* *@ + + + } + +
+ + ID Descr. Filename Macchina Creato Previsione Prod Arch Time
+ + @* *@ + + + @if (item.PType == Enums.BWType.BEAM) + { + + + + } + else + { + + + + } +  @item.ProjExtId + + + @item.ProjDescription + + @item.BTLFileName + + @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 @@ -
- @if (currMode != CtMode.Company) - { - - } -
-@if (currMode == CtMode.Company) +@if (currMode == CtMode.Loading) { + +} +else if (currMode == CtMode.Company) + { } else if (currMode == CtMode.Users) diff --git a/MagMan.UI/Pages/AdminArea.razor.cs b/MagMan.UI/Pages/AdminArea.razor.cs index c035dc3..d27e5d3 100644 --- a/MagMan.UI/Pages/AdminArea.razor.cs +++ b/MagMan.UI/Pages/AdminArea.razor.cs @@ -11,6 +11,7 @@ namespace MagMan.UI.Pages protected enum CtMode { + Loading, Company, Users, Machine, @@ -36,12 +37,19 @@ namespace MagMan.UI.Pages AppMService.ShowSearch = false; AppMService.PageName = "Admin Area"; AppMService.PageIcon = "fa-solid fa-house pr-2"; + AppMService.EA_CustomerSel += AppMService_EA_CustomerSel; + CustomerID = AppMService.CustomerID; } - protected void SaveCust(int newCustId) + private async void AppMService_EA_CustomerSel() { - CustomerID = newCustId; - } + var actMode = currMode; + currMode = CtMode.Loading; + CustomerID = AppMService.CustomerID; + await Task.Delay(50); + currMode = actMode; + await InvokeAsync(StateHasChanged); + } #endregion Protected Methods diff --git a/MagMan.UI/Pages/Index.razor b/MagMan.UI/Pages/Index.razor index d1470ea..d2ceafa 100644 --- a/MagMan.UI/Pages/Index.razor +++ b/MagMan.UI/Pages/Index.razor @@ -7,7 +7,7 @@ @attribute [AllowAnonymous] -
+

Mag-Man

@@ -42,7 +42,7 @@
-
+
@@ -52,7 +52,7 @@
-
+
@@ -62,7 +62,17 @@
-
+
+ + + + +

Progetti

+
+
+
+
+
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 new file mode 100644 index 0000000..38886fd --- /dev/null +++ b/MagMan.UI/Pages/ProjectsStatus.razor @@ -0,0 +1,26 @@ +@page "/ProjectsStatus" + +Projects Status + +@if (isLoading) +{ + +} +else if (CustomerID == 0) +{ + +} +else +{ +
+
+ +
+ @if (ProjSel != null) + { +
+ @* *@ +
+ } +
+} \ No newline at end of file diff --git a/MagMan.UI/Pages/ProjectsStatus.razor.cs b/MagMan.UI/Pages/ProjectsStatus.razor.cs new file mode 100644 index 0000000..3703c1e --- /dev/null +++ b/MagMan.UI/Pages/ProjectsStatus.razor.cs @@ -0,0 +1,86 @@ +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 => ProjSel == 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 SaveProj(ProjModel? newMat) + { + ProjSel = newMat; + } + + #endregion Protected Methods + + #region Private Fields + + private int KeyNum = 0; + + private ProjModel? ProjSel = 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/ResetCache.razor.cs b/MagMan.UI/Pages/ResetCache.razor.cs index 4f66efc..8155a55 100644 --- a/MagMan.UI/Pages/ResetCache.razor.cs +++ b/MagMan.UI/Pages/ResetCache.razor.cs @@ -14,7 +14,7 @@ namespace MagMan.UI.Pages // resetto cache redis await MTService.FlushRedisCache(); string baseAppPath = Configuration["OptConf:BaseUrl"]; - NavMan.NavigateTo(baseAppPath); + NavMan.NavigateTo(baseAppPath, true); } [Inject] private NavigationManager NavMan { get; set; } = null!; diff --git a/MagMan.UI/Pages/WareHouse.razor b/MagMan.UI/Pages/WareHouse.razor index 91abc55..a7760c0 100644 --- a/MagMan.UI/Pages/WareHouse.razor +++ b/MagMan.UI/Pages/WareHouse.razor @@ -2,21 +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 3a501b0..e7d7e0d 100644 --- a/MagMan.UI/Pages/WareHouse.razor.cs +++ b/MagMan.UI/Pages/WareHouse.razor.cs @@ -20,8 +20,6 @@ namespace MagMan.UI.Pages [Inject] protected MessageService AppMService { get; set; } = null!; - protected int CustomerID { get; set; } = 0; - protected string mainCss { get => MaterialSel == null ? "col-12" : "col-6 small"; @@ -37,18 +35,14 @@ 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; // rileggo dati await ReloadData(); } - protected async Task SaveCust(int newCustId) - { - CustomerID = newCustId; - await ReloadData(); - } - protected void SaveMat(MaterialModel? newMat) { MaterialSel = newMat; @@ -65,12 +59,21 @@ namespace MagMan.UI.Pages #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; diff --git a/MagMan.UI/Shared/MainLayout.razor b/MagMan.UI/Shared/MainLayout.razor index 2131c01..7605263 100644 --- a/MagMan.UI/Shared/MainLayout.razor +++ b/MagMan.UI/Shared/MainLayout.razor @@ -14,7 +14,7 @@
@*
*@ -
+
@Body
diff --git a/MagMan.UI/Shared/MainLayout.razor.css b/MagMan.UI/Shared/MainLayout.razor.css index cb44e9f..8dc4822 100644 --- a/MagMan.UI/Shared/MainLayout.razor.css +++ b/MagMan.UI/Shared/MainLayout.razor.css @@ -23,7 +23,7 @@ main { .top-row ::deep a, .top-row .btn-link { white-space: nowrap; - margin-left: 1.5rem; + margin-left: 0.5rem; } .top-row a:first-child { @@ -85,8 +85,8 @@ main { } .top-row, article { - padding-left: 2rem !important; - padding-right: 1.5rem !important; + padding-left: 1rem !important; + padding-right: 1.0rem !important; } .bottom-row { diff --git a/Resources/ChangeLog.html b/Resources/ChangeLog.html index 1f0e378..cae6966 100644 --- a/Resources/ChangeLog.html +++ b/Resources/ChangeLog.html @@ -1,6 +1,6 @@ MagMan - Wood Warehouse Management System -

Versione: 1.0.2401.2309

+

Versione: 1.0.2401.2418


Note di rilascio:
  • diff --git a/Resources/VersNum.txt b/Resources/VersNum.txt index 8a1d986..112a2c7 100644 --- a/Resources/VersNum.txt +++ b/Resources/VersNum.txt @@ -1 +1 @@ -1.0.2401.2309 +1.0.2401.2418 diff --git a/Resources/manifest.xml b/Resources/manifest.xml index 2ef87ac..8ea9ceb 100644 --- a/Resources/manifest.xml +++ b/Resources/manifest.xml @@ -1,6 +1,6 @@ - 1.0.2401.2309 + 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 diff --git a/TestWinFormVB/Form1.vb b/TestWinFormVB/Form1.vb index f28d002..a906826 100644 --- a/TestWinFormVB/Form1.vb +++ b/TestWinFormVB/Form1.vb @@ -44,7 +44,7 @@ Public Class Form1 Dim result As String = "" - Dim matList = Await commLib.GetMaterials() + Dim matList = Await commLib.MaterialsGet() If matList IsNot Nothing Then For Each item In matList @@ -53,7 +53,7 @@ Public Class Form1 result += $"Dtmx Code: {item.MatDtmx}{Environment.NewLine}" result += $"descript: {item.MatDesc}{Environment.NewLine}" result += $"Dimensions W x T x L: {item.WMm:N3} x {item.TMm:N3} x {item.LMm:N3}{Environment.NewLine}" - If item.ItemNav IsNot Nothing Then + If item.ItemList IsNot Nothing Then 'result += $"Items count: {item.ItemList.Count}" result += $"{Environment.NewLine}" End If @@ -71,7 +71,7 @@ Public Class Form1 Dim result As String = "" Dim sepShort As String = "----" - Dim matList = Await commLib.GetInventario(0) + Dim matList = Await commLib.InventoryGet(0) If matList IsNot Nothing Then @@ -81,13 +81,13 @@ Public Class Form1 result += $"Dtmx Code: {item.MatDtmx}{Environment.NewLine}" result += $"descript: {item.MatDesc}{Environment.NewLine}" result += $"Dimensions W x T x L: {item.WMm:N3} x {item.TMm:N3} x {item.LMm:N3}{Environment.NewLine}" - If item.ItemNav IsNot Nothing Then - result += $"Items count: {item.ItemNav.Count}" + If item.ItemList IsNot Nothing Then + result += $"Items count: {item.ItemList.Count}" - If item.ItemNav.Count > 0 Then + If item.ItemList.Count > 0 Then result += "Inventario:" - For Each itemInv In item.ItemNav + For Each itemInv In item.ItemList result += $"{sepShort}{Environment.NewLine}" result += $"ID: {itemInv.ItemID}{Environment.NewLine}" result += $"Location: {itemInv.Location}{Environment.NewLine}" diff --git a/TestWinFormVB/TestWinFormVB.vbproj b/TestWinFormVB/TestWinFormVB.vbproj index 2432a7b..b1be613 100644 --- a/TestWinFormVB/TestWinFormVB.vbproj +++ b/TestWinFormVB/TestWinFormVB.vbproj @@ -49,7 +49,7 @@ - ..\packages\EgwProxy.MagMan.0.9.2401-beta.1719\lib\EgwProxy.MagMan.dll + ..\packages\EgwProxy.MagMan.0.9.2401.2309\lib\EgwProxy.MagMan.dll ..\packages\Microsoft.Bcl.AsyncInterfaces.7.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll diff --git a/TestWinFormVB/packages.config b/TestWinFormVB/packages.config index 9b9b66b..c43b2f0 100644 --- a/TestWinFormVB/packages.config +++ b/TestWinFormVB/packages.config @@ -1,6 +1,6 @@  - +