diff --git a/MP.Land/Pages/About.razor.cs b/MP.Land/Pages/About.razor.cs
index be225631..c18f570c 100644
--- a/MP.Land/Pages/About.razor.cs
+++ b/MP.Land/Pages/About.razor.cs
@@ -1,11 +1,21 @@
+using Microsoft.AspNetCore.Components;
+using MP.Land.Data;
using NLog;
using System;
+using System.Net.NetworkInformation;
using System.Threading.Tasks;
namespace MP.Land.Pages
{
public partial class About
{
+
+
+
+ [Inject]
+ protected MessageService AppMService { get; set; } = null!;
+ [Inject]
+ protected LicenseService LicServ{get;set;}=null!;
#region Protected Methods
protected override async Task OnInitializedAsync()
diff --git a/MP.Land/Pages/UpdateManager.razor.cs b/MP.Land/Pages/UpdateManager.razor.cs
index ae02e862..63ab72d0 100644
--- a/MP.Land/Pages/UpdateManager.razor.cs
+++ b/MP.Land/Pages/UpdateManager.razor.cs
@@ -7,6 +7,7 @@ using MP.Land.Data;
using System;
using System.Collections.Generic;
using System.Diagnostics;
+using System.Drawing;
using System.IO;
using System.Linq;
using System.Reflection;
@@ -18,6 +19,32 @@ namespace MP.Land.Pages
{
#region Public Methods
+ ///
+ /// Procedura di aggiunta folder a ZipFile, ricorsiva
+ ///
+ ///
+ ///
+ ///
+ public void AddFolderToZip(ZipFile f, string root, string folder)
+ {
+ string relative = folder.Substring(root.Length);
+ if (relative.Length > 0)
+ {
+ f.AddDirectory(relative);
+ }
+
+ foreach (string file in Directory.GetFiles(folder))
+ {
+ relative = file.Substring(root.Length);
+ f.Add(file, relative);
+ }
+
+ foreach (string subFolder in Directory.GetDirectories(folder))
+ {
+ this.AddFolderToZip(f, root, subFolder);
+ }
+ }
+
public void Dispose()
{
ListRecords = null;
@@ -59,6 +86,9 @@ namespace MP.Land.Pages
protected bool showProgress { get; set; } = false;
protected bool showUpdate { get; set; } = false;
+ [Inject]
+ protected SyncService SyncServ { get; set; } = null!;
+
#endregion Protected Properties
#region Protected Methods
@@ -174,8 +204,8 @@ namespace MP.Land.Pages
authList.Add(item);
}
}
- // numero app + IOB + ZIP
- numTot = authList.Count + 2;
+ // numero app + IOB + DB + ZIP
+ numTot = authList.Count + 3;
// recupero conf files
foreach (var item in authList)
@@ -187,9 +217,11 @@ namespace MP.Land.Pages
}
// recupero i file IOB
RecuperaIobConf();
+ // salvo Tab Db come json
+ SaveDbConfAsJson();
// ora creo il file zip
- await PrepareZip();
+ PrepareZip();
// effettuo upload
await UploadZip();
@@ -212,12 +244,18 @@ namespace MP.Land.Pages
#endregion Private Fields
#region Private Properties
+
#if DEBUG
private DirectoryInfo AppDir => new DirectoryInfo(Path.Combine("\\\\iis01.egalware.com", "c$\\inetpub\\wwwroot\\MP\\LAND"));
#else
private DirectoryInfo AppDir => new DirectoryInfo(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location));
#endif
+ ///
+ /// Nome del file ZIP da gestire
+ ///
+ private string zFileName => Path.Combine(AppDir.FullName, "temp", "zip", "MAPO.zip");
+
#endregion Private Properties
#region Private Methods
@@ -225,126 +263,22 @@ namespace MP.Land.Pages
///
/// Preparazione ZIP con password = AuthKey
///
- private async Task PrepareZip()
+ private void PrepareZip()
{
string srcPath = Path.Combine(AppDir.FullName, "temp", "orig");
string destPath = Path.Combine(AppDir.FullName, "temp", "zip");
- if(!Directory.Exists(destPath))
+ if (!Directory.Exists(destPath))
{
Directory.CreateDirectory(destPath);
}
- string zFile = Path.Combine(AppDir.FullName, "temp", "zip", "MAPO.zip");
-
-#if false
- ZipDirectory(folderName, zFile, 9);
- await Task.Delay(1);
-
-#endif
- using (ZipFile zipFile = ZipFile.Create(zFile))
+ using (ZipFile zipFile = ZipFile.Create(zFileName))
{
+ zipFile.Password = LicServ.MasterKey;
zipFile.BeginUpdate();
- addFolderToZip(zipFile, srcPath, srcPath);
+ AddFolderToZip(zipFile, srcPath, srcPath);
zipFile.CommitUpdate();
zipFile.Close();
}
-
-
- }
-
- public void addFolderToZip(ZipFile f, string root, string folder)
- {
-
- string relative = folder.Substring(root.Length);
- if (relative.Length > 0)
- {
- f.AddDirectory(relative);
- }
-
- foreach (string file in Directory.GetFiles(folder))
- {
- relative = file.Substring(root.Length);
- f.Add(file, relative);
- }
-
- foreach (string subFolder in Directory.GetDirectories(folder))
- {
- this.addFolderToZip(f, root, subFolder);
- }
- }
-
- ///
- /// Method that compress all the files inside a folder (non-recursive) into a zip file.
- ///
- ///
- ///
- ///
- private void ZipDirectory(string DirectoryPath, string OutputFilePath, int CompressionLevel = 9)
- {
- try
- {
- // Depending on the directory this could be very large and would require more attention
- // in a commercial package.
- string[] filenames = Directory.GetFiles(DirectoryPath);
-
- // 'using' statements guarantee the stream is closed properly which is a big source
- // of problems otherwise. Its exception safe as well which is great.
- using (ZipOutputStream OutputStream = new ZipOutputStream(File.Create(OutputFilePath)))
- {
-
- // Define the compression level
- // 0 - store only to 9 - means best compression
- OutputStream.SetLevel(CompressionLevel);
-
- byte[] buffer = new byte[4096];
-
- foreach (string file in filenames)
- {
-
- // Using GetFileName makes the result compatible with XP
- // as the resulting path is not absolute.
- ZipEntry entry = new ZipEntry(Path.GetFileName(file));
-
- // Setup the entry data as required.
-
- // Crc and size are handled by the library for seakable streams
- // so no need to do them here.
-
- // Could also use the last write time or similar for the file.
- entry.DateTime = DateTime.Now;
- OutputStream.PutNextEntry(entry);
-
- using (FileStream fs = File.OpenRead(file))
- {
-
- // Using a fixed size buffer here makes no noticeable difference for output
- // but keeps a lid on memory usage.
- int sourceBytes;
-
- do
- {
- sourceBytes = fs.Read(buffer, 0, buffer.Length);
- OutputStream.Write(buffer, 0, sourceBytes);
- } while (sourceBytes > 0);
- }
- }
-
- // Finish/Close arent needed strictly as the using statement does this automatically
-
- // Finish is important to ensure trailing information for a Zip file is appended. Without this
- // the created file would be invalid.
- OutputStream.Finish();
-
- // Close is important to wrap things up and unlock the file.
- OutputStream.Close();
-
- Console.WriteLine("Files successfully compressed");
- }
- }
- catch (Exception ex)
- {
- // No need to rethrow the exception as for our purposes its handled.
- Console.WriteLine("Exception during processing {0}", ex);
- }
}
///
@@ -423,6 +357,46 @@ namespace MP.Land.Pages
}
}
+ ///
+ /// Salvataggio tabelle di configurazione specifica come tracciati json
+ ///
+ ///
+ private void SaveDbConfAsJson()
+ {
+ long size = 0;
+
+ string dstDir = Path.Combine(AppDir.FullName, "temp", "orig", "DB");
+ if (!Directory.Exists(dstDir))
+ {
+ Directory.CreateDirectory(dstDir);
+ }
+ // va fatta 1:1 per ogni tabella
+
+#if false
+ string srcIobDir = Path.Combine(AppDir.Parent.FullName, "IO", "fileUpload");
+ // recupero elenco files tipo appsettings*.json
+ if (Directory.Exists(srcIobDir))
+ {
+ var dirInfo = new DirectoryInfo(srcIobDir);
+ // recupero files CORE
+ List fileList = dirInfo.GetFiles().ToList();
+ // procedo!
+ foreach (var file in fileList)
+ {
+ string fileDestPath = Path.Combine(dstDir, file.Name);
+ file.CopyTo(fileDestPath, true);
+ size += file.Length;
+ }
+ }
+#endif
+
+ numDone++;
+ percLoading = 100 * numDone / numTot;
+ TotalMb += size;
+ outMessages = $"Configurazioni preparate: {numDone}/{numTot} | {CalcSize(TotalMb)}";
+ }
+
+
///
/// Effettua download di una singola app
///
@@ -449,13 +423,14 @@ namespace MP.Land.Pages
///
///
///
- private async Task UploadZip()
+ private async Task
UploadZip()
{
- await Task.Delay(200);
+ // chiamo SendZipFile di SyncService...
+ FileInfo zFileInfo = new FileInfo(zFileName);
+ var fatto = await SyncServ.SendZipFile(LicServ.Applicazione, LicServ.Installazione, true, false, zFileInfo);
+ return fatto;
}
#endregion Private Methods
-
-
}
}
\ No newline at end of file
diff --git a/MP.Land/Resources/ChangeLog.html b/MP.Land/Resources/ChangeLog.html
index 99342e44..06b7ca50 100644
--- a/MP.Land/Resources/ChangeLog.html
+++ b/MP.Land/Resources/ChangeLog.html
@@ -1,6 +1,6 @@
Modulo Tablet MAPO - DotNet6
- Versione: 6.16.2410.1719
+ Versione: 6.16.2410.1815
Note di rilascio:
diff --git a/MP.Land/Resources/VersNum.txt b/MP.Land/Resources/VersNum.txt
index 8021a159..aa74da27 100644
--- a/MP.Land/Resources/VersNum.txt
+++ b/MP.Land/Resources/VersNum.txt
@@ -1 +1 @@
-6.16.2410.1719
+6.16.2410.1815
diff --git a/MP.Land/Resources/manifest.xml b/MP.Land/Resources/manifest.xml
index c50f8022..63a924b1 100644
--- a/MP.Land/Resources/manifest.xml
+++ b/MP.Land/Resources/manifest.xml
@@ -1,6 +1,6 @@
-
- 6.16.2410.1719
+ 6.16.2410.1815
https://nexus.steamware.net/repository/SWS/MP-LAND/stable/LAST/MP.Land.zip
https://nexus.steamware.net/repository/SWS/MP-LAND/stable/LAST/ChangeLog.html
false