diff --git a/MP.AppAuth/Controllers/AppAuthController.cs b/MP.AppAuth/Controllers/AppAuthController.cs
index 3c2897a9..316d3743 100644
--- a/MP.AppAuth/Controllers/AppAuthController.cs
+++ b/MP.AppAuth/Controllers/AppAuthController.cs
@@ -96,7 +96,6 @@ namespace MP.AppAuth.Controllers
dbResult = dbCtx
.DbSetUpdMan
- //.Where(x => !string.IsNullOrEmpty(x.AppName))
.ToList();
return dbResult;
diff --git a/MP.AppAuth/Models/UpdMan.cs b/MP.AppAuth/Models/UpdMan.cs
index ff1efe8b..d1496155 100644
--- a/MP.AppAuth/Models/UpdMan.cs
+++ b/MP.AppAuth/Models/UpdMan.cs
@@ -16,7 +16,7 @@ namespace MP.AppAuth.Models
public string AppName { get; set; }
public string AppUrl { get; set; }
- public bool? IsAuth { get; set; }
+ public bool IsAuth { get; set; } = false;
public string LicenseKey { get; set; }
public string LocalRepo { get; set; }
public string ManifestUrl { get; set; }
diff --git a/MP.AppAuth/UpdateMan.cs b/MP.AppAuth/UpdateMan.cs
new file mode 100644
index 00000000..06b39a98
--- /dev/null
+++ b/MP.AppAuth/UpdateMan.cs
@@ -0,0 +1,270 @@
+using NLog;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Net;
+using System.Net.Http;
+using System.Text;
+using System.Threading.Tasks;
+using System.Xml;
+
+namespace MP.AppAuth
+{
+ ///
+ /// Object of this class gives you all the details about the update useful in handling the update logic yourself.
+ ///
+ public class UpdateInfoEventArgs : EventArgs
+ {
+ #region Public Properties
+
+ ///
+ /// URL of the webpage specifying changes in the new update.
+ ///
+ public string ChangelogURL { get; set; }
+
+ ///
+ /// Returns newest version of the application available to download.
+ ///
+ public Version CurrentVersion { get; set; }
+
+ ///
+ /// Download URL of the update file.
+ ///
+ public string DownloadURL { get; set; }
+
+ ///
+ /// Returns version of the application currently installed on the user's PC.
+ ///
+ public Version InstalledVersion { get; set; }
+
+ ///
+ /// If new update is available then returns true otherwise false.
+ ///
+ public bool IsUpdateAvailable { get; set; }
+
+ ///
+ /// Shows if the update is required or optional.
+ ///
+ public bool Mandatory { get; set; }
+
+ #endregion Public Properties
+ }
+
+ ///
+ /// Gestione update applicazioni
+ ///
+ public class UpdateMan
+ {
+ #region Private Fields
+
+ private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
+
+ #endregion Private Fields
+
+ #region Protected Fields
+
+ protected bool doAuth = false;
+
+ #endregion Protected Fields
+
+ #region Public Fields
+
+ ///
+ /// Init classe
+ ///
+ public static UpdateMan obj = new UpdateMan();
+
+ #endregion Public Fields
+
+ #region Public Constructors
+
+ ///
+ /// Init classe
+ ///
+ public UpdateMan()
+ { }
+
+ ///
+ /// Init classe
+ ///
+ ///
+ ///
+ public UpdateMan(string user, string pwd)
+ {
+ userName = user;
+ passwd = pwd;
+ doAuth = !string.IsNullOrEmpty($"{userName}{passwd}");
+ }
+
+ #endregion Public Constructors
+
+ #region Protected Properties
+
+ protected string passwd { get; set; } = "";
+ protected string userName { get; set; } = "";
+
+ #endregion Protected Properties
+
+ #region Public Methods
+
+ ///
+ /// Effettua download ultima versione applicativo
+ ///
+ ///
+ ///
+ ///
+ public long downloadLatest(string remoteUrl, string localRepo, string packName)
+ {
+ long size = 0;
+ // verifico directory
+ if (!Directory.Exists(localRepo))
+ {
+ Directory.CreateDirectory(localRepo);
+ }
+ string localFile = "";
+ string localLast = "";
+ string DownloadURL = "";
+ try
+ {
+ // in primis scarico update info...
+ UpdateInfoEventArgs updateData = getUpdateInfo(remoteUrl);
+ if (updateData.IsUpdateAvailable)
+ {
+ DownloadURL = updateData.DownloadURL;
+ localFile = string.Format(@"{0}\{1}_Build_{2}.zip", localRepo, packName, updateData.CurrentVersion);
+ localLast = string.Format(@"{0}\{1}.zip", localRepo, packName);
+ // scarica file e salva in directory locale...
+ using (var http = new HttpClient())
+ {
+ //var client = new WebClient();
+ //bool doAuth = !string.IsNullOrEmpty($"{userName}{passwd}");
+ if (doAuth)
+ {
+ //client.Credentials = new System.Net.NetworkCredential(userName, passwd);
+ http.DefaultRequestHeaders.Accept.Clear();
+ var byteArray = System.Text.ASCIIEncoding.UTF8.GetBytes($"{userName}:{passwd}");
+ http.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", Convert.ToBase64String(byteArray));
+ }
+ //client.DownloadFile(updateData.DownloadURL, localFile);
+
+ // url da chiamare
+ http.BaseAddress = new Uri(DownloadURL);
+ // lettura
+ var data = http.GetAsync(DownloadURL).Result;
+ using (var myReader = data.Content.ReadAsStreamAsync())
+ {
+ //var myReader = data.Content.ReadAsStreamAsync();
+ if (data.StatusCode != HttpStatusCode.OK)
+ {
+ Log.Info($"Errore in chiamata getUpdateInfo per URL {remoteUrl}: status code: {data.StatusCode}");
+ }
+ else
+ {
+ using (Stream outStream = File.OpenWrite(localFile))
+ {
+ myReader.Result.CopyTo(outStream);
+ }
+ // ora lo copio come latest...
+ File.Copy(localFile, localLast, true);
+ // indico come fatto!
+ var thisFile = new FileInfo(localLast);
+ size = thisFile.Length;
+ }
+ }
+ }
+ }
+ else
+ {
+ localFile = string.Format(@"{0}\Error.log", localRepo);
+ // scrivo file in area target...
+ using (StreamWriter sw = File.AppendText(localFile))
+ {
+ sw.WriteLine($"{DateTime.Now:yyyy-MM-dd HH:mm:ss} ATTENZIONE! Installer NON disponibile | {remoteUrl}");
+ }
+ }
+ }
+ catch (Exception exc)
+ {
+ localFile = string.Format(@"{0}\Error.log", localRepo);
+ // scrivo file in area target...
+ using (StreamWriter sw = File.AppendText(localFile))
+ {
+ sw.WriteLine($"{DateTime.Now:yyyy-MM-dd HH:mm:ss} Errore in fase di download installers{Environment.NewLine}XML: {remoteUrl}{Environment.NewLine}URL: {DownloadURL}");
+ sw.WriteLine(exc.ToString());
+ }
+ }
+ return size;
+ }
+
+ ///
+ /// Recupera l'ultima versione disponibile
+ ///
+ ///
+ ///
+ public UpdateInfoEventArgs getUpdateInfo(string remoteUrl)
+ {
+ //bool doAuth = !string.IsNullOrEmpty($"{userName}{passwd}");
+
+ UpdateInfoEventArgs args = new UpdateInfoEventArgs();
+ Version CurrentVersion;
+ bool Mandatory;
+ XmlDocument recXml = new XmlDocument();
+ try
+ {
+ // recupero dati
+ using (var http = new HttpClient())
+ {
+ if (doAuth)
+ {
+ http.DefaultRequestHeaders.Accept.Clear();
+ var byteArray = System.Text.ASCIIEncoding.UTF8.GetBytes($"{userName}:{passwd}");
+ http.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", Convert.ToBase64String(byteArray));
+ }
+ // url da chiamare
+ http.BaseAddress = new Uri(remoteUrl);
+ // lettura
+ var data = http.GetAsync(remoteUrl).Result;
+ var myReader = data.Content.ReadAsStreamAsync();
+ if (data.StatusCode != HttpStatusCode.OK)
+ {
+ Log.Info($"Errore in chiamata getUpdateInfo per URL {remoteUrl}: status code: {data.StatusCode}");
+ }
+ else
+ {
+ recXml.Load(myReader.Result);
+
+ XmlNodeList recData = recXml.SelectNodes("item");
+ if (recData != null)
+ {
+ foreach (XmlNode item in recData)
+ {
+ XmlNode appCastVersion = item.SelectSingleNode("version");
+ Version.TryParse(appCastVersion?.InnerText, out CurrentVersion);
+ args.CurrentVersion = CurrentVersion;
+ XmlNode appCastChangeLog = item.SelectSingleNode("changelog");
+ args.ChangelogURL = appCastChangeLog?.InnerText;
+ XmlNode appCastUrl = item.SelectSingleNode("url");
+ args.DownloadURL = appCastUrl?.InnerText;
+ XmlNode mandatory = item.SelectSingleNode("mandatory");
+ Boolean.TryParse(mandatory?.InnerText, out Mandatory);
+ args.Mandatory = Mandatory;
+ args.IsUpdateAvailable = true;
+ }
+ }
+ }
+ }
+ }
+ catch (Exception exc)
+ {
+ Log.Info($"Eccezione in getUpdateInfo:{Environment.NewLine}{exc}");
+ // metto versione = 0 + errore...
+ args.IsUpdateAvailable = false;
+ args.CurrentVersion = new Version("0.0.0.0");
+ }
+ return args;
+ }
+
+ #endregion Public Methods
+ }
+}
\ No newline at end of file
diff --git a/MP.Land/Components/HomeLink.razor b/MP.Land/Components/HomeLink.razor
index e8ca1aa0..653cb0fa 100644
--- a/MP.Land/Components/HomeLink.razor
+++ b/MP.Land/Components/HomeLink.razor
@@ -67,7 +67,7 @@
protected bool authOk()
{
- bool answ = !string.IsNullOrEmpty(CurrItem.LicenseKey) && Convert.ToBoolean(CurrItem.IsAuth);
+ bool answ = !string.IsNullOrEmpty(CurrItem.LicenseKey);
return answ;
}
diff --git a/MP.Land/Components/SingleDownload.razor b/MP.Land/Components/SingleDownload.razor
new file mode 100644
index 00000000..4530ffe6
--- /dev/null
+++ b/MP.Land/Components/SingleDownload.razor
@@ -0,0 +1,14 @@
+
+ @if (authOk())
+ {
+
+
@CurrItem.AppName
+
+
+
+
+
+ @outMessage
+
+ }
+
\ No newline at end of file
diff --git a/MP.Land/Components/SingleDownload.razor.cs b/MP.Land/Components/SingleDownload.razor.cs
new file mode 100644
index 00000000..58975b3d
--- /dev/null
+++ b/MP.Land/Components/SingleDownload.razor.cs
@@ -0,0 +1,111 @@
+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;
+
+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);
+ return answ;
+ }
+
+ ///
+ /// effettua download del pacchetto indicato
+ ///
+ 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["BaseUrl"]}{relUrl}";
+ }
+
+ protected string localPath(string localRepo)
+ {
+ return @$"{Configuration["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
+ }
+}
\ No newline at end of file
diff --git a/MP.Land/Components/UserCard.razor b/MP.Land/Components/UserCard.razor
index 6e0b7852..247d9bbf 100644
--- a/MP.Land/Components/UserCard.razor
+++ b/MP.Land/Components/UserCard.razor
@@ -8,10 +8,10 @@
-
EgalWare 
+
EgalWare
- @*

