Display Update avanzamento download

This commit is contained in:
Samuele Locatelli
2021-09-20 20:03:16 +02:00
parent c740b4492f
commit 97e0224e77
6 changed files with 84 additions and 6 deletions
+1 -1
View File
@@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<RootNamespace>MP.Land</RootNamespace>
<Version>1.1.2109.2019</Version>
<Version>1.1.2109.2020</Version>
</PropertyGroup>
<ItemGroup>
+10 -1
View File
@@ -19,7 +19,16 @@
<div class="h2">
ALL Packages <i class="fas fa-download"></i>
</div>
<button class="btn btn-success btn-block">Download ALL Latest</button>
<button class="btn btn-success btn-block" @onclick="() => DownloadAll()">Download ALL Latest</button>
</div>
<div class="col-12">
@if (showProgress)
{
<div class="progress">
<div class="progress-bar progress-bar-striped progress-bar-animated" style="width:@percLoading%;"></div>
</div>
}
<p>@outMessages</p>
</div>
</div>
</div>
+70 -1
View File
@@ -1,7 +1,10 @@
using Microsoft.AspNetCore.Components;
using Microsoft.Extensions.Configuration;
using MP.AppAuth;
using MP.Land.Data;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
@@ -17,8 +20,14 @@ namespace MP.Land.Pages
#region Protected Fields
protected int numDone = 0;
protected int numTot = 0;
protected int totalCount = 0;
protected double TotalMb = 0;
protected UpdateMan updateManAuth = new UpdateMan("SWDownloader", "viaD@nte16");
#endregion Protected Fields
#region Protected Properties
@@ -26,18 +35,78 @@ namespace MP.Land.Pages
[Inject]
protected MessageService AppMService { get; set; }
[Inject]
protected IConfiguration Configuration { get; set; }
[Inject]
protected AppAuthService DataService { get; set; }
protected string outMessages { get; set; } = "";
protected int percLoading { get; set; } = 0;
protected bool showProgress { get; set; } = false;
#endregion Protected Properties
#region Private Methods
private async Task<long> scaricaSingolo(AppAuth.Models.UpdMan item)
{
long size = 0;
if (item.IsAuth)
{
size = updateManAuth.downloadLatest(item.ManifestUrl, localPath(item.LocalRepo), item.PackName);
}
else
{
size = UpdateMan.obj.downloadLatest(item.ManifestUrl, localPath(item.LocalRepo), item.PackName);
}
numDone++;
percLoading = 100 * numDone / numTot;
return await Task.FromResult(size);
}
#endregion Private Methods
#region Protected Methods
/// <summary>
/// Cicla su tutti i record ed effettua il download
/// </summary>
protected void DownloadAll()
protected async Task DownloadAll()
{
// init progress...
showProgress = true;
StateHasChanged();
percLoading = 0;
TotalMb = 0;
numDone = 0;
numTot = ListRecords.Count;
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
// ciclo su tutti
foreach (var item in ListRecords)
{
long size = 0;
size = await scaricaSingolo(item);
TotalMb += (double)size / (1024 * 1024);
outMessages = $"Scaricati {numDone}/{numTot} update per {TotalMb:N2}";
StateHasChanged();
await Task.Delay(1);
}
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
outMessages = $"Effettuato download di {numDone} update per {TotalMb:N2} mb in {ts.TotalSeconds:N2} s";
StateHasChanged();
await Task.Delay(2000);
showProgress = false;
StateHasChanged();
}
protected string localPath(string localRepo)
{
return @$"{Configuration["downloadPath"]}\{localRepo}\{Configuration["appVers"]}"; ;
}
protected override void OnInitialized()
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>Modulo gestione Programmi MAPO</i>
<h4>Versione: 1.1.2109.2019</h4>
<h4>Versione: 1.1.2109.2020</h4>
<br />
Note di rilascio:
<ul>
+1 -1
View File
@@ -1 +1 @@
1.1.2109.2019
1.1.2109.2020
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>1.1.2109.2019</version>
<version>1.1.2109.2020</version>
<url>https://nexus.steamware.net/repository/SWS/MP-PROG/stable/LAST/MP.Land.zip</url>
<changelog>https://nexus.steamware.net/repository/SWS/MP-PROG/stable/LAST/ChangeLog.html</changelog>
<mandatory>false</mandatory>