Merge branch 'Release/TaskExecMan06'

This commit is contained in:
Samuele Locatelli
2024-10-29 10:41:42 +01:00
23 changed files with 1094 additions and 337 deletions
+401 -53
View File
@@ -10,6 +10,7 @@ using System.Threading.Tasks;
using MP.FileData.DatabaseModels;
using Newtonsoft.Json;
using MP.FileData.DTO;
using System.Text.RegularExpressions;
namespace MP.FileData.Controllers
{
@@ -121,29 +122,15 @@ namespace MP.FileData.Controllers
{
Log.Info($"CheckFileArchived S00 | macchina: {idxMacchina} | path: {path} | pattern: {searchPattern} | # ExcludedFileExt: {currRule.ExcludedFileExt.Count()}");
int checkDone = 0;
DirectoryInfo dirInfo = new DirectoryInfo(path);
FileInfo[] fileListRaw = dirInfo.GetFiles(searchPattern, SearchOption.AllDirectories);
List<FileInfo> fileList = new List<FileInfo>();
DateTime adesso = DateTime.Now;
// se ho un limite x giorni indietor x modifiche --> limito!
if (numDayPre > 0)
{
foreach (var item in fileListRaw)
{
if (adesso.Subtract(item.LastWriteTime).TotalDays <= numDayPre)
{
fileList.Add(item);
}
}
}
else
{
fileList = fileListRaw.ToList();
}
// leggo i files rispettando regole e filtri vari
fileList = GetFiltFileFromDisk(path, numDayPre, searchPattern, currRule, fileList);
Log.Debug($"CheckFileArchived S01 | file trovati: {fileList.Count()}");
List<FileInfo> fileNew = new List<FileInfo>();
List<FileModel> fileChecked = new List<FileModel>();
List<FileModel> fileMod = new List<FileModel>();
List<FileModel> fileDel = new List<FileModel>();
// recupera elenco file nel DB
List<FileModel> archivedFile = new List<FileModel>();
@@ -163,7 +150,7 @@ namespace MP.FileData.Controllers
Log.Debug($"CheckFileArchived S01.C | Recuperati {archivedFile.Count()} da DB per confronto");
using (System.Security.Cryptography.MD5 md5 = System.Security.Cryptography.MD5.Create())
{
// verifica i file
// verifica i file partendo dal filesystem
foreach (var file in fileList)
{
// escludo i file con desinenza da escludere...
@@ -208,6 +195,28 @@ namespace MP.FileData.Controllers
}
}
}
// ora parto dal DB ed escludo quelli già mappati...
foreach (var fileDb in archivedFile)
{
// escludo i file con desinenza da escludere...
if (!string.IsNullOrEmpty(fileDb.Extension) && currRule.ExcludedFileExt.Contains(fileDb.Extension))
{
Log.Trace($"CheckFileArchived S02: escluso {fileDb.Name} | estensione {fileDb.Extension}");
}
else
{
// cerca nel filesystem...
var currRecord = fileList
.Where(x => fileDb.Path == x.FullName)
.FirstOrDefault();
// se NON trova lo crea
if (currRecord == null)
{
fileDel.Add(fileDb);
}
}
}
}
// salvo i NUOVI file
@@ -231,6 +240,13 @@ namespace MP.FileData.Controllers
FileSetChecked(fileChecked, path, currRule, forceTag);
Log.Trace($"CheckFileArchived S05 | refreshed {fileChecked.Count} files");
}
// indico infine i file modificati
if (fileDel != null && fileDel.Count > 0)
{
checkDone += fileDel.Count;
FileSetMissing(fileDel, path, currRule, false);
Log.Trace($"FileArchivedMissing S06 | missing {fileDel.Count} files");
}
Log.Info($"Effettuati {checkDone} controlli");
// svuoto
@@ -241,6 +257,200 @@ namespace MP.FileData.Controllers
// chiudo
return checkDone;
}
/// <summary>
/// Recupera file dal disco saltando eventuali math di esclusione e/o filtro date/nome file
/// </summary>
/// <param name="path"></param>
/// <param name="numDayPre"></param>
/// <param name="searchPattern"></param>
/// <param name="currRule"></param>
/// <param name="fileList"></param>
/// <returns></returns>
private static List<FileInfo> GetFiltFileFromDisk(string path, int numDayPre, string searchPattern, SearchRules currRule, List<FileInfo> fileList)
{
DirectoryInfo dirInfo = new DirectoryInfo(path);
var fileListRaw = dirInfo.GetFiles(searchPattern, SearchOption.AllDirectories).ToList();
List<FileInfo> file2Rem = new List<FileInfo>();
// se richiesto filtro i files esclusi da regexp li calcolo...
if (currRule.ExclFileEnabled)
{
foreach (var item in fileListRaw)
{
string pattern = currRule.ExclFileRegExPattern;
// uso regexp
MatchCollection hasMatch = Regex.Matches(item.Name, pattern);
if (hasMatch.Count > 0)
{
file2Rem.Add(item);
}
}
// quindi li rimuovo da elenco raw...
if (file2Rem.Count > 0)
{
foreach (var f2d in file2Rem)
{
fileListRaw.Remove(f2d);
}
}
}
DateTime adesso = DateTime.Now;
// se ho un limite x giorni indietro x modifiche --> limito!
if (numDayPre > 0)
{
foreach (var item in fileListRaw)
{
if (adesso.Subtract(item.LastWriteTime).TotalDays <= numDayPre)
{
fileList.Add(item);
}
}
}
else
{
fileList = fileListRaw.ToList();
}
return fileList;
}
/// <summary>
/// Effettua la comparazione tra i file in archivio ed i file attuali e segna info LastCheck
/// e Changed (se cambiati)
/// </summary>
/// <param name="idxMacchina">cod macchina</param>
/// <param name="FileList">Elenco dei files (su DB) da verificare</param>
/// <param name="path">path ricerca x macchina</param>
/// <param name="searchPattern">pattern di ricerca (*.*)</param>
/// <param name="forceTag">Forza il controllo dei Tags</param>
/// <param name="currRule">Regole di ricerca applicate</param>
/// <param name="UserName">Utente connesso x approvazione</param>
/// <param name="DoApprove">indica se vada approvata la modifica o lasciato "in sospeso"</param>
/// <returns></returns>
public int CheckFileListArchived(string idxMacchina, List<FileModel> FileList, string path, string searchPattern, bool forceTag, SearchRules currRule, string UserName, bool DoApprove)
{
Log.Info($"CheckFileListArchived S00 | macchina: {idxMacchina} | path: {path} | pattern: {searchPattern} | # ExcludedFileExt: {currRule.ExcludedFileExt.Count()}");
int checkDone = 0;
DirectoryInfo dirInfo = new DirectoryInfo(path);
FileInfo[] fileListRaw = null;
if (FileList.Count == 1)
{
// leggo il singolo... imposto il search pattern...
searchPattern = $"{FileList.FirstOrDefault().Name}";
fileListRaw = dirInfo.GetFiles(searchPattern, SearchOption.AllDirectories);
}
else
{
fileListRaw = dirInfo.GetFiles(searchPattern, SearchOption.AllDirectories);
}
List<FileInfo> fileList = new List<FileInfo>();
DateTime adesso = DateTime.Now;
// prendo tutti i files
fileList = fileListRaw.ToList();
Log.Debug($"CheckFileListArchived S01 | file trovati: {fileList.Count()}");
List<FileModel> fileChecked = new List<FileModel>();
List<FileModel> fileMod = new List<FileModel>();
List<FileModel> fileDel = new List<FileModel>();
// recupera elenco file nel DB
List<FileModel> archivedFile = new List<FileModel>();
List<FileModel> dbFileListRaw = FileGetByPath(path, true);
// preparo lista di interi
List<string> FilePathList = FileList.Select(x => x.Path).ToList();
// ora li filtro: prendo solo quelli che sono nell'elenco dei files da controllare...
List<FileModel> foundFile = dbFileListRaw.Where(x => FilePathList.Contains(x.Path)).ToList();
// rimuovo eventuali file con estensioni escluse...
foreach (var fRec in foundFile)
{
if (!string.IsNullOrEmpty(fRec.Extension) && currRule.ExcludedFileExt.Contains(fRec.Extension))
{
Log.Trace($"CheckFileListArchived S01.B: escluso {fRec.Name} | estensione {fRec.Extension}");
}
else
{
archivedFile.Add(fRec);
}
}
Log.Debug($"CheckFileListArchived S01.C | Recuperati {archivedFile.Count()} da DB per confronto");
using (System.Security.Cryptography.MD5 md5 = System.Security.Cryptography.MD5.Create())
{
// parto dal DB ed escludo quelli già mappati...
foreach (var fileDb in archivedFile)
{
// escludo i file con desinenza da escludere...
if (!string.IsNullOrEmpty(fileDb.Extension) && currRule.ExcludedFileExt.Contains(fileDb.Extension))
{
Log.Trace($"CheckFileListArchived S02: escluso {fileDb.Name} | estensione {fileDb.Extension}");
}
else
{
// cerca nel filesystem...
var currRecord = fileList
.Where(x => fileDb.Path == x.FullName)
.FirstOrDefault();
// se NON trova lo crea
if (currRecord == null)
{
fileDel.Add(fileDb);
}
else
{
// verifico se data modifica sia cambiata...
if (fileDb.LastMod != currRecord.LastWriteTime)
{
// calcolo e verifico MD5
var fileContent = File.ReadAllBytes(currRecord.FullName);
var hash = md5.ComputeHash(fileContent);
var newMD5 = BitConverter.ToString(hash).Replace("-", "").ToLowerInvariant();
if (newMD5 != fileDb.MD5)
{
fileMod.Add(fileDb);
}
else
{
fileChecked.Add(fileDb);
}
}
else
{
fileChecked.Add(fileDb);
}
}
}
}
}
// aggiorno i file modificati
if (fileMod != null && fileMod.Count > 0)
{
checkDone += fileMod.Count;
FileSetUpdated(fileMod);
Log.Trace($"CheckFileListArchived S04 | update {fileMod.Count} files");
}
// segno data-ora ultimo controllo x file invariati
if (fileChecked != null && fileChecked.Count > 0)
{
checkDone += fileChecked.Count;
FileSetChecked(fileChecked, path, currRule, forceTag);
Log.Trace($"CheckFileListArchived S05 | refreshed {fileChecked.Count} files");
}
// indico infine i file modificati
if (fileDel != null && fileDel.Count > 0)
{
checkDone += fileDel.Count;
FileSetMissing(fileDel, path, currRule, false);
Log.Trace($"FileArchivedMissing S06 | missing {fileDel.Count} files");
}
Log.Info($"Effettuati {checkDone} controlli");
// svuoto
fileChecked = new List<FileModel>();
fileMod = new List<FileModel>();
GC.Collect();
// chiudo
return checkDone;
}
public void Dispose()
{
@@ -335,6 +545,8 @@ namespace MP.FileData.Controllers
return done;
}
/// <summary>
/// Cerca il file x chiave ID
/// </summary>
@@ -353,6 +565,33 @@ namespace MP.FileData.Controllers
return thisFile;
}
/// <summary>
///recupera tutte le revisioni dato un singolo record, ordinate x REV descending
/// </summary>
/// <param name="FileId"></param>
/// <returns></returns>
public List<FileModel> FileGetAllRevByKey(int FileId)
{
List<FileModel> dbResult = new List<FileModel>();
using (MoonPro_ProgContext localDbCtx = new MoonPro_ProgContext(_configuration))
{
var thisRec = localDbCtx
.DbSetProgFile
.Where(x => x.FileId == FileId)
.FirstOrDefault();
if (thisRec != null)
{
dbResult = localDbCtx
.DbSetProgFile
.Where(x => x.Path == thisRec.Path)
.OrderByDescending(x => x.Rev)
.ToList();
}
}
return dbResult;
}
/// <summary>
/// Cerca un file dato un fice successivo specificando rev richiesta)
/// </summary>
@@ -378,14 +617,14 @@ namespace MP.FileData.Controllers
{
tFile = localDbCtx
.DbSetProgFile
.Where(x => x.Name == oFile.Name && x.IdxMacchina == oFile.IdxMacchina && x.Path == oFile.Path)
.Where(x => x.IdxMacchina == oFile.IdxMacchina && x.Path == oFile.Path && x.Rev == Rev)
//.Where(x => x.Name == oFile.Name && x.IdxMacchina == oFile.IdxMacchina && x.Path == oFile.Path)
.FirstOrDefault();
}
}
return tFile;
}
public List<FileModel> FileGetByPath(string path, bool onlyActive)
{
List<FileModel> dbResult = new List<FileModel>();
@@ -540,38 +779,6 @@ namespace MP.FileData.Controllers
return answ;
}
/// <summary>
/// Imposta utente approvazione + data modifica File
/// </summary>
/// <param name="currFile"></param>
/// <param name="UserName"></param>
/// <returns></returns>
public bool FileSetUserApp(FileModel currFile, string UserName)
{
bool done = false;
List<FileInfo> listUpdate = new List<FileInfo>();
using (MoonPro_ProgContext localDbCtx = new MoonPro_ProgContext(_configuration))
{
FileModel currRec = localDbCtx
.DbSetProgFile
.Where(x => x.FileId == currFile.FileId)
.FirstOrDefault();
if (currRec != null)
{
DateTime adesso = DateTime.Now;
currRec.UserAppr = UserName;
currRec.LastMod = adesso;
currRec.LastCheck = adesso;
//currFile.DiskStatus = FileState.Ok;
localDbCtx.Entry(currRec).State = EntityState.Modified;
// salvo DB
localDbCtx.SaveChanges();
}
}
return done;
}
/// <summary>
/// Approvazione modifica File
/// </summary>
@@ -756,6 +963,113 @@ namespace MP.FileData.Controllers
return answ;
}
/// <summary>
/// Effettua update di un record in archivio da lista (SOLO STATUS)
/// </summary>
/// <param name="missFiles">Elenco file MISSING</param>
/// <param name="basePath">Path base macchina</param>
/// <param name="currRule">Configuraizone ricerca</param>
/// <param name="forceTag">Indica se fare COMUNQUE verifica del TAG</param>
/// <returns></returns>
public bool FileSetMissing(List<FileModel> missFiles, string basePath, SearchRules currRule, bool forceTag)
{
bool answ = false;
DateTime adesso = DateTime.Now;
using (MoonPro_ProgContext localDbCtx = new MoonPro_ProgContext(_configuration))
{
// SOLO SE richiesto forzatura tags
if (forceTag)
{
// elenco Tags
List<TagModel> currTags = localDbCtx.DbSetTags.ToList();
FileModel currItem = null;
foreach (var item in missFiles)
{
// recupero record da DB...
currItem = localDbCtx
.DbSetProgFile
.Where(x => x.FileId == item.FileId)
.Include(x => x.Tags)
.FirstOrDefault();
List<string> Tags = new List<string>();
List<TagModel> Tag4File = new List<TagModel>();
// se necessario bonifico filename...
string fileName = item.Name;
if (currRule.FileNameExtReplace.Count > 0)
{
foreach (var fReplace in currRule.FileNameExtReplace)
{
fileName = fileName.Replace(fReplace.Key, fReplace.Value).Trim();
}
}
// cerco codice tag da configurazione
if (currRule.Mode == SearchMode.StringOnFile)
{
Tags = TagsUtils.SearchProgComment(fileName, item.FileStringContent, currRule);
}
else if (currRule.Mode == SearchMode.TagListed)
{
Tags = TagsUtils.SearchTagListed(fileName, item.FileStringContent, currRule);
}
else
{
Tags = TagsUtils.SearchPathName(item.Path, basePath, currRule);
}
foreach (var tag in Tags)
{
var foundTag = currTags.SingleOrDefault(x => x.TagId.ToLower() == tag.ToLower());
//var foundTag = currTags.SingleOrDefault(x => x.TagId == tag);
// aggiungo i tags SE non ci fossero
if (foundTag == null)
{
var newTag = new TagModel() { TagId = tag };
currTags.Add(newTag);
//localDbCtx.SaveChanges();
Tag4File.Add(newTag);
}
else
{
// al file aggiungo comunque
Tag4File.Add(foundTag);
}
}
// aggiungo ai file
if (Tag4File.Count > 0)
{
// salvo i tags relativi ai files
currItem.Tags.Clear();
currItem.Tags = Tag4File;
//localDbCtx.Entry(currItem).State = EntityState.Modified;
}
//localDbCtx.SaveChanges();
}
}
// update comunque data-ora e stato missing
foreach (var item in missFiles)
{
// salvo update file
item.DiskStatus = FileState.Missing;
item.LastCheck = adesso;
localDbCtx.Entry(item).State = EntityState.Modified;
}
try
{
// salvo
localDbCtx.SaveChanges();
}
catch (Exception exc)
{
Log.Error($"Errore in salvataggio FileSetChecked{Environment.NewLine}{exc}");
}
answ = true;
}
GC.Collect();
return answ;
}
/// <summary>
/// Effettua update di un record in archivio da lista (solo status, da approvare)
/// </summary>
@@ -783,6 +1097,36 @@ namespace MP.FileData.Controllers
return answ;
}
/// <summary>
/// Imposta utente approvazione + data modifica File
/// </summary>
/// <param name="currFile"></param>
/// <param name="UserName"></param>
/// <returns></returns>
public bool FileSetUserApp(FileModel currFile, string UserName)
{
bool done = false;
List<FileInfo> listUpdate = new List<FileInfo>();
using (MoonPro_ProgContext localDbCtx = new MoonPro_ProgContext(_configuration))
{
FileModel currRec = localDbCtx
.DbSetProgFile
.Where(x => x.FileId == currFile.FileId)
.FirstOrDefault();
if (currRec != null)
{
DateTime adesso = DateTime.Now;
currRec.UserAppr = UserName;
currRec.LastCheck = adesso;
//currFile.DiskStatus = FileState.Ok;
localDbCtx.Entry(currRec).State = EntityState.Modified;
// salvo DB
localDbCtx.SaveChanges();
}
}
return done;
}
/// <summary>
/// Aggiorna un record FILE rileggendo e ricalcolando...
/// </summary>
@@ -859,6 +1203,10 @@ namespace MP.FileData.Controllers
.Where(x => x.DiskStatus == FileState.Changed)
.Count();
item.NumMissing = activeRecords
.Where(x => x.DiskStatus == FileState.Missing)
.Count();
item.NoTags = activeRecords
.Where(x => x.Tags.Count == 0)
.Count();
+4
View File
@@ -36,6 +36,10 @@ namespace MP.FileData.DTO
/// </summary>
public int NumChanged { get; set; } = 0;
/// <summary>
/// NBumero file eliminati/missing
/// </summary>
public int NumMissing{ get; set; } = 0;
/// <summary>
/// Conteggio totale tags x macchina
/// </summary>
public int TotalTags { get; set; }
+1 -1
View File
@@ -13,7 +13,7 @@ namespace MP.FileData
{
ND = 0,
Changed,
Deleted,
Missing,
Ok
}
}
+10
View File
@@ -93,6 +93,16 @@ namespace MP.FileData
/// </summary>
public List<string> Tag2Collect { get; set; } = new List<string>();
/// <summary>
/// Configurazione opzionale x escludere files da regexp su filename
/// </summary>
public bool ExclFileEnabled { get; set; } = false;
/// <summary>
/// Pattern in formato RegExp x esclusione file da nome
/// </summary>
public string ExclFileRegExPattern { get; set; } = "";
#endregion Public Properties
}
}
+5 -1
View File
@@ -70,7 +70,8 @@
<th>Path</th>
<th class="text-end">Tags</th>
<th class="text-end">Senza Tag</th>
<th class="text-end">Modificati</th>
<th class="text-end" title="Modificati">Modif.</th>
<th class="text-end" title="Eliminati">Miss.</th>
<th class="text-end">Tot File</th>
<th></th>
</tr>
@@ -110,6 +111,9 @@
<td class="text-end">
@record.NumChanged
</td>
<td class="text-end">
@record.NumMissing
</td>
<td class="text-end">
<b>
@record.TotFile
+1 -1
View File
@@ -162,7 +162,7 @@ namespace MP.Prog.Components
sw.Restart();
// recupero elenco macchine
percLoading += 100 / numMacchine;
numChecks = await FDService.UpdateMachineArchive(idxMacchina, numDays, true, false, MServ.UserName, false);
numChecks = await FDService.UpdateMachineArchive(idxMacchina, numDays, true, false, "", false);
await Task.Delay(1);
setupMessages.Add($"{idxMacchina}: {numChecks} files");
await InvokeAsync(StateHasChanged);
+3 -9
View File
@@ -1,14 +1,14 @@
<div class="card">
<div class="card-header bg-dark text-light">
<div class="d-flex just">
<div class="col-4">
<div class="col-3">
<div class="d-flex">
<div class="px-0">
<h4>Dettaglio modifiche</h4>
</div>
</div>
</div>
<div class="col-4">
<div class="col-6">
<div class="d-flex justify-content-around text-nowrap">
@if (_currItem.Rev > 0)
{
@@ -64,18 +64,12 @@
else
{
<div class="px-0">
<div class="row">
<div class="col-6">
<button type="button" class="btn btn-success w-100" value="" @onclick="ExportArchive">Sostituisci da Archivio <i class="fas fa-file-download"></i></button>
</div>
<div class="col-6">
</div>
</div>
</div>
}
</div>
</div>
<div class="col-4 text-end">
<div class="col-3 text-end">
<button type="button" class="btn btn-light" value="Cancel" @onclick="cancelUpdate" title="Chiudi">Chiudi <i class="fas fa-xmark"></i></button>
</div>
</div>
+146 -127
View File
@@ -2,6 +2,7 @@
using Microsoft.JSInterop;
using MP.FileData.DatabaseModels;
using MP.Prog.Data;
using NLog;
using System;
using System.Collections.Generic;
using System.IO;
@@ -12,14 +13,11 @@ namespace MP.Prog.Components
{
public partial class FileEditor : ComponentBase
{
#region Public Fields
public FileModel _currItem = new FileModel();
#endregion Public Fields
#region Public Properties
/// <summary>
/// Item richiesto x display
/// </summary>
[Parameter]
public FileModel currItem
{
@@ -31,9 +29,12 @@ namespace MP.Prog.Components
{
_currItem = value;
CompareRev = false;
LoadRevision();
FixTitles();
}
}
private static Logger Log = LogManager.GetCurrentClassLogger();
[Parameter]
public EventCallback<int> DataReset { get; set; }
@@ -43,91 +44,32 @@ namespace MP.Prog.Components
[Parameter]
public List<ArchMaccModel> MacList { get; set; }
/// <summary>
/// Rev richiesta (x confronto)
/// </summary>
[Parameter]
public int ReqRev
{
get => SelRevDx;
set
{
if (value > 0)
{
CompareRev = true;
SelRevDx = value;
}
else
{
CompareRev = false;
}
}
}
[Parameter]
public List<TagModel> TagList { get; set; }
#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<int> ListRevSx
{
get
{
List<int> answ = new List<int>() { 0 };
for (int i = 1; i < SelRevDx; i++)
{
answ.Add(i);
}
return answ;
}
}
private List<int> ListRevDx
{
get
{
List<int> answ = new List<int>();
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)
@@ -159,19 +101,93 @@ namespace MP.Prog.Components
[Inject]
protected MessageService MServ { get; set; }
protected int SelRevDx
{
get => _selRevDx;
set
{
if (_selRevDx != value)
{
_selRevDx = value;
LoadRevision();
FixTitles();
}
}
}
protected int SelRevSx
{
get => _selRevSx;
set
{
if (_selRevSx != value)
{
_selRevSx = value;
// ricarico file SX
LoadRevision();
FixTitles();
}
}
}
#endregion Protected Properties
#region Protected Methods
protected void diffDoneHandler(int numChanges)
protected override void OnParametersSet()
{
#if false
numDiff = numChanges;
#endif
LoadRevision();
}
#endregion Protected Methods
#region Private Fields
private FileModel _currItem = new FileModel();
private int _selRevDx = 0;
private int _selRevSx = 0;
#endregion Private Fields
#region Private Properties
private bool CompareRev { get; set; } = false;
private string FileContDx { get; set; } = "";
private string FileContSx { get; set; } = "";
private List<int> ListRevDx
{
get
{
List<int> answ = new List<int>();
for (int i = 0; i <= _currItem.Rev; i++)
{
answ.Add(i);
}
return answ;
}
}
private List<int> ListRevSx
{
get
{
List<int> answ = new List<int>() { 0 };
for (int i = 1; i < SelRevDx; i++)
{
answ.Add(i);
}
return answ;
}
}
private string TitleDx { get; set; } = "Attuale";
private string TitleSx { get; set; } = "Archivio";
#endregion Private Properties
#region Private Methods
private async Task ApproveChange()
@@ -186,7 +202,7 @@ namespace MP.Prog.Components
}
else
{
Console.WriteLine("File null!");
Log.Error("_currItem null!");
}
}
@@ -207,10 +223,21 @@ namespace MP.Prog.Components
}
else
{
Console.WriteLine("File null!");
Log.Error("_currItem null!");
}
}
private void DoCompare()
{
CompareRev = !CompareRev;
if (CompareRev)
{
SelRevDx = _currItem.Rev;
}
LoadRevision();
FixTitles();
}
/// <summary>
/// Esporta da archivio a filesystem
/// </summary>
@@ -230,10 +257,34 @@ namespace MP.Prog.Components
}
else
{
Console.WriteLine("File null!");
Log.Error("_currItem null!");
}
}
private void FixTitles()
{
// sistemo titoli
TitleSx = CompareRev ? $"Rev. {SelRevSx}" : "Archivio";
TitleDx = CompareRev ? $"Rev. {SelRevDx}" : "Attuale";
}
private void LoadRevision()
{
if (CompareRev)
{
var reqSx = FDService.FileGetByKeyRev(_currItem.FileId, SelRevSx);
var reqDx = FDService.FileGetByKeyRev(_currItem.FileId, SelRevDx);
FileContSx = reqSx.FileStringContent;
FileContDx = reqDx.FileStringContent;
}
else
{
FileContSx = _currItem.FileStringContent;
FileContDx = CurrFileContent(_currItem.Path);
}
FixTitles();
}
private async Task RejectChange()
{
if (!await JSRuntime.InvokeAsync<bool>("confirm", "Sicuro di voler eliminare la modifica del file selezionato e sovrascrivere la versione in rete?"))
@@ -246,7 +297,7 @@ namespace MP.Prog.Components
}
else
{
Console.WriteLine("File null!");
Log.Error("_currItem null!");
}
}
@@ -259,42 +310,10 @@ namespace MP.Prog.Components
}
else
{
Console.WriteLine("File null!");
Log.Error("_currItem null!");
}
}
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
}
}
+61
View File
@@ -0,0 +1,61 @@
<table class="table table-sm table-striped table-responsive-lg">
<thead>
<tr>
<th class="text-center">Rev</th>
<th class="text-center">Size / User</th>
</tr>
</thead>
<tbody>
@foreach (var record in ListRecords)
{
<tr>
<td class="text-center">
<button class="btn btn-sm btn-primary border border-info border-2 rounded px-2 py-0" title="Seleziona Release" @onclick="() => SelRev(record)">
@record.Rev
</button>
<div>
<span title="@record.DiskStatus | Ultimo controllo: @record.LastCheck.ToString("yyyy.MM.dd HH:mm:ss")">
<span class="@(cssStatusByCod(record.DiskStatus))">
@record.DiskStatus
</span>
</span>
</div>
</td>
<td class="text-center px-1" style="width: 8rem;">
<div class="text-end px-3">
@CalcSize(record.Size)
</div>
<div class="text-end small">
@if (!string.IsNullOrEmpty(record.UserAppr))
{
<div class="border border-dark rounded p-0 small">
<i class="fas fa-user-alt"></i>
<span class="px-1">@record.UserAppr</span>
</div>
}
else
{
<button class="btn btn-sm btn-primary border border-info border-2 rounded px-2 py-0" title="Forza approvazione Release" @onclick="() => FileSetUserApp(record)">
<i class="fas fa-user-alt"></i>
Approva
<i class="fas fa-floppy-disk"></i>
</button>
}
</div>
</td>
<td class="text-end">
<div>@record.LastMod.ToString("yyyy.MM.dd")</div>
<div class="small">@record.LastMod.ToString("ddd HH:mm.ss")</div>
</td>
<td class="text-end">
@if (string.IsNullOrEmpty(record.UserAppr))
{
<button class="btn btn-sm btn-danger " @onclick="() => DeleteRec(record)" title="Elimina Record"><i class="fa-solid fa-trash"></i></button>
}
</td>
</tr>
}
</tbody>
</table>
+153
View File
@@ -0,0 +1,153 @@
using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;
using MP.FileData;
using MP.FileData.DatabaseModels;
using MP.Prog.Data;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace MP.Prog.Components
{
public partial class RevList
{
#region Public Properties
[Parameter]
public FileModel CurrRec { get; set; }
/// <summary>
/// Evento selezione rev x confronto, valore = rev
/// </summary>
[Parameter]
public EventCallback<int> EC_selRev { get; set; }
/// <summary>
/// Evento richiesta approvazione versione, valore = record
/// </summary>
[Parameter]
public EventCallback<FileModel> EC_reqAppr { get; set; }
/// <summary>
/// Evento richeista eliminazione da DB del File
/// </summary>
[Parameter]
public EventCallback<FileModel> EC_reqDelete { get; set; }
#endregion Public Properties
#region Protected Properties
[Inject]
protected FileArchDataService FDService { get; set; } = null!;
[Inject]
protected IJSRuntime JSRuntime { get; set; } = null!;
[Inject]
protected MessageService MServ { get; set; } = null!;
#endregion Protected Properties
#region Protected Methods
/// <summary>
/// Restituisce size calcolata
/// </summary>
/// <param name="origSize"></param>
/// <returns></returns>
protected string CalcSize(long origSize)
{
return MeasureUtils.SizeSuffix(origSize, 1);
}
/// <summary>
/// Forza approvazione utente corrente
/// </summary>
/// <returns></returns>
protected async Task FileSetUserApp(FileModel CurrRec)
{
await EC_reqAppr.InvokeAsync(CurrRec);
await Task.Delay(100);
await ReloadData();
}
/// <summary>
/// Selezione Rev x display confronto
/// </summary>
/// <returns></returns>
protected async Task SelRev(FileModel CurrRec)
{
await EC_selRev.InvokeAsync(CurrRec.Rev);
await ReloadData();
}
/// <summary>
/// Elimina record (non approvato) corrente e riattiva precedente
/// </summary>
/// <returns></returns>
protected async Task DeleteRec(FileModel CurrRec)
{
await EC_reqDelete.InvokeAsync(CurrRec);
await Task.Delay(100);
await ReloadData();
}
protected override async Task OnParametersSetAsync()
{
await ReloadData();
}
protected async Task ReloadData()
{
// valutare recupero info + redis + pagiazione EX POST...
if (CurrRec != null)
{
ListRecords = FDService.FileGetAllRevByKey(CurrRec.FileId);
}
else
{
ListRecords = new List<FileModel>();
}
await Task.Delay(1);
}
#endregion Protected Methods
#region Private Fields
private List<FileModel> ListRecords;
#endregion Private Fields
#region Private Methods
private string cssStatusByCod(FileState currStatus)
{
string answ = "badge";
switch (currStatus)
{
case FileState.Changed:
answ += " text-bg-warning";
break;
case FileState.Missing:
answ += " text-bg-danger";
break;
case FileState.Ok:
answ += " text-bg-success";
break;
case FileState.ND:
default:
answ += " text-bg-light";
break;
}
return answ;
}
#endregion Private Methods
}
}
+29 -27
View File
@@ -1,29 +1,31 @@
{
"ExcludedTags": [
"M4",
"M5",
"M4+A",
"M4+B",
"M5+A",
"M5+B"
],
"ExcludedFileExt": [
".xls",
".xls#",
".xlsx"
],
"FileNameExtReplace": {
".P-2": ""
},
"MaxChar2Search": 100,
"Mode": 0,
"Name": "Tag da Commento Filename",
"OutExcludeFileName": true,
"OutReplace": {
"(": " ",
")": " "
},
"RegExPattern": "\\b{{fileName}}.{0,2}\\([\\w\\d\\s./\\-=]+\\)",
"RegExRepFileName": true,
"ReplaceCR": true
"ExcludedTags": [
"M4",
"M5",
"M4+A",
"M4+B",
"M5+A",
"M5+B"
],
"ExcludedFileExt": [
".xls",
".xls#",
".xlsx"
],
"FileNameExtReplace": {
".P-2": ""
},
"MaxChar2Search": 100,
"Mode": 0,
"Name": "Tag da Commento Filename",
"OutExcludeFileName": true,
"OutReplace": {
"(": " ",
")": " "
},
"RegExPattern": "\\b{{fileName}}.{0,2}\\([\\w\\d\\s./\\-=]+\\)",
"RegExRepFileName": true,
"ReplaceCR": true,
"ExclFileEnabled": true,
"ExclFileRegExPattern": "^~\\$"
}
+23 -21
View File
@@ -1,23 +1,25 @@
{
"ExcludedTags": [],
"ExcludedFileExt": [
".xls",
".xls#",
".xlsx"
],
"FileNameExtReplace": {
".P-2": ""
},
"MaxChar2Search": 1,
"Mode": 1,
"Name": "Tag da Directory + Filename",
"OutExcludeFileName": false,
"OutReplace": {
".WPD": "",
".MPF": "",
".SPF": ""
},
"RegExPattern": "",
"RegExRepFileName": true,
"ReplaceCR": false
"ExcludedTags": [],
"ExcludedFileExt": [
".xls",
".xls#",
".xlsx"
],
"FileNameExtReplace": {
".P-2": ""
},
"MaxChar2Search": 1,
"Mode": 1,
"Name": "Tag da Directory + Filename",
"OutExcludeFileName": false,
"OutReplace": {
".WPD": "",
".MPF": "",
".SPF": ""
},
"RegExPattern": "",
"RegExRepFileName": true,
"ReplaceCR": false,
"ExclFileEnabled": true,
"ExclFileRegExPattern": "^~\\$"
}
+35 -33
View File
@@ -1,35 +1,37 @@
{
"ExcludedTags": [
"M4",
"M5",
"M4+A",
"M4+B",
"M5+A",
"M5+B",
"M6+A",
"M6+B",
"+A"
],
"ExcludedFileExt": [
".xls",
".xls#",
".xlsx"
],
"FileNameExtReplace": {
".P-2": "",
".tim": ""
},
"MaxChar2Search": 100,
"Mode": 0,
"Name": "Tag da Commento Filename Tornoss TISIS",
"OutExcludeFileName": true,
"OutReplace": {
"(": " ",
")": " ",
"<": " ",
">": " "
},
"RegExPattern": "\\b{{fileName}}.{0,2}\\([\\<\\w\\d\\s./\\-=\\+\\>]+\\)",
"RegExRepFileName": true,
"ReplaceCR": true
"ExcludedTags": [
"M4",
"M5",
"M4+A",
"M4+B",
"M5+A",
"M5+B",
"M6+A",
"M6+B",
"+A"
],
"ExcludedFileExt": [
".xls",
".xls#",
".xlsx"
],
"FileNameExtReplace": {
".P-2": "",
".tim": ""
},
"MaxChar2Search": 100,
"Mode": 0,
"Name": "Tag da Commento Filename Tornoss TISIS",
"OutExcludeFileName": true,
"OutReplace": {
"(": " ",
")": " ",
"<": " ",
">": " "
},
"RegExPattern": "\\b{{fileName}}.{0,2}\\([\\<\\w\\d\\s./\\-=\\+\\>]+\\)",
"RegExRepFileName": true,
"ReplaceCR": true,
"ExclFileEnabled": true,
"ExclFileRegExPattern": "^~\\$"
}
+4 -2
View File
@@ -1,5 +1,5 @@
{
"ExcludedTags": [ ],
"ExcludedTags": [],
"ExcludedFileExt": [
".bak",
".bck"
@@ -33,5 +33,7 @@
"IP=",
"AUTO_CHANGE_ODL=",
"AUTO_SNAPSHOT_DOSSIER="
]
],
"ExclFileEnabled": true,
"ExclFileRegExPattern": "^~\\$"
}
+4 -2
View File
@@ -1,5 +1,5 @@
{
"ExcludedTags": [ ],
"ExcludedTags": [],
"ExcludedFileExt": [
".bak",
".bck",
@@ -39,5 +39,7 @@
"\"QrJumpPath\":",
"\"Environment\":",
"\"appVers\":"
]
],
"ExclFileEnabled": true,
"ExclFileRegExPattern": "^~\\$"
}
+8 -4
View File
@@ -152,11 +152,15 @@ namespace MP.Prog.Controllers
// ciclo ogni file modificato
foreach (var cFile in listChanged)
{
// approvo il file modificato con utente anonimo (auto-Approve)
bool fatto = await FADService.FileModApprove(cFile, "");
if (fatto)
// se è modificato...
if (cFile.DiskStatus == FileData.FileState.Changed)
{
answ.Add(cFile.Path);
// approvo il file modificato con utente anonimo (auto-Approve)
bool fatto = await FADService.FileModApprove(cFile, "");
if (fatto)
{
answ.Add(cFile.Path);
}
}
}
return answ;
+110 -6
View File
@@ -164,11 +164,27 @@ namespace MP.Prog.Data
Log.Trace($"Effettuata lettura da DB per FileCountFilt: {ts.TotalMilliseconds} ms");
return await Task.FromResult(numCount);
}
public Task<FileModel> FileGetByKey(int FileId)
/// <summary>
/// Recupera un record data chiave
/// </summary>
/// <param name="FileId"></param>
/// <returns></returns>
public FileModel FileGetByKey(int FileId)
{
return Task.FromResult(dbController.FileGetByKey(FileId));
return dbController.FileGetByKey(FileId);
}
/// <summary>
/// Recupera tutte le revisioni dato un FileId (ordinate desc)
/// </summary>
/// <param name="FileId"></param>
/// <returns></returns>
public List<FileModel> FileGetAllRevByKey(int FileId)
{
return dbController.FileGetAllRevByKey(FileId);
}
/// <summary>
/// Restituisce il file dato un ID + revisione
/// cerca a pari nome, macchina + REV specifica)
@@ -176,9 +192,9 @@ namespace MP.Prog.Data
/// <param name="FileId">Id del file originale</param>
/// <param name="Rev">Rev specifica richiesta</param>
/// <returns></returns>
public Task<FileModel> FileGetByKeyRev(int FileId, int Rev)
public FileModel FileGetByKeyRev(int FileId, int Rev)
{
return Task.FromResult(dbController.FileGetByKeyRev(FileId, Rev));
return dbController.FileGetByKeyRev(FileId, Rev);
}
public async Task<List<FileModel>> FileGetFilt(SelectData CurrFilter)
@@ -286,7 +302,7 @@ namespace MP.Prog.Data
}
/// <summary>
/// Aggiorna archivio di una amcchina scansionando path relativo
/// Aggiorna archivio di una macchina scansionando path relativo
/// </summary>
/// <param name="idxMacchina">Codice macchina</param>
/// <param name="numDayPre">
@@ -375,6 +391,94 @@ namespace MP.Prog.Data
return checkDone;
}
/// <summary>
/// Aggiorna archivio di una amcchina scansionando path relativo
/// </summary>
/// <param name="idxMacchina">Codice macchina</param>
/// <param name="FileList">Elenco dei files (su DB) da verificare</param>
/// <param name="forceTag">Forza la riverifica dei tags (x update da setup)</param>
/// <param name="fullLog">Scrittura log verboso macchina</param>
/// <param name="UserName">Utente attivo</param>
/// <param name="DoApprove">indica se vada approvata la modifica o lasciato "in sospeso"</param>
/// <returns></returns>
public async Task<int> UpdateMachineFilesArchive(string idxMacchina, List<FileModel> FileList, bool forceTag, bool fullLog, string UserName, bool DoApprove)
{
int checkDone = 0;
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
string ruleName = "Rule00.json";
try
{
ArchMaccModel macchina = await ArchMaccGetByKey(idxMacchina);
if (macchina != null && !string.IsNullOrEmpty(macchina.BasePath))
{
if (!string.IsNullOrEmpty(macchina.RuleName))
{
ruleName = macchina.RuleName;
// gestione confRule...
SearchRules currRule = new SearchRules();
try
{
string rawData = File.ReadAllText(FileController.rulePath(ruleName));
currRule = JsonConvert.DeserializeObject<SearchRules>(rawData);
}
catch (Exception exc)
{
Log.Error($"Eccezione in deserializzazione conf rule{Environment.NewLine}{exc}");
}
// se NON deserializzato inizializzo hard-coded
if (currRule.Name == "ND")
{
// fare: lettura conf rule x recupero tag x singola macchina
//$"\\b{fileName}" + @".{0,2}\([\w\d\s.]+\)";
Dictionary<string, string> confReplace = new Dictionary<string, string>();
confReplace.Add("(", " ");
confReplace.Add(")", " ");
Dictionary<string, string> fileExtReplace = new Dictionary<string, string>();
fileExtReplace.Add(".P-2", "");
// hard coded + salvataggio conf x creare json
currRule = new SearchRules()
{
Name = "Commento Filename",
Mode = SearchMode.StringOnFile,
MaxChar2Search = 100,
ReplaceCR = true,
RegExPattern = "\\b{{fileName}}" + @".{0,2}\([\w\d\s./]+\)",
RegExRepFileName = true,
FileNameExtReplace = fileExtReplace,
ExcludedTags = new List<string>() { "M4", "M5", "M4+A", "M4+B", "M5+A", "M5+B" },
OutReplace = confReplace,
OutExcludeFileName = true
};
if (fullLog)
{
// serializzo
string rawRule = JsonConvert.SerializeObject(currRule, Formatting.Indented);
Log.Trace($"Conf rule generato:{Environment.NewLine}{rawRule}");
}
}
checkDone = dbController.CheckFileListArchived(macchina.IdxMacchina, FileList, macchina.BasePath, "*.*", forceTag, currRule, UserName, DoApprove);
}
}
}
catch (Exception exc)
{
Log.Error($"Eccezione in UpdateMachineArchive{Environment.NewLine}{exc}{Environment.NewLine}{exc.InnerException}");
}
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
Log.Info($"Effettuato update archivio file MACCHINA | # file {FileList.Count} | {checkDone} checked | {ts.TotalMilliseconds} ms");
// svuoto cache!
await ResetArchiveCache();
// restituisco conteggio
return checkDone;
}
#endregion Public Methods
#region Internal Methods
+1 -1
View File
@@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<RootNamespace>MP.Prog</RootNamespace>
<Version>6.16.2410.2816</Version>
<Version>6.16.2410.2910</Version>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
</PropertyGroup>
+55 -37
View File
@@ -97,7 +97,7 @@
<div class="card-body p-1">
@if (currRecord != null)
{
<FileEditor currItem="@currRecord" DataReset="ResetData" DataUpdated="UpdateData" TagList="@TagList" MacList="@MacList"></FileEditor>
<FileEditor currItem="@currRecord" DataReset="ResetData" DataUpdated="UpdateData" TagList="@TagList" MacList="@MacList" ReqRev="@ReqRevDx"></FileEditor>
}
@if (ListRecords == null)
{
@@ -110,7 +110,7 @@
else
{
<div class="row">
<div class="col-12">
<div class="@mainCol">
<table class="table table-sm table-striped table-responsive-lg">
<thead>
<tr>
@@ -124,11 +124,17 @@
</th>
<th>File</th>
<th class="text-center">Rev</th>
<th class="text-center">Size / User</th>
@if (currRecord == null || currRecord.Rev == 0)
{
<th class="text-center">Size / User</th>
}
<th>Macchina</th>
<th>Tags</th>
<th class="text-end">Modificato</th>
<th></th>
@if (currRecord == null || currRecord.Rev == 0)
{
<th class="text-end">Modificato</th>
<th></th>
}
</tr>
</thead>
<tbody>
@@ -157,29 +163,32 @@
</span>
</div>
</td>
<td class="text-center px-1" style="width: 8rem;">
<div class="text-end px-3">
@CalcSize(record.Size)
</div>
<div class="text-end small">
@if (!string.IsNullOrEmpty(record.UserAppr))
{
<button class="btn btn-sm btn-outline-dark px-1 py-0" title="Filtra Utente" @onclick="() => FilterUserName(record.UserAppr)">
<i class="fas fa-user-alt"></i>
<span class="small">@record.UserAppr</span>
</button>
}
else
{
@if (currRecord == null || currRecord.Rev == 0)
{
<td class="text-center px-1" style="width: 8rem;">
<div class="text-end px-3">
@CalcSize(record.Size)
</div>
<div class="text-end small">
@if (!string.IsNullOrEmpty(record.UserAppr))
{
<button class="btn btn-sm btn-outline-dark px-1 py-0" title="Filtra Utente" @onclick="() => FilterUserName(record.UserAppr)">
<i class="fas fa-user-alt"></i>
<span class="small">@record.UserAppr</span>
</button>
}
else
{
<button class="btn btn-sm btn-primary border border-info border-2 rounded px-2 py-0" title="Forza approvazione Release" @onclick="() => FileSetUserApp(record)">
<i class="fas fa-user-alt"></i>
Approva
<i class="fas fa-floppy-disk"></i>
</button>
}
</div>
</td>
<button class="btn btn-sm btn-primary border border-info border-2 rounded px-2 py-0" title="Forza approvazione Release" @onclick="() => FileSetUserApp(record)">
<i class="fas fa-user-alt"></i>
Approva
<i class="fas fa-floppy-disk"></i>
</button>
}
</div>
</td>
}
<td>
<div>@record.Macchina.Nome</div>
<div class="small">@record.Macchina.Descrizione</div>
@@ -192,22 +201,31 @@
</button>
}
</td>
<td class="text-end">
<div>@record.LastMod.ToString("yyyy.MM.dd")</div>
<div class="small">@record.LastMod.ToString("ddd HH:mm.ss")</div>
@if (currRecord == null || currRecord.Rev == 0)
{
<td class="text-end">
<div>@record.LastMod.ToString("yyyy.MM.dd")</div>
<div class="small">@record.LastMod.ToString("ddd HH:mm.ss")</div>
</td>
<td class="text-end">
@if (string.IsNullOrEmpty(record.UserAppr))
{
<button class="btn btn-sm btn-danger " @onclick="() => DeleteRec(record)" title="Elimina Record"><i class="fa-solid fa-trash"></i></button>
}
</td>
</td>
<td class="text-end">
@if (string.IsNullOrEmpty(record.UserAppr))
{
<button class="btn btn-sm btn-danger " @onclick="() => DeleteRec(record)" title="Elimina Record"><i class="fa-solid fa-trash"></i></button>
}
</td>
}
</tr>
}
</tbody>
</table>
</div>
@if (currRecord != null && currRecord.Rev > 0)
{
<div class="col-3">
<RevList CurrRec="@currRecord" EC_selRev="SelRev" EC_reqAppr="FileSetUserApp" EC_reqDelete="DeleteRec"></RevList>
</div>
}
</div>
}
</div>
+37 -9
View File
@@ -65,13 +65,13 @@ namespace MP.Prog.Pages
#region Protected Properties
[Inject]
protected FileArchDataService FDService { get; set; }
protected FileArchDataService FDService { get; set; } = null!;
[Inject]
protected IJSRuntime JSRuntime { get; set; }
protected IJSRuntime JSRuntime { get; set; } = null!;
[Inject]
protected MessageService MServ { get; set; }
protected MessageService MServ { get; set; } = null!;
[Inject]
protected NavigationManager NavManager { get; set; }
@@ -122,15 +122,19 @@ namespace MP.Prog.Pages
/// <returns></returns>
protected async Task DeleteRec(FileModel CurrRec)
{
if (!await JSRuntime.InvokeAsync<bool>("confirm", "Sicuro di voler eliminare il record e riattivare la revisione antecedente? Il file potrebbe risultare modificato"))
string delMessage = CurrRec.Rev > 0 ? "Sicuro di voler eliminare il record e riattivare la revisione antecedente? Il file potrebbe risultare modificato." : "Sicuro di voler eliminare il record? Non ci sono altre revisioni e quindi sarà definitivamente eliminato.";
if (!await JSRuntime.InvokeAsync<bool>("confirm", delMessage))
return;
// elimino
await FDService.FileDelete(CurrRec);
//// verifico eventuali modifiche
//var numCheck = await FDService.UpdateMachineArchive(CurrRec.IdxMacchina, 30, false, false, "");
// verifico eventuali modifiche del SINGOLO
List<FileModel> FileIdList = new List<FileModel>() { CurrRec };
var numCheck = await FDService.UpdateMachineFilesArchive(CurrRec.IdxMacchina, FileIdList, false, false, "", false);
isLoading = true;
currRecord = null;
await ReloadData();
isLoading = false;
}
@@ -144,7 +148,8 @@ namespace MP.Prog.Pages
}
// rileggo dal DB il record corrente...
currRecord = await FDService.FileGetByKey(selRecord.FileId);
ReqRevDx = 0;
currRecord = FDService.FileGetByKey(selRecord.FileId);
}
/// <summary>
@@ -233,7 +238,7 @@ namespace MP.Prog.Pages
ListRecords = null;
// importante altrimenti NON mostra update UI
await Task.Delay(1);
var numCheck = await FDService.UpdateAllArchive(numDays, false, MServ.UserName, false);
var numCheck = await FDService.UpdateAllArchive(numDays, false, "", false);
await ReloadAllData();
await Task.Delay(1);
await RefreshDisplayLoading();
@@ -348,6 +353,15 @@ namespace MP.Prog.Pages
currRecord = selRecord;
}
/// <summary>
/// imposta revisione richiesta
/// </summary>
/// <param name="reqRev"></param>
protected void SelRev(int reqRev)
{
ReqRevDx = reqRev;
}
/// <summary>
/// Imposta pagina corrente
/// </summary>
@@ -397,9 +411,18 @@ namespace MP.Prog.Pages
#region Private Fields
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
private FileModel currRecord = null;
private List<FileModel> ListRecords;
private List<ArchMaccModel> MacList;
/// <summary>
/// Revisione richiesta a dx
/// </summary>
private int ReqRevDx = 0;
private List<TagModel> TagList;
#endregion Private Fields
@@ -420,6 +443,11 @@ namespace MP.Prog.Pages
private bool isLoading { get; set; } = false;
private string mainCol
{
get => currRecord == null || currRecord.Rev == 0 ? "col-12" : "col-9";
}
private int numRecord
{
get
@@ -651,7 +679,7 @@ namespace MP.Prog.Pages
answ += " text-bg-warning";
break;
case FileState.Deleted:
case FileState.Missing:
answ += " text-bg-danger";
break;
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>Modulo gestione Programmi MAPO</i>
<h4>Versione: 6.16.2410.2816</h4>
<h4>Versione: 6.16.2410.2910</h4>
<br />
Note di rilascio:
<ul>
+1 -1
View File
@@ -1 +1 @@
6.16.2410.2816
6.16.2410.2910
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>6.16.2410.2816</version>
<version>6.16.2410.2910</version>
<url>https://nexus.steamware.net/repository/SWS/MP-PROG/stable/LAST/MP.Prog.zip</url>
<changelog>https://nexus.steamware.net/repository/SWS/MP-PROG/stable/LAST/ChangeLog.html</changelog>
<mandatory>false</mandatory>