diff --git a/MP.FileData/MeasureUtils.cs b/MP.FileData/MeasureUtils.cs
new file mode 100644
index 00000000..14a9384f
--- /dev/null
+++ b/MP.FileData/MeasureUtils.cs
@@ -0,0 +1,53 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MP.FileData
+{
+ public class MeasureUtils
+ {
+ #region Public Fields
+
+ public static readonly string[] SizeSuffixes = { "b", "Kb", "Mb", "Gb", "Tb", "Pb", "Eb", "Zb", "Yb" };
+
+ #endregion Public Fields
+
+ #region Public Methods
+
+ ///
+ /// Calcola dimensione file automaticamwente secondo dimensione
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static string SizeSuffix(Int64 value, int decimalPlaces = 1)
+ {
+ if (decimalPlaces < 0) { throw new ArgumentOutOfRangeException("decimalPlaces"); }
+ if (value < 0) { return "-" + SizeSuffix(-value, decimalPlaces); }
+ if (value == 0) { return string.Format("{0:n" + decimalPlaces + "} bytes", 0); }
+
+ // mag is 0 for bytes, 1 for KB, 2, for MB, etc.
+ int mag = (int)Math.Log(value, 1024);
+
+ // 1L << (mag * 10) == 2 ^ (10 * mag) [i.e. the number of bytes in the unit
+ // corresponding to mag]
+ decimal adjustedSize = (decimal)value / (1L << (mag * 10));
+
+ // make adjustment when the value is large enough that it would round up to 1000 or more
+ if (Math.Round(adjustedSize, decimalPlaces) >= 1000)
+ {
+ mag += 1;
+ adjustedSize /= 1024;
+ }
+
+ return string.Format("{0:n" + decimalPlaces + "} {1}",
+ adjustedSize,
+ SizeSuffixes[mag]);
+ }
+
+ #endregion Public Methods
+ }
+}
\ No newline at end of file
diff --git a/MP.Prog/Components/DiffView.razor b/MP.Prog/Components/DiffView.razor
index 600ec22d..af2aab1c 100644
--- a/MP.Prog/Components/DiffView.razor
+++ b/MP.Prog/Components/DiffView.razor
@@ -31,119 +31,13 @@
-
@((MarkupString)oldResult)
+
@((MarkupString)StrFix(oldResult))
-
@((MarkupString)newResult)
+
@((MarkupString)StrFix(newResult))
-@code {
-
- string sepDest = "
";
-
- protected int pHeight = 25;
-
- protected string oldResult = "";
- protected string newResult = "";
-
- protected string _oldText = "";
- protected string _newText = "";
-
- [Parameter]
- public EventCallback diffDone { get; set; }
-
- protected int numChanges { get; set; } = 0;
-
- [Parameter]
- public string oldText
- {
- get
- {
- return _oldText;
- }
- set
- {
- _oldText = value;
- }
- }
-
- protected string oldTextFix
- {
- get
- {
- return _oldText.Replace(" ", " ").Replace(Environment.NewLine, sepDest).Replace("\n", sepDest).Replace("\r", sepDest);
- }
- }
-
- protected string newTextFix
- {
- get
- {
- return _newText.Replace(" ", " ").Replace(Environment.NewLine, sepDest).Replace("\n", sepDest).Replace("\r", sepDest);
- }
- }
- [Parameter]
- public string newText
- {
- get
- {
- return _newText;
- }
- set
- {
- _newText = value;
- ReloadData();
- }
- }
- protected void ReloadData()
- {
- numChanges = 0;
- // calcolo diff
- diff_match_patch dmp = new diff_match_patch();
- List diff = dmp.diff_main(oldTextFix, newTextFix);
- dmp.diff_cleanupSemantic(diff);
-
- // predispongo la stringa secondo l'elenco dei diff....
- StringBuilder sbNew = new StringBuilder();
- StringBuilder sbOld = new StringBuilder();
- foreach (var item in diff)
- {
- switch (item.operation)
- {
- case Operation.DELETE:
- sbOld.Append($"{item.text}");
- numChanges++;
- break;
- case Operation.INSERT:
- sbNew.Append($"{item.text}");
- numChanges++;
- break;
- case Operation.EQUAL:
- sbNew.Append($"{item.text}");
- sbOld.Append($"{item.text}");
- break;
- default:
- break;
- }
- }
-
- newResult = sbNew.ToString().Trim();
- oldResult = sbOld.ToString().Trim();
- var pUpd = Task.Run(async () =>
- {
- await diffDone.InvokeAsync(numChanges);
- });
- pUpd.Wait();
- }
-
- protected override Task OnInitializedAsync()
- {
- ReloadData();
- return base.OnInitializedAsync();
- }
-
-}
\ No newline at end of file
diff --git a/MP.Prog/Components/DiffView.razor.cs b/MP.Prog/Components/DiffView.razor.cs
new file mode 100644
index 00000000..7b9ce7b8
--- /dev/null
+++ b/MP.Prog/Components/DiffView.razor.cs
@@ -0,0 +1,128 @@
+using DiffMatchPatch;
+using Microsoft.AspNetCore.Components;
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MP.Prog.Components
+{
+ public partial class DiffView
+ {
+ #region Public Properties
+
+ [Parameter]
+ public EventCallback diffDone { get; set; }
+
+ [Parameter]
+ public string newText
+ {
+ get => _newText;
+ set => _newText = value;
+ }
+
+ [Parameter]
+ public string oldText
+ {
+ get => _oldText;
+ set => _oldText = value;
+ }
+
+ #endregion Public Properties
+
+ #region Protected Fields
+
+ protected string _newText = "";
+
+ protected string _oldText = "";
+
+ protected string newResult = "";
+
+ protected string oldResult = "";
+
+ protected int pHeight = 25;
+
+ #endregion Protected Fields
+
+ #region Protected Properties
+
+ protected int numChanges { get; set; } = 0;
+
+ #endregion Protected Properties
+
+ #region Protected Methods
+
+ protected override Task OnInitializedAsync()
+ {
+ ReloadData();
+ return base.OnInitializedAsync();
+ }
+
+ protected override void OnParametersSet()
+ {
+ ReloadData();
+ }
+
+ protected void ReloadData()
+ {
+ numChanges = 0;
+ // calcolo diff
+ diff_match_patch dmp = new diff_match_patch();
+ List diff = dmp.diff_main(oldText, newText);
+ //List diff = dmp.diff_main(oldTextFix, newTextFix);
+ dmp.diff_cleanupSemantic(diff);
+
+ // predispongo la stringa secondo l'elenco dei diff....
+ StringBuilder sbNew = new StringBuilder();
+ StringBuilder sbOld = new StringBuilder();
+ foreach (var item in diff)
+ {
+ switch (item.operation)
+ {
+ case Operation.DELETE:
+ sbOld.Append($"{item.text}");
+ numChanges++;
+ break;
+
+ case Operation.INSERT:
+ sbNew.Append($"{item.text}");
+ numChanges++;
+ break;
+
+ case Operation.EQUAL:
+ sbNew.Append($"{item.text}");
+ sbOld.Append($"{item.text}");
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ newResult = sbNew.ToString().Trim();
+ oldResult = sbOld.ToString().Trim();
+ var pUpd = Task.Run(async () =>
+ {
+ await diffDone.InvokeAsync(numChanges);
+ });
+ pUpd.Wait();
+ }
+
+ #endregion Protected Methods
+
+ #region Private Fields
+
+ private string sepDest = "
";
+
+ #endregion Private Fields
+
+ #region Private Methods
+
+ private string StrFix(string origVal)
+ {
+ return origVal.Replace(" ", " ").Replace(Environment.NewLine, sepDest).Replace("\n", sepDest).Replace("\r", sepDest);
+ }
+
+ #endregion Private Methods
+ }
+}
\ No newline at end of file
diff --git a/MP.Prog/Components/FileEditor.razor b/MP.Prog/Components/FileEditor.razor
index 03f788a7..be370606 100644
--- a/MP.Prog/Components/FileEditor.razor
+++ b/MP.Prog/Components/FileEditor.razor
@@ -11,10 +11,10 @@
{
-
+
-
+
}
@@ -23,7 +23,7 @@
{
-
+
@@ -33,11 +33,11 @@
-
+
-
+
\ No newline at end of file
diff --git a/MP.Prog/MP.Prog.csproj b/MP.Prog/MP.Prog.csproj
index de16f6e2..1bde64d9 100644
--- a/MP.Prog/MP.Prog.csproj
+++ b/MP.Prog/MP.Prog.csproj
@@ -3,7 +3,7 @@
net6.0
MP.Prog
- 6.16.2410.2120
+ 6.16.2410.2210
diff --git a/MP.Prog/Pages/Archive.razor b/MP.Prog/Pages/Archive.razor
index e4b457ab..a38313e0 100644
--- a/MP.Prog/Pages/Archive.razor
+++ b/MP.Prog/Pages/Archive.razor
@@ -150,7 +150,7 @@
@record.Rev
- @((((double)record.Size) / 1024).ToString("N2")) k
+ @CalcSize(record.Size)
|
diff --git a/MP.Prog/Pages/Archive.razor.cs b/MP.Prog/Pages/Archive.razor.cs
index 22fae417..affad72a 100644
--- a/MP.Prog/Pages/Archive.razor.cs
+++ b/MP.Prog/Pages/Archive.razor.cs
@@ -1,5 +1,6 @@
using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;
+using MP.FileData;
using MP.FileData.DatabaseModels;
using MP.Prog.Data;
using NLog;
@@ -293,26 +294,26 @@ namespace MP.Prog.Pages
return answ;
}
- private string cssStatusByCod(FileData.FileState currStatus)
+ private string cssStatusByCod(FileState currStatus)
{
string answ = "badge";
switch (currStatus)
{
- case FileData.FileState.Changed:
- answ += " badge-warning";
+ case FileState.Changed:
+ answ += " text-bg-warning";
break;
- case FileData.FileState.Deleted:
- answ += " badge-danger";
+ case FileState.Deleted:
+ answ += " text-bg-danger";
break;
- case FileData.FileState.Ok:
- answ += " badge-success";
+ case FileState.Ok:
+ answ += " text-bg-success";
break;
- case FileData.FileState.ND:
+ case FileState.ND:
default:
- answ += " badge-light";
+ answ += " text-bg-light";
break;
}
return answ;
@@ -366,6 +367,16 @@ namespace MP.Prog.Pages
isLoading = false;
}
+ ///
+ /// Restituisce size calcolata
+ ///
+ ///
+ ///
+ protected string CalcSize(long origSize)
+ {
+ return MeasureUtils.SizeSuffix(origSize, 1);
+ }
+
protected async Task FilterTag(string searchVal)
{
SelTag = searchVal;
diff --git a/MP.Prog/Resources/ChangeLog.html b/MP.Prog/Resources/ChangeLog.html
index 414f0fd9..bbb1bb4e 100644
--- a/MP.Prog/Resources/ChangeLog.html
+++ b/MP.Prog/Resources/ChangeLog.html
@@ -1,6 +1,6 @@
Modulo gestione Programmi MAPO
- Versione: 6.16.2410.2120
+ Versione: 6.16.2410.2210
Note di rilascio:
diff --git a/MP.Prog/Resources/VersNum.txt b/MP.Prog/Resources/VersNum.txt
index 2fd4f529..ce5039c4 100644
--- a/MP.Prog/Resources/VersNum.txt
+++ b/MP.Prog/Resources/VersNum.txt
@@ -1 +1 @@
-6.16.2410.2120
+6.16.2410.2210
diff --git a/MP.Prog/Resources/manifest.xml b/MP.Prog/Resources/manifest.xml
index 94b2e066..08d26d10 100644
--- a/MP.Prog/Resources/manifest.xml
+++ b/MP.Prog/Resources/manifest.xml
@@ -1,6 +1,6 @@
-
- 6.16.2410.2120
+ 6.16.2410.2210
https://nexus.steamware.net/repository/SWS/MP-PROG/stable/LAST/MP.Prog.zip
https://nexus.steamware.net/repository/SWS/MP-PROG/stable/LAST/ChangeLog.html
false
|