Merge branch 'feature/TagArtDataModelFix' into develop
This commit is contained in:
@@ -8,6 +8,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using MP.FileData.DatabaseModels;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace MP.FileData.Controllers
|
||||
{
|
||||
@@ -34,57 +35,42 @@ namespace MP.FileData.Controllers
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Elenco tabella Articoli (FILTRATO!!!)
|
||||
/// </summary>
|
||||
/// <param name="searchVal"></param>
|
||||
/// <param name="maxNum"></param>
|
||||
/// <returns></returns>
|
||||
public List<DatabaseModels.ArticoloModel> ArtGetFilt(string searchVal, int maxNum = 100)
|
||||
{
|
||||
maxNum = maxNum <= 0 ? 100 : maxNum;
|
||||
List<DatabaseModels.ArticoloModel> dbResult = new List<DatabaseModels.ArticoloModel>();
|
||||
using (MoonPro_ProgContext localDbCtx = new MoonPro_ProgContext(_configuration))
|
||||
{
|
||||
int totRecord = localDbCtx
|
||||
.DbSetArticoli
|
||||
.Where(x => x.CodArticolo.Contains(searchVal) || x.DescArticolo.Contains(searchVal) || x.Disegno.Contains(searchVal))
|
||||
.Count();
|
||||
if (totRecord > maxNum)
|
||||
{
|
||||
dbResult = localDbCtx
|
||||
.DbSetArticoli
|
||||
.Where(x => x.CodArticolo.Contains(searchVal) || x.DescArticolo.Contains(searchVal) || x.Disegno.Contains(searchVal))
|
||||
.OrderBy(x => x.DescArticolo)
|
||||
.Take(maxNum)
|
||||
.ToList();
|
||||
dbResult.Add(new DatabaseModels.ArticoloModel() { CodArticolo = "#####", DescArticolo = $"... +{totRecord - maxNum} rec ..." });
|
||||
}
|
||||
else
|
||||
{
|
||||
dbResult = localDbCtx
|
||||
.DbSetArticoli
|
||||
.Where(x => x.CodArticolo.Contains(searchVal) || x.DescArticolo.Contains(searchVal) || x.Disegno.Contains(searchVal))
|
||||
.OrderBy(x => x.DescArticolo)
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <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="path">path ricerca x macchina</param>
|
||||
/// <param name="numDayPre">Numero giorni x ricerca all'indietro da data corrente / 0 = nessun limite</param>
|
||||
/// <param name="searchPattern">pattern di ricerca (*.*)</param>
|
||||
/// <param name="SearchRules">Regole di ricerca applicate</param>
|
||||
/// <returns></returns>
|
||||
public bool CheckFileArchived(string idxMacchina, string path, string searchPattern)
|
||||
public bool CheckFileArchived(string idxMacchina, string path, int numDayPre, string searchPattern, SearchRules currRule)
|
||||
{
|
||||
Log.Info($"CheckFileArchived S00 | macchina: {idxMacchina} | path: {path} | pattern: {searchPattern} | # ExcludedFileExt: {currRule.ExcludedFileExt.Count()}");
|
||||
bool answ = false;
|
||||
DirectoryInfo dirInfo = new DirectoryInfo(path);
|
||||
FileInfo[] fileList = dirInfo.GetFiles(searchPattern);
|
||||
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();
|
||||
}
|
||||
Log.Info($"CheckFileArchived S01 | file trovati: {fileList.Count()}");
|
||||
List<FileInfo> fileNew = new List<FileInfo>();
|
||||
List<FileModel> fileChecked = new List<FileModel>();
|
||||
List<FileModel> fileMod = new List<FileModel>();
|
||||
DateTime adesso = DateTime.Now;
|
||||
|
||||
// recupera elenco file nel DB
|
||||
var archivedFile = FileGetByPath(path, true);
|
||||
@@ -93,38 +79,46 @@ namespace MP.FileData.Controllers
|
||||
// verifica i file
|
||||
foreach (var file in fileList)
|
||||
{
|
||||
// cerca nel DB...
|
||||
FileModel currRecord = archivedFile
|
||||
.Where(x => x.Active && x.Path == file.FullName)
|
||||
.OrderByDescending(y => y.Rev)
|
||||
.FirstOrDefault();
|
||||
// se NON trova lo crea
|
||||
if (currRecord == null)
|
||||
// escludo i file con desinenza da escludere...
|
||||
if (!string.IsNullOrEmpty(file.Extension) && currRule.ExcludedFileExt.Contains(file.Extension))
|
||||
{
|
||||
fileNew.Add(file);
|
||||
Log.Info($"CheckFileArchived S02: escluso {file.Name} | estensione {file.Extension}");
|
||||
}
|
||||
else
|
||||
{
|
||||
// verifico se data modifica sia cambiata...
|
||||
if (currRecord.LastMod != file.LastWriteTime)
|
||||
// cerca nel DB...
|
||||
FileModel currRecord = archivedFile
|
||||
.Where(x => x.Active && x.Path == file.FullName)
|
||||
.OrderByDescending(y => y.Rev)
|
||||
.FirstOrDefault();
|
||||
// se NON trova lo crea
|
||||
if (currRecord == null)
|
||||
{
|
||||
// calcolo e verifico MD5
|
||||
var fileContent = File.ReadAllBytes(file.FullName);
|
||||
var hash = md5.ComputeHash(fileContent);
|
||||
var newMD5 = BitConverter.ToString(hash).Replace("-", "").ToLowerInvariant();
|
||||
if (newMD5 != currRecord.MD5)
|
||||
fileNew.Add(file);
|
||||
}
|
||||
else
|
||||
{
|
||||
// verifico se data modifica sia cambiata...
|
||||
if (currRecord.LastMod != file.LastWriteTime)
|
||||
{
|
||||
fileMod.Add(currRecord);
|
||||
// calcolo e verifico MD5
|
||||
var fileContent = File.ReadAllBytes(file.FullName);
|
||||
var hash = md5.ComputeHash(fileContent);
|
||||
var newMD5 = BitConverter.ToString(hash).Replace("-", "").ToLowerInvariant();
|
||||
if (newMD5 != currRecord.MD5)
|
||||
{
|
||||
fileMod.Add(currRecord);
|
||||
}
|
||||
else
|
||||
{
|
||||
fileChecked.Add(currRecord);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fileChecked.Add(currRecord);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fileChecked.Add(currRecord);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -132,12 +126,14 @@ namespace MP.FileData.Controllers
|
||||
// salvo i NUOVI file
|
||||
if (fileNew != null && fileNew.Count > 0)
|
||||
{
|
||||
FileInsert(idxMacchina, fileNew, 0);
|
||||
FileInsert(idxMacchina, fileNew, 0, currRule);
|
||||
Log.Info($"CheckFileArchived S03 | insert {fileNew.Count} files");
|
||||
}
|
||||
// aggiorno i file modificati
|
||||
if (fileMod != null && fileMod.Count > 0)
|
||||
{
|
||||
FileSetUpdated(fileMod);
|
||||
Log.Info($"CheckFileArchived S04 | update {fileMod.Count} files");
|
||||
}
|
||||
// segno data-ora ultimo controllo x file invariati
|
||||
if (fileChecked != null && fileChecked.Count > 0)
|
||||
@@ -176,7 +172,7 @@ namespace MP.FileData.Controllers
|
||||
// se ce ne fosse un altro precedente --> lo (ri)attiva
|
||||
var file2open = localDbCtx
|
||||
.DbSetProgFile
|
||||
.Where(x => x.Articolo == currItem.Articolo && x.IdxMacchina == currItem.IdxMacchina)
|
||||
.Where(x => x.Name == currItem.Name && x.IdxMacchina == currItem.IdxMacchina)
|
||||
.OrderByDescending(y => y.Rev)
|
||||
.FirstOrDefault();
|
||||
if (file2open != null)
|
||||
@@ -242,7 +238,7 @@ namespace MP.FileData.Controllers
|
||||
dbResult = localDbCtx
|
||||
.DbSetProgFile
|
||||
.Include(m => m.Macchina)
|
||||
.Include(a => a.Articolo)
|
||||
.Include(t => t.Tags)
|
||||
.Where(x => (x.IdxMacchina == IdxMacchina || IdxMacchina == "0") && (x.Active == OnlyActive || !OnlyActive) && (!OnlyMod || x.DiskStatus != FileState.Ok) && (x.Name.Contains(SearchVal) || string.IsNullOrEmpty(SearchVal)))
|
||||
.OrderByDescending(x => x.LastMod)
|
||||
.ToList();
|
||||
@@ -257,8 +253,10 @@ namespace MP.FileData.Controllers
|
||||
/// <param name="newFiles"></param>
|
||||
/// <param name="rev"></param>
|
||||
/// <returns></returns>
|
||||
public bool FileInsert(string idxMacchina, List<FileInfo> newFiles, int rev)
|
||||
public bool FileInsert(string idxMacchina, List<FileInfo> newFiles, int rev, SearchRules currRule)
|
||||
{
|
||||
// fare: lettura conf x macchina
|
||||
Log.Info($"FileInsert S01 per macchina {idxMacchina}: {newFiles.Count} files da valutare");
|
||||
bool answ = false;
|
||||
DateTime adesso = DateTime.Now;
|
||||
// MD5 hash
|
||||
@@ -270,7 +268,6 @@ namespace MP.FileData.Controllers
|
||||
List<DatabaseModels.FileModel> newRec = newFiles.Select(o => new DatabaseModels.FileModel()
|
||||
{
|
||||
Active = true,
|
||||
CodArticolo = "ND",
|
||||
DiskStatus = FileState.Ok,
|
||||
IdxMacchina = idxMacchina,
|
||||
LastCheck = adesso,
|
||||
@@ -283,11 +280,51 @@ namespace MP.FileData.Controllers
|
||||
FileContent = File.ReadAllBytes(o.FullName)
|
||||
}).ToList();
|
||||
|
||||
// calcolo MD5
|
||||
// gestione Tags (da migliorare...)
|
||||
List<TagModel> currTags = localDbCtx.DbSetTags.ToList();
|
||||
|
||||
// calcolo MD5 e tags
|
||||
foreach (var item in newRec)
|
||||
{
|
||||
var hash = md5.ComputeHash(item.FileContent);
|
||||
item.MD5 = BitConverter.ToString(hash).Replace("-", "").ToLowerInvariant();
|
||||
|
||||
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
|
||||
Tags = TagsUtils.searchProgComment(fileName, item.FileStringContent, currRule);
|
||||
|
||||
foreach (var tag in Tags)
|
||||
{
|
||||
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);
|
||||
Tag4File.Add(newTag);
|
||||
}
|
||||
else
|
||||
{
|
||||
// al file aggiungo comunque
|
||||
Tag4File.Add(foundTag);
|
||||
}
|
||||
}
|
||||
// aggiungo ai file
|
||||
if (Tag4File.Count > 0)
|
||||
{
|
||||
// salvo i tags relativi ai files
|
||||
item.Tags = Tag4File;
|
||||
}
|
||||
}
|
||||
|
||||
// aggiungo in blocco
|
||||
@@ -295,11 +332,14 @@ namespace MP.FileData.Controllers
|
||||
.DbSetProgFile
|
||||
.AddRange(newRec);
|
||||
|
||||
Log.Info($"FileInsert S02 per macchina {idxMacchina}: {newRec.Count} files da aggiungere EFCore");
|
||||
|
||||
// salvo
|
||||
localDbCtx.SaveChanges();
|
||||
answ = true;
|
||||
}
|
||||
}
|
||||
Log.Info($"FileInsert S03 per macchina {idxMacchina}");
|
||||
return answ;
|
||||
}
|
||||
|
||||
@@ -313,8 +353,31 @@ namespace MP.FileData.Controllers
|
||||
var newFileInfo = new FileInfo(currFile.Path);
|
||||
listUpdate.Add(newFileInfo);
|
||||
|
||||
// fixme todo !!! fix da conf file
|
||||
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
|
||||
SearchRules currRule = new SearchRules()
|
||||
{
|
||||
Name = "Commento Filename",
|
||||
Mode = SearchMode.StringOnFile,
|
||||
MaxChar2Search = 100,
|
||||
ReplaceCR = true,
|
||||
RegExPattern = "\\b{{fileName}}" + @".{0,2}\([\w\d\s.]+\)",
|
||||
RegExRepFileName = true,
|
||||
ExcludedTags = new List<string>() { "M4", "M5", "M4+A", "M4+B", "M5+A", "M5+B" },
|
||||
FileNameExtReplace = fileExtReplace,
|
||||
OutReplace = confReplace,
|
||||
OutExcludeFileName = true
|
||||
};
|
||||
|
||||
// inserisco come REVISIONE
|
||||
FileInsert(currFile.IdxMacchina, listUpdate, currFile.Rev + 1);
|
||||
FileInsert(currFile.IdxMacchina, listUpdate, currFile.Rev + 1, currRule);
|
||||
|
||||
// archivio vecchio file
|
||||
currFile.Active = false;
|
||||
@@ -444,6 +507,151 @@ namespace MP.FileData.Controllers
|
||||
return done;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco tabella Macchine
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<DatabaseModels.MacchinaModel> MacchineGetAll()
|
||||
{
|
||||
List<DatabaseModels.MacchinaModel> dbResult = new List<DatabaseModels.MacchinaModel>();
|
||||
using (MoonPro_ProgContext localDbCtx = new MoonPro_ProgContext(_configuration))
|
||||
{
|
||||
dbResult = localDbCtx
|
||||
.DbSetMacchine
|
||||
.OrderBy(x => x.IdxMacchina)
|
||||
.ToList();
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
public void ResetController()
|
||||
{
|
||||
dbCtx = new MoonPro_ProgContext(_configuration);
|
||||
Log.Info("Effettuato reset FileController");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Annulla modifiche su una specifica entity (cancel update)
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
/// <returns></returns>
|
||||
public bool RollBackEntity(object item)
|
||||
{
|
||||
bool answ = false;
|
||||
try
|
||||
{
|
||||
if (dbCtx.Entry(item).State == Microsoft.EntityFrameworkCore.EntityState.Deleted || dbCtx.Entry(item).State == Microsoft.EntityFrameworkCore.EntityState.Modified)
|
||||
{
|
||||
dbCtx.Entry(item).Reload();
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione in rollBackEntity{Environment.NewLine}{exc}");
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco TAGS (tutti)
|
||||
/// </summary>
|
||||
/// <param name="searchVal"></param>
|
||||
/// <param name="maxNum"></param>
|
||||
/// <returns></returns>
|
||||
public List<DatabaseModels.TagModel> TagGetAll()
|
||||
{
|
||||
List<DatabaseModels.TagModel> dbResult = new List<DatabaseModels.TagModel>();
|
||||
using (MoonPro_ProgContext localDbCtx = new MoonPro_ProgContext(_configuration))
|
||||
{
|
||||
dbResult = localDbCtx
|
||||
.DbSetTags
|
||||
.OrderBy(x => x.TagId)
|
||||
.ToList();
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco TAGS (FILTRATO!!!)
|
||||
/// </summary>
|
||||
/// <param name="searchVal"></param>
|
||||
/// <param name="maxNum"></param>
|
||||
/// <returns></returns>
|
||||
public List<DatabaseModels.TagModel> TagGetFilt(string searchVal, int maxNum = 100)
|
||||
{
|
||||
maxNum = maxNum <= 0 ? 100 : maxNum;
|
||||
List<DatabaseModels.TagModel> dbResult = new List<DatabaseModels.TagModel>();
|
||||
using (MoonPro_ProgContext localDbCtx = new MoonPro_ProgContext(_configuration))
|
||||
{
|
||||
int totRecord = localDbCtx
|
||||
.DbSetTags
|
||||
.Where(x => x.TagId.Contains(searchVal))
|
||||
.Count();
|
||||
if (totRecord > maxNum)
|
||||
{
|
||||
dbResult = localDbCtx
|
||||
.DbSetTags
|
||||
.Where(x => x.TagId.Contains(searchVal))
|
||||
.OrderBy(x => x.TagId)
|
||||
.Take(maxNum)
|
||||
.ToList();
|
||||
dbResult.Add(new DatabaseModels.TagModel() { TagId = $"... +{totRecord - maxNum} rec ..." });
|
||||
}
|
||||
else
|
||||
{
|
||||
dbResult = localDbCtx
|
||||
.DbSetTags
|
||||
.Where(x => x.TagId.Contains(searchVal))
|
||||
.OrderBy(x => x.TagId)
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ricerca singolo record
|
||||
/// </summary>
|
||||
/// <param name="TagId"></param>
|
||||
/// <returns></returns>
|
||||
public TagModel TagGetSingle(string TagId)
|
||||
{
|
||||
TagModel dbResult = new TagModel();
|
||||
using (MoonPro_ProgContext localDbCtx = new MoonPro_ProgContext(_configuration))
|
||||
{
|
||||
dbResult = localDbCtx
|
||||
.DbSetTags
|
||||
.Where(x => x.TagId == TagId)
|
||||
.FirstOrDefault();
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// inserisce i tag
|
||||
/// </summary>
|
||||
/// <param name="newTags"></param>
|
||||
/// <returns></returns>
|
||||
public bool TagInsert(List<TagModel> newTags)
|
||||
{
|
||||
bool done = false;
|
||||
using (MoonPro_ProgContext localDbCtx = new MoonPro_ProgContext(_configuration))
|
||||
{
|
||||
try
|
||||
{
|
||||
localDbCtx.DbSetTags.AddRange(newTags);
|
||||
localDbCtx.SaveChanges();
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione in TagInsert{Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
return done;
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#if false
|
||||
/// <summary>
|
||||
/// Elenco Azioni (decodifica)
|
||||
@@ -500,54 +708,6 @@ namespace MP.FileData.Controllers
|
||||
return dbResult;
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Elenco tabella Macchine
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<DatabaseModels.MacchinaModel> MacchineGetAll()
|
||||
{
|
||||
List<DatabaseModels.MacchinaModel> dbResult = new List<DatabaseModels.MacchinaModel>();
|
||||
using (MoonPro_ProgContext localDbCtx = new MoonPro_ProgContext(_configuration))
|
||||
{
|
||||
dbResult = localDbCtx
|
||||
.DbSetMacchine
|
||||
.OrderBy(x => x.IdxMacchina)
|
||||
.ToList();
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
public void ResetController()
|
||||
{
|
||||
dbCtx = new MoonPro_ProgContext(_configuration);
|
||||
Log.Info("Effettuato reset FileController");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Annulla modifiche su una specifica entity (cancel update)
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
/// <returns></returns>
|
||||
public bool RollBackEntity(object item)
|
||||
{
|
||||
bool answ = false;
|
||||
try
|
||||
{
|
||||
if (dbCtx.Entry(item).State == Microsoft.EntityFrameworkCore.EntityState.Deleted || dbCtx.Entry(item).State == Microsoft.EntityFrameworkCore.EntityState.Modified)
|
||||
{
|
||||
dbCtx.Entry(item).Reload();
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione in rollBackEntity{Environment.NewLine}{exc}");
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#if false
|
||||
/// <summary>
|
||||
/// Elenco tabella controlli da filtro
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
// <Auto-Generated>
|
||||
// This is here so CodeMaid doesn't reorganize this document
|
||||
// </Auto-Generated>
|
||||
namespace MP.FileData.DatabaseModels
|
||||
{
|
||||
[Table("Articoli")]
|
||||
public partial class ArticoloModel
|
||||
{
|
||||
#region Public Properties
|
||||
|
||||
[Key]
|
||||
public string CodArticolo { get; set; }
|
||||
public string DescArticolo { get; set; }
|
||||
public string Disegno { get; set; }
|
||||
public string Tipo { get; set; }
|
||||
|
||||
#endregion Public Properties
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,6 @@ namespace MP.FileData.DatabaseModels
|
||||
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int FileId { get; set; }
|
||||
public bool Active { get; set; } = true;
|
||||
public string CodArticolo { get; set; }
|
||||
public string IdxMacchina { get; set; } = "";
|
||||
public string Name { get; set; } = "";
|
||||
public int Rev { get; set; } = 0;
|
||||
@@ -51,8 +50,6 @@ namespace MP.FileData.DatabaseModels
|
||||
}
|
||||
}
|
||||
|
||||
[ForeignKey("CodArticolo")]
|
||||
public virtual ArticoloModel Articolo { get; set; }
|
||||
[ForeignKey("IdxMacchina")]
|
||||
public virtual MacchinaModel Macchina { get; set; }
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace MP.FileData.DatabaseModels
|
||||
|
||||
[Key]
|
||||
public string IdxMacchina { get; set; } = "";
|
||||
public string CodMacchina { get; set; } = "";
|
||||
public string RuleName { get; set; } = "";
|
||||
public string Nome { get; set; } = "";
|
||||
public string Descrizione { get; set; } = "";
|
||||
public string BasePath { get; set; } = "";
|
||||
|
||||
+5
-44
@@ -10,7 +10,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
namespace MP.FileData.Migrations
|
||||
{
|
||||
[DbContext(typeof(MoonPro_ProgContext))]
|
||||
[Migration("20210907103215_InitDb")]
|
||||
[Migration("20210908125127_InitDb")]
|
||||
partial class InitDb
|
||||
{
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
@@ -37,34 +37,6 @@ namespace MP.FileData.Migrations
|
||||
b.ToTable("FileModelTagModel");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MP.FileData.DatabaseModels.ArticoloModel", b =>
|
||||
{
|
||||
b.Property<string>("CodArticolo")
|
||||
.HasColumnType("nvarchar(450)");
|
||||
|
||||
b.Property<string>("DescArticolo")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Disegno")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Tipo")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("CodArticolo");
|
||||
|
||||
b.ToTable("Articoli");
|
||||
|
||||
b.HasData(
|
||||
new
|
||||
{
|
||||
CodArticolo = "ND",
|
||||
DescArticolo = "--- Tutti ---",
|
||||
Disegno = "",
|
||||
Tipo = "ND"
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MP.FileData.DatabaseModels.FileModel", b =>
|
||||
{
|
||||
b.Property<int>("FileId")
|
||||
@@ -75,9 +47,6 @@ namespace MP.FileData.Migrations
|
||||
b.Property<bool>("Active")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<string>("CodArticolo")
|
||||
.HasColumnType("nvarchar(450)");
|
||||
|
||||
b.Property<int>("DiskStatus")
|
||||
.HasColumnType("int");
|
||||
|
||||
@@ -113,8 +82,6 @@ namespace MP.FileData.Migrations
|
||||
|
||||
b.HasKey("FileId");
|
||||
|
||||
b.HasIndex("CodArticolo");
|
||||
|
||||
b.HasIndex("IdxMacchina");
|
||||
|
||||
b.ToTable("Files");
|
||||
@@ -128,9 +95,6 @@ namespace MP.FileData.Migrations
|
||||
b.Property<string>("BasePath")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("CodMacchina")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Descrizione")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
@@ -143,6 +107,9 @@ namespace MP.FileData.Migrations
|
||||
b.Property<string>("Note")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("RuleName")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("ShowOrder")
|
||||
.HasColumnType("int");
|
||||
|
||||
@@ -155,11 +122,11 @@ namespace MP.FileData.Migrations
|
||||
{
|
||||
IdxMacchina = "0",
|
||||
BasePath = "",
|
||||
CodMacchina = "0",
|
||||
Descrizione = "--- Tutte ---",
|
||||
ImgUrl = "",
|
||||
Nome = "--- Tutte ---",
|
||||
Note = "",
|
||||
RuleName = "0",
|
||||
ShowOrder = 0
|
||||
});
|
||||
});
|
||||
@@ -191,16 +158,10 @@ namespace MP.FileData.Migrations
|
||||
|
||||
modelBuilder.Entity("MP.FileData.DatabaseModels.FileModel", b =>
|
||||
{
|
||||
b.HasOne("MP.FileData.DatabaseModels.ArticoloModel", "Articolo")
|
||||
.WithMany()
|
||||
.HasForeignKey("CodArticolo");
|
||||
|
||||
b.HasOne("MP.FileData.DatabaseModels.MacchinaModel", "Macchina")
|
||||
.WithMany()
|
||||
.HasForeignKey("IdxMacchina");
|
||||
|
||||
b.Navigation("Articolo");
|
||||
|
||||
b.Navigation("Macchina");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
+3
-37
@@ -7,26 +7,12 @@ namespace MP.FileData.Migrations
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Articoli",
|
||||
columns: table => new
|
||||
{
|
||||
CodArticolo = table.Column<string>(type: "nvarchar(450)", nullable: false),
|
||||
DescArticolo = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
||||
Disegno = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
||||
Tipo = table.Column<string>(type: "nvarchar(max)", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Articoli", x => x.CodArticolo);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Macchine",
|
||||
columns: table => new
|
||||
{
|
||||
IdxMacchina = table.Column<string>(type: "nvarchar(450)", nullable: false),
|
||||
CodMacchina = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
||||
RuleName = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
||||
Nome = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
||||
Descrizione = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
||||
BasePath = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
||||
@@ -57,7 +43,6 @@ namespace MP.FileData.Migrations
|
||||
FileId = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
Active = table.Column<bool>(type: "bit", nullable: false),
|
||||
CodArticolo = table.Column<string>(type: "nvarchar(450)", nullable: true),
|
||||
IdxMacchina = table.Column<string>(type: "nvarchar(450)", nullable: true),
|
||||
Name = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
||||
Rev = table.Column<int>(type: "int", nullable: false),
|
||||
@@ -73,12 +58,6 @@ namespace MP.FileData.Migrations
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Files", x => x.FileId);
|
||||
table.ForeignKey(
|
||||
name: "FK_Files_Articoli_CodArticolo",
|
||||
column: x => x.CodArticolo,
|
||||
principalTable: "Articoli",
|
||||
principalColumn: "CodArticolo",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
table.ForeignKey(
|
||||
name: "FK_Files_Macchine_IdxMacchina",
|
||||
column: x => x.IdxMacchina,
|
||||
@@ -111,26 +90,16 @@ namespace MP.FileData.Migrations
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.InsertData(
|
||||
table: "Articoli",
|
||||
columns: new[] { "CodArticolo", "DescArticolo", "Disegno", "Tipo" },
|
||||
values: new object[] { "ND", "--- Tutti ---", "", "ND" });
|
||||
|
||||
migrationBuilder.InsertData(
|
||||
table: "Macchine",
|
||||
columns: new[] { "IdxMacchina", "BasePath", "CodMacchina", "Descrizione", "ImgUrl", "Nome", "Note", "ShowOrder" },
|
||||
values: new object[] { "0", "", "0", "--- Tutte ---", "", "--- Tutte ---", "", 0 });
|
||||
columns: new[] { "IdxMacchina", "BasePath", "Descrizione", "ImgUrl", "Nome", "Note", "RuleName", "ShowOrder" },
|
||||
values: new object[] { "0", "", "--- Tutte ---", "", "--- Tutte ---", "", "0", 0 });
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_FileModelTagModel_TagsTagId",
|
||||
table: "FileModelTagModel",
|
||||
column: "TagsTagId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Files_CodArticolo",
|
||||
table: "Files",
|
||||
column: "CodArticolo");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Files_IdxMacchina",
|
||||
table: "Files",
|
||||
@@ -148,9 +117,6 @@ namespace MP.FileData.Migrations
|
||||
migrationBuilder.DropTable(
|
||||
name: "Tags");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Articoli");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Macchine");
|
||||
}
|
||||
@@ -35,34 +35,6 @@ namespace MP.FileData.Migrations
|
||||
b.ToTable("FileModelTagModel");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MP.FileData.DatabaseModels.ArticoloModel", b =>
|
||||
{
|
||||
b.Property<string>("CodArticolo")
|
||||
.HasColumnType("nvarchar(450)");
|
||||
|
||||
b.Property<string>("DescArticolo")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Disegno")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Tipo")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("CodArticolo");
|
||||
|
||||
b.ToTable("Articoli");
|
||||
|
||||
b.HasData(
|
||||
new
|
||||
{
|
||||
CodArticolo = "ND",
|
||||
DescArticolo = "--- Tutti ---",
|
||||
Disegno = "",
|
||||
Tipo = "ND"
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MP.FileData.DatabaseModels.FileModel", b =>
|
||||
{
|
||||
b.Property<int>("FileId")
|
||||
@@ -73,9 +45,6 @@ namespace MP.FileData.Migrations
|
||||
b.Property<bool>("Active")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<string>("CodArticolo")
|
||||
.HasColumnType("nvarchar(450)");
|
||||
|
||||
b.Property<int>("DiskStatus")
|
||||
.HasColumnType("int");
|
||||
|
||||
@@ -111,8 +80,6 @@ namespace MP.FileData.Migrations
|
||||
|
||||
b.HasKey("FileId");
|
||||
|
||||
b.HasIndex("CodArticolo");
|
||||
|
||||
b.HasIndex("IdxMacchina");
|
||||
|
||||
b.ToTable("Files");
|
||||
@@ -126,9 +93,6 @@ namespace MP.FileData.Migrations
|
||||
b.Property<string>("BasePath")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("CodMacchina")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Descrizione")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
@@ -141,6 +105,9 @@ namespace MP.FileData.Migrations
|
||||
b.Property<string>("Note")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("RuleName")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("ShowOrder")
|
||||
.HasColumnType("int");
|
||||
|
||||
@@ -153,11 +120,11 @@ namespace MP.FileData.Migrations
|
||||
{
|
||||
IdxMacchina = "0",
|
||||
BasePath = "",
|
||||
CodMacchina = "0",
|
||||
Descrizione = "--- Tutte ---",
|
||||
ImgUrl = "",
|
||||
Nome = "--- Tutte ---",
|
||||
Note = "",
|
||||
RuleName = "0",
|
||||
ShowOrder = 0
|
||||
});
|
||||
});
|
||||
@@ -189,16 +156,10 @@ namespace MP.FileData.Migrations
|
||||
|
||||
modelBuilder.Entity("MP.FileData.DatabaseModels.FileModel", b =>
|
||||
{
|
||||
b.HasOne("MP.FileData.DatabaseModels.ArticoloModel", "Articolo")
|
||||
.WithMany()
|
||||
.HasForeignKey("CodArticolo");
|
||||
|
||||
b.HasOne("MP.FileData.DatabaseModels.MacchinaModel", "Macchina")
|
||||
.WithMany()
|
||||
.HasForeignKey("IdxMacchina");
|
||||
|
||||
b.Navigation("Articolo");
|
||||
|
||||
b.Navigation("Macchina");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
|
||||
@@ -18,14 +18,9 @@ namespace MP.FileData
|
||||
/// <param name="modelBuilder"></param>
|
||||
public static void Seed(this ModelBuilder modelBuilder)
|
||||
{
|
||||
// inizializzazione dei valori di default x USER
|
||||
// inizializzazione dei valori di default x MACCHINA
|
||||
modelBuilder.Entity<MacchinaModel>().HasData(
|
||||
new MacchinaModel { IdxMacchina = "0", CodMacchina = "0", Descrizione = "--- Tutte ---", Nome = "--- Tutte ---", BasePath = "", ImgUrl = "", Note = "", ShowOrder = 0 }
|
||||
);
|
||||
|
||||
// inizializzazione dei valori di default x Plant
|
||||
modelBuilder.Entity<ArticoloModel>().HasData(
|
||||
new ArticoloModel { CodArticolo = "ND", DescArticolo = "--- Tutti ---", Disegno = "", Tipo = "ND" }
|
||||
new MacchinaModel { IdxMacchina = "0", RuleName = "0", Descrizione = "--- Tutte ---", Nome = "--- Tutte ---", BasePath = "", ImgUrl = "", Note = "", ShowOrder = 0 }
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -59,9 +59,9 @@ namespace MP.FileData
|
||||
|
||||
#region Public Properties
|
||||
|
||||
public virtual DbSet<ArticoloModel> DbSetArticoli { get; set; }
|
||||
public virtual DbSet<MacchinaModel> DbSetMacchine { get; set; }
|
||||
public virtual DbSet<FileModel> DbSetProgFile { get; set; }
|
||||
public virtual DbSet<TagModel> DbSetTags { get; set; }
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MP.FileData
|
||||
{
|
||||
public enum SearchMode
|
||||
{
|
||||
/// <summary>
|
||||
/// Ricerca occorrenze di una RegExp dentro il contenuto del file
|
||||
/// </summary>
|
||||
StringOnFile,
|
||||
|
||||
/// <summary>
|
||||
/// Cerca da path relativo + nume file
|
||||
/// </summary>
|
||||
PathAndName
|
||||
}
|
||||
|
||||
public class SearchRules
|
||||
{
|
||||
#region Public Properties
|
||||
|
||||
/// <summary>
|
||||
/// Estensioni file esclusi
|
||||
/// </summary>
|
||||
public List<string> ExcludedFileExt { get; set; } = new List<string>();
|
||||
|
||||
/// <summary>
|
||||
/// Pattern esclusione Tags (stop-words)
|
||||
/// </summary>
|
||||
public List<string> ExcludedTags { get; set; } = new List<string>();
|
||||
|
||||
/// <summary>
|
||||
/// Pattern in formato RegExp
|
||||
/// </summary>
|
||||
public Dictionary<string, string> FileNameExtReplace { get; set; } = new Dictionary<string, string>();
|
||||
|
||||
/// <summary>
|
||||
/// Quantità massima di caratteri da analizzare, 0 = tutti
|
||||
/// </summary>
|
||||
public int MaxChar2Search { get; set; } = 100;
|
||||
|
||||
/// <summary>
|
||||
/// Modalità ricerca
|
||||
/// </summary>
|
||||
public SearchMode Mode { get; set; } = SearchMode.StringOnFile;
|
||||
|
||||
/// <summary>
|
||||
/// Nome della regola di ricerca
|
||||
/// </summary>
|
||||
public string Name { get; set; } = "ND";
|
||||
|
||||
/// <summary>
|
||||
/// Configurazione opzionale x rimozione filename da output finali
|
||||
/// </summary>
|
||||
public bool OutExcludeFileName { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Replace in uscita per "bonificare" il tag
|
||||
/// </summary>
|
||||
public Dictionary<string, string> OutReplace { get; set; } = new Dictionary<string, string>();
|
||||
|
||||
/// <summary>
|
||||
/// Pattern in formato RegExp
|
||||
/// </summary>
|
||||
public string RegExPattern { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Configurazione opzionale x sostituzione placeholder {{fileName}} in RegExp con il VERO nome file
|
||||
/// </summary>
|
||||
public bool RegExRepFileName { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Configurazione opzionale x sostituzione carriage return --> spazi
|
||||
/// </summary>
|
||||
public bool ReplaceCR { get; set; } = true;
|
||||
|
||||
#endregion Public Properties
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
using NLog;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MP.FileData
|
||||
{
|
||||
/// <summary>
|
||||
/// Helper estrazione tag x programmi
|
||||
/// </summary>
|
||||
public class TagsUtils
|
||||
{
|
||||
#region Private Fields
|
||||
|
||||
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
protected static List<string> ExcludeTags = new List<string>();
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Cerca tag di commento inseriti nel formato
|
||||
/// NOME_PROG(commento)
|
||||
///
|
||||
/// es: O00123(172L D20.5) --> estrae 172L, D20.5
|
||||
/// </summary>
|
||||
/// <param name="fileName">Nome del file (da cercare per contenuto)</param>
|
||||
/// <param name="fileContent">Contenuto del file da analizzare</param>
|
||||
/// <param name="currRule">Parametri analisi</param>
|
||||
/// <returns></returns>
|
||||
public static List<string> searchProgComment(string fileName, string fileContent, SearchRules currRule)
|
||||
{
|
||||
// verifico se trimmare contenuto file
|
||||
if (fileContent.Length > currRule.MaxChar2Search && currRule.MaxChar2Search > 0)
|
||||
{
|
||||
fileContent = fileContent.Substring(0, currRule.MaxChar2Search);
|
||||
}
|
||||
// bonifico: a capo --> spazi
|
||||
fileContent = fileContent.Replace(Environment.NewLine, " ").ToUpper();
|
||||
//string pattern = $"\\b{fileName}" + @".{0,2}\([\w\d\s.]+\)";
|
||||
string pattern = currRule.RegExPattern;
|
||||
if (currRule.RegExRepFileName)
|
||||
{
|
||||
pattern = pattern.Replace("{{fileName}}", fileName);
|
||||
}
|
||||
List<string> answ = new List<string>();
|
||||
if (fileContent.Length > 0)
|
||||
{
|
||||
// uso regexp
|
||||
MatchCollection matchTags = Regex.Matches(fileContent, pattern);
|
||||
if (matchTags.Count > 0)
|
||||
{
|
||||
for (int count = 0; count < matchTags.Count; count++)
|
||||
{
|
||||
string currMatch = matchTags[count].Value;
|
||||
// bonifica preliminare (se richiesta)
|
||||
if (currRule.OutExcludeFileName)
|
||||
{
|
||||
currMatch = currMatch.Replace(fileName, "");
|
||||
}
|
||||
if (currRule.OutReplace.Count > 0)
|
||||
{
|
||||
foreach (var item in currRule.OutReplace)
|
||||
{
|
||||
currMatch = currMatch.Replace(item.Key, item.Value);
|
||||
}
|
||||
}
|
||||
// trim finale
|
||||
currMatch = currMatch.Trim();
|
||||
|
||||
// split con spazi
|
||||
var splitTags = currMatch.Split(" ");
|
||||
foreach (var item in splitTags)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(item))
|
||||
{
|
||||
if (!currRule.ExcludedTags.Contains(item) && item != fileName)
|
||||
{
|
||||
// esclusione valori ignorati
|
||||
answ.Add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// se nullo --> segnalo!
|
||||
if (answ.Count == 0)
|
||||
{
|
||||
Log.Warn($"searchProgComment Attenzione Tag non trovati | {fileName} | pattern: {pattern}{Environment.NewLine}{fileContent}");
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
}
|
||||
}
|
||||
@@ -4,37 +4,17 @@
|
||||
<div class="col-12 small">
|
||||
@if (totalCount > 0)
|
||||
{
|
||||
<Pagination Class="mb-0">
|
||||
<PaginationItem>
|
||||
<PaginationLink Clicked="@HandlePaginationItemClick" Page="1">
|
||||
<i class="fas fa-angle-double-left"></i>
|
||||
</PaginationLink>
|
||||
</PaginationItem>
|
||||
<PaginationItem>
|
||||
<PaginationLink Clicked="@HandlePaginationItemClick" Page="@prevBlock.ToString()">
|
||||
<span aria-hidden="true"><i class="fas fa-angle-left"></i></span>
|
||||
</PaginationLink>
|
||||
</PaginationItem>
|
||||
<ul class="pagination pagination-sm mb-1">
|
||||
<li class="page-item"><button class="page-link" @onclick="() => PaginationItemClick(1)"><i class="fas fa-angle-double-left"></i></button></li>
|
||||
<li class="page-item"><button class="page-link" @onclick="() => PaginationItemClick(prevBlock)"><i class="fas fa-angle-left"></i></button></li>
|
||||
@for (int i = @startPage; i <= endPage; ++i)
|
||||
{
|
||||
var pageNum = i;
|
||||
<PaginationItem Active="@(currPage.Equals(pageNum))">
|
||||
<PaginationLink Clicked="@HandlePaginationItemClick" Page="@pageNum.ToString()">
|
||||
@pageNum
|
||||
</PaginationLink>
|
||||
</PaginationItem>
|
||||
<li class="page-item @cssActive(pageNum)"><button class="page-link" @onclick="() => PaginationItemClick(pageNum)">@pageNum</button></li>
|
||||
}
|
||||
<PaginationItem>
|
||||
<PaginationLink Clicked="@HandlePaginationItemClick" Page="@nextBlock.ToString()">
|
||||
<i class="fas fa-angle-right"></i>
|
||||
</PaginationLink>
|
||||
</PaginationItem>
|
||||
<PaginationItem>
|
||||
<PaginationLink Clicked="@HandlePaginationItemClick" Page="@LastPage.ToString()">
|
||||
<i class="fas fa-angle-double-right"></i>
|
||||
</PaginationLink>
|
||||
</PaginationItem>
|
||||
</Pagination>
|
||||
<li class="page-item"><button class="page-link" @onclick="() => PaginationItemClick(nextBlock)"><i class="fas fa-angle-right"></i></button></li>
|
||||
<li class="page-item"><button class="page-link" @onclick="() => PaginationItemClick(LastPage)"><i class="fas fa-angle-double-right"></i></button></li>
|
||||
</ul>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
@@ -42,9 +22,9 @@
|
||||
<div class="col-12 small">
|
||||
@if (showLoading)
|
||||
{
|
||||
<Progress>
|
||||
<ProgressBar Value="@percLoading" Striped="true" Animated="true" />
|
||||
</Progress>
|
||||
<div class="progress" style="height: 10px;">
|
||||
<div class="progress-bar progress-bar-striped progress-bar-animated" style="width:@percLoading%;"></div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using MP.Prog.Components;
|
||||
using MP.Prog.Data;
|
||||
|
||||
namespace MP.Prog.Components
|
||||
{
|
||||
@@ -168,9 +164,14 @@ namespace MP.Prog.Components
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
protected void HandlePaginationItemClick(string page)
|
||||
protected string cssActive(int numPage)
|
||||
{
|
||||
currPage = int.Parse(page);
|
||||
string answ = "";
|
||||
if (numPage == currPage)
|
||||
{
|
||||
answ = "active";
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
@@ -178,6 +179,11 @@ namespace MP.Prog.Components
|
||||
await Task.Run(() => showLoading = false);
|
||||
}
|
||||
|
||||
protected void PaginationItemClick(int page)
|
||||
{
|
||||
currPage = page;
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
}
|
||||
}
|
||||
@@ -24,8 +24,8 @@
|
||||
</div>
|
||||
<div class="col-4">
|
||||
</div>
|
||||
<div class="col-4 text-right">
|
||||
<span class="border border-danger table-danger px-2"><b>@numChanges</b> modifiche</span>
|
||||
<div class="col-4 text-right p-2">
|
||||
<span class="border border-danger table-danger py-1 px-2"><b>@numChanges</b> modifiche</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -36,9 +36,6 @@ namespace MP.Prog.Components
|
||||
|
||||
#region Public Properties
|
||||
|
||||
[Parameter]
|
||||
public List<ArticoloModel> ArtList { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public FileModel currItem
|
||||
{
|
||||
@@ -61,6 +58,9 @@ namespace MP.Prog.Components
|
||||
[Parameter]
|
||||
public List<MacchinaModel> MacList { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public List<TagModel> TagList { get; set; }
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
#region Private Methods
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
<h3>Test</h3>
|
||||
|
||||
<button type="button" @onclick="@PlaceOrder_Clicked" disabled="@DisablePlaceOrderButton">@Title</button>
|
||||
|
||||
@code{
|
||||
private bool DisablePlaceOrderButton { get; set; } = false;
|
||||
|
||||
public string Title { get; set; } = "Place Order";
|
||||
|
||||
private async Task PlaceOrder_Clicked()
|
||||
{
|
||||
|
||||
await DisablePlaceOrder();
|
||||
|
||||
DisablePlaceOrderButton = false;
|
||||
Title = "Place Order";
|
||||
|
||||
}
|
||||
|
||||
async Task DisablePlaceOrder()
|
||||
{
|
||||
DisablePlaceOrderButton = true;
|
||||
Title = "Wait...";
|
||||
await Task.Delay(1000);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"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
|
||||
}
|
||||
@@ -2,12 +2,16 @@
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using MP.FileData;
|
||||
using Newtonsoft.Json;
|
||||
using NLog;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace MP.Prog.Data
|
||||
{
|
||||
@@ -19,7 +23,7 @@ namespace MP.Prog.Data
|
||||
|
||||
private static ILogger<FileArchDataService> _logger;
|
||||
|
||||
private static List<MP.FileData.DatabaseModels.MacchinaModel> ElencoMacchine = new List<MP.FileData.DatabaseModels.MacchinaModel>();
|
||||
private static List<FileData.DatabaseModels.MacchinaModel> ElencoMacchine = new List<FileData.DatabaseModels.MacchinaModel>();
|
||||
|
||||
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
@@ -50,7 +54,7 @@ namespace MP.Prog.Data
|
||||
|
||||
#region Public Fields
|
||||
|
||||
public static MP.FileData.Controllers.FileController dbController;
|
||||
public static FileData.Controllers.FileController dbController;
|
||||
|
||||
#endregion Public Fields
|
||||
|
||||
@@ -71,7 +75,7 @@ namespace MP.Prog.Data
|
||||
}
|
||||
else
|
||||
{
|
||||
dbController = new MP.FileData.Controllers.FileController(configuration);
|
||||
dbController = new FileData.Controllers.FileController(configuration);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.AppendLine($"DbController OK");
|
||||
_logger.LogInformation(sb.ToString());
|
||||
@@ -100,6 +104,15 @@ namespace MP.Prog.Data
|
||||
|
||||
#endregion Private Properties
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
protected string rulePath(string ruleName)
|
||||
{
|
||||
return string.Format($"Conf/{ruleName}");
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Internal Methods
|
||||
|
||||
internal Task FileApprove(FileData.DatabaseModels.FileModel currItem)
|
||||
@@ -205,39 +218,40 @@ namespace MP.Prog.Data
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public Task<List<MP.FileData.DatabaseModels.ArticoloModel>> ArticoliGetFilt(string SearchVal)
|
||||
{
|
||||
return Task.FromResult(dbController.ArtGetFilt(SearchVal, 200).ToList());
|
||||
//return Task.FromResult(dbController.ArtGetFilt(SearchVal, 20).ToList());
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
// Clear database controller
|
||||
dbController.Dispose();
|
||||
}
|
||||
|
||||
public Task<MP.FileData.DatabaseModels.FileModel> FileGetByKey(int FileId)
|
||||
public Task<FileData.DatabaseModels.FileModel> FileGetByKey(int FileId)
|
||||
{
|
||||
return Task.FromResult(dbController.FileGetByKey(FileId));
|
||||
}
|
||||
|
||||
public Task<List<MP.FileData.DatabaseModels.FileModel>> FileGetFilt(string IdxMacchina, string CodArticolo, bool OnlyActive, bool OnlyMod, string SearchVal)
|
||||
public async Task<List<FileData.DatabaseModels.FileModel>> FileGetFilt(string IdxMacchina, string CodArticolo, bool OnlyActive, bool OnlyMod, string SearchVal)
|
||||
{
|
||||
return Task.FromResult(dbController.FileGetFilt(IdxMacchina, CodArticolo, OnlyActive, OnlyMod, SearchVal).ToList());
|
||||
List<FileData.DatabaseModels.FileModel> dbResult = new List<FileData.DatabaseModels.FileModel>();
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
dbResult = dbController.FileGetFilt(IdxMacchina, CodArticolo, OnlyActive, OnlyMod, SearchVal).ToList();
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Info($"Effettuata lettura da DB + caching per FileGetFilt: {ts.TotalMilliseconds} ms");
|
||||
return await Task.FromResult(dbResult);
|
||||
}
|
||||
|
||||
public Task<List<MP.FileData.DatabaseModels.MacchinaModel>> MacchineGetAll()
|
||||
public Task<List<FileData.DatabaseModels.MacchinaModel>> MacchineGetAll()
|
||||
{
|
||||
return Task.FromResult(dbController.MacchineGetAll().ToList());
|
||||
}
|
||||
|
||||
public Task<List<AutocompleteModel>> MachineList()
|
||||
public async Task<List<AutocompleteModel>> MachineList()
|
||||
{
|
||||
List<AutocompleteModel> answ = new List<AutocompleteModel>();
|
||||
answ.Add(new AutocompleteModel { LabelField = "--- TUTTE ---", ValueField = "*" });
|
||||
answ.AddRange(dbController.MacchineGetAll().Select(x => new AutocompleteModel { LabelField = $"{x.IdxMacchina} | {x.Nome} {x.Descrizione} ", ValueField = x.IdxMacchina }).ToList());
|
||||
return Task.FromResult(answ);
|
||||
return await Task.FromResult(answ);
|
||||
}
|
||||
|
||||
public void rollBackEdit(object item)
|
||||
@@ -245,22 +259,82 @@ namespace MP.Prog.Data
|
||||
dbController.RollBackEntity(item);
|
||||
}
|
||||
|
||||
public async Task<List<FileData.DatabaseModels.TagModel>> TagGetFilt(string SearchVal)
|
||||
{
|
||||
return await Task.FromResult(dbController.TagGetFilt(SearchVal, 200).ToList());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Aggiorna intero archivio scansionando dati x tutte le macchine che hanno un path valido
|
||||
/// </summary>
|
||||
/// <param name="numDayPre">Numero giorni x ricerca all'indietro da data corrente / 0 = nessun limite</param>
|
||||
/// <returns></returns>
|
||||
public async Task updateAllArchive()
|
||||
public async Task<bool> updateAllArchive(int numDayPre)
|
||||
{
|
||||
bool done = false;
|
||||
string ruleName = "Rule01.json";
|
||||
try
|
||||
{
|
||||
var listaMacchine = await MacchineGetAll();
|
||||
foreach (var item in listaMacchine.Where(x => !string.IsNullOrEmpty(x.BasePath)).ToList())
|
||||
{
|
||||
dbController.CheckFileArchived(item.IdxMacchina, item.BasePath, "*.*");
|
||||
if (!string.IsNullOrEmpty(item.RuleName))
|
||||
{ }
|
||||
// gestione confRule...
|
||||
SearchRules currRule = new SearchRules();
|
||||
try
|
||||
{
|
||||
string rawData = File.ReadAllText(rulePath(ruleName));
|
||||
currRule = JsonConvert.DeserializeObject<SearchRules>(rawData);
|
||||
Log.Info($"Conf rule acquisito da file {ruleName}:{Environment.NewLine}{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
|
||||
};
|
||||
|
||||
// serializzo
|
||||
|
||||
string rawRule = JsonConvert.SerializeObject(currRule, Formatting.Indented);
|
||||
Log.Info($"Conf rule generato:{Environment.NewLine}{rawRule}");
|
||||
}
|
||||
|
||||
done = dbController.CheckFileArchived(item.IdxMacchina, item.BasePath, numDayPre, "*.*", currRule);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione in updateAllArchive{Environment.NewLine}{exc}{Environment.NewLine}{exc.InnerException}");
|
||||
}
|
||||
|
||||
return await Task.FromResult(done);
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
@@ -12,10 +12,27 @@ namespace MP.Prog.Data
|
||||
public string CodArticolo { get; set; } = "";
|
||||
public DateTime DateEnd { get; set; } = DateTime.Now.AddMinutes(1);
|
||||
public DateTime DateStart { get; set; } = DateTime.Now.AddDays(-7);
|
||||
|
||||
/// <summary>
|
||||
/// Primo record x selezione paginata, tipicamente primo della "decina" della pagina corrente
|
||||
/// </summary>
|
||||
public int FirstRecord
|
||||
{
|
||||
get
|
||||
{
|
||||
int primaPag = PageNum % 10;
|
||||
int decina = PageNum - primaPag;
|
||||
return PageSize * decina + 1;
|
||||
}
|
||||
}
|
||||
|
||||
public string IdxMacchina { get; set; } = "";
|
||||
public bool OnlyActive { get; set; } = true;
|
||||
public bool OnlyMod { get; set; } = false;
|
||||
|
||||
public int PageNum { get; set; } = 1;
|
||||
public int PageSize { get; set; } = 10;
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
#region Public Methods
|
||||
@@ -43,6 +60,11 @@ namespace MP.Prog.Data
|
||||
{
|
||||
if (!(obj is SelectData item))
|
||||
return false;
|
||||
|
||||
if (PageSize != item.PageSize)
|
||||
return false;
|
||||
if (PageNum != item.PageNum)
|
||||
return false;
|
||||
if (OnlyActive != item.OnlyActive)
|
||||
return false;
|
||||
if (OnlyMod != item.OnlyMod)
|
||||
|
||||
@@ -5,11 +5,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="Components\DataPager.razor.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Remove="Components\DataPager.razor" />
|
||||
<Content Remove="Components\CodArtSelector.razor" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@@ -20,7 +16,8 @@
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.Extensions.Caching.StackExchangeRedis" Version="5.0.1" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="5.0.2" />
|
||||
<PackageReference Include="NLog.Web.AspNetCore" Version="4.13.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||
<PackageReference Include="NLog.Web.AspNetCore" Version="4.14.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
+25
-14
@@ -1,5 +1,7 @@
|
||||
@page "/Archive"
|
||||
|
||||
@using MP.Prog.Components
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header table-primary h3">
|
||||
<div class="row">
|
||||
@@ -10,12 +12,19 @@
|
||||
<div class="form-row">
|
||||
<div class="col-1">
|
||||
<div class="form-group mb-0">
|
||||
<button id="btnForceCheck" class="btn btn-warning btn-sm btn-block" @onclick="() => ForceCheck()" title="Forza verifica archivio">
|
||||
<button id="btnForceCheck" class="btn btn-danger btn-sm btn-block" @onclick="() => ForceCheck(0)" title="Forza verifica archivio (totale)">
|
||||
<i class="far fa-folder-open"></i> <i class="fas fa-sync-alt"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-2">
|
||||
<div class="col-1">
|
||||
<div class="form-group mb-0">
|
||||
<button id="btnForceCheck" class="btn btn-warning btn-sm btn-block" @onclick="() => TestLoading()" title="Ultime modifiche (last 48h)">
|
||||
<i class="far fa-folder-open"></i> <i class="fas fa-sync-alt"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-1">
|
||||
<div class="input-group input-group-sm">
|
||||
<div class="input-group-prepend">
|
||||
</div>
|
||||
@@ -25,17 +34,17 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-2">
|
||||
<div class="col-1">
|
||||
<div class="input-group input-group-sm">
|
||||
<div class="input-group-prepend">
|
||||
</div>
|
||||
<div class="custom-control custom-switch">
|
||||
<input type="checkbox" class="custom-control-input" id="togModificati" title="Solo Aperti / Mostra tutti" @bind-value="@OnlyMod" checked="@OnlyMod" />
|
||||
<label class="custom-control-label small" for="togModificati"><sub>Modifiche</sub></label>
|
||||
<label class="custom-control-label small" for="togModificati"><sub>Mod</sub></label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<div class="col-7">
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text">
|
||||
@@ -47,7 +56,7 @@
|
||||
{
|
||||
foreach (var item in MacList)
|
||||
{
|
||||
<option value="@item.IdxMacchina">@item.Descrizione (@item.CodMacchina)</option>
|
||||
<option value="@item.IdxMacchina">@item.Descrizione (@item.RuleName)</option>
|
||||
}
|
||||
}
|
||||
</select>
|
||||
@@ -65,12 +74,12 @@
|
||||
<div class="card-body p-1">
|
||||
@if (currRecord != null)
|
||||
{
|
||||
<MP.Prog.Components.FileEditor currItem="@currRecord" DataReset="ResetData" DataUpdated="UpdateData" ArtList="@ArtList" MacList="@MacList"></MP.Prog.Components.FileEditor>
|
||||
<FileEditor currItem="@currRecord" DataReset="ResetData" DataUpdated="UpdateData" TagList="@TagList" MacList="@MacList"></FileEditor>
|
||||
}
|
||||
@if (ListRecords == null)
|
||||
{
|
||||
<MP.Prog.Components.LoadingData></MP.Prog.Components.LoadingData>
|
||||
<d2>RELOADING</d2>
|
||||
<h1 class="alert alert-info">Working</h1>
|
||||
<LoadingData></LoadingData>
|
||||
}
|
||||
else if (totalCount == 0)
|
||||
{
|
||||
@@ -89,7 +98,7 @@
|
||||
<th>Size</th>
|
||||
<th class="text-center">State</th>
|
||||
<th>Macchina</th>
|
||||
<th>Articolo</th>
|
||||
<th>Tags</th>
|
||||
<th class="text-right">Modificato</th>
|
||||
@*<th>Controllo</th>*@
|
||||
</tr>
|
||||
@@ -132,12 +141,14 @@
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<div>@record.Macchina.CodMacchina</div>
|
||||
<div>@record.Macchina.Nome</div>
|
||||
<div class="small">@record.Macchina.Descrizione</div>
|
||||
</td>
|
||||
<td>
|
||||
<div>@record.Articolo.Disegno</div>
|
||||
<div class="small">@record.Articolo.DescArticolo</div>
|
||||
@foreach (var item in record.Tags)
|
||||
{
|
||||
<span class="badge badge-info small">@item.TagId</span>
|
||||
}
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<div>@record.LastMod.ToString("yyyy.MM.dd")</div>
|
||||
@@ -156,6 +167,6 @@
|
||||
}
|
||||
</div>
|
||||
<div class="card-footer p-1">
|
||||
@*<DataPager PageSize="numRecord" currPage="currPage" numRecordChanged="ForceReload" numPageChanged="ForceReloadPage" totalCount="totalCount" showLoading="isLoading" />*@
|
||||
<DataPager PageSize="numRecord" currPage="currPage" numRecordChanged="PagerReloadNum" numPageChanged="PagerReloadPage" totalCount="totalCount" showLoading="isLoading" />
|
||||
</div>
|
||||
</div>
|
||||
@@ -5,6 +5,7 @@ using MP.Prog.Data;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MP.Prog.Pages
|
||||
@@ -13,25 +14,23 @@ namespace MP.Prog.Pages
|
||||
{
|
||||
#region Private Fields
|
||||
|
||||
private List<ArticoloModel> ArtList;
|
||||
|
||||
private FileModel currRecord = null;
|
||||
private List<FileModel> ListRecords;
|
||||
private List<MacchinaModel> MacList;
|
||||
private List<FileModel> SearchRecords;
|
||||
private List<TagModel> TagList;
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
protected string _SearchArt;
|
||||
protected string _SearchTag;
|
||||
|
||||
protected string defCodArt = "";
|
||||
protected string defTag = "";
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Private Properties
|
||||
|
||||
#if false
|
||||
private int _currPage { get; set; } = 1;
|
||||
|
||||
private int _numRecord { get; set; } = 10;
|
||||
@@ -49,9 +48,37 @@ namespace MP.Prog.Pages
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#region Private Properties
|
||||
|
||||
private int currPage
|
||||
{
|
||||
get
|
||||
{
|
||||
return AppMService.File_Filter.PageNum;
|
||||
}
|
||||
set
|
||||
{
|
||||
AppMService.File_Filter.PageNum = value;
|
||||
}
|
||||
}
|
||||
|
||||
private bool isLoading { get; set; } = false;
|
||||
|
||||
private int numRecord
|
||||
{
|
||||
get
|
||||
{
|
||||
return AppMService.File_Filter.PageSize;
|
||||
}
|
||||
set
|
||||
{
|
||||
AppMService.File_Filter.PageSize = value;
|
||||
}
|
||||
}
|
||||
|
||||
#if false
|
||||
private int numRecord
|
||||
{
|
||||
get => _numRecord;
|
||||
@@ -65,6 +92,7 @@ namespace MP.Prog.Pages
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
private bool OnlyActive
|
||||
{
|
||||
@@ -110,28 +138,6 @@ namespace MP.Prog.Pages
|
||||
}
|
||||
}
|
||||
|
||||
private string SelCodArt
|
||||
{
|
||||
get
|
||||
{
|
||||
string answ = "";
|
||||
if (AppMService.File_Filter != null)
|
||||
{
|
||||
answ = AppMService.File_Filter.CodArticolo;
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (!AppMService.File_Filter.CodArticolo.Equals(value))
|
||||
{
|
||||
AppMService.File_Filter.CodArticolo = value;
|
||||
var pUpd = Task.Run(async () => await ReloadData());
|
||||
pUpd.Wait();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private string SelIdxMacc
|
||||
{
|
||||
get
|
||||
@@ -170,26 +176,25 @@ namespace MP.Prog.Pages
|
||||
[Inject]
|
||||
protected NavigationManager NavManager { get; set; }
|
||||
|
||||
protected string SearchArt
|
||||
protected string SearchTag
|
||||
{
|
||||
get
|
||||
{
|
||||
return _SearchArt;
|
||||
return _SearchTag;
|
||||
}
|
||||
set
|
||||
{
|
||||
isLoading = true;
|
||||
_SearchArt = value;
|
||||
_SearchTag = value;
|
||||
// se son > 3 char... debounce...
|
||||
if (string.IsNullOrEmpty(value))
|
||||
{
|
||||
_SearchArt = defCodArt;
|
||||
_SearchTag = defTag;
|
||||
}
|
||||
if (value.Length >= defCodArt.Length)
|
||||
if (value.Length >= defTag.Length)
|
||||
{
|
||||
var pUpd = Task.Run(async () =>
|
||||
{
|
||||
ArtList = await DataService.ArticoliGetFilt(SearchArt);
|
||||
TagList = await DataService.TagGetFilt(SearchTag);
|
||||
});
|
||||
pUpd.Wait();
|
||||
}
|
||||
@@ -245,14 +250,6 @@ namespace MP.Prog.Pages
|
||||
return answ;
|
||||
}
|
||||
|
||||
private async Task ReloadData()
|
||||
{
|
||||
isLoading = true;
|
||||
SearchRecords = await DataService.FileGetFilt(AppMService.File_Filter.IdxMacchina, AppMService.File_Filter.CodArticolo, AppMService.File_Filter.OnlyActive, AppMService.File_Filter.OnlyMod, AppMService.SearchVal);
|
||||
ListRecords = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList();
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
|
||||
#region Protected Methods
|
||||
@@ -264,37 +261,45 @@ namespace MP.Prog.Pages
|
||||
pUpd.Wait();
|
||||
}
|
||||
|
||||
protected async Task ForceCheck()
|
||||
protected void ForceCheck(int maxHour)
|
||||
{
|
||||
isLoading = true;
|
||||
await DataService.updateAllArchive();
|
||||
currRecord = null;
|
||||
SearchRecords = null;
|
||||
ListRecords = null;
|
||||
AppMService.File_Filter = SelectData.Init(5, 10);
|
||||
isLoading = false;
|
||||
await ReloadAllData();
|
||||
}
|
||||
|
||||
protected void ForceReload(int newNum)
|
||||
{
|
||||
numRecord = newNum;
|
||||
}
|
||||
|
||||
protected void ForceReloadPage(int newNum)
|
||||
{
|
||||
currPage = newNum;
|
||||
var pUpd = Task.Run(async () =>
|
||||
{
|
||||
currRecord = null;
|
||||
SearchRecords = null;
|
||||
ListRecords = null;
|
||||
await DataService.updateAllArchive(maxHour);
|
||||
AppMService.File_Filter = SelectData.Init(5, 10);
|
||||
await ReloadAllData();
|
||||
isLoading = false;
|
||||
});
|
||||
pUpd.Wait();
|
||||
}
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
DataService.ResetController();
|
||||
SearchArt = defCodArt;
|
||||
SearchTag = defTag;
|
||||
AppMService.ShowSearch = false;
|
||||
AppMService.PageName = "Archivio File Programmi";
|
||||
AppMService.PageIcon = "fas fa-folder pr-2";
|
||||
AppMService.EA_SearchUpdated += OnSeachUpdated;
|
||||
await ReloadAllData();
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
protected async Task PagerReloadNum(int newNum)
|
||||
{
|
||||
numRecord = newNum;
|
||||
await ReloadData();
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
protected async Task PagerReloadPage(int newNum)
|
||||
{
|
||||
currPage = newNum;
|
||||
await ReloadData();
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
protected async Task ReloadAllData()
|
||||
@@ -302,14 +307,20 @@ namespace MP.Prog.Pages
|
||||
isLoading = true;
|
||||
MacList = await DataService.MacchineGetAll();
|
||||
SelIdxMacc = "0";
|
||||
SearchArt = defCodArt;
|
||||
|
||||
ArtList = await DataService.ArticoliGetFilt(SearchArt);
|
||||
|
||||
isLoading = false;
|
||||
SearchTag = defTag;
|
||||
TagList = await DataService.TagGetFilt(SearchTag);
|
||||
await ReloadData();
|
||||
}
|
||||
|
||||
protected async Task ReloadData()
|
||||
{
|
||||
isLoading = true;
|
||||
await Task.Delay(1);
|
||||
SearchRecords = await DataService.FileGetFilt(AppMService.File_Filter.IdxMacchina, AppMService.File_Filter.CodArticolo, AppMService.File_Filter.OnlyActive, AppMService.File_Filter.OnlyMod, AppMService.SearchVal);
|
||||
// faccio paginazione SOLO NELLA DECINA attuale... (quindi non tutte le pagine ma solo subset)
|
||||
ListRecords = SearchRecords.Skip(numRecord * (currPage % 10 - 1)).Take(numRecord).ToList();
|
||||
}
|
||||
|
||||
protected void ResetData()
|
||||
{
|
||||
DataService.rollBackEdit(currRecord);
|
||||
@@ -322,18 +333,14 @@ namespace MP.Prog.Pages
|
||||
SearchRecords = null;
|
||||
ListRecords = null;
|
||||
AppMService.File_Filter = SelectData.Init(5, 10);
|
||||
SearchArt = defCodArt;
|
||||
SearchTag = defTag;
|
||||
await ReloadAllData();
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
protected void ResetSearchArt()
|
||||
protected void ResetSearchTag()
|
||||
{
|
||||
SearchArt = defCodArt;
|
||||
}
|
||||
|
||||
protected void searchArtUpd(string newCod)
|
||||
{
|
||||
SelCodArt = newCod;
|
||||
SearchTag = defTag;
|
||||
}
|
||||
|
||||
protected void Select(FileModel selRecord)
|
||||
@@ -342,6 +349,19 @@ namespace MP.Prog.Pages
|
||||
currRecord = selRecord;
|
||||
}
|
||||
|
||||
protected async Task TestLoading()
|
||||
{
|
||||
//isLoading = !isLoading;
|
||||
await TestLoadingCloseTest();
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
protected async Task TestLoadingCloseTest()
|
||||
{
|
||||
isLoading = true;
|
||||
await Task.Delay(1000);
|
||||
}
|
||||
|
||||
protected async Task UpdateData()
|
||||
{
|
||||
currRecord = null;
|
||||
|
||||
@@ -8,45 +8,8 @@
|
||||
|
||||
<h3>Setup</h3>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<textarea @bind="@oldText" cols="50" rows="30" />
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<textarea @bind="@newText" cols="50" rows="30" />
|
||||
</div>
|
||||
<div class="col-12">
|
||||
<MP.Prog.Components.DiffView oldText="@oldText" newText="@newText"></MP.Prog.Components.DiffView>
|
||||
</div>
|
||||
</div>
|
||||
<MP.Prog.Components.Test></MP.Prog.Components.Test>
|
||||
|
||||
@code {
|
||||
|
||||
protected string _oldText = "Prova primo testo";
|
||||
protected string _newText = "Prova secondo testo";
|
||||
|
||||
protected string oldText
|
||||
{
|
||||
get
|
||||
{
|
||||
return _oldText;
|
||||
}
|
||||
set
|
||||
{
|
||||
_oldText = value;
|
||||
}
|
||||
}
|
||||
|
||||
protected string newText
|
||||
{
|
||||
get
|
||||
{
|
||||
return _newText;
|
||||
}
|
||||
set
|
||||
{
|
||||
_newText = value;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<RootNamespace>MP.Stats</RootNamespace>
|
||||
<UserSecretsId>826e877c-ba70-4253-84cb-d0b1cafd4440</UserSecretsId>
|
||||
<Version>1.0.2109.0318</Version>
|
||||
<Version>1.0.2109.1308</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<body>
|
||||
<i>Modulo statistiche MAPO</i>
|
||||
<h4>Versione: 1.0.2109.0318</h4>
|
||||
<h4>Versione: 1.0.2109.1308</h4>
|
||||
<br />
|
||||
Note di rilascio:
|
||||
<ul>
|
||||
|
||||
@@ -1 +1 @@
|
||||
1.0.2109.0318
|
||||
1.0.2109.1308
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<item>
|
||||
<version>1.0.2109.0318</version>
|
||||
<version>1.0.2109.1308</version>
|
||||
<url>http://nexus.steamware.net/repository/SWS/MP-STATS/stable/0/MP.Stats.zip</url>
|
||||
<changelog>http://nexus.steamware.net/repository/SWS/MP-STATS/stable/0/ChangeLog.html</changelog>
|
||||
<mandatory>false</mandatory>
|
||||
|
||||
Reference in New Issue
Block a user