Continuo pagina setup x ricalcolo completo archivio
This commit is contained in:
@@ -9,6 +9,7 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using MP.FileData.DatabaseModels;
|
||||
using Newtonsoft.Json;
|
||||
using MP.FileData.DTO;
|
||||
|
||||
namespace MP.FileData.Controllers
|
||||
{
|
||||
@@ -535,6 +536,38 @@ namespace MP.FileData.Controllers
|
||||
return done;
|
||||
}
|
||||
|
||||
public List<ArchiveStatusDTO> GetArchiveStatus()
|
||||
{
|
||||
List<ArchiveStatusDTO> ArchiveList = new List<ArchiveStatusDTO>();
|
||||
using (MoonPro_ProgContext localDbCtx = new MoonPro_ProgContext(_configuration))
|
||||
{
|
||||
ArchiveList = localDbCtx
|
||||
.DbSetMacchine
|
||||
.Select(x => new ArchiveStatusDTO()
|
||||
{
|
||||
IdxMacchina = x.IdxMacchina,
|
||||
Nome = x.Nome,
|
||||
Descrizione = x.Descrizione,
|
||||
BasePath = x.BasePath
|
||||
})
|
||||
.ToList();
|
||||
// ora ciclo a cercare i file...
|
||||
foreach (var item in ArchiveList)
|
||||
{
|
||||
item.TotFile = localDbCtx
|
||||
.DbSetProgFile
|
||||
.Where(x => x.IdxMacchina == item.IdxMacchina && x.Active)
|
||||
.Count();
|
||||
|
||||
item.NumChanged = localDbCtx
|
||||
.DbSetProgFile
|
||||
.Where(x => x.IdxMacchina == item.IdxMacchina && x.Active && x.DiskStatus == FileState.Changed)
|
||||
.Count();
|
||||
}
|
||||
}
|
||||
return ArchiveList;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco tabella Macchine
|
||||
/// </summary>
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MP.FileData.DTO
|
||||
{
|
||||
// <Auto-Generated>
|
||||
// This is here so CodeMaid doesn't reorganize this document
|
||||
// </Auto-Generated>
|
||||
public class ArchiveStatusDTO
|
||||
{
|
||||
public string IdxMacchina { get; set; } = "";
|
||||
public string Nome { get; set; } = "";
|
||||
public string Descrizione { get; set; } = "";
|
||||
public string BasePath { get; set; } = "";
|
||||
|
||||
public int TotFile { get; set; } = 0;
|
||||
public int NumChanged { get; set; } = 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
<div class="row">
|
||||
<div class="col-4">
|
||||
<button id="btnForceCheck" class="btn btn-danger btn-sm btn-block" @onclick="() => ForceCheck(0)" title="Forza verifica archivio (totale)">
|
||||
<i class="fas fa-sync-alt"></i> Update Completo Archivio <i class="far fa-folder-open"></i>
|
||||
</button>
|
||||
</div>
|
||||
<div class="col-8 py-2">
|
||||
@if (showProgress)
|
||||
{
|
||||
<div class="progress">
|
||||
<div class="progress-bar progress-bar-striped progress-bar-animated" style="width:@percLoading%;"></div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
<div class="col-12 mt-2">
|
||||
@if (ListRecords == null)
|
||||
{
|
||||
<LoadingData></LoadingData>
|
||||
}
|
||||
else if (totalCount == 0)
|
||||
{
|
||||
<div class="alert alert-warning text-center display-4">Nessun record trovato</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
<table class="table table-sm table-striped table-responsive-lg">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Macchina</th>
|
||||
<th>Path</th>
|
||||
<th class="text-right">Modificati</th>
|
||||
<th class="text-right">Tot File</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var record in ListRecords)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@record.Nome
|
||||
</td>
|
||||
<td>
|
||||
<div class="small">@record.BasePath</div>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
@record.NumChanged
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<b>
|
||||
@record.TotFile
|
||||
</b>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="alert aler-info">
|
||||
<i>@lastMessage</i>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,92 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using MP.FileData.DTO;
|
||||
using MP.Prog.Data;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MP.Prog.Components
|
||||
{
|
||||
public partial class ArchiveStatus
|
||||
{
|
||||
#region Private Fields
|
||||
|
||||
private List<ArchiveStatusDTO> ListRecords;
|
||||
|
||||
private int numChecks = 0;
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Private Properties
|
||||
|
||||
private string lastMessage { get; set; } = "";
|
||||
|
||||
private int totalCount
|
||||
{
|
||||
get
|
||||
{
|
||||
int answ = 0;
|
||||
if (ListRecords != null)
|
||||
answ = ListRecords.Count();
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Private Properties
|
||||
|
||||
#region Protected Properties
|
||||
|
||||
[Inject]
|
||||
protected FileArchDataService DataService { get; set; }
|
||||
|
||||
protected int percLoading { get; set; } = 0;
|
||||
protected bool showProgress { get; set; } = true;
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
protected async Task ArchiveCheck(int maxHour)
|
||||
{
|
||||
numChecks = await DataService.updateAllArchive(maxHour);
|
||||
lastMessage = $"Effettuata verifica e rilettura di {numChecks} files!";
|
||||
await Task.Delay(1);
|
||||
await ReloadData();
|
||||
}
|
||||
|
||||
protected async Task ClearMessage()
|
||||
{
|
||||
await Task.Delay(100);
|
||||
lastMessage = "";
|
||||
}
|
||||
|
||||
protected async Task ForceCheck(int maxHour)
|
||||
{
|
||||
lastMessage = "Inizio Analisi Archivio...";
|
||||
ListRecords = null;
|
||||
//await Task.Delay(1);
|
||||
await ArchiveCheck(maxHour);
|
||||
//await Task.Delay(1);
|
||||
await ReloadData();
|
||||
await ClearMessage();
|
||||
}
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
ListRecords = null;
|
||||
await ReloadData();
|
||||
}
|
||||
|
||||
protected async Task ReloadData()
|
||||
{
|
||||
await Task.Delay(10);
|
||||
numChecks = 0;
|
||||
ListRecords = await DataService.GetArchiveStatus();
|
||||
await Task.Delay(100);
|
||||
lastMessage = "";
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,7 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Diagnostics;
|
||||
using MP.FileData.Controllers;
|
||||
using MP.FileData.DTO;
|
||||
|
||||
namespace MP.Prog.Data
|
||||
{
|
||||
@@ -246,6 +247,18 @@ namespace MP.Prog.Data
|
||||
return await Task.FromResult(dbResult);
|
||||
}
|
||||
|
||||
public async Task<List<ArchiveStatusDTO>> GetArchiveStatus()
|
||||
{
|
||||
List<ArchiveStatusDTO> dbResult = new List<ArchiveStatusDTO>();
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
dbResult = dbController.GetArchiveStatus();
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Info($"Effettuata lettura da DB + caching per GetArchiveStatus: {ts.TotalMilliseconds} ms");
|
||||
return await Task.FromResult(dbResult);
|
||||
}
|
||||
|
||||
public Task<List<FileData.DatabaseModels.MacchinaModel>> MacchineGetAll()
|
||||
{
|
||||
return Task.FromResult(dbController.MacchineGetAll().ToList());
|
||||
|
||||
@@ -222,12 +222,8 @@ namespace MP.Prog.Pages
|
||||
isLoading = true;
|
||||
currRecord = null;
|
||||
ListRecords = null;
|
||||
//var pUpd = Task.Run(async () =>
|
||||
//{
|
||||
await ReloadData();
|
||||
isLoading = false;
|
||||
//});
|
||||
//pUpd.Wait();
|
||||
}
|
||||
|
||||
protected void Edit(FileModel selRecord)
|
||||
|
||||
@@ -11,17 +11,7 @@
|
||||
<h4>Setup</h4>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
@if(isLoading)
|
||||
{
|
||||
<MP.Prog.Components.LoadingData></MP.Prog.Components.LoadingData>
|
||||
}
|
||||
else
|
||||
|
||||
{
|
||||
<button id="btnForceCheck" class="btn btn-danger btn-sm btn-block" @onclick="() => ForceCheck(0)" title="Forza verifica archivio (totale)">
|
||||
<i class="fas fa-sync-alt"></i> Update Completo Archivio <i class="far fa-folder-open"></i>
|
||||
</button>
|
||||
}
|
||||
<MP.Prog.Components.ArchiveStatus></MP.Prog.Components.ArchiveStatus>
|
||||
</div>
|
||||
@*<div class="card-footer">Footer</div>*@
|
||||
</div>
|
||||
@@ -1,30 +1,19 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using MP.Prog.Data;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MP.Prog.Pages
|
||||
{
|
||||
public partial class Setup
|
||||
public partial class Setup : ComponentBase
|
||||
{
|
||||
#region Private Properties
|
||||
|
||||
private bool isLoading { get; set; } = false;
|
||||
|
||||
#endregion Private Properties
|
||||
|
||||
#region Protected Properties
|
||||
|
||||
[Inject]
|
||||
protected FileArchDataService DataService { get; set; }
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
protected async void ForceCheck(int maxHour)
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
isLoading = true;
|
||||
await DataService.updateAllArchive(maxHour);
|
||||
isLoading = false;
|
||||
AppMService.ShowSearch = false;
|
||||
AppMService.PageName = "Setup";
|
||||
AppMService.PageIcon = "fas fa-wrench pr-2";
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
Reference in New Issue
Block a user