EgalWare*@
+ @*

EgalWare*@
@Environment
diff --git a/MP.Land/MP.Land.csproj b/MP.Land/MP.Land.csproj
index 7f2be65a..85d4b197 100644
--- a/MP.Land/MP.Land.csproj
+++ b/MP.Land/MP.Land.csproj
@@ -3,7 +3,7 @@
net5.0
MP.Land
- 1.1.2109.2016
+ 1.1.2109.2019
diff --git a/MP.Land/Pages/Index.razor b/MP.Land/Pages/Index.razor
index 6c3b2895..54c0195e 100644
--- a/MP.Land/Pages/Index.razor
+++ b/MP.Land/Pages/Index.razor
@@ -17,7 +17,7 @@
diff --git a/MP.Land/Pages/Index.razor.cs b/MP.Land/Pages/Index.razor.cs
index a5c69119..89eb18b1 100644
--- a/MP.Land/Pages/Index.razor.cs
+++ b/MP.Land/Pages/Index.razor.cs
@@ -24,12 +24,6 @@ namespace MP.Land.Pages
#endregion Protected Fields
- #region Private Properties
-
- private bool isLoading { get; set; } = false;
-
- #endregion Private Properties
-
#region Protected Properties
[Inject]
@@ -56,14 +50,11 @@ namespace MP.Land.Pages
protected async Task ReloadAllData()
{
- isLoading = true;
- //MacList = await DataService.MacchineGetAll();
await ReloadData();
}
protected async Task ReloadData()
{
- isLoading = true;
// importante altrimenti NON mostra update UI
await Task.Delay(1);
ListRecords = await DataService.UpdManList();
diff --git a/MP.Land/Pages/UpdateManager.razor b/MP.Land/Pages/UpdateManager.razor
new file mode 100644
index 00000000..9fd8b77b
--- /dev/null
+++ b/MP.Land/Pages/UpdateManager.razor
@@ -0,0 +1,48 @@
+@page "/UpdateManager"
+
+@using MP.Land.Data
+@using MP.Land.Components
+
+
+
+
+

+
+
+
Aggiornamento Moduli
+
+ Ultime release applicazioni
+
+
Scaricare uno o più pacchetti selezionando dall'elenco riportato.
+
+
+
+ ALL Packages
+
+
+
+
+
+
+
+ @if (ListRecords == null)
+ {
+
+ }
+ else if (totalCount == 0)
+ {
+
Nessun record trovato
+ }
+ else
+ {
+
+ @foreach (var item in ListRecords)
+ {
+
+
+
+ }
+
+ }
+
+
\ No newline at end of file
diff --git a/MP.Land/Pages/UpdateManager.razor.cs b/MP.Land/Pages/UpdateManager.razor.cs
new file mode 100644
index 00000000..0d06a403
--- /dev/null
+++ b/MP.Land/Pages/UpdateManager.razor.cs
@@ -0,0 +1,64 @@
+using Microsoft.AspNetCore.Components;
+using MP.Land.Data;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace MP.Land.Pages
+{
+ public partial class UpdateManager
+ {
+ #region Private Fields
+
+ private List ListRecords;
+
+ #endregion Private Fields
+
+ #region Protected Fields
+
+ protected int totalCount = 0;
+
+ #endregion Protected Fields
+
+ #region Protected Properties
+
+ [Inject]
+ protected MessageService AppMService { get; set; }
+
+ [Inject]
+ protected AppAuthService DataService { get; set; }
+
+ #endregion Protected Properties
+
+ #region Protected Methods
+
+ protected override void OnInitialized()
+ {
+ AppMService.ShowSearch = false;
+ AppMService.PageName = "Update Manager";
+ AppMService.PageIcon = "fas fa-download pr-2";
+ }
+
+ protected override async Task OnInitializedAsync()
+ {
+ await ReloadAllData();
+ }
+
+ protected async Task ReloadAllData()
+ {
+ await ReloadData();
+ }
+
+ protected async Task ReloadData()
+ {
+ // importante altrimenti NON mostra update UI
+ await Task.Delay(1);
+ ListRecords = await DataService.UpdManList();
+ totalCount = ListRecords.Count();
+ await Task.Delay(1);
+ }
+
+ #endregion Protected Methods
+ }
+}
\ No newline at end of file
diff --git a/MP.Land/Resources/ChangeLog.html b/MP.Land/Resources/ChangeLog.html
index 324bb6d0..5b062486 100644
--- a/MP.Land/Resources/ChangeLog.html
+++ b/MP.Land/Resources/ChangeLog.html
@@ -1,6 +1,6 @@
Modulo gestione Programmi MAPO
- Versione: 1.1.2109.2016
+ Versione: 1.1.2109.2019
Note di rilascio:
diff --git a/MP.Land/Resources/VersNum.txt b/MP.Land/Resources/VersNum.txt
index f22c4f6c..f70d4f1a 100644
--- a/MP.Land/Resources/VersNum.txt
+++ b/MP.Land/Resources/VersNum.txt
@@ -1 +1 @@
-1.1.2109.2016
+1.1.2109.2019
diff --git a/MP.Land/Resources/manifest.xml b/MP.Land/Resources/manifest.xml
index 67ba9dd0..e50b6b2b 100644
--- a/MP.Land/Resources/manifest.xml
+++ b/MP.Land/Resources/manifest.xml
@@ -1,6 +1,6 @@
-
- 1.1.2109.2016
+ 1.1.2109.2019
https://nexus.steamware.net/repository/SWS/MP-PROG/stable/LAST/MP.Land.zip
https://nexus.steamware.net/repository/SWS/MP-PROG/stable/LAST/ChangeLog.html
false
diff --git a/MP.Land/Shared/NavMenu.razor b/MP.Land/Shared/NavMenu.razor
index ff8b5485..3730d9e3 100644
--- a/MP.Land/Shared/NavMenu.razor
+++ b/MP.Land/Shared/NavMenu.razor
@@ -14,12 +14,12 @@
-
- QR User
+ QR Card User
-
- Update vers
+ Update Manager
-
diff --git a/MP.Land/appsettings.json b/MP.Land/appsettings.json
index 731901a3..5a66223a 100644
--- a/MP.Land/appsettings.json
+++ b/MP.Land/appsettings.json
@@ -16,6 +16,8 @@
"AllowedHosts": "*",
"BaseUrl": "https://localhost:44309/",
"Environment": "Steam DEV",
+ "downloadPath": "C:\\Steamware\\installers\\MP",
+ "appVers": "stable",
"ConnectionStrings": {
"DefaultConnection": "Server=SQL2016DEV;Database=MoonPro;Trusted_Connection=True;MultipleActiveResultSets=true",
"MP.Land": "Server=SQL2016DEV;Database=MoonPro;User ID=sa;Password=keyhammer16;integrated security=False;MultipleActiveResultSets=True;App=MP.Land;",
diff --git a/MP.Land/wwwroot/img/LogoBluGreen.png b/MP.Land/wwwroot/img/LogoBluGreen.png
new file mode 100644
index 00000000..0f58f814
Binary files /dev/null and b/MP.Land/wwwroot/img/LogoBluGreen.png differ
diff --git a/MP.Land/wwwroot/img/LogoMapoFull.png b/MP.Land/wwwroot/img/LogoMapoFull.png
new file mode 100644
index 00000000..3d766f04
Binary files /dev/null and b/MP.Land/wwwroot/img/LogoMapoFull.png differ