29079a578f
- spostamento servizio AppAuth i proj generico
116 lines
3.2 KiB
C#
116 lines
3.2 KiB
C#
using Microsoft.AspNetCore.Components;
|
|
using MP.AppAuth;
|
|
using MP.AppAuth.Models;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.Extensions.Configuration;
|
|
using MP.Land.Data;
|
|
using System.Diagnostics;
|
|
using MP.AppAuth.Services;
|
|
|
|
namespace MP.Land.Components
|
|
{
|
|
public partial class SingleDownload
|
|
{
|
|
#region Protected Fields
|
|
|
|
protected string outMessage = "";
|
|
protected UpdateInfoEventArgs updArgs = new UpdateInfoEventArgs();
|
|
protected UpdateMan updateManAuth = new UpdateMan("SWDownloader", "viaD@nte16");
|
|
|
|
#endregion Protected Fields
|
|
|
|
#region Protected Properties
|
|
|
|
[Inject]
|
|
protected IConfiguration Configuration { get; set; }
|
|
|
|
[Inject]
|
|
protected AppAuthService DataService { get; set; }
|
|
|
|
#endregion Protected Properties
|
|
|
|
#region Public Properties
|
|
|
|
[Parameter]
|
|
public UpdMan CurrItem { get; set; }
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Protected Methods
|
|
|
|
protected bool authOk()
|
|
{
|
|
bool answ = !string.IsNullOrEmpty(CurrItem.LicenseKey);
|
|
if (answ)
|
|
{
|
|
answ = LicServ.checkLicenseActive(CurrItem.LicenseKey);
|
|
}
|
|
return answ;
|
|
}
|
|
|
|
/// <summary>
|
|
/// effettua download del pacchetto indicato
|
|
/// </summary>
|
|
protected void DownloadPack()
|
|
{
|
|
long size = 0;
|
|
Stopwatch stopWatch = new Stopwatch();
|
|
stopWatch.Start();
|
|
if (CurrItem.IsAuth)
|
|
{
|
|
size = updateManAuth.downloadLatest(CurrItem.ManifestUrl, localPath(CurrItem.LocalRepo), CurrItem.PackName);
|
|
}
|
|
else
|
|
{
|
|
size = UpdateMan.obj.downloadLatest(CurrItem.ManifestUrl, localPath(CurrItem.LocalRepo), CurrItem.PackName);
|
|
}
|
|
stopWatch.Stop();
|
|
TimeSpan ts = stopWatch.Elapsed;
|
|
|
|
if (size > 0)
|
|
{
|
|
outMessage = $"Scaricati {(double)size / (1024 * 1024):N2} Mb in {ts.TotalSeconds:N2} s";
|
|
}
|
|
else
|
|
{
|
|
outMessage = $"Download non riuscito per {CurrItem.AppName}";
|
|
}
|
|
}
|
|
|
|
protected string fullUrl(string relUrl)
|
|
{
|
|
return $"{Configuration["ServerConf:BaseUrl"]}{relUrl}";
|
|
}
|
|
|
|
protected string localPath(string localRepo)
|
|
{
|
|
return @$"{Configuration["ServerConf:downloadPath"]}\{localRepo}\{Configuration["appVers"]}"; ;
|
|
}
|
|
|
|
protected override void OnInitialized()
|
|
{
|
|
// Recupero info ADM...
|
|
if (CurrItem.IsAuth)
|
|
{
|
|
updArgs = updateManAuth.getUpdateInfo(CurrItem.ManifestUrl);
|
|
}
|
|
else
|
|
{
|
|
updArgs = UpdateMan.obj.getUpdateInfo(CurrItem.ManifestUrl);
|
|
}
|
|
}
|
|
|
|
protected MarkupString traduci(string lemma)
|
|
{
|
|
MarkupString answ;
|
|
string rawHtml = DataService.Traduci(lemma, "IT");
|
|
answ = new MarkupString(rawHtml);
|
|
return answ;
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
}
|
|
} |