diff --git a/LiMan.Api/Data/ApiDataService.cs b/LiMan.Api/Data/ApiDataService.cs index 1d57491..fecca66 100644 --- a/LiMan.Api/Data/ApiDataService.cs +++ b/LiMan.Api/Data/ApiDataService.cs @@ -357,6 +357,44 @@ namespace LiMan.APi.Data return await Task.FromResult(dbResult); } + /// + /// Statistiche del LOG chiamate all'API dato filtro + /// + /// Data minima + /// DataMax + /// Valore cercato, se "" è tutti + /// + public async Task> StatsLogCallGetFilt(DateTime DateFrom, DateTime DateTo, string SearchVal = "") + { + List dbResult = new List(); + string cacheKey = $"{rKeyStatslogCall}:{DateFrom:yyyyMMdd}:{DateTo:yyyyMMdd}"; + if(!string.IsNullOrEmpty(SearchVal)) + { + cacheKey += $":{SearchVal}"; + } + trackCache(cacheKey); + string rawData = await getRSV(cacheKey); + if (!string.IsNullOrEmpty(rawData)) + { + dbResult = JsonConvert.DeserializeObject>(rawData); + } + else + { + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + dbResult = dbController.StatsLogCallGetFilt(DateFrom, DateTo, SearchVal); + if (dbResult != null) + { + rawData = JsonConvert.SerializeObject(dbResult); + await setRSV(cacheKey, rawData, shortTTL); + } + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Trace($"Effettuata lettura da DB per StatsLogCallGetFilt: {ts.TotalMilliseconds} ms"); + } + return await Task.FromResult(dbResult); + } + /// /// Effettua refresh del payload della licenza dato info + enigma generato dal client /// @@ -623,6 +661,11 @@ namespace LiMan.APi.Data /// protected const string rKeySampleVars = "LiMan.UI:SampleStats:Vars"; + /// + /// Chiave redis x statistiche chiamate + /// + protected const string rKeyStatslogCall = "LiMan.UI:StatsLogCall"; + /// /// TTL da 1 min x cache Redis /// diff --git a/LiMan.DB/Controllers/DbController.cs b/LiMan.DB/Controllers/DbController.cs index 062a922..17c8d06 100644 --- a/LiMan.DB/Controllers/DbController.cs +++ b/LiMan.DB/Controllers/DbController.cs @@ -2,11 +2,14 @@ using Core.DTO; using LiMan.DB.DBModels; using LiMan.DB.DTO; +using Microsoft.Data.SqlClient; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using NLog; using System; using System.Collections.Generic; +using System.ComponentModel.Design; +using System.Data; using System.IO; using System.Linq; using System.Security.Cryptography; @@ -928,6 +931,32 @@ namespace LiMan.DB.Controllers return answ; } + /// + /// Statistiche del LOGchiamate all'API dato filtro + /// + /// Data minima + /// DataMax + /// Valore cercato, se "" è tutti + /// + public List StatsLogCallGetFilt(DateTime DateFrom, DateTime DateTo, string SearchVal = "") + { + List dbResult = new List(); + using (LMDbContext localDbCtx = new LMDbContext(_configuration)) + { + var dtFrom = new SqlParameter("@DateFrom", DateFrom); + var dtTo = new SqlParameter("@DateTo", DateTo); + var srcVal = new SqlParameter("@SearchVal", SearchVal); + dbResult = localDbCtx + .DbSetStatCall + .FromSqlRaw("exec dbo.stp_StatsCall_filt @DateFrom, @DateTo, @SearchVal", dtFrom, dtTo, srcVal) + .AsNoTracking() + .OrderByDescending(x => x.YearRef) + .ThenByDescending(x => x.TotCall) + .ToList(); + } + return dbResult; + } + public bool TicketAddNew(SupportRequest currRequest) { bool fatto = false; diff --git a/LiMan.DB/LMDbContext.cs b/LiMan.DB/LMDbContext.cs index 38a2cbe..4c44e19 100644 --- a/LiMan.DB/LMDbContext.cs +++ b/LiMan.DB/LMDbContext.cs @@ -76,7 +76,9 @@ namespace LiMan.DB } else { - optionsBuilder.UseSqlServer("Server=SQLSTEAM;Database=LiMan.DB;Trusted_Connection=True;"); + //optionsBuilder.UseSqlServer("Server=SQLSTEAM;Database=LiMan.DB;Trusted_Connection=True;"); + optionsBuilder.UseSqlServer("Server=W2019-SQL-STEAM;Database=LiMan.DB;Trusted_Connection=True;"); + //optionsBuilder.UseSqlServer("Server=W2019-SQL-STEAM;Database=LiMan.DB;User ID=sa;Password=keyhammer16;integrated security=False;MultipleActiveResultSets=True;App=LiMan.UI"); } } } diff --git a/LiMan.DB/LiMan.DB.csproj b/LiMan.DB/LiMan.DB.csproj index 17f0fb7..840e89d 100644 --- a/LiMan.DB/LiMan.DB.csproj +++ b/LiMan.DB/LiMan.DB.csproj @@ -22,4 +22,13 @@ + + + + Always + + + Always + + \ No newline at end of file diff --git a/LiMan.DB/Migrations/20240531171929_AddViewAndStored01.cs b/LiMan.DB/Migrations/20240531171929_AddViewAndStored01.cs index 809d29a..cae7194 100644 --- a/LiMan.DB/Migrations/20240531171929_AddViewAndStored01.cs +++ b/LiMan.DB/Migrations/20240531171929_AddViewAndStored01.cs @@ -26,7 +26,7 @@ namespace LiMan.DB.Migrations private void addView(MigrationBuilder migrationBuilder, string viewName) { - string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "SqlScripts", "View", $"{viewName}.sql"); + string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "SqlScripts", "Views", $"{viewName}.sql"); string viewBody = File.ReadAllText(path); migrationBuilder.Sql(viewBody); } diff --git a/LiMan.DB/SqlScripts/Stored/stp_StatsCall_filt.sql b/LiMan.DB/SqlScripts/Stored/stp_StatsCall_filt.sql index f4a8041..362bb47 100644 --- a/LiMan.DB/SqlScripts/Stored/stp_StatsCall_filt.sql +++ b/LiMan.DB/SqlScripts/Stored/stp_StatsCall_filt.sql @@ -5,6 +5,8 @@ SET QUOTED_IDENTIFIER ON GO +DROP PROCEDURE IF EXISTS dbo.stp_StatsCall_filt; +GO /*-- ============================================= -- Author: S.E.L. @@ -16,8 +18,8 @@ EXEC dbo.stp_StatsCall_filt '2024-01-01', GETDATE(), '' -- =============================================*/ CREATE PROCEDURE [dbo].[stp_StatsCall_filt] ( - @DtFrom INT = 0 - ,@DtTo INT = 0 + @DtFrom DATETIME + ,@DtTo DATETIME ,@SearchVal NVARCHAR(250) ) AS diff --git a/LiMan.DB/SqlScripts/Views/v_StatsCall.sql b/LiMan.DB/SqlScripts/Views/v_StatsCall.sql index 7f2b10e..e25bf85 100644 --- a/LiMan.DB/SqlScripts/Views/v_StatsCall.sql +++ b/LiMan.DB/SqlScripts/Views/v_StatsCall.sql @@ -4,6 +4,9 @@ GO SET QUOTED_IDENTIFIER ON GO +DROP VIEW IF EXISTS dbo.v_StatsCall; +GO + CREATE VIEW [dbo].[v_StatsCall] AS @@ -16,6 +19,5 @@ WITH cteDati AS SELECT * FROM cteDati -ORDER BY YearRef DESC, TotCall DESC GO \ No newline at end of file diff --git a/LiMan.Transfer/Resources/ChangeLog.html b/LiMan.Transfer/Resources/ChangeLog.html index c512968..e55d02b 100644 --- a/LiMan.Transfer/Resources/ChangeLog.html +++ b/LiMan.Transfer/Resources/ChangeLog.html @@ -1,6 +1,6 @@ License Manager -

