@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"
+
+
+
+
+ @if (currRecord != null)
+ {
+
+ }
+ @if (ListRecords == null)
+ {
+
+ }
+ else if (totalCount == 0)
+ {
+
Nessun record trovato
+ }
+ else
+ {
+
+
+
+
+
+ |
+ Impianto |
+ Data Ordine |
+ Ordine |
+ Fornitore |
+ Richiesta |
+ Carico |
+ Effettivo |
+
+
+
+ @foreach (var record in ListRecords)
+ {
+
+ |
+ @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
-{
-
-
-
- | Date |
- Temp. (C) |
- Temp. (F) |
- Summary |
-
-
-
- @foreach (var forecast in forecasts)
- {
-
- | @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 @@
🗙