222 lines
6.3 KiB
C#
222 lines
6.3 KiB
C#
using Microsoft.AspNetCore.Components;
|
|
using Microsoft.Extensions.Configuration;
|
|
using MP.AppAuth;
|
|
using MP.AppAuth.Models;
|
|
using MP.AppAuth.Services;
|
|
using MP.Land.Data;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace MP.Land.Pages
|
|
{
|
|
public partial class ConfSync : IDisposable
|
|
{
|
|
#region Public Methods
|
|
|
|
public void Dispose()
|
|
{
|
|
listAnagKeyValLoc = null;
|
|
listConfigLoc = null;
|
|
listVocabolarioLoc = null;
|
|
listAnagKeyValRem = null;
|
|
listConfigRem = null;
|
|
listVocabolarioRem = null;
|
|
GC.Collect();
|
|
}
|
|
|
|
#endregion Public Methods
|
|
|
|
#region Protected Fields
|
|
|
|
protected int numDone = 0;
|
|
protected int numTot = 0;
|
|
protected double TotalMb = 0;
|
|
protected UpdateMan updateManAuth = new UpdateMan("SWDownloader", "viaD@nte16");
|
|
|
|
#endregion Protected Fields
|
|
|
|
#region Protected Properties
|
|
|
|
protected List<AnagKeyValueModel> AKVList
|
|
{
|
|
get
|
|
{
|
|
return SyncServ.AKVList;
|
|
}
|
|
|
|
set
|
|
{
|
|
SyncServ.AKVList = value;
|
|
}
|
|
}
|
|
|
|
[Inject]
|
|
protected LMessageService AppMService { get; set; }
|
|
|
|
[Inject]
|
|
protected IConfiguration Configuration { get; set; }
|
|
|
|
[Inject]
|
|
protected AppAuthService DataService { get; set; }
|
|
|
|
protected bool isLoadingLoc { get; set; } = false;
|
|
|
|
protected bool isLoadingRem { get; set; } = false;
|
|
|
|
[Inject]
|
|
protected LicenseService LicServ { get; set; } = null!;
|
|
|
|
protected bool showUpdate { get; set; } = false;
|
|
|
|
[Inject]
|
|
protected SyncService SyncServ { get; set; } = null!;
|
|
|
|
#endregion Protected Properties
|
|
|
|
#region Protected Methods
|
|
|
|
protected string localPath(string localRepo)
|
|
{
|
|
return @$"{Configuration["ServerConf:downloadPath"]}\{localRepo}\{Configuration["appVers"]}"; ;
|
|
}
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
AppMService.ShowSearch = true;
|
|
AppMService.PageName = "Config Sync";
|
|
AppMService.PageIcon = "fas fa-file-import pe-2";
|
|
await RefreshData();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Cicla su tutti i record ed effettua il download
|
|
/// </summary>
|
|
protected async Task RefreshData()
|
|
{
|
|
// init progress...
|
|
showUpdate = true;
|
|
CompType = "";
|
|
numDone = 0;
|
|
numTot = 3;
|
|
await fixAKV();
|
|
numDone++;
|
|
await ReloadDataLoc();
|
|
numDone++;
|
|
await ReloadDataRem();
|
|
numDone++;
|
|
await Task.Delay(10);
|
|
showUpdate = false;
|
|
}
|
|
|
|
/// <summary>
|
|
/// rilettura parziale dati locali secondo codice richiesto
|
|
/// </summary>
|
|
/// <param name="valReq"></param>
|
|
protected async Task ReloadPartial(string valReq)
|
|
{
|
|
isLoadingLoc = true;
|
|
await InvokeAsync(StateHasChanged);
|
|
switch (valReq)
|
|
{
|
|
case "AnagKeyVal":
|
|
await Task.Delay(tDelay);
|
|
listAnagKeyValLoc = await DataService.AnagKeyValList();
|
|
break;
|
|
case "Config":
|
|
await Task.Delay(tDelay);
|
|
listConfigLoc = await DataService.ConfigList();
|
|
break;
|
|
case "Vocabolario":
|
|
await Task.Delay(tDelay);
|
|
listVocabolarioLoc = await DataService.VocabolarioList();
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
isLoadingLoc = false;
|
|
}
|
|
|
|
protected void doClose()
|
|
{
|
|
CompType = "";
|
|
}
|
|
|
|
protected bool showDetail(string valReq)
|
|
{
|
|
return !string.IsNullOrEmpty(CompType) && CompType.Equals(valReq);
|
|
}
|
|
|
|
protected async Task ReloadDataLoc()
|
|
{
|
|
isLoadingLoc = true;
|
|
await InvokeAsync(StateHasChanged);
|
|
await Task.Delay(tDelay);
|
|
listAnagKeyValLoc = await DataService.AnagKeyValList();
|
|
await Task.Delay(tDelay);
|
|
listConfigLoc = await DataService.ConfigList();
|
|
await Task.Delay(tDelay);
|
|
listVocabolarioLoc = await DataService.VocabolarioList();
|
|
isLoadingLoc = false;
|
|
}
|
|
|
|
protected async Task ReloadDataRem()
|
|
{
|
|
isLoadingRem = true;
|
|
await InvokeAsync(StateHasChanged);
|
|
await Task.Delay(tDelay);
|
|
listAnagKeyValRem = await SyncServ.OnlineListAnagKeyVal();
|
|
await Task.Delay(tDelay);
|
|
listConfigRem = await SyncServ.OnlineListConfig();
|
|
await Task.Delay(tDelay);
|
|
listVocabolarioRem = await SyncServ.OnlineListVocabolario();
|
|
isLoadingRem = false;
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Fields
|
|
|
|
private int tDelay = 50;
|
|
|
|
#endregion Private Fields
|
|
|
|
#region Private Properties
|
|
|
|
private List<AnagKeyValueModel> listAnagKeyValLoc { get; set; } = new List<AnagKeyValueModel>();
|
|
|
|
private List<AnagKeyValueModel> listAnagKeyValRem { get; set; } = new List<AnagKeyValueModel>();
|
|
|
|
private List<ConfigModel> listConfigLoc { get; set; } = new List<ConfigModel>();
|
|
|
|
private List<ConfigModel> listConfigRem { get; set; } = new List<ConfigModel>();
|
|
|
|
private List<VocabolarioModel> listVocabolarioLoc { get; set; } = new List<VocabolarioModel>();
|
|
|
|
private List<VocabolarioModel> listVocabolarioRem { get; set; } = new List<VocabolarioModel>();
|
|
|
|
#endregion Private Properties
|
|
|
|
#region Private Methods
|
|
|
|
private async Task fixAKV()
|
|
{
|
|
// check init AKV
|
|
if (AKVList == null || AKVList.Count == 0)
|
|
{
|
|
AKVList = await DataService.AnagKeyValList();
|
|
SyncServ.InitAkv();
|
|
}
|
|
}
|
|
|
|
#endregion Private Methods
|
|
|
|
protected async Task DoCompare(string compType)
|
|
{
|
|
CompType = compType;
|
|
await InvokeAsync(StateHasChanged);
|
|
}
|
|
|
|
private string CompType = "";
|
|
}
|
|
} |