From 0ef3249b7f91ca155da166d426de6958bd8424c3 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Thu, 16 Dec 2021 10:25:26 +0100 Subject: [PATCH] UPdate display planner GPW CORE --- GPW.CORE.Data/Controllers/GPWController.cs | 15 +- GPW.CORE.UI/Components/RegAtt.razor | 26 +--- GPW.CORE.UI/Pages/Test.razor | 72 ++++++++++ GPW.CORE.UI/Pages/Test.razor.cs | 153 +++++++++++++++++++++ GPW.CORE.UI/Shared/MainLayout.razor | 2 +- 5 files changed, 243 insertions(+), 25 deletions(-) create mode 100644 GPW.CORE.UI/Pages/Test.razor create mode 100644 GPW.CORE.UI/Pages/Test.razor.cs diff --git a/GPW.CORE.Data/Controllers/GPWController.cs b/GPW.CORE.Data/Controllers/GPWController.cs index 79bfb45..5a630b4 100644 --- a/GPW.CORE.Data/Controllers/GPWController.cs +++ b/GPW.CORE.Data/Controllers/GPWController.cs @@ -37,11 +37,17 @@ namespace GPW.CORE.Data.Controllers // cerco su DB recuperando set di dati.... using (GPWContext localDbCtx = new GPWContext(_configuration)) { - // recupero intero set dati timbrature e attività.... - dbResult = localDbCtx + try + { + // recupero intero set dati timbrature e attività.... + dbResult = localDbCtx .DbSetAnagFasi - //.Include(p => p.ProgettoNav) - .ToList(); + .ToList(); + } + catch(Exception exc) + { + Log.Error($"Errore in AnagFasiAll:{Environment.NewLine}{exc}"); + } } return dbResult; } @@ -78,6 +84,7 @@ namespace GPW.CORE.Data.Controllers rawRegAtt = localDbCtx .DbSetRegAttivita .Where(x => x.IdxDipendente == idxDipendente && dtInizio <= x.Inizio && x.Inizio <= dtFine) + .Include(a => a.FasiNav).ThenInclude(p=>p.ProgettoNav) .ToList(); // calcolo intervallo date... diff --git a/GPW.CORE.UI/Components/RegAtt.razor b/GPW.CORE.UI/Components/RegAtt.razor index 7e60593..8c63b30 100644 --- a/GPW.CORE.UI/Components/RegAtt.razor +++ b/GPW.CORE.UI/Components/RegAtt.razor @@ -2,17 +2,18 @@ @using UI.Data @inject GpwDataService GDataServ -
+
@if (@CurrData.IdxFase > 0) { -
+
@CurrData.Inizio.ToString("HH:mm")
-
@CurrData.Fine.ToString("HH:mm")
+
@CurrData.Fine.ToString("HH:mm")
@($"{CurrData.OreTot:N2}h")
-
@(headFase(CurrData.IdxFase))
+
@CurrData.FasiNav?.ProgettoNav?.NomeProj
+
@CurrData.FasiNav?.DescrizioneFase
@CurrData.Descrizione
} @@ -56,25 +57,10 @@ { get { - string answ = CurrData.IdxFase == 0 ? "" : "table-info border border-info rounded"; + string answ = CurrData.IdxFase == 0 ? "" : " border border-info rounded"; return answ; } } - private string headFase(int idxFase) - { - string answ = $"F.{idxFase}"; - if (ListFasi != null) - { - var currFase = ListFasi - .Where(x => x.IdxFase == idxFase) - .FirstOrDefault(); - if (currFase != null) - { - answ = $"{currFase.NomeFase}"; - } - } - return answ; - } } diff --git a/GPW.CORE.UI/Pages/Test.razor b/GPW.CORE.UI/Pages/Test.razor new file mode 100644 index 0000000..f017645 --- /dev/null +++ b/GPW.CORE.UI/Pages/Test.razor @@ -0,0 +1,72 @@ +@page "/Test" + + +@using GPW.CORE.UI.Components + +Test - Fasi + +
+
+

Fasi

