From 4f62986402630938e8d8ec530a3e05f4c669f717 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Fri, 3 Sep 2021 13:24:02 +0200 Subject: [PATCH] Integrazione dati x archivio file --- MP.FileData/Controllers/FileController.cs | 334 ++++++++++++++++++ MP.FileData/MP.FileData.csproj | 1 - MP.Prog/Components/CmpFooter.razor | 2 +- MP.Prog/Data/AutoCompleteModel.cs | 17 + MP.Prog/Data/FileArchDataService.cs | 408 ++++++++++++++++++++++ MP.Prog/Data/SelectData.cs | 6 + MP.Prog/Data/WeatherForecast.cs | 15 - MP.Prog/Data/WeatherForecastService.cs | 25 -- MP.Prog/Pages/Archive.razor | 190 ++++++++++ MP.Prog/Pages/Archive.razor.cs | 271 ++++++++++++++ MP.Prog/Pages/Counter.razor | 16 - MP.Prog/Pages/FetchData.razor | 46 --- MP.Prog/Pages/Index.razor | 4 +- MP.Prog/Pages/_Host.cshtml | 14 +- MP.Prog/Program.cs | 40 ++- MP.Prog/Shared/NavMenu.razor | 13 +- MP.Prog/Shared/SurveyPrompt.razor | 16 - MP.Prog/Startup.cs | 11 +- MP.Prog/appsettings.Development.json.bak | 10 - MP.Prog/appsettings.json.bak | 10 - MP.Stats/Data/MpStatsService.cs | 12 +- MP.Stats/MP.Stats.csproj | 2 +- MP.Stats/Startup.cs | 4 +- Resources/ChangeLog.html | 2 +- Resources/VersNum.txt | 2 +- Resources/manifest.xml | 2 +- 26 files changed, 1301 insertions(+), 172 deletions(-) create mode 100644 MP.FileData/Controllers/FileController.cs create mode 100644 MP.Prog/Data/AutoCompleteModel.cs create mode 100644 MP.Prog/Data/FileArchDataService.cs delete mode 100644 MP.Prog/Data/WeatherForecast.cs delete mode 100644 MP.Prog/Data/WeatherForecastService.cs create mode 100644 MP.Prog/Pages/Archive.razor create mode 100644 MP.Prog/Pages/Archive.razor.cs delete mode 100644 MP.Prog/Pages/Counter.razor delete mode 100644 MP.Prog/Pages/FetchData.razor delete mode 100644 MP.Prog/Shared/SurveyPrompt.razor delete mode 100644 MP.Prog/appsettings.Development.json.bak delete mode 100644 MP.Prog/appsettings.json.bak diff --git a/MP.FileData/Controllers/FileController.cs b/MP.FileData/Controllers/FileController.cs new file mode 100644 index 00000000..c40c6c55 --- /dev/null +++ b/MP.FileData/Controllers/FileController.cs @@ -0,0 +1,334 @@ +using Microsoft.Extensions.Configuration; +using NLog; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MP.FileData.Controllers +{ + public class FileController : IDisposable + { + #region Private Fields + + private static IConfiguration _configuration; + private static MoonPro_ProgContext dbCtx; + private static NLog.Logger Log = LogManager.GetCurrentClassLogger(); + + #endregion Private Fields + + #region Public Constructors + + public FileController(IConfiguration configuration) + { + _configuration = configuration; + dbCtx = new MoonPro_ProgContext(configuration); + Log.Info("Avviata classe FileController"); + } + + #endregion Public Constructors + +#if false + /// + /// Elenco Azioni (decodifica) + /// + /// + public List ActionsGetAll() + { + List dbResult = new List(); + + dbResult = dbCtx + .DbSetAzioniUL + .ToList(); + + return dbResult; + } + + /// + /// Elenco tabella Articoli da filtro + /// + /// + /// + /// + public List ArticoliGetSearch(int numRecord, string searchVal = "") + { + List dbResult = new List(); + + dbResult = dbCtx + .DbSetArticoli + .Where(x => x.CodArticolo.Contains(searchVal) || x.DescArticolo.Contains(searchVal) || x.Disegno.Contains(searchVal) || string.IsNullOrEmpty(searchVal)) + .OrderBy(x => x.CodArticolo) + .Take(numRecord) + .ToList(); + + return dbResult; + } + + /// + /// Elenco tabella Articoli da filtro + /// + /// + /// + /// + public List CommesseGetSearch(int numRecord, string searchVal = "") + { + List dbResult = new List(); + + dbResult = dbCtx + .DbSetODL + .Where(x => x.KeyRichiesta.Contains(searchVal) || string.IsNullOrEmpty(searchVal)) + .OrderBy(x => x.KeyRichiesta) + .Take(numRecord) + .ToList(); + + return dbResult; + } +#endif + + #region Public Methods + + public void Dispose() + { + // Clear database context + dbCtx.Dispose(); + } + + /// + /// Elenco tabella Macchine + /// + /// + public List MacchineGetAll() + { + List dbResult = new List(); + + dbResult = dbCtx + .DbSetMacchine + .OrderBy(x => x.IdxMacchina) + .ToList(); + + return dbResult; + } + + public void ResetController() + { + dbCtx = new MoonPro_ProgContext(_configuration); + Log.Info("Effettuato reset FileController"); + } + + /// + /// Annulla modifiche su una specifica entity (cancel update) + /// + /// + /// + public bool RollBackEntity(object item) + { + bool answ = false; + try + { + if (dbCtx.Entry(item).State == Microsoft.EntityFrameworkCore.EntityState.Deleted || dbCtx.Entry(item).State == Microsoft.EntityFrameworkCore.EntityState.Modified) + { + dbCtx.Entry(item).Reload(); + } + } + catch (Exception exc) + { + Log.Error($"Eccezione in rollBackEntity{Environment.NewLine}{exc}"); + } + return answ; + } + + #endregion Public Methods + +#if false + /// + /// Elenco tabella controlli da filtro + /// + /// + /// + /// + public List StatControlliGetAll(DateTime DataStart, DateTime DataEnd, string IdxMacchina, int IdxODL, string KeyRichiesta, string CodArticolo) + { + List dbResult = new List(); + + var dataFrom = new SqlParameter("@dataFrom", DataStart); + var dataTo = new SqlParameter("@dataTo", DataEnd); + var idxMacchina = new SqlParameter("@idxMacchina", IdxMacchina); + var idxODL = new SqlParameter("@IdxODL", IdxODL); + var keyRichiesta = new SqlParameter("@KeyRichiesta", KeyRichiesta); + var codArticolo = new SqlParameter("@CodArticolo", CodArticolo); + + dbResult = dbCtx + .DbSetControlli + .FromSqlRaw("EXEC stp_UI_RC_GetByFilter @dataFrom,@dataTo,@idxMacchina,@IdxODL,@KeyRichiesta,@CodArticolo", dataFrom, dataTo, idxMacchina, idxODL, keyRichiesta, codArticolo) + .ToList(); + + return dbResult; + } + + /// + /// Elenco tabella DDB da filtro + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public List StatDdbGetAll(DateTime DataStart, DateTime DataEnd, string IdxMacchina, int IdxODL, string KeyRichiesta, string CodArticolo, int FirstRecord, int NumRecord) + { + List dbResult = new List(); + + var dataFrom = new SqlParameter("@dataFrom", DataStart); + var dataTo = new SqlParameter("@dataTo", DataEnd); + var idxMacchina = new SqlParameter("@idxMacchina", IdxMacchina); + var idxODL = new SqlParameter("@IdxODL", IdxODL); + var keyRichiesta = new SqlParameter("@KeyRichiesta", KeyRichiesta); + var codArticolo = new SqlParameter("@CodArticolo", CodArticolo); + var firstRecord = new SqlParameter("@FirstRecord", FirstRecord); + var numRecord = new SqlParameter("@NumRecord", NumRecord); + + dbResult = dbCtx + .DbSetDdbTurni + .FromSqlRaw("EXEC stp_UI_DDBTurni_GetByFilter @dataFrom,@dataTo,@idxMacchina,@IdxODL,@KeyRichiesta,@CodArticolo,@FirstRecord,@NumRecord", dataFrom, dataTo, idxMacchina, idxODL, keyRichiesta, codArticolo, firstRecord, numRecord) + .ToList(); + + return dbResult; + } + + /// + /// Elenco tabella DDB da filtro + /// + /// + /// + /// + /// + /// + /// + /// + public int StatDdbGetCount(DateTime DataStart, DateTime DataEnd, string IdxMacchina, int IdxODL, string KeyRichiesta, string CodArticolo) + { + var dbResult = dbCtx + .DbSetDdbTurni + .Where(x => (x.IdxMacchina == IdxMacchina || IdxMacchina == "*") && (x.IdxOdl == IdxODL || IdxODL == -999) && (x.KeyRichiesta == KeyRichiesta || KeyRichiesta == "*") && (x.CodArticolo == CodArticolo || CodArticolo == "*") && (x.InizioPeriodo >= DataStart && x.InizioPeriodo <= DataEnd)) + .Count(); + + return dbResult; + } + + /// + /// Elenco tabella ODL da filtro + /// + /// + /// + /// + public List StatOdlGetAll(DateTime DataStart, DateTime DataEnd, string IdxMacchina, int IdxODL, string KeyRichiesta, string CodArticolo) + { + List dbResult = new List(); + + var dataFrom = new SqlParameter("@dataFrom", DataStart); + var dataTo = new SqlParameter("@dataTo", DataEnd); + var idxMacchina = new SqlParameter("@idxMacchina", IdxMacchina); + var idxODL = new SqlParameter("@IdxODL", IdxODL); + var keyRichiesta = new SqlParameter("@KeyRichiesta", KeyRichiesta); + var codArticolo = new SqlParameter("@CodArticolo", CodArticolo); + + dbResult = dbCtx + .DbSetODL + .FromSqlRaw("EXEC stp_UI_Odl_GetByFilter @dataFrom,@dataTo,@idxMacchina,@IdxODL,@KeyRichiesta,@CodArticolo", dataFrom, dataTo, idxMacchina, idxODL, keyRichiesta, codArticolo) + .ToList(); + + return dbResult; + } + + /// + /// Elenco tabella scarti da filtro + /// + /// + /// + /// + /// + /// + public List StatScartiGetAll(DateTime DataStart, DateTime DataEnd, string IdxMacchina, int IdxODL, string KeyRichiesta, string CodArticolo) + { + List dbResult = new List(); + + var dataFrom = new SqlParameter("@dataFrom", DataStart); + var dataTo = new SqlParameter("@dataTo", DataEnd); + var idxMacchina = new SqlParameter("@idxMacchina", IdxMacchina); + var idxODL = new SqlParameter("@IdxODL", IdxODL); + var keyRichiesta = new SqlParameter("@KeyRichiesta", KeyRichiesta); + var codArticolo = new SqlParameter("@CodArticolo", CodArticolo); + + dbResult = dbCtx + .DbSetScarti + .FromSqlRaw("EXEC stp_UI_RS_GetByFilter @dataFrom,@dataTo,@idxMacchina,@IdxODL,@KeyRichiesta,@CodArticolo", dataFrom, dataTo, idxMacchina, idxODL, keyRichiesta, codArticolo) + .ToList(); + + return dbResult; + } + + /// + /// Elenco tabella TurniOee da filtro + /// + /// + /// + /// + /// + /// + public List StatTurniOeeGetAll(DateTime DataStart, DateTime DataEnd, string IdxMacchina, int IdxODL, string KeyRichiesta, string CodArticolo) + { + List dbResult = new List(); + + var dataFrom = new SqlParameter("@dataFrom", DataStart); + var dataTo = new SqlParameter("@dataTo", DataEnd); + var idxMacchina = new SqlParameter("@idxMacchina", IdxMacchina); + var idxODL = new SqlParameter("@IdxODL", IdxODL); + var keyRichiesta = new SqlParameter("@KeyRichiesta", KeyRichiesta); + var codArticolo = new SqlParameter("@CodArticolo", CodArticolo); + + dbResult = dbCtx + .DbSetTurniOee + .FromSqlRaw("EXEC stp_UI_TurniOee_GetByFilter @dataFrom,@dataTo,@idxMacchina,@IdxODL,@KeyRichiesta,@CodArticolo", dataFrom, dataTo, idxMacchina, idxODL, keyRichiesta, codArticolo) + .ToList(); + + return dbResult; + } + + /// + /// Elenco tabella UserLog da filtro + /// + /// + /// + /// + public List StatUserLogGetAll(DateTime DataStart, DateTime DataEnd, string IdxMacchina, int IdxODL, string KeyRichiesta, string CodArticolo) + { + List dbResult = new List(); + + //dbResult = dbCtx + // .DbSetUserLog + // .Where(x => x.Valore.Contains(searchVal) || x.Cognome.Contains(searchVal) || x.CodArticolo.Contains(searchVal) || string.IsNullOrEmpty(searchVal)) + // .OrderByDescending(x => x.DataOraRif) + // .Take(numRecord) + // .ToList(); + + var dataFrom = new SqlParameter("@dataFrom", DataStart); + var dataTo = new SqlParameter("@dataTo", DataEnd); + var idxMacchina = new SqlParameter("@idxMacchina", IdxMacchina); + var idxODL = new SqlParameter("@IdxODL", IdxODL); + var keyRichiesta = new SqlParameter("@KeyRichiesta", KeyRichiesta); + var codArticolo = new SqlParameter("@CodArticolo", CodArticolo); + + dbResult = dbCtx + .DbSetUserLog + .FromSqlRaw("EXEC stp_UI_UL_GetByFilter @dataFrom,@dataTo,@idxMacchina,@IdxODL,@KeyRichiesta,@CodArticolo", dataFrom, dataTo, idxMacchina, idxODL, keyRichiesta, codArticolo) + .ToList(); + + return dbResult; + } +#endif + } +} \ No newline at end of file diff --git a/MP.FileData/MP.FileData.csproj b/MP.FileData/MP.FileData.csproj index c6cd20ce..fd3be750 100644 --- a/MP.FileData/MP.FileData.csproj +++ b/MP.FileData/MP.FileData.csproj @@ -21,7 +21,6 @@ - diff --git a/MP.Prog/Components/CmpFooter.razor b/MP.Prog/Components/CmpFooter.razor index e85aaf30..23e14731 100644 --- a/MP.Prog/Components/CmpFooter.razor +++ b/MP.Prog/Components/CmpFooter.razor @@ -1,6 +1,6 @@ 
- GWMS v.@version + MP.Prog v.@version
@adesso diff --git a/MP.Prog/Data/AutoCompleteModel.cs b/MP.Prog/Data/AutoCompleteModel.cs new file mode 100644 index 00000000..02fbabcc --- /dev/null +++ b/MP.Prog/Data/AutoCompleteModel.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace MP.Prog.Data +{ + public class AutocompleteModel + { + #region Public Properties + + public string LabelField { get; set; } + public string ValueField { get; set; } + + #endregion Public Properties + } +} \ No newline at end of file diff --git a/MP.Prog/Data/FileArchDataService.cs b/MP.Prog/Data/FileArchDataService.cs new file mode 100644 index 00000000..14a13a91 --- /dev/null +++ b/MP.Prog/Data/FileArchDataService.cs @@ -0,0 +1,408 @@ +using Microsoft.Extensions.Caching.Distributed; +using Microsoft.Extensions.Caching.Memory; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Logging; +using NLog; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MP.Prog.Data +{ + public class FileArchDataService : IDisposable + { + #region Private Fields + + private static IConfiguration _configuration; + + private static ILogger _logger; + + private static List ElencoMacchine = new List(); + + private static NLog.Logger Log = LogManager.GetCurrentClassLogger(); + + private readonly IDistributedCache distributedCache; + + private readonly IMemoryCache memoryCache; + + /// + /// Durata assoluta massima della cache + /// + private int chAbsExp = 15; + + /// + /// Durata della cache in modalità inattiva (non acceduta) prima di venire rimossa + /// NON estende oltre il tempo massimo di validità della cache (chAbsExp) + /// + private int chSliExp = 5; + + #endregion Private Fields + + #region Protected Fields + + protected static string connStringBBM = ""; + + protected static string connStringFatt = ""; + + #endregion Protected Fields + + #region Public Fields + + public static MP.FileData.Controllers.FileController dbController; + + #endregion Public Fields + + #region Public Constructors + + public FileArchDataService(IConfiguration configuration, ILogger logger, IMemoryCache memoryCache, IDistributedCache distributedCache) + { + _logger = logger; + _configuration = configuration; + // conf cache + this.memoryCache = memoryCache; + this.distributedCache = distributedCache; + // conf DB + string connStr = _configuration.GetConnectionString("Mp.Prog"); + if (string.IsNullOrEmpty(connStr)) + { + _logger.LogError("ConnString empty!"); + } + else + { + dbController = new MP.FileData.Controllers.FileController(configuration); + StringBuilder sb = new StringBuilder(); + sb.AppendLine($"DbController OK"); + _logger.LogInformation(sb.ToString()); + } + } + + #endregion Public Constructors + + #region Private Properties + + private DistributedCacheEntryOptions cacheOpt + { + get + { + return new DistributedCacheEntryOptions().SetAbsoluteExpiration(DateTime.Now.AddMinutes(chAbsExp)).SetSlidingExpiration(TimeSpan.FromMinutes(chSliExp)); + } + } + + private DistributedCacheEntryOptions cacheOptLong + { + get + { + return new DistributedCacheEntryOptions().SetAbsoluteExpiration(DateTime.Now.AddMinutes(chAbsExp * 10)).SetSlidingExpiration(TimeSpan.FromMinutes(chSliExp)); + } + } + + #endregion Private Properties + + #region Internal Methods + + internal void ResetController() + { + dbController.ResetController(); + } + + #endregion Internal Methods + +#if false + protected string getCacheKey(string TableName, SelectData CurrFilter) + { + string answ = $"{TableName}:M_{CurrFilter.IdxMacchina}:A_{CurrFilter.CodArticolo}:K_{CurrFilter.KeyRichiesta}:O_{CurrFilter.IdxOdl}:D_{CurrFilter.DateStart:yyyyMMddHHmm}_{CurrFilter.DateEnd:yyyyMMddHHmm}"; + return answ; + } + + protected string getCacheKeyPaged(string TableName, SelectData CurrFilter) + { + string answ = $"{TableName}:M_{CurrFilter.IdxMacchina}:A_{CurrFilter.CodArticolo}:K_{CurrFilter.KeyRichiesta}:O_{CurrFilter.IdxOdl}:D_{CurrFilter.DateStart:yyMMddHHmm}_{CurrFilter.DateEnd:yyMMddHHmm}:R_{CurrFilter.FirstRecord}_{CurrFilter.FirstRecord + CurrFilter.NumRecord}"; + return answ; + } +#endif + +#if false + public async Task> ActionsGetAll() + { + //return Task.FromResult(dbController.ActionsGetAll()); + List dbResult = new List(); + string cacheKey = "MP:STATS:AZIONI_ALL"; + 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 = dbController.ActionsGetAll(); + rawData = JsonConvert.SerializeObject(dbResult); + redisDataList = Encoding.UTF8.GetBytes(rawData); + await distributedCache.SetAsync(cacheKey, redisDataList, cacheOpt); + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Info($"Effettuata lettura da DB + caching per AzioniUL: {ts.TotalMilliseconds} ms"); + } + return await Task.FromResult(dbResult); + } + + public Task> ArticoliGetSearch(int numRecord, string searchVal = "") + { + List answ = new List(); + answ.Add(new AutocompleteModel { LabelField = "--- TUTTE ---", ValueField = "*" }); + if (numRecord > -1) + { + answ.AddRange(dbController.ArticoliGetSearch(numRecord, searchVal).Select(x => new AutocompleteModel { LabelField = $"{x.CodArticolo} {x.DescArticolo} {x.Disegno}", ValueField = x.CodArticolo }).ToList()); + } + return Task.FromResult(answ); + } + + public async Task> ArticoliList(string searchVal) + { + List answ = new List(); + answ.Add(new AutocompleteModel { LabelField = "--- TUTTE ---", ValueField = "*" }); + var listMacchine = dbController.MacchineGetAll(); + answ.AddRange(listMacchine.Select(x => new AutocompleteModel { LabelField = x.IdxMacchina, ValueField = x.IdxMacchina }).ToList()); + return await Task.FromResult(answ); + } + + public Task> CommesseGetSearch(int numRecord, string searchVal = "") + { + List answ = new List(); + answ.Add(new AutocompleteModel { LabelField = "--- TUTTE ---", ValueField = "*" }); + if (numRecord > -1) + { + answ.AddRange(dbController.CommesseGetSearch(numRecord, searchVal).GroupBy(x => x.KeyRichiesta).Select(x => new AutocompleteModel { LabelField = $"{x.First().CodArticolo} | {x.First().KeyRichiesta}", ValueField = x.First().KeyRichiesta }).ToList()); + } + return Task.FromResult(answ); + } +#endif + + #region Public Methods + + public void Dispose() + { + // Clear database controller + dbController.Dispose(); + } + + public Task> MacchineGetAll() + { + return Task.FromResult(dbController.MacchineGetAll().ToList()); + } + + public Task> MachineList() + { + List answ = new List(); + answ.Add(new AutocompleteModel { LabelField = "--- TUTTE ---", ValueField = "*" }); + answ.AddRange(dbController.MacchineGetAll().Select(x => new AutocompleteModel { LabelField = $"{x.IdxMacchina} | {x.Nome} {x.Descrizione} ", ValueField = x.IdxMacchina }).ToList()); + return Task.FromResult(answ); + } + + public void rollBackEdit(object item) + { + dbController.RollBackEntity(item); + } + + #endregion Public Methods + +#if false + public async Task> StatControlliGetAll(SelectData CurrFilter, string searchVal = "") + { + //return Task.FromResult(dbController.StatControlliGetAll(DataStart, DataEnd, IdxMacchina, IdxODL, KeyRichiesta, CodArticolo).ToArray()); + List dbResult = new List(); + string cacheKey = getCacheKey("MP:STATS:CONTROLLI", CurrFilter); + 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 = dbController.StatControlliGetAll(CurrFilter.DateStart, CurrFilter.DateEnd, CurrFilter.IdxMacchina, CurrFilter.IdxOdl, CurrFilter.KeyRichiesta, CurrFilter.CodArticolo); + rawData = JsonConvert.SerializeObject(dbResult); + redisDataList = Encoding.UTF8.GetBytes(rawData); + await distributedCache.SetAsync(cacheKey, redisDataList, cacheOpt); + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Info($"Effettuata lettura da DB + caching per ResControlli: {ts.TotalMilliseconds} ms"); + } + return await Task.FromResult(dbResult); + } + + public async Task> StatDdbGetAll(SelectData CurrFilter, string searchVal = "") + { + //return Task.FromResult(dbController.StatDdbGetAll(numRecord, searchVal).ToArray()); + List dbResult = new List(); + string cacheKey = getCacheKeyPaged("MP:STATS:DDBT", CurrFilter); + 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 = dbController.StatDdbGetAll(CurrFilter.DateStart, CurrFilter.DateEnd, CurrFilter.IdxMacchina, CurrFilter.IdxOdl, CurrFilter.KeyRichiesta, CurrFilter.CodArticolo, CurrFilter.FirstRecord, CurrFilter.NumRecord); + rawData = JsonConvert.SerializeObject(dbResult); + redisDataList = Encoding.UTF8.GetBytes(rawData); + await distributedCache.SetAsync(cacheKey, redisDataList, cacheOpt); + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Info($"Effettuata lettura da DB + caching per DdbTurni: {ts.TotalMilliseconds} ms"); + } + return await Task.FromResult(dbResult); + } + + public async Task StatDdbGetCount(SelectData CurrFilter, string searchVal = "") + { + int numRec = 0; + string cacheKey = getCacheKey("MP:STATS:DDBT-COUNT", CurrFilter); + string rawData; + var redisDataList = await distributedCache.GetAsync(cacheKey); + if (redisDataList != null) + { + rawData = Encoding.UTF8.GetString(redisDataList); + int.TryParse(rawData, out numRec); + } + else + { + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + numRec = dbController.StatDdbGetCount(CurrFilter.DateStart, CurrFilter.DateEnd, CurrFilter.IdxMacchina, CurrFilter.IdxOdl, CurrFilter.KeyRichiesta, CurrFilter.CodArticolo); + rawData = $"{numRec}"; + redisDataList = Encoding.UTF8.GetBytes(rawData); + await distributedCache.SetAsync(cacheKey, redisDataList, cacheOptLong); + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Info($"Effettuata lettura da DB + caching per DdbTurni: {ts.TotalMilliseconds} ms"); + } + return await Task.FromResult(numRec); + } + + public async Task> StatOdlGetAll(SelectData CurrFilter, string searchVal = "") + { + //return Task.FromResult(dbController.StatOdlGetAll(numRecord, searchVal)); + List dbResult = new List(); + string cacheKey = getCacheKey("MP:STATS:ODL", CurrFilter); + 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 = dbController.StatOdlGetAll(CurrFilter.DateStart, CurrFilter.DateEnd, CurrFilter.IdxMacchina, CurrFilter.IdxOdl, CurrFilter.KeyRichiesta, CurrFilter.CodArticolo); + rawData = JsonConvert.SerializeObject(dbResult); + redisDataList = Encoding.UTF8.GetBytes(rawData); + await distributedCache.SetAsync(cacheKey, redisDataList, cacheOpt); + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Info($"Effettuata lettura da DB + caching per ODL: {ts.TotalMilliseconds} ms"); + } + return await Task.FromResult(dbResult); + } + + public async Task> StatScartiGetAll(SelectData CurrFilter, string searchVal = "") + { + //return Task.FromResult(dbController.StatScartiGetAll(DataStart, DataEnd, IdxMacchina, IdxODL, KeyRichiesta, CodArticolo).ToArray()); + List dbResult = new List(); + string cacheKey = getCacheKey("MP:STATS:SCARTI:RAW", CurrFilter); + 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 = dbController.StatScartiGetAll(CurrFilter.DateStart, CurrFilter.DateEnd, CurrFilter.IdxMacchina, CurrFilter.IdxOdl, CurrFilter.KeyRichiesta, CurrFilter.CodArticolo); + rawData = JsonConvert.SerializeObject(dbResult); + redisDataList = Encoding.UTF8.GetBytes(rawData); + await distributedCache.SetAsync(cacheKey, redisDataList, cacheOpt); + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Info($"Effettuata lettura da DB + caching per ResScarti: {ts.TotalMilliseconds} ms"); + } + return await Task.FromResult(dbResult); + } + + public async Task> StatTurniOeeGetAllAsync(DateTime DataStart, DateTime DataEnd, string IdxMacchina, int IdxODL, string KeyRichiesta, string CodArticolo, string searchVal = "") + { + return await Task.FromResult(dbController.StatTurniOeeGetAll(DataStart, DataEnd, IdxMacchina, IdxODL, KeyRichiesta, CodArticolo)); + } + + public async Task> StatTurniOeeGetAllCached(SelectData CurrFilter, string searchVal = "") + { + List dbResult = new List(); + string cacheKey = getCacheKey("MP:STATS:OEE", CurrFilter); + 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 = dbController.StatTurniOeeGetAll(CurrFilter.DateStart, CurrFilter.DateEnd, CurrFilter.IdxMacchina, CurrFilter.IdxOdl, CurrFilter.KeyRichiesta, CurrFilter.CodArticolo); + rawData = JsonConvert.SerializeObject(dbResult); + redisDataList = Encoding.UTF8.GetBytes(rawData); + await distributedCache.SetAsync(cacheKey, redisDataList, cacheOpt); + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Info($"Effettuata lettura da DB + caching per TurniOee: {ts.TotalMilliseconds} ms"); + } + return await Task.FromResult(dbResult); + } + + public async Task> StatUserLogGetAll(SelectData CurrFilter, string searchVal = "") + { + //return Task.FromResult(dbController.StatUserLogGetAll(DataStart, DataEnd, IdxMacchina, IdxODL, KeyRichiesta, CodArticolo).ToArray()); + List dbResult = new List(); + string cacheKey = getCacheKey("MP:STATS:USRACTLOG", CurrFilter); + 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 = dbController.StatUserLogGetAll(CurrFilter.DateStart, CurrFilter.DateEnd, CurrFilter.IdxMacchina, CurrFilter.IdxOdl, CurrFilter.KeyRichiesta, CurrFilter.CodArticolo); + rawData = JsonConvert.SerializeObject(dbResult); + redisDataList = Encoding.UTF8.GetBytes(rawData); + await distributedCache.SetAsync(cacheKey, redisDataList, cacheOpt); + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Info($"Effettuata lettura da DB + caching per UserActionLog: {ts.TotalMilliseconds} ms"); + } + return await Task.FromResult(dbResult); + } +#endif + } +} \ No newline at end of file diff --git a/MP.Prog/Data/SelectData.cs b/MP.Prog/Data/SelectData.cs index 2d176677..187318e8 100644 --- a/MP.Prog/Data/SelectData.cs +++ b/MP.Prog/Data/SelectData.cs @@ -9,8 +9,10 @@ namespace MP.Prog.Data { #region Public Properties + public string CodArticolo { get; set; } = ""; public DateTime DateEnd { get; set; } = DateTime.Now.AddMinutes(1); public DateTime DateStart { get; set; } = DateTime.Now.AddDays(-7); + public string IdxMacchina { get; set; } = ""; #endregion Public Properties @@ -40,6 +42,10 @@ namespace MP.Prog.Data if (!(obj is SelectData item)) return false; + if (CodArticolo != item.CodArticolo) + return false; + if (IdxMacchina != item.IdxMacchina) + return false; if (DateEnd != item.DateEnd) return false; if (DateStart != item.DateStart) diff --git a/MP.Prog/Data/WeatherForecast.cs b/MP.Prog/Data/WeatherForecast.cs deleted file mode 100644 index 821c7654..00000000 --- a/MP.Prog/Data/WeatherForecast.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; - -namespace MP.Prog.Data -{ - public class WeatherForecast - { - public DateTime Date { get; set; } - - public int TemperatureC { get; set; } - - public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); - - public string Summary { get; set; } - } -} diff --git a/MP.Prog/Data/WeatherForecastService.cs b/MP.Prog/Data/WeatherForecastService.cs deleted file mode 100644 index f5fb02de..00000000 --- a/MP.Prog/Data/WeatherForecastService.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System; -using System.Linq; -using System.Threading.Tasks; - -namespace MP.Prog.Data -{ - public class WeatherForecastService - { - private static readonly string[] Summaries = new[] - { - "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" - }; - - public Task GetForecastAsync(DateTime startDate) - { - var rng = new Random(); - return Task.FromResult(Enumerable.Range(1, 5).Select(index => new WeatherForecast - { - Date = startDate.AddDays(index), - TemperatureC = rng.Next(-20, 55), - Summary = Summaries[rng.Next(Summaries.Length)] - }).ToArray()); - } - } -} diff --git a/MP.Prog/Pages/Archive.razor b/MP.Prog/Pages/Archive.razor new file mode 100644 index 00000000..0d2984cb --- /dev/null +++ b/MP.Prog/Pages/Archive.razor @@ -0,0 +1,190 @@ +@page "/Archive" + +
+
+
+
+ Elenco Ordini +
+
+
+
+
+ +
+
+
+
+
+
+
+ + +
+
+
+
+ @if (ShowAddNew) + { + + } +
+
+
+
+
+
+
+
+ inizio: +
+ +
+
+
+
+
+ fine: +
+ +
+
+
+
+
+
+
+
+
+ + + +
+ +
+
+
+
+
+ + + +
+ +
+
+
+
+
+
+
+ @if (currRecord != null) + { + + } + @if (ListRecords == null) + { + + } + else if (totalCount == 0) + { +
Nessun record trovato
+ } + else + { +
+
+ + + + + + + + + + + + + + + @foreach (var record in ListRecords) + { + + + + + + + + + + + } + +
ImpiantoData OrdineOrdineFornitoreRichiestaCaricoEffettivo
+ @if (currRecord == null) + { + + } + else + { + + } + +
@record.Plant.PlantCode
+
@record.Plant.PlantDesc
+
+
@record.DtOrder.ToString("yyyy.MM.dd")
+
@record.DtOrder.ToString("ddd HH:mm.ss")
+
@record.OrderCode | @record.OrderDesc +
+ @record.Supplier.SupplierDesc +
+
@record.Transporter.TransporterDesc
+
+ @record.OrderQty.ToString("N0") + + @if (!record.DtExecStart.Equals(@record.DtExecEnd)) + { +
+ @record.DtExecStart.Date.ToString("ddd dd/MM/yyyyy") +
+
@record.DtExecStart.ToString("HH:mm:ss") --> @record.DtExecEnd.ToString("HH:mm:ss")
+ } +
+ @if (record.ExecutionQty > 0) + { + @record.ExecutionQty.ToString("N0") + } +
+
+
+ } +
+ +
\ No newline at end of file diff --git a/MP.Prog/Pages/Archive.razor.cs b/MP.Prog/Pages/Archive.razor.cs new file mode 100644 index 00000000..77bab15a --- /dev/null +++ b/MP.Prog/Pages/Archive.razor.cs @@ -0,0 +1,271 @@ +using Microsoft.AspNetCore.Components; +using Microsoft.JSInterop; +using MP.FileData.DatabaseModels; +using MP.Prog.Data; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace MP.Prog.Pages +{ + public partial class Archive : ComponentBase, IDisposable + { + #region Private Fields + + private List ArtList; + private FileModel currRecord = null; + private List ListRecords; + private List MacList; + private List SearchRecords; + + #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 numRecord + { + get => _numRecord; + set + { + if (_numRecord != value) + { + _numRecord = value; + var pUpd = Task.Run(async () => await ReloadData()); + pUpd.Wait(); + } + } + } + + private string SelCodArt + { + get + { + string answ = ""; + if (AppMService.File_Filter != null) + { + answ = AppMService.File_Filter.CodArticolo; + } + return answ; + } + set + { + if (!AppMService.File_Filter.CodArticolo.Equals(value)) + { + AppMService.File_Filter.CodArticolo = value; + var pUpd = Task.Run(async () => await ReloadData()); + pUpd.Wait(); + } + } + } + + private string SelIdxMacc + { + get + { + string answ = ""; + if (AppMService.File_Filter != null) + { + answ = AppMService.File_Filter.IdxMacchina; + } + return answ; + } + set + { + if (!AppMService.File_Filter.IdxMacchina.Equals(value)) + { + AppMService.File_Filter.IdxMacchina = value; + var pUpd = Task.Run(async () => await ReloadData()); + pUpd.Wait(); + } + } + } + + #endregion Private Properties + + #region Protected Properties + + [Inject] + protected MessageService AppMService { get; set; } + + [Inject] + protected FileArchDataService DataService { get; set; } + + [Inject] + protected IJSRuntime JSRuntime { get; set; } + + [Inject] + protected NavigationManager NavManager { get; set; } + + 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; +#if false + SearchRecords = await DataService.OrdersGetFilt(AppMService.Order_Filter); + ListRecords = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList(); +#endif + isLoading = false; + } + + #endregion Private Methods + + #region Protected Methods + + protected void Edit(FileModel selRecord) + { +#if false + // rileggo dal DB il record corrente... + var pUpd = Task.Run(async () => currRecord = await DataService.OrderGetByCode(selRecord.OrderCode)); + pUpd.Wait(); +#endif + } + + protected void ForceReload(int newNum) + { + numRecord = newNum; + } + + protected void ForceReloadPage(int newNum) + { + currPage = newNum; + } + + protected override async Task OnInitializedAsync() + { + DataService.ResetController(); + AppMService.ShowSearch = false; + AppMService.PageName = "Archivio File Programmi"; + AppMService.PageIcon = "fas fa-folder pr-2"; + AppMService.EA_SearchUpdated += OnSeachUpdated; + await ReloadAllData(); + } + + protected async Task ReloadAllData() + { + isLoading = true; +#if false + SuppliersList = await DataService.SuppliersGetAll(); + SelIdxMacc = 0; + PlantsList = null; + await GetClaimsData(); + // se ho un plantId valido --> altrimenti non abilitato + if (ClaimPlantId == 0) + { + PlantsList = await DataService.PlantsGetAll(); + } + else if (ClaimPlantId > 0) + { + var rawData = await DataService.PlantsGetAll(); + PlantsList = rawData.Where(x => x.PlantId == ClaimPlantId).ToList(); + SelIdxMacc = ClaimPlantId; + } + else + { + PlantsList = new List(); + } +#endif + isLoading = false; + await ReloadData(); + } + + protected void ResetData() + { + DataService.rollBackEdit(currRecord); + currRecord = null; + } + + protected async Task ResetFilter() + { + currRecord = null; + SearchRecords = null; + ListRecords = null; + AppMService.File_Filter = SelectData.Init(5, 10); + await ReloadAllData(); + } + + protected void Select(FileModel selRecord) + { + // applico filtro da selezione + currRecord = selRecord; + } + + protected async Task UpdateData() + { + currRecord = null; + DataService.ResetController(); + await ReloadData(); + } + + #endregion Protected Methods + + #region Public Methods + + public string checkSelect(int FileId) + { + string answ = ""; + if (currRecord != null) + { + try + { + answ = (currRecord.FileId == FileId) ? "table-info" : ""; + } + catch + { } + } + return answ; + } + + public void Dispose() + { + AppMService.EA_SearchUpdated -= OnSeachUpdated; + } + + public async void OnSeachUpdated() + { + await InvokeAsync(() => + { + Task task = UpdateData(); + StateHasChanged(); + }); + } + + #endregion Public Methods + } +} \ No newline at end of file diff --git a/MP.Prog/Pages/Counter.razor b/MP.Prog/Pages/Counter.razor deleted file mode 100644 index 8641f781..00000000 --- a/MP.Prog/Pages/Counter.razor +++ /dev/null @@ -1,16 +0,0 @@ -@page "/counter" - -

Counter

- -

Current count: @currentCount

- - - -@code { - private int currentCount = 0; - - private void IncrementCount() - { - currentCount++; - } -} diff --git a/MP.Prog/Pages/FetchData.razor b/MP.Prog/Pages/FetchData.razor deleted file mode 100644 index 9986a63b..00000000 --- a/MP.Prog/Pages/FetchData.razor +++ /dev/null @@ -1,46 +0,0 @@ -@page "/fetchdata" - -@using MP.Prog.Data -@inject WeatherForecastService ForecastService - -

Weather forecast

- -

This component demonstrates fetching data from a service.

- -@if (forecasts == null) -{ -

Loading...

-} -else -{ - - - - - - - - - - - @foreach (var forecast in forecasts) - { - - - - - - - } - -
DateTemp. (C)Temp. (F)Summary
@forecast.Date.ToShortDateString()@forecast.TemperatureC@forecast.TemperatureF@forecast.Summary
-} - -@code { - private WeatherForecast[] forecasts; - - protected override async Task OnInitializedAsync() - { - forecasts = await ForecastService.GetForecastAsync(DateTime.Now); - } -} diff --git a/MP.Prog/Pages/Index.razor b/MP.Prog/Pages/Index.razor index e54d9143..73d0d8b8 100644 --- a/MP.Prog/Pages/Index.razor +++ b/MP.Prog/Pages/Index.razor @@ -2,6 +2,4 @@

Hello, world!

-Welcome to your new app. - - +Welcome to your new app. \ No newline at end of file diff --git a/MP.Prog/Pages/_Host.cshtml b/MP.Prog/Pages/_Host.cshtml index c9343e10..3e9c92a6 100644 --- a/MP.Prog/Pages/_Host.cshtml +++ b/MP.Prog/Pages/_Host.cshtml @@ -1,4 +1,6 @@ @page "/" +@using System.Globalization +@using Microsoft.AspNetCore.Localization @namespace MP.Prog.Pages @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers @{ @@ -9,10 +11,14 @@ - + + + MP.Prog + + @@ -30,6 +36,12 @@ 🗙
+ + + + + + diff --git a/MP.Prog/Program.cs b/MP.Prog/Program.cs index 1c36f1d7..514283f1 100644 --- a/MP.Prog/Program.cs +++ b/MP.Prog/Program.cs @@ -2,6 +2,7 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; +using NLog.Web; using System; using System.Collections.Generic; using System.Linq; @@ -11,16 +12,43 @@ namespace MP.Prog { public class Program { - public static void Main(string[] args) - { - CreateHostBuilder(args).Build().Run(); - } + #region Public Methods public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args) .ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup(); - }); + }) + .ConfigureLogging(logging => + { + logging.ClearProviders(); + logging.SetMinimumLevel(Microsoft.Extensions.Logging.LogLevel.Trace); + }) + .UseNLog(); + + public static void Main(string[] args) + { + // inclusione NLog: + // https://github.com/NLog/NLog/wiki/Getting-started-with-ASP.NET-Core-5 + // https://codewithmukesh.com/blog/logging-with-nlog-in-aspnet-core/ + var logger = NLog.Web.NLogBuilder.ConfigureNLog("NLog.config").GetCurrentClassLogger(); + try + { + logger.Info("MP.Prog Application Starting Up"); + CreateHostBuilder(args).Build().Run(); + } + catch (Exception exception) + { + logger.Error(exception, "Stopped MP.Prog program because of exception"); + throw; + } + finally + { + NLog.LogManager.Shutdown(); + } + } + + #endregion Public Methods } -} +} \ No newline at end of file diff --git a/MP.Prog/Shared/NavMenu.razor b/MP.Prog/Shared/NavMenu.razor index 83a982d7..344b1697 100644 --- a/MP.Prog/Shared/NavMenu.razor +++ b/MP.Prog/Shared/NavMenu.razor @@ -9,17 +9,12 @@ @@ -34,4 +29,4 @@ { collapseNavMenu = !collapseNavMenu; } -} +} \ No newline at end of file diff --git a/MP.Prog/Shared/SurveyPrompt.razor b/MP.Prog/Shared/SurveyPrompt.razor deleted file mode 100644 index 66edfb87..00000000 --- a/MP.Prog/Shared/SurveyPrompt.razor +++ /dev/null @@ -1,16 +0,0 @@ - - -@code { - // Demonstrates how a parent component can supply parameters - [Parameter] - public string Title { get; set; } -} diff --git a/MP.Prog/Startup.cs b/MP.Prog/Startup.cs index d8f24e2e..9a2f02f1 100644 --- a/MP.Prog/Startup.cs +++ b/MP.Prog/Startup.cs @@ -207,15 +207,14 @@ namespace MP.Prog services.AddStackExchangeRedisCache(options => { //options.Configuration = "localhost:6379"; - options.ConfigurationOptions = new StackExchange.Redis.ConfigurationOptions() { KeepAlive = 180, DefaultDatabase = 12, EndPoints = { { "localhost", 6379 } } }; - options.InstanceName = "GWMS:"; + options.ConfigurationOptions = new StackExchange.Redis.ConfigurationOptions() { KeepAlive = 180, DefaultDatabase = 5, EndPoints = { { "localhost", 6379 } } }; + options.InstanceName = "MP:Prog"; }); services.AddLocalization(); services.AddRazorPages(); services.AddServerSideBlazor(); - services.AddSingleton(); #if false services.AddScoped>(); @@ -224,10 +223,8 @@ namespace MP.Prog services.AddSingleton(Configuration); //services.AddTransient(); -#if false - //services.AddSingleton(); - services.AddScoped(); -#endif + //services.AddSingleton(); + services.AddScoped(); services.AddScoped(); } diff --git a/MP.Prog/appsettings.Development.json.bak b/MP.Prog/appsettings.Development.json.bak deleted file mode 100644 index 51737579..00000000 --- a/MP.Prog/appsettings.Development.json.bak +++ /dev/null @@ -1,10 +0,0 @@ -{ - "DetailedErrors": true, - "Logging": { - "LogLevel": { - "Default": "Information", - "Microsoft": "Warning", - "Microsoft.Hosting.Lifetime": "Information" - } - } -} diff --git a/MP.Prog/appsettings.json.bak b/MP.Prog/appsettings.json.bak deleted file mode 100644 index d9d9a9bf..00000000 --- a/MP.Prog/appsettings.json.bak +++ /dev/null @@ -1,10 +0,0 @@ -{ - "Logging": { - "LogLevel": { - "Default": "Information", - "Microsoft": "Warning", - "Microsoft.Hosting.Lifetime": "Information" - } - }, - "AllowedHosts": "*" -} diff --git a/MP.Stats/Data/MpStatsService.cs b/MP.Stats/Data/MpStatsService.cs index f1e85089..29c4cb64 100644 --- a/MP.Stats/Data/MpStatsService.cs +++ b/MP.Stats/Data/MpStatsService.cs @@ -15,16 +15,20 @@ using NLog; namespace MP.Stats.Data { - public class MpStatsService + public class MpStatsService : IDisposable { #region Private Fields private static IConfiguration _configuration; + private static ILogger _logger; private static List ActionsList = new List(); + private static NLog.Logger Log = LogManager.GetCurrentClassLogger(); + private readonly IDistributedCache distributedCache; + private readonly IMemoryCache memoryCache; /// @@ -177,6 +181,12 @@ namespace MP.Stats.Data return Task.FromResult(answ); } + public void Dispose() + { + // Clear database controller + dbController.Dispose(); + } + public Task> MacchineGetAll() { return Task.FromResult(dbController.MacchineGetAll().ToList()); diff --git a/MP.Stats/MP.Stats.csproj b/MP.Stats/MP.Stats.csproj index bfbe015d..3f4b55aa 100644 --- a/MP.Stats/MP.Stats.csproj +++ b/MP.Stats/MP.Stats.csproj @@ -4,7 +4,7 @@ net5.0 MP.Stats 826e877c-ba70-4253-84cb-d0b1cafd4440 - 1.0.2109.0309 + 1.0.2109.0312 diff --git a/MP.Stats/Startup.cs b/MP.Stats/Startup.cs index b1484b1d..ba6e51ab 100644 --- a/MP.Stats/Startup.cs +++ b/MP.Stats/Startup.cs @@ -95,7 +95,9 @@ namespace MP.Stats services.AddStackExchangeRedisCache(options => { - options.Configuration = "localhost:6379"; + //options.Configuration = "localhost:6379"; + options.ConfigurationOptions = new StackExchange.Redis.ConfigurationOptions() { KeepAlive = 180, DefaultDatabase = 5, EndPoints = { { "localhost", 6379 } } }; + options.InstanceName = "MP:Stats"; }); services.AddLocalization(); diff --git a/Resources/ChangeLog.html b/Resources/ChangeLog.html index 8309cc7a..eb5cb1c0 100644 --- a/Resources/ChangeLog.html +++ b/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo statistiche MAPO -

Versione: 1.0.2109.0309

+

Versione: 1.0.2109.0312


Note di rilascio:
    diff --git a/Resources/VersNum.txt b/Resources/VersNum.txt index d790cb28..87a0cf41 100644 --- a/Resources/VersNum.txt +++ b/Resources/VersNum.txt @@ -1 +1 @@ -1.0.2109.0309 +1.0.2109.0312 diff --git a/Resources/manifest.xml b/Resources/manifest.xml index 3ec95204..c65af70a 100644 --- a/Resources/manifest.xml +++ b/Resources/manifest.xml @@ -1,6 +1,6 @@ - 1.0.2109.0309 + 1.0.2109.0312 http://nexus.steamware.net/repository/SWS/MP-STATS/stable/0/MP.Stats.zip http://nexus.steamware.net/repository/SWS/MP-STATS/stable/0/ChangeLog.html false