From 417aaa9d28e88b9b406080b415ba6179d2d71dfe Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Tue, 22 Oct 2024 18:37:30 +0200 Subject: [PATCH] PROG - fix gestione display versioni fix update in selezione --- MP.FileData/Controllers/FileController.cs | 38 +++++++ MP.Prog/Components/DiffView.razor | 11 +- MP.Prog/Components/DiffView.razor.cs | 21 ++-- MP.Prog/Components/FileEditor.razor | 97 ++++++++++++----- MP.Prog/Components/FileEditor.razor.cs | 120 ++++++++++++++++++++-- MP.Prog/Components/TagSearch.razor | 2 +- MP.Prog/Data/FileArchDataService.cs | 11 ++ MP.Prog/MP.Prog.csproj | 2 +- MP.Prog/Pages/Archive.razor | 23 ++--- MP.Prog/Resources/ChangeLog.html | 2 +- MP.Prog/Resources/VersNum.txt | 2 +- MP.Prog/Resources/manifest.xml | 2 +- MP.Prog/appsettings.Development.json | 2 +- 13 files changed, 267 insertions(+), 66 deletions(-) diff --git a/MP.FileData/Controllers/FileController.cs b/MP.FileData/Controllers/FileController.cs index acdb8df1..3cea0400 100644 --- a/MP.FileData/Controllers/FileController.cs +++ b/MP.FileData/Controllers/FileController.cs @@ -331,6 +331,11 @@ namespace MP.FileData.Controllers return done; } + /// + /// Cerca il file x chiave ID + /// + /// + /// public FileModel FileGetByKey(int FileId) { FileModel thisFile = null; @@ -344,6 +349,39 @@ namespace MP.FileData.Controllers return thisFile; } + /// + /// Cerca un file dato un fice successivo specificando rev richiesta) + /// + /// + /// + /// + public FileModel FileGetByKeyRev(int FileId, int Rev) + { + FileModel oFile = null; + FileModel tFile = null; + using (MoonPro_ProgContext localDbCtx = new MoonPro_ProgContext(_configuration)) + { + oFile = localDbCtx + .DbSetProgFile + .Where(x => x.FileId == FileId) + .FirstOrDefault(); + // se la rev è diversa --> la cerco! + if (oFile.Rev == Rev) + { + tFile = oFile; + } + else + { + tFile = localDbCtx + .DbSetProgFile + .Where(x => x.Name == oFile.Name && x.IdxMacchina == oFile.IdxMacchina && x.Path == oFile.Path) + .FirstOrDefault(); + } + } + return tFile; + } + + public List FileGetByPath(string path, bool onlyActive) { List dbResult = new List(); diff --git a/MP.Prog/Components/DiffView.razor b/MP.Prog/Components/DiffView.razor index f1c3b368..76624666 100644 --- a/MP.Prog/Components/DiffView.razor +++ b/MP.Prog/Components/DiffView.razor @@ -6,7 +6,7 @@
-

Archivio

+

@OldTitle

@@ -18,7 +18,14 @@
-

Attuale