+
+
+ @if (ListRecords == null) + { + + } + else if (totalCount == 0) + { +
No Record Found
+ } + else + { +
+
+ @*
*@ + + + + @**@ + + + + + + + + @foreach (var record in ListRecords) + { + + @**@ + + + + + + } + +
IDCodNomeDescrizione
+ + + P@record.IdxProgetto | @record.IdxFase (← @record.IdxFaseAncest) + + @record.CodFase + + @record.NomeFase + + @record.DescrizioneFase +
+
+
+ } +
+ +
+ + + + diff --git a/GPW.CORE.UI/Pages/Test.razor.cs b/GPW.CORE.UI/Pages/Test.razor.cs new file mode 100644 index 0000000..f2fb5af --- /dev/null +++ b/GPW.CORE.UI/Pages/Test.razor.cs @@ -0,0 +1,153 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Components; +using System.Net.Http; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Components.Authorization; +using Microsoft.AspNetCore.Components.Forms; +using Microsoft.AspNetCore.Components.Routing; +using Microsoft.AspNetCore.Components.Web; +using Microsoft.AspNetCore.Components.Web.Virtualization; +using Microsoft.JSInterop; +using GPW.CORE.UI; +using GPW.CORE.UI.Shared; +using GPW.CORE.UI.Components; +using GPW.CORE.Data.DbModels; +using GPW.CORE.UI.Data; + +namespace GPW.CORE.UI.Pages +{ + public partial class Test : ComponentBase, IDisposable + { + #region Private Fields + + private List ListRecords = null!; + private List SearchRecords = null!; + + #endregion Private Fields + + #region Private Properties + + private int _currPage { get; set; } = 1; + + private int _numRecord { get; set; } = 10; + + private int currPage + { + get => _currPage; + set + { + if (_currPage != value) + { + _currPage = value; + var pUpd = Task.Run(async () => await ReloadData()); + pUpd.Wait(); + } + } + } + + private bool isLoading { get; set; } = false; + + private int IdxDipSel = 0; + + [Inject] + private NavigationManager NavManager { get; set; } = null!; + + private int numRecord + { + get => _numRecord; + set + { + if (_numRecord != value) + { + _numRecord = value; + var pUpd = Task.Run(async () => await ReloadData()); + pUpd.Wait(); + } + } + } + + #endregion Private Properties + + #region Protected Properties + + [Inject] + + protected MessageService AppMService { get; set; } = null!; + + [Inject] + protected GpwDataService DataService { get; set; } = null!; + + [Inject] + protected IJSRuntime JSRuntime { get; set; } = null!; + + protected int totalCount + { + get + { + int answ = 0; + if (SearchRecords != null) + { + answ = SearchRecords.Count; + } + return answ; + } + } + + #endregion Protected Properties + + #region Private Methods + + private async Task ReloadData() + { + isLoading = true; + SearchRecords = await DataService.AnagFasiAll(); + ListRecords = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList(); + isLoading = false; + } + + #endregion Private Methods + + #region Protected Methods + + protected void ForceReload(int newNum) + { + numRecord = newNum; + } + + protected void ForceReloadPage(int newNum) + { + currPage = newNum; + } + + protected override async Task OnInitializedAsync() + { + await ReloadData(); + } + + protected void ResetData() + { + //DataService.rollBackEdit(currRecord); + } + + protected void Select(DipendentiModel selRecord) + { + IdxDipSel = selRecord.IdxDipendente; + //// rimando a remnants + //NavManager.NavigateTo($"Remnants"); + } + + #endregion Protected Methods + + #region Public Methods + + public void Dispose() + { + //AppMService.EA_SearchUpdated -= OnSeachUpdated; + } + + #endregion Public Methods + } +} \ No newline at end of file diff --git a/GPW.CORE.UI/Shared/MainLayout.razor b/GPW.CORE.UI/Shared/MainLayout.razor index 3262d81..b056888 100644 --- a/GPW.CORE.UI/Shared/MainLayout.razor +++ b/GPW.CORE.UI/Shared/MainLayout.razor @@ -13,7 +13,7 @@ About
-
+
@Body