Versione: 1.1.2405.3119

+

Versione: 1.1.2406.0109


Note di rilascio:
    diff --git a/LiMan.Transfer/Resources/VersNum.txt b/LiMan.Transfer/Resources/VersNum.txt index b8ca2db..86dc20d 100644 --- a/LiMan.Transfer/Resources/VersNum.txt +++ b/LiMan.Transfer/Resources/VersNum.txt @@ -1 +1 @@ -1.1.2405.3119 +1.1.2406.0109 diff --git a/LiMan.Transfer/Resources/manifest.xml b/LiMan.Transfer/Resources/manifest.xml index 8b42a55..d07f3f1 100644 --- a/LiMan.Transfer/Resources/manifest.xml +++ b/LiMan.Transfer/Resources/manifest.xml @@ -1,6 +1,6 @@ - 1.1.2405.3119 + 1.1.2406.0109 https://nexus.steamware.net/repository/SWS/LiMan/stable/LAST/LiMan.Transfer.zip https://nexus.steamware.net/repository/SWS/LiMan/stable/LAST/ChangeLog.html false diff --git a/LiMan.UI/Components/StatsCallList.razor b/LiMan.UI/Components/StatsCallList.razor new file mode 100644 index 0000000..2e4f37c --- /dev/null +++ b/LiMan.UI/Components/StatsCallList.razor @@ -0,0 +1,80 @@ +@using LiMan.UI.Components + +
    +
    +
    +
    +

    Elenco Clienti/Programmi

    +
    +
    + ...filtro periodo + search +
    +
    +
    +
    + @if (ListRecords == null) + { + + } + else if (totalCount == 0) + { +
    Nessun record trovato
    + } + else + { +
    +
    + + + + + + + + + + + + @foreach (var record in ListRecords) + { + + + + + + + + } + +
    AnnoCodiceApp# Call
    + @if (currRecord == null) + { + + } + else + { + + } + + @record.YearRef + + @record.CodInst + + @record.CodApp + +
    @record.TotCall
    +
    +
    +
    + } +
    + +
    + + diff --git a/LiMan.UI/Components/StatsCallList.razor.cs b/LiMan.UI/Components/StatsCallList.razor.cs new file mode 100644 index 0000000..b653cae --- /dev/null +++ b/LiMan.UI/Components/StatsCallList.razor.cs @@ -0,0 +1,149 @@ +using LiMan.DB.DBModels; +using LiMan.UI.Data; +using Microsoft.AspNetCore.Components; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace LiMan.UI.Components +{ + public partial class StatsCallList + { + #region Public Methods + + public string checkSelect(StatsCallModel testRec) + { + string answ = ""; + if (currRecord != null) + { + try + { + answ = (currRecord.CodInst == testRec.CodInst && currRecord.YearRef == testRec.YearRef) ? "table-info" : ""; + } + catch + { } + } + return answ; + } + + #endregion Public Methods + + #region Protected Fields + + protected DateTime dtFrom = DateTime.Today.AddMonths(-12); + protected DateTime dtTo = DateTime.Today.AddDays(1); + protected string searchVal = ""; + protected int totalCount = 0; + + #endregion Protected Fields + + #region Protected Properties + + [Inject] + protected MessageService AppMService { get; set; } + + [Inject] + protected LiManDataService DataService { get; set; } + + #endregion Protected Properties + + #region Protected Methods + + protected override async Task OnInitializedAsync() + { + await ReloadAllData(); + } + + protected async Task PagerReloadNum(int newNum) + { + numRecord = newNum; + await ReloadAllData(); + isLoading = false; + } + + protected async Task PagerReloadPage(int newNum) + { + currPage = newNum; + await ReloadAllData(); + isLoading = false; + } + + protected async Task ResetData() + { + await fullReload(); + } + + protected void Select(StatsCallModel selRecord) + { + currRecord = selRecord; + } + + protected async Task UpdateData() + { + await fullReload(); + } + + #endregion Protected Methods + + #region Private Fields + + private StatsCallModel currRecord = null; + private List ListRecords; + private List SearchRecords; + + #endregion Private Fields + + #region Private Properties + + private int currPage + { + get + { + return AppMService.PageNum; + } + set + { + AppMService.PageNum = value; + } + } + + private bool isLoading { get; set; } = false; + + private int numRecord + { + get + { + return AppMService.PageSize; + } + set + { + AppMService.PageSize = value; + } + } + + #endregion Private Properties + + #region Private Methods + + private async Task fullReload() + { + currRecord = null; + await DataService.InvalidateAllCache(); + await ReloadAllData(); + } + + private async Task ReloadAllData() + { + isLoading = true; + await Task.Delay(1); + //ListRecords = null; + SearchRecords = await DataService.StatsLogCallGetFilt(dtFrom, dtTo, searchVal); + totalCount = SearchRecords.Count(); + ListRecords = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList(); + isLoading = false; + } + + #endregion Private Methods + } +} \ No newline at end of file diff --git a/LiMan.UI/Data/LiManDataService.cs b/LiMan.UI/Data/LiManDataService.cs index 894250a..1894525 100644 --- a/LiMan.UI/Data/LiManDataService.cs +++ b/LiMan.UI/Data/LiManDataService.cs @@ -1,5 +1,6 @@ using Core; using Core.DTO; +using LiMan.DB.Controllers; using LiMan.DB.DBModels; using Microsoft.AspNetCore.Identity.UI.Services; using Microsoft.Extensions.Caching.Distributed; @@ -588,6 +589,44 @@ namespace LiMan.UI.Data return answ; } + + /// + /// Statistiche del LOG chiamate all'API dato filtro + /// + /// Data minima + /// DataMax + /// Valore cercato, se "" è tutti + /// + public async Task> StatsLogCallGetFilt(DateTime DateFrom, DateTime DateTo, string SearchVal = "") + { + List dbResult = new List(); + string cacheKey = mHash($"StatslogCall:{DateFrom:yyyyMMdd}:{DateTo:yyyyMMdd}"); + if (!string.IsNullOrEmpty(SearchVal)) + { + cacheKey += $":{SearchVal}"; + } + string rawData; + var redisDataList = await distributedCache.GetAsync(cacheKey); + if (redisDataList != null) + { + rawData = Encoding.UTF8.GetString(redisDataList); + dbResult = JsonConvert.DeserializeObject>(rawData); + } + else + { + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + dbResult = dbControllerNext.StatsLogCallGetFilt(DateFrom, DateTo, SearchVal); + rawData = JsonConvert.SerializeObject(dbResult); + redisDataList = Encoding.UTF8.GetBytes(rawData); + await distributedCache.SetAsync(cacheKey, redisDataList, cacheOpt(true)); + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Trace($"Effettuata lettura da DB + caching per StatsLogCallGetFilt: {ts.TotalMilliseconds} ms"); + } + return await Task.FromResult(dbResult); + } + /// /// Recupera elenco Tickets filtrato /// diff --git a/LiMan.UI/LiMan.UI.csproj b/LiMan.UI/LiMan.UI.csproj index 0929a6f..f4c2773 100644 --- a/LiMan.UI/LiMan.UI.csproj +++ b/LiMan.UI/LiMan.UI.csproj @@ -2,7 +2,7 @@ net6.0 - 1.1.2405.3119 + 1.1.2406.0109 LiMan.UI LiMan.UI diff --git a/LiMan.UI/Pages/StatsLogCall.razor b/LiMan.UI/Pages/StatsLogCall.razor new file mode 100644 index 0000000..7a44b28 --- /dev/null +++ b/LiMan.UI/Pages/StatsLogCall.razor @@ -0,0 +1,8 @@ +@page "/StatsLogCall" +@attribute [Authorize] + +@using LiMan.UI.Components +@using LiMan.UI.Data +@inject MessageService AppMService + + \ No newline at end of file diff --git a/LiMan.UI/Pages/StatsLogCall.razor.cs b/LiMan.UI/Pages/StatsLogCall.razor.cs new file mode 100644 index 0000000..144e3ba --- /dev/null +++ b/LiMan.UI/Pages/StatsLogCall.razor.cs @@ -0,0 +1,12 @@ +namespace LiMan.UI.Pages +{ + public partial class StatsLogCall + { + protected override void OnInitialized() + { + AppMService.ShowSearch = false; + AppMService.PageName = "Statistiche Log Chiamate"; + AppMService.PageIcon = "fas fa-chart-pie"; + } + } +} \ No newline at end of file diff --git a/LiMan.UI/Resources/ChangeLog.html b/LiMan.UI/Resources/ChangeLog.html index 5ec8e44..0e754f0 100644 --- a/LiMan.UI/Resources/ChangeLog.html +++ b/LiMan.UI/Resources/ChangeLog.html @@ -1,6 +1,6 @@ License Manager -

    Versione: 1.1.2405.3119

    +

    Versione: 1.1.2406.0109


    Note di rilascio:
    • diff --git a/LiMan.UI/Resources/VersNum.txt b/LiMan.UI/Resources/VersNum.txt index b8ca2db..86dc20d 100644 --- a/LiMan.UI/Resources/VersNum.txt +++ b/LiMan.UI/Resources/VersNum.txt @@ -1 +1 @@ -1.1.2405.3119 +1.1.2406.0109 diff --git a/LiMan.UI/Resources/manifest.xml b/LiMan.UI/Resources/manifest.xml index 243b895..4d235b7 100644 --- a/LiMan.UI/Resources/manifest.xml +++ b/LiMan.UI/Resources/manifest.xml @@ -1,6 +1,6 @@ - 1.1.2405.3119 + 1.1.2406.0109 https://nexus.steamware.net/repository/SWS/LiMan/stable/LAST/LiMan.UI.zip https://nexus.steamware.net/repository/SWS/LiMan/stable/LAST/ChangeLog.html false diff --git a/LiMan.UI/Shared/NavMenu.razor b/LiMan.UI/Shared/NavMenu.razor index 506e8dc..fba652b 100644 --- a/LiMan.UI/Shared/NavMenu.razor +++ b/LiMan.UI/Shared/NavMenu.razor @@ -34,6 +34,11 @@
    • +