+ @if(CompareVers) + { +

@NewTitle

+ } + else + { +

@NewTitle

+ }
diff --git a/MP.Prog/Components/DiffView.razor.cs b/MP.Prog/Components/DiffView.razor.cs index 73e490dc..098e1d94 100644 --- a/MP.Prog/Components/DiffView.razor.cs +++ b/MP.Prog/Components/DiffView.razor.cs @@ -12,23 +12,32 @@ namespace MP.Prog.Components { #region Public Properties + [Parameter] + public bool CompareVers { get; set; } = false; + [Parameter] public EventCallback diffDone { get; set; } [Parameter] - public string newText + public string NewText { get => _newText; set => _newText = value; } [Parameter] - public string oldText + public string NewTitle { get; set; } = "Attuale"; + + [Parameter] + public string OldText { get => _oldText; set => _oldText = value; } + [Parameter] + public string OldTitle { get; set; } = "Archivio"; + #endregion Public Properties #region Protected Fields @@ -69,7 +78,7 @@ namespace MP.Prog.Components numChanges = 0; // calcolo diff diff_match_patch dmp = new diff_match_patch(); - List diff = dmp.diff_main(oldText, newText); + List diff = dmp.diff_main(OldText, NewText); //List diff = dmp.diff_main(oldTextFix, newTextFix); dmp.diff_cleanupSemantic(diff); @@ -86,12 +95,12 @@ namespace MP.Prog.Components switch (item.operation) { case Operation.DELETE: - sbOld.Append($"{HttpUtility.HtmlEncode(item.text)}"); + sbOld.Append($"{HttpUtility.HtmlEncode(item.text)}"); numChanges++; break; case Operation.INSERT: - sbNew.Append($"{HttpUtility.HtmlEncode(item.text)}"); + sbNew.Append($"{HttpUtility.HtmlEncode(item.text)}"); numChanges++; break; @@ -129,8 +138,6 @@ namespace MP.Prog.Components string fixVal = origVal.Trim() .Replace(" ", "  ") .Replace(Environment.NewLine, sepDest); - //.Replace("\r", sepDest) - //.Replace("\n", sepDest); return new MarkupString(fixVal); } diff --git a/MP.Prog/Components/FileEditor.razor b/MP.Prog/Components/FileEditor.razor index be370606..8f4b4f58 100644 --- a/MP.Prog/Components/FileEditor.razor +++ b/MP.Prog/Components/FileEditor.razor @@ -1,43 +1,86 @@ 
-
-
+
+
-

Dettaglio modifiche

+
+
+

Dettaglio modifiche

+
+
- @if (_currItem.Active) - { - @if (_currItem.DiskStatus != FileData.FileState.Ok) +
+ @if (_currItem.Rev > 0) { -
-
- +
+ @if (CompareRev) + { +
+ SX + + DX + + +
+ } + else + { + + } +
+ } + @if (_currItem.Active) + { + @if (_currItem.DiskStatus != FileData.FileState.Ok) + { +
+
+
+ +
+
+ +
+
-
- + } + } + else + { +
+
+
+ +
+
+
} - } - else - { -
-
- -
-
-
-
- } +
-
-
-
- +
+
- +
\ No newline at end of file diff --git a/MP.Prog/Components/FileEditor.razor.cs b/MP.Prog/Components/FileEditor.razor.cs index 20f5e634..b8fc6a45 100644 --- a/MP.Prog/Components/FileEditor.razor.cs +++ b/MP.Prog/Components/FileEditor.razor.cs @@ -47,6 +47,86 @@ namespace MP.Prog.Components #endregion Public Properties + private bool CompareRev = false; + protected int SelRevSx + { + get => _selRevSx; + set + { + if (_selRevSx != value) + { + _selRevSx = value; + // ricarico file SX + var pUpd = Task.Run(async () => + { + await LoadRevision(); + }); + pUpd.Wait(); + FixTitles(); + } + } + } + protected int SelRevDx + { + get => _selRevDx; + set + { + if (_selRevDx != value) + { + _selRevDx = value; + // ricarico file DX + var pUpd = Task.Run(async () => + { + await LoadRevision(); + }); + pUpd.Wait(); + FixTitles(); + } + } + } + private int _selRevSx = 0; + private int _selRevDx = 0; + + private List ListRevSx + { + get + { + List answ = new List() { 0 }; + for (int i = 1; i < SelRevDx; i++) + { + answ.Add(i); + } + return answ; + } + } + private List ListRevDx + { + get + { + List answ = new List(); + for (int i = 0; i <= _currItem.Rev; i++) + { + answ.Add(i); + } + return answ; + } + } + + + private async Task DoCompare() + { + CompareRev = !CompareRev; + await LoadRevision(); + FixTitles(); + } + + private void FixTitles() + { + // sistemo titoli + TitleSx = CompareRev ? $"Rev. {SelRevSx}" : "Archivio"; + TitleDx = CompareRev ? $"Rev. {SelRevDx}" : "Attuale"; + } + #region Public Methods public string CurrFileContent(string fullPath) @@ -91,12 +171,6 @@ namespace MP.Prog.Components #endregion Protected Methods - //private string userName = ""; - //protected override void OnInitialized() - //{ - // userName = MServ.UserName; - //} - #region Private Methods private async Task ApproveChange() @@ -150,7 +224,7 @@ namespace MP.Prog.Components await DataReset.InvokeAsync(0); await FDService.FileExport(_currItem); await DataReset.InvokeAsync(0); - await FDService.UpdateMachineArchive(_currItem.IdxMacchina, 1, false, false,MServ.UserName); + await FDService.UpdateMachineArchive(_currItem.IdxMacchina, 1, false, false, MServ.UserName); await DataUpdated.InvokeAsync(1); } else @@ -188,6 +262,38 @@ namespace MP.Prog.Components } } + private string FileContSx { get; set; } = ""; + private string FileContDx { get; set; } = ""; + + private string TitleSx { get; set; } = "Archivio"; + private string TitleDx { get; set; } = "Attuale"; + + + protected override void OnParametersSet() + { + FileContSx = _currItem.FileStringContent; + FileContDx = CurrFileContent(_currItem.Path); + SelRevDx = _currItem.Rev; + FixTitles(); + } + + private async Task LoadRevision() + { + if (CompareRev) + { + var reqSx = await FDService.FileGetByKeyRev(_currItem.FileId, SelRevSx); + var reqDx = await FDService.FileGetByKeyRev(_currItem.FileId, SelRevDx); + FileContSx = reqSx.FileStringContent; + FileContDx = reqDx.FileStringContent; + } + else + { + FileContSx = _currItem.FileStringContent; + FileContDx = CurrFileContent(_currItem.Path); + } + FixTitles(); + } + #endregion Private Methods } } \ No newline at end of file diff --git a/MP.Prog/Components/TagSearch.razor b/MP.Prog/Components/TagSearch.razor index d1bf7e85..c16def20 100644 --- a/MP.Prog/Components/TagSearch.razor +++ b/MP.Prog/Components/TagSearch.razor @@ -14,7 +14,7 @@
- @if (TagList != null) { foreach (var item in TagList) diff --git a/MP.Prog/Data/FileArchDataService.cs b/MP.Prog/Data/FileArchDataService.cs index e5a352af..c01312cc 100644 --- a/MP.Prog/Data/FileArchDataService.cs +++ b/MP.Prog/Data/FileArchDataService.cs @@ -169,6 +169,17 @@ namespace MP.Prog.Data { return Task.FromResult(dbController.FileGetByKey(FileId)); } + /// + /// Restituisce il file dato un ID + revisione + /// cerca a pari nome, macchina + REV specifica) + /// + /// Id del file originale + /// Rev specifica richiesta + /// + public Task FileGetByKeyRev(int FileId, int Rev) + { + return Task.FromResult(dbController.FileGetByKeyRev(FileId, Rev)); + } public async Task> FileGetFilt(SelectData CurrFilter) { diff --git a/MP.Prog/MP.Prog.csproj b/MP.Prog/MP.Prog.csproj index 5c77f33a..6aa9bb42 100644 --- a/MP.Prog/MP.Prog.csproj +++ b/MP.Prog/MP.Prog.csproj @@ -3,7 +3,7 @@ net6.0 MP.Prog - 6.16.2410.2211 + 6.16.2410.2218 diff --git a/MP.Prog/Pages/Archive.razor b/MP.Prog/Pages/Archive.razor index 2039d0c7..dfeeeedc 100644 --- a/MP.Prog/Pages/Archive.razor +++ b/MP.Prog/Pages/Archive.razor @@ -123,18 +123,7 @@ { - @if (currRecord == null) - { - - } - else - { - - } +
@@ -150,11 +139,11 @@ @record.Rev
- - - @record.DiskStatus - - + + + @record.DiskStatus + +
@CalcSize(record.Size) diff --git a/MP.Prog/Resources/ChangeLog.html b/MP.Prog/Resources/ChangeLog.html index b2c82f16..b605f0cc 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.2211

+

Versione: 6.16.2410.2218


Note di rilascio:
    diff --git a/MP.Prog/Resources/VersNum.txt b/MP.Prog/Resources/VersNum.txt index 608c2973..ec69c37d 100644 --- a/MP.Prog/Resources/VersNum.txt +++ b/MP.Prog/Resources/VersNum.txt @@ -1 +1 @@ -6.16.2410.2211 +6.16.2410.2218 diff --git a/MP.Prog/Resources/manifest.xml b/MP.Prog/Resources/manifest.xml index bfe55f7a..a5145f6a 100644 --- a/MP.Prog/Resources/manifest.xml +++ b/MP.Prog/Resources/manifest.xml @@ -1,6 +1,6 @@ - 6.16.2410.2211 + 6.16.2410.2218 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 diff --git a/MP.Prog/appsettings.Development.json b/MP.Prog/appsettings.Development.json index 9645b0c6..fb218b9a 100644 --- a/MP.Prog/appsettings.Development.json +++ b/MP.Prog/appsettings.Development.json @@ -1,5 +1,5 @@ { - //"DetailedErrors": true, + "DetailedErrors": true, "Logging": { "LogLevel": { "Default": "Information",