Merge branch 'release/UpdateCompoComparer01'

This commit is contained in:
Samuele Locatelli
2023-09-11 12:01:36 +02:00
14 changed files with 570 additions and 246 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>WebDoorCreator - Egalware</i>
<h4>Version: 0.9.2309.0516</h4>
<h4>Version: 0.9.2309.1112</h4>
<br /> Release note:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
0.9.2309.0516
0.9.2309.1112
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>0.9.2309.0516</version>
<version>0.9.2309.1112</version>
<url>http://nexus.steamware.net/repository/SWS/WDC/stable/WDC.UI.zip</url>
<changelog>http://nexus.steamware.net/repository/SWS/WDC/stable/ChangeLog.html</changelog>
<mandatory>false</mandatory>
+1 -1
View File
@@ -9,7 +9,7 @@ using static WebDoorCreator.Core.Enum;
namespace WebDoorCreator.Data.DTO
{
/// <summary>
/// COmpany data DTO
/// File data DTO
/// </summary>
[Serializable]
public class FileDTO
@@ -8,6 +8,7 @@ using NLog;
using Org.BouncyCastle.Asn1.Pkcs;
using StackExchange.Redis;
using System.Diagnostics;
using System.IdentityModel.Tokens.Jwt;
using System.Security.Cryptography;
using System.Text;
using WebDoorCreator.Core;
@@ -3479,10 +3480,14 @@ namespace WebDoorCreator.Data.Services
/// Esegue scansione dir richeista
/// </summary>
/// <param name="rootPath"></param>
/// <param name="useCache">indica se leggere da cache Redis(true) o da FS (false)</param>
/// <returns></returns>
public async Task<Dictionary<string, FileDTO>> scanSrcDestDir(string rootPath)
public async Task<Dictionary<string, FileDTO>> scanSrcDestDir(string rootPath, bool useCache)
{
await Task.Delay(1);
string mode = "FS";
string currKey = $"{Constants.rKeyDirsScan}:{rootPath}";
string? rawData = "";
List<FileDTO> dirAFiles = new List<FileDTO>();
Dictionary<string, FileDTO> filesDict = new Dictionary<string, FileDTO>();
try
@@ -3490,78 +3495,93 @@ namespace WebDoorCreator.Data.Services
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
string[] dirs = Directory.GetDirectories(rootPath);
using (MD5 md5 = MD5.Create())
if (useCache)
{
foreach (var dir in dirs)
mode = "cache";
rawData = await redisDb.StringGetAsync(currKey);
if (!string.IsNullOrEmpty(rawData))
{
string[] iniFiles = Directory.GetFiles(dir, "Config.ini");
string compoCode = "";
foreach (var file in iniFiles)
var rawList = JsonConvert.DeserializeObject<Dictionary<string, FileDTO>>(rawData);
if(rawList!=null)
{
List<string> lines = File.ReadAllLines(file).ToList();
IniFile fIni = new IniFile(file);
var compoName = fIni.ReadString("Compo", "Name", "COMPONAME");
var compoT = fIni.ReadString("Template", "Name", "TEMPSHAPE");
compoCode = compoName.Split("/")[0].Trim();
filesDict = rawList;
}
string[] templateDirectories = Directory.GetDirectories(dir);
}
}
else
{
foreach (var tplDir in templateDirectories)
string[] dirs = Directory.GetDirectories(rootPath);
using (MD5 md5 = MD5.Create())
{
foreach (var dir in dirs)
{
string[] tpls = Directory.GetFiles(tplDir, "*");
//var archiviedFiles = dbController.DoorOpTypeGetByPath(tplDir);
foreach (var tpl in tpls)
string[] iniFiles = Directory.GetFiles(dir, "Config.ini");
string compoCode = "";
foreach (var file in iniFiles)
{
FileInfo fi = new FileInfo(tpl);
var fileName = Path.GetFileName(tpl).Split("\\")[Path.GetFileName(tpl).Split("\\").Length - 1];
var fileContent = File.ReadAllBytes(tpl);
var hash = md5.ComputeHash(fileContent);
var newMD5 = BitConverter.ToString(hash).Replace("-", "").ToLowerInvariant();
FileDTO currFileInfo = new FileDTO()
{
//FileBaseDir = tplDir,
//FileAbsPath = fi.FullName,
FileRelPath = fileName,
FileDim = fi.Length,
FileMD5 = newMD5,
lastModTime = fi.LastWriteTime
};
string relDirPath = fi.FullName.Replace($"{rootPath}\\", "");
var src = relDirPath.Split("\\").ToArray();
//var src = fi.FullName.Split("\\").Skip(6).ToArray();
StringBuilder sb = new StringBuilder();
foreach (var line in src)
{
if (src.Last().ToString() == line)
{
sb.Append($"{line}");
}
else
{
sb.Append($"{line}\\");
}
}
List<string> lines = File.ReadAllLines(file).ToList();
IniFile fIni = new IniFile(file);
if (!filesDict.ContainsKey(sb.ToString()))
var compoName = fIni.ReadString("Compo", "Name", "COMPONAME");
var compoT = fIni.ReadString("Template", "Name", "TEMPSHAPE");
compoCode = compoName.Split("/")[0].Trim();
}
string[] templateDirectories = Directory.GetDirectories(dir);
foreach (var tplDir in templateDirectories)
{
string[] tpls = Directory.GetFiles(tplDir, "*");
//var archiviedFiles = dbController.DoorOpTypeGetByPath(tplDir);
foreach (var tpl in tpls)
{
filesDict.Add(sb.ToString(), currFileInfo);
FileInfo fi = new FileInfo(tpl);
var fileName = Path.GetFileName(tpl).Split("\\")[Path.GetFileName(tpl).Split("\\").Length - 1];
var fileContent = File.ReadAllBytes(tpl);
var hash = md5.ComputeHash(fileContent);
var newMD5 = BitConverter.ToString(hash).Replace("-", "").ToLowerInvariant();
FileDTO currFileInfo = new FileDTO()
{
//FileBaseDir = tplDir,
//FileAbsPath = fi.FullName,
FileRelPath = fileName,
FileDim = fi.Length,
FileMD5 = newMD5,
lastModTime = fi.LastWriteTime
};
string relDirPath = fi.FullName.Replace($"{rootPath}\\", "");
var src = relDirPath.Split("\\").ToArray();
//var src = fi.FullName.Split("\\").Skip(6).ToArray();
StringBuilder sb = new StringBuilder();
foreach (var line in src)
{
if (src.Last().ToString() == line)
{
sb.Append($"{line}");
}
else
{
sb.Append($"{line}\\");
}
}
if (!filesDict.ContainsKey(sb.ToString()))
{
filesDict.Add(sb.ToString(), currFileInfo);
}
}
}
}
}
rawData = JsonConvert.SerializeObject(filesDict);
await redisDb.StringSetAsync(currKey, rawData);
}
string currKey = $"{Constants.rKeyDirsScan}:{rootPath}";
string rawData = JsonConvert.SerializeObject(filesDict);
await redisDb.StringSetAsync(currKey, rawData);
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
Log.Debug($"scanSrcDestDir in: {ts.TotalMilliseconds} ms");
Log.Debug($"scanSrcDestDir | {mode} | done in: {ts.TotalMilliseconds} ms");
}
catch (Exception exc)
{
@@ -1,12 +1,77 @@
<div class="d-flex justify-content-between my-2">
<div class="col-5 text-center fw-bold border-bottom border-secondary" style="font-size: 1.5rem;">
New Data
<div class="col-5 text-center fw-bold border-bottom border-secondary fs-3">
<div class="row">
<div class="col-3">
@if (showBtnNew)
{
<button class="btn btn-primary w-100" @onclick="()=>doScan(false, true)">Scan NEW <i class="fa-solid fa-arrows-rotate"></i></button>
}
</div>
<div class="col-6">
New Data
</div>
<div class="col-3">
@if (showBtnNew)
{
<button class="btn btn-dark w-100" @onclick="()=>doScan(true, true)">ALL <i class="fa-solid fa-arrows-rotate"></i></button>
}
</div>
</div>
</div>
<div class="col-2 text-center"><button class="btn btn-dark" @onclick="()=>doScan()">Scan Dir New</button></div>
<div class="col-5 text-center fw-bold border-bottom border-secondary" style="font-size: 1.5rem;">
Current Data
<div class="col-2 text-center">
@* <button class="btn btn-dark" @onclick="()=>doScan()">Scan Dir New</button> *@
</div>
<div class="col-5 text-center fw-bold border-bottom border-secondary fs-3">
<div class="row">
<div class="col-3">
@if (showBtnCur)
{
<button class="btn btn-dark w-100" @onclick="()=>doScan(true, true)">ALL <i class="fa-solid fa-arrows-rotate"></i></button>
}
</div>
<div class="col-6">
Current Data
</div>
<div class="col-3">
@if (showBtnCur)
{
<button class="btn btn-primary w-100" @onclick="()=>doScan(true, false)">Scan Current <i class="fa-solid fa-arrows-rotate"></i></button>
}
</div>
</div>
</div>
</div>
<div class="d-flex justify-content-between my-2">
<div class="col-4 text-center">
@if (ListType != null)
{
<select @bind="@TypeSel" class="form-select">
<option value="*">-- All Types --</option>
@foreach (var item in ListType)
{
<option value="@item">@item</option>
}
</select>
}
</div>
<div class="col-4 text-center">
</div>
<div class="col-4 text-end">
@if (searchRecords != null && searchRecords.Count() > 0)
{
<div class="text-nowrap">
<div class="btn-group" role="group">
<button type="button" class="btn btn-sm col-3 btn-secondary" disabled>FILTER BY: </button>
<button type="button" class="btn btn-sm col-3 @filtBtnAddCss()" @onclick="()=>filtBtnSet(Core.Enum.fileStatus.add)">Add</button>
<button type="button" class="btn btn-sm col-3 @filtBtnUpdCss()" @onclick="()=>filtBtnSet(Core.Enum.fileStatus.mod)">Update</button>
@* <button type="button" class="btn btn-sm col-3 @filtBtnRemCss()" @onclick="()=>filtBtnSet(Core.Enum.fileStatus.rem)">Delete</button> *@
</div>
</div>
}
</div>
</div>
@if (isLoading)
{
@@ -17,74 +82,73 @@ else if (files2Chk != null && files2Chk.Count() > 0)
<table class="table table-striped">
<thead>
<tr class="row">
@*<th class="col-1"></th>*@
<th class="col-1">Type</th>
<th class="col-1">Folder</th>
<th class="col-1">File</th>
<th class="col-1">Size</th>
<th class="col-4 text-center">
<th class="col-3 text-end">Folder/File</th>
<th class="col-1 text-end">Size</th>
<th class="col-2 text-center">
<input class="form-check-input mt-0" type="checkbox" value="" id="selUns" aria-label="Select or Unselect all" @bind="@selUns">
<label for="#selUns">Select/Unselect all</label>
</th>
<th class="col-1">Type</th>
<th class="col-1">Folder</th>
<th class="col-1">File</th>
<th class="col-1">Size</th>
@*<th class="col-1"></th>*@
<th class="col-3 text-end">Folder/File</th>
<th class="col-1 text-end">Size</th>
</tr>
</thead>
<tbody>
@foreach (var item in files2Chk)
@if (isDrawing)
{
<tr class="row" style="cursor: pointer;">
@*<td class="col-1">
<button class="btn btn-sm btn-info" data-bs-toggle="modal" data-bs-target="#fileDiffModal" @onclick="()=>showDiff(item, item.Value.status)"><i class="fa-solid fa-magnifying-glass"></i></button>
</td>*@
@if (item.Value.status == Core.Enum.fileStatus.add || item.Value.status == Core.Enum.fileStatus.mod)
{
<td class="col-1" data-bs-toggle="modal" data-bs-target="#fileDiffModal" @onclick="()=>showDiff(item, item.Value.status)">
@item.Key.Split("\\")[0]
<LoadingData></LoadingData>
}
else
{
@foreach (var item in files2Chk)
{
<tr class="row" style="cursor: pointer;">
@if (item.Value.status == Core.Enum.fileStatus.add || item.Value.status == Core.Enum.fileStatus.mod)
{
<td class="col-1" data-bs-toggle="modal" data-bs-target="#fileDiffModal" @onclick="()=>showDiff(item, item.Value.status)">
<h5><b>@item.Key.Split("\\")[0]</b></h5>
</td>
<td class="col-3 text-end" data-bs-toggle="modal" data-bs-target="#fileDiffModal" @onclick="()=>showDiff(item, item.Value.status)">
<b>@item.Key.Split("\\")[1]</b>
<div class="small">
@item.Value.FileRelPath
@* @item.Key.Split("\\")[2] *@
</div>
</td>
<td class="col-1 text-end" data-bs-toggle="modal" data-bs-target="#fileDiffModal" @onclick="()=>showDiff(item, item.Value.status)">
@($"{item.Value.FileDim / 1024} kb")
</td>
}
else
{
<td class="col-5" colspan="4" data-bs-toggle="modal" data-bs-target="#fileDiffModal" @onclick="()=>showDiff(item, item.Value.status)"></td>
}
<td class="col-2 text-center">
<button class="btn @btnCssClass(item.Value.status, item.Value.action)" @onclick="()=>changeDoAct(item)" disabled="@(item.Value.status== Core.Enum.fileStatus.rem)">@btnTxt(item.Value.status) &nbsp; <i class="@btnIcon(item.Value.status)"></i></button>
</td>
<td class="col-1" data-bs-toggle="modal" data-bs-target="#fileDiffModal" @onclick="()=>showDiff(item, item.Value.status)">
@item.Key.Split("\\")[1]
</td>
<td class="col-1" data-bs-toggle="modal" data-bs-target="#fileDiffModal" @onclick="()=>showDiff(item, item.Value.status)">
@item.Key.Split("\\")[2]
</td>
<td class="col-1" data-bs-toggle="modal" data-bs-target="#fileDiffModal" @onclick="()=>showDiff(item, item.Value.status)">
@($"{item.Value.FileDim / 1024} kb")
</td>
}
else
{
<td class="col-4" colspan="4" data-bs-toggle="modal" data-bs-target="#fileDiffModal" @onclick="()=>showDiff(item, item.Value.status)"></td>
}
<td class="col-4 text-center">
<button class="btn @btnCssClass(item.Value.status, item.Value.action)" @onclick="()=>changeDoAct(item)">@btnTxt(item.Value.status) &nbsp; <i class="@btnIcon(item.Value.status)"></i></button>
</td>
@if (item.Value.status == Core.Enum.fileStatus.rem || item.Value.status == Core.Enum.fileStatus.mod)
{
<td class="col-1" data-bs-toggle="modal" data-bs-target="#fileDiffModal" @onclick="()=>showDiff(item, item.Value.status)">
@item.Key.Split("\\")[0]
</td>
<td class="col-1" data-bs-toggle="modal" data-bs-target="#fileDiffModal" @onclick="()=>showDiff(item, item.Value.status)">
@item.Key.Split("\\")[1]
</td>
<td class="col-1" data-bs-toggle="modal" data-bs-target="#fileDiffModal" @onclick="()=>showDiff(item, item.Value.status)">
@item.Key.Split("\\")[2]
</td>
<td class="col-1" data-bs-toggle="modal" data-bs-target="#fileDiffModal" @onclick="()=>showDiff(item, item.Value.status)">
@($"{item.Value.FileDim / 1024} kb")
</td>
}
else
{
<td class="col-4" colspan="4" data-bs-toggle="modal" data-bs-target="#fileDiffModal" @onclick="()=>showDiff(item, item.Value.status)"></td>
}
@*<td class="col-1 text-end">
<button class="btn btn-sm btn-info" data-bs-toggle="modal" data-bs-target="#fileDiffModal" @onclick="()=>showDiff(item, item.Value.status)"><i class="fa-solid fa-magnifying-glass"></i></button>
</td>*@
</tr>
@if (item.Value.status == Core.Enum.fileStatus.rem || item.Value.status == Core.Enum.fileStatus.mod)
{
<td class="col-1" data-bs-toggle="modal" data-bs-target="#fileDiffModal" @onclick="()=>showDiff(item, item.Value.status)">
<h5><b>@item.Key.Split("\\")[0]</b></h5>
</td>
<td class="col-3 text-end" data-bs-toggle="modal" data-bs-target="#fileDiffModal" @onclick="()=>showDiff(item, item.Value.status)">
<b>@item.Key.Split("\\")[1]</b>
<div class="small">
@item.Value.FileRelPath
@* @item.Key.Split("\\")[2] *@
</div>
</td>
<td class="col-1 text-end" data-bs-toggle="modal" data-bs-target="#fileDiffModal" @onclick="()=>showDiff(item, item.Value.status)">
@($"{item.Value.FileDim / 1024} kb")
</td>
}
else
{
<td class="col-5" colspan="4" data-bs-toggle="modal" data-bs-target="#fileDiffModal" @onclick="()=>showDiff(item, item.Value.status)"></td>
}
</tr>
}
}
</tbody>
</table>
@@ -102,8 +166,15 @@ else if (files2Chk != null && files2Chk.Count() > 0)
else if (files2Chk == null || files2Chk.Count() == 0)
{
<div class="alert alert-info text-dark">
<div class="w-100 text-center fs-4"><i class="fa-solid fa-arrow-up"></i></div>
<div class="w-100 text-center fs-4">@scanMsg</div>
<div class="w-100 text-center fs-4">
@scanMsg
</div>
<div class="w-100 text-center fs-4">
<i class="fa-solid fa-arrow-down"></i>
</div>
<div class="w-100 text-center fs-4">
<button class="btn btn-dark btn-lg" @onclick="()=>doScan(true, true)">Scan Data</button>
</div>
</div>
}
@@ -1,6 +1,5 @@
using Microsoft.AspNetCore.Components;
using NLog;
using System.Text;
using WebDoorCreator.Data.DbModels;
using WebDoorCreator.Data.DTO;
using WebDoorCreator.Data.Services;
@@ -10,20 +9,7 @@ namespace WebDoorCreator.UI.Components.FilesMan
{
public partial class CompoCompare
{
protected List<DoorOpTypeModel> tempDOT = new List<DoorOpTypeModel>();
private Dictionary<string, FileDTO> files2Chk = new Dictionary<string, FileDTO>();
private Dictionary<string, FileDTO> searchRecords = new Dictionary<string, FileDTO>();
private Dictionary<string, FileDTO> files2Save = new Dictionary<string, FileDTO>();
private int sendDataMaxVal = 100;
private int sendDataNextVal = 0;
private int sendDataVal = 0;
private string titleMsg = "Scanning directories";
private string scanMsg = "CLICK TO SCAN";
#region Public Properties
[Parameter]
public CompoSelectFilter actFilter { get; set; } = new CompoSelectFilter();
@@ -31,77 +17,79 @@ namespace WebDoorCreator.UI.Components.FilesMan
[Parameter]
public EventCallback<int> updateRecordCount { get; set; }
#endregion Public Properties
#region Protected Fields
protected static Logger Log = LogManager.GetCurrentClassLogger();
protected List<DoorOpTypeModel> tempDOT = new List<DoorOpTypeModel>();
#endregion Protected Fields
#region Protected Properties
protected bool _showAdd { get; set; } = true;
protected bool _showDel { get; set; } = true;
protected bool _showUpd { get; set; } = true;
protected KeyValuePair<string, FileDTO> actFile { get; set; } = new KeyValuePair<string, FileDTO>();
[Inject]
protected IConfiguration configuration { get; set; } = null!;
protected double expTime { get; set; } = 6;
protected bool isLoading { get; set; } = false;
protected bool isDrawing { get; set; } = false;
protected int numSteps { get; set; } = 4;
protected bool show { get; set; } = false;
protected string txtSx { get; set; } = "";
protected bool showAdd
{
get => _showAdd;
set => _showAdd = value;
}
protected bool showBtnCur
{
get => NumFileCur > 0;
}
protected bool showBtnNew
{
get => NumFileNew > 0;
}
protected bool showDel
{
get => _showDel;
set => _showDel = value;
}
protected bool showUpd
{
get => _showUpd;
set => _showUpd = value;
}
protected string txtDx { get; set; } = "";
protected string txtSx { get; set; } = "";
[Inject]
protected WebDoorCreatorService WDCService { get; set; } = null!;
private bool _selUns { get; set; } = false;
[Inject]
protected WDCUserService WDCUService { get; set; } = null!;
private int _totalCount { get; set; } = 0;
#endregion Protected Properties
private int currPage
{
get => actFilter.CurrPage;
set
{
selUns = false;
actFilter.CurrPage = value;
}
}
private int numRecord
{
get => actFilter.NumRec;
set => actFilter.NumRec = value;
}
private string rootPathNew
{
get => configuration.GetValue<string>("CompoBaseDirs:NewCompoDir");
}
private string rootPathOld
{
get => configuration.GetValue<string>("CompoBaseDirs:CurrCompoDir");
}
private string rootPathBck
{
get => configuration.GetValue<string>("CompoBaseDirs:BckCompoDir");
}
private bool selUns
{
get => _selUns;
set
{
_selUns = value;
selectAll(_selUns);
}
}
private int totalCount
{
get => _totalCount;
set
{
if (_totalCount != value)
{
_totalCount = value;
updateRecordCount.InvokeAsync(value);
}
}
}
#region Protected Methods
protected string btnCssClass(Core.Enum.fileStatus fStat, bool doAct)
{
@@ -179,24 +167,23 @@ namespace WebDoorCreator.UI.Components.FilesMan
foreach (var dir in fileDirs.SkipLast(1))
{
dir2chk += $"\\{dir}";
if (!Directory.Exists($"{rootPathOld}{dir2chk}"))
if (!Directory.Exists($"{rootPathCur}{dir2chk}"))
{
Directory.CreateDirectory($"{rootPathOld}{dir2chk}");
Directory.CreateDirectory($"{rootPathCur}{dir2chk}");
}
}
if (item.Value.status == Core.Enum.fileStatus.add)
{
File.Copy($"{rootPathNew}\\{item.Key}", $"{rootPathOld}\\{item.Key}");
File.Copy($"{rootPathNew}\\{item.Key}", $"{rootPathCur}\\{item.Key}");
}
else if (item.Value.status == Core.Enum.fileStatus.mod)
{
ReplaceFile($"{rootPathNew}\\{item.Key}", $"{rootPathOld}\\{item.Key}");
ReplaceFile($"{rootPathNew}\\{item.Key}", $"{rootPathCur}\\{item.Key}");
}
else if (item.Value.status == Core.Enum.fileStatus.rem)
{
File.Delete($"{rootPathOld}\\{item.Key}");
File.Delete($"{rootPathCur}\\{item.Key}");
}
}
}
@@ -205,25 +192,26 @@ namespace WebDoorCreator.UI.Components.FilesMan
sendDataVal = 30;
var updTask2 = Task.Run(async () =>
{
await WDCService.ListValuesLuaNgeInsert(rootPathOld);
await WDCService.ListValuesLuaNgeInsert(rootPathCur);
});
await updTask2;
isLoading = true;
await doScan();
await doScan(true, true);
sendDataVal = 90;
}
[Inject]
protected WDCUserService WDCUService { get; set; } = null!;
protected static Logger Log = LogManager.GetCurrentClassLogger();
protected async Task doScan()
/// <summary>
/// Scansione e comparazione directory COMPO
/// </summary>
/// <param name="scanCur"></param>
/// <param name="scanNew"></param>
/// <returns></returns>
protected async Task doScan(bool scanCur, bool scanNew)
{
files2Chk.Clear();
searchRecords.Clear();
ListType = new List<string>();
Log.Info($"Component scan started by user {WDCUService.userId}");
//await StartLongTimer();
//isSendingData = true;
isLoading = true;
sendDataVal = 0;
var updTask1 = Task.Run(async () =>
@@ -232,47 +220,49 @@ namespace WebDoorCreator.UI.Components.FilesMan
await updTask1;
searchRecords = new Dictionary<string, FileDTO>();
tempDOT.Clear();
var updTask2 = Task.Run(async () =>
await WDCService.scanSrcDestDir(rootPathOld)
);
var oldFiles = await updTask2;
// gestioen files cur
var curFiles = await getCurFiles(rootPathCur, !scanCur);
NumFileCur = curFiles.Count;
sendDataVal = 30;
var updTask3 = Task.Run(async () =>
await WDCService.scanSrcDestDir(rootPathNew)
);
var newFiles = await updTask3;
// gestione files nuovi
var newFiles = await getCurFiles(rootPathNew, !scanNew);
NumFileNew = newFiles.Count;
sendDataVal = 60;
//tempDOT = await WDCService.scanAndCompare();
foreach (var item in newFiles)
{
if (oldFiles.ContainsKey(item.Key))
if (curFiles.ContainsKey(item.Key))
{
if (oldFiles[item.Key].FileMD5 != item.Value.FileMD5)
if (curFiles[item.Key].FileMD5 != item.Value.FileMD5)
{
item.Value.status = Core.Enum.fileStatus.mod;
checkItemType(item);
}
oldFiles.Remove(item.Key);
//files2Chk.Add(item.Key, item.Value);
curFiles.Remove(item.Key);
}
else
{
item.Value.status = Core.Enum.fileStatus.add;
checkItemType(item);
}
searchRecords.Add(item.Key, item.Value);
}
sendDataVal = 90;
foreach (var item in oldFiles)
foreach (var item in curFiles)
{
item.Value.status = Core.Enum.fileStatus.rem;
searchRecords.Add(item.Key, item.Value);
}
searchRecords = searchRecords.Where(x => x.Value.status > 0).ToDictionary(x => x.Key, x => x.Value);
stats2show.Add(Core.Enum.fileStatus.add);
stats2show.Add(Core.Enum.fileStatus.mod);
stats2show.Add(Core.Enum.fileStatus.rem);
await ReloadData();
sendDataVal = 100;
sendDataNextVal = 100;
isLoading = false;
if (searchRecords.Count == 0)
{
@@ -281,25 +271,160 @@ namespace WebDoorCreator.UI.Components.FilesMan
Log.Info($"Component scan COMPLETED");
}
private void checkItemType(KeyValuePair<string, FileDTO> item)
{
string type = getType(item.Key);
if (!ListType.Contains(type))
{
ListType.Add(type);
}
}
public static string getType(string key)
{
string answ = "";
if (key.Contains("\\"))
{
answ = key.Split("\\")[0];
}
return answ;
}
public static string getFolder(string key)
{
string answ = "";
if (key.Contains("\\"))
{
answ = key.Split("\\")[1];
}
return answ;
}
protected string filtBtnAddCss()
{
string answ = "";
if (showAdd)
{
answ = "btn-primary";
}
else
{
answ = "btn-secondary";
}
return answ;
}
protected string filtBtnRemCss()
{
string answ = "";
if (showDel)
{
answ = "btn-danger";
}
else
{
answ = "btn-secondary";
}
return answ;
}
protected async Task filtBtnSet(Core.Enum.fileStatus fileStat)
{
switch (fileStat)
{
case Core.Enum.fileStatus.add:
showAdd = !showAdd;
if (showAdd && !stats2show.Contains(Core.Enum.fileStatus.add))
{
stats2show.Add(Core.Enum.fileStatus.add);
}
else if (!showAdd && stats2show.Contains(Core.Enum.fileStatus.add))
{
stats2show.Remove(Core.Enum.fileStatus.add);
}
break;
case Core.Enum.fileStatus.mod:
showUpd = !showUpd;
if (showUpd && !stats2show.Contains(Core.Enum.fileStatus.mod))
{
stats2show.Add(Core.Enum.fileStatus.mod);
}
else if (!showUpd && stats2show.Contains(Core.Enum.fileStatus.mod))
{
stats2show.Remove(Core.Enum.fileStatus.mod);
}
break;
case Core.Enum.fileStatus.rem:
showDel = !showDel;
if (showDel && !stats2show.Contains(Core.Enum.fileStatus.rem))
{
stats2show.Add(Core.Enum.fileStatus.rem);
}
else if (!showDel && stats2show.Contains(Core.Enum.fileStatus.rem))
{
stats2show.Remove(Core.Enum.fileStatus.rem);
}
break;
}
await ReloadData();
}
protected string filtBtnUpdCss()
{
string answ = "";
if (showUpd)
{
answ = "btn-warning";
}
else
{
answ = "btn-secondary";
}
return answ;
}
protected override async Task OnParametersSetAsync()
{
await ReloadData();
}
protected string TypeSel
{
get => _typeSel;
set
{
if (_typeSel != value)
{
_typeSel = value;
ReloadData().ConfigureAwait(false);
}
}
}
private string _typeSel { get; set; } = "";
protected List<string> ListType { get; set; } = new List<string>();
protected async Task ReloadData()
{
isDrawing = true;
await Task.Delay(1);
totalCount = searchRecords.Count;
files2Chk = searchRecords
.Skip(numRecord * (currPage - 1))
.Take(numRecord)
.ToDictionary(x => x.Key, x => x.Value);
var filtData = searchRecords
.Where(x => stats2show.Contains(x.Value.status) && (TypeSel == "*" || x.Key.StartsWith(TypeSel)))
.ToList();
totalCount = filtData.Count;
files2Chk = filtData
.Skip(numRecord * (currPage - 1))
.Take(numRecord)
.ToDictionary(x => x.Key, x => x.Value);
//await InvokeAsync(() => StateHasChanged());
isDrawing = false;
}
protected void ReplaceFile(string FileToMoveAndDelete, string FileToReplace)
{
File.Replace(FileToMoveAndDelete, FileToReplace, null);
}
@@ -311,8 +436,6 @@ namespace WebDoorCreator.UI.Components.FilesMan
}
}
protected KeyValuePair<string, FileDTO> actFile { get; set; } = new KeyValuePair<string, FileDTO>();
protected async Task showDiff(KeyValuePair<string, FileDTO> currFile, Core.Enum.fileStatus cStatus)
{
await Task.Delay(1);
@@ -325,17 +448,128 @@ namespace WebDoorCreator.UI.Components.FilesMan
case Core.Enum.fileStatus.add:
txtSx = File.ReadAllText($"{rootPathNew}\\{currFile.Key}");
break;
case Core.Enum.fileStatus.mod:
txtSx = File.ReadAllText($"{rootPathNew}\\{currFile.Key}");
txtDx = File.ReadAllText($"{rootPathOld}\\{currFile.Key}");
txtDx = File.ReadAllText($"{rootPathCur}\\{currFile.Key}");
break;
case Core.Enum.fileStatus.rem:
txtDx = File.ReadAllText($"{rootPathOld}\\{currFile.Key}");
txtDx = File.ReadAllText($"{rootPathCur}\\{currFile.Key}");
break;
case Core.Enum.fileStatus.none:
default:
break;
}
}
#endregion Protected Methods
#region Private Fields
private Dictionary<string, FileDTO> files2Chk = new Dictionary<string, FileDTO>();
private Dictionary<string, FileDTO> files2Save = new Dictionary<string, FileDTO>();
private string scanMsg = "CLICK TO SCAN";
private Dictionary<string, FileDTO> searchRecords = new Dictionary<string, FileDTO>();
private int sendDataMaxVal = 100;
private int sendDataVal = 0;
private List<Core.Enum.fileStatus> stats2show = new List<Core.Enum.fileStatus>();
private string titleMsg = "Scanning directories";
#endregion Private Fields
#region Private Properties
private bool _selUns { get; set; } = false;
private int _totalCount { get; set; } = -1;
private int currPage
{
get => actFilter.CurrPage;
set
{
selUns = false;
actFilter.CurrPage = value;
}
}
/// <summary>
/// Numero files CURRENT
/// </summary>
private int NumFileCur { get; set; } = 0;
/// <summary>
/// Numero files NEW
/// </summary>
private int NumFileNew { get; set; } = 0;
private int numRecord
{
get => actFilter.NumRec;
set => actFilter.NumRec = value;
}
private string rootPathCur
{
get => configuration.GetValue<string>("CompoBaseDirs:CurrCompoDir");
}
private string rootPathNew
{
get => configuration.GetValue<string>("CompoBaseDirs:NewCompoDir");
}
private bool selUns
{
get => _selUns;
set
{
_selUns = value;
selectAll(_selUns);
}
}
private int totalCount
{
get => _totalCount;
set
{
if (_totalCount != value)
{
_totalCount = value;
updateRecordCount.InvokeAsync(value);
}
}
}
#endregion Private Properties
#region Private Methods
/// <summary>
/// Recupera i dati files current,
/// </summary>
/// <param name="rootPath">Path di ricerca</param>
/// <param name="useCache">Usa cache Redis vs lettura da filesystem</param>
/// <returns></returns>
private async Task<Dictionary<string, FileDTO>> getCurFiles(string rootPath, bool useCache)
{
var updTask = Task.Run(async () =>
await WDCService.scanSrcDestDir(rootPath, useCache)
);
var listFiles = await updTask;
return listFiles;
}
#endregion Private Methods
}
}
@@ -1,7 +1,7 @@
<svg viewBox="0 0 @ObjW @ObjH" width="100%" height="100%" xmlns="http://www.w3.org/2000/svg">
<g transform="translate(0,@LineDist)">
<foreignObject width="@TextAreaWidth" height="100%">
<div class="d-flex justify-content-between rectangle p-3 @cardClass @TextCss" style="@TextStyle;" @onclick="() => doExecFunc(ActionReq.Select, false)">
<div class="d-flex justify-content-between rectangle p-3 @cardClass @TextCss" style="@TextStyle" @onclick="() => doExecFunc(ActionReq.Select, false)">
<div>
@ItemName
</div>
@@ -246,6 +246,7 @@ namespace WebDoorCreator.UI.Pages
protected async Task clearFields()
{
await Task.Delay(1);
companyExtCode = "";
companyName = "";
address = "";
+1
View File
@@ -143,6 +143,7 @@
protected async Task scanB()
{
await Task.Delay(1);
tempDOT.Clear();
//tempDOT = await WDCService.scanAndCompare();
}
+1 -1
View File
@@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<Version>0.9.2309.0516</Version>
<Version>0.9.2309.1112</Version>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>aspnet-WebDoorCreator.UI-dfe95fed-1398-4144-bd43-8b3a765d6608</UserSecretsId>
</PropertyGroup>
@@ -16,8 +16,7 @@
"WDC.DB": "Server=SQL2016PROD;Database=DCA_WebDoorCreator; User ID=sa;Password=keyhammer16; integrated security=False; MultipleActiveResultSets=True; App=WebDoorCreator.UI;"
},
"CompoBaseDirs": {
"CurrCompoDir": "\\\\egw-tnas-00\\EgwTech\\WebDoor\\CurComp",
"NewCompoDir": "\\\\egw-tnas-00\\EgwTech\\WebDoor\\NewComp",
"BckCompoDir": "\\\\egw-tnas-00\\EgwTech\\WebDoor\\Bck"
"CurrCompoDir": "\\\\IIS04\\WebDoorSync\\NewComp\\Compo",
"NewCompoDir": "\\\\IIS04\\WebDoorSync\\CurrentComp\\Compo"
}
}
+2 -3
View File
@@ -11,8 +11,7 @@
"BaseUrl": "/WDC/UI"
},
"CompoBaseDirs": {
"CurrCompoDir": "\\\\egw-tnas-00\\EgwTech\\WebDoor\\CurComp",
"NewCompoDir": "\\\\egw-tnas-00\\EgwTech\\WebDoor\\NewComp",
"BckCompoDir": "\\\\egw-tnas-00\\EgwTech\\WebDoor\\Bck"
"CurrCompoDir": "\\\\IIS04\\WebDoorSync\\NewComp\\Compo",
"NewCompoDir": "\\\\IIS04\\WebDoorSync\\CurrentComp\\Compo"
}
}
+2 -3
View File
@@ -51,8 +51,7 @@
"RemoveDoorOps": true
},
"CompoBaseDirs": {
"CurrCompoDir": "r:\\WebDoor\\CurComp",
"NewCompoDir": "r:\\WebDoor\\NewComp",
"BckCompoDir": "r:\\WebDoor\\Bck"
"CurrCompoDir": "\\\\IIS04\\WebDoorSync\\NewComp\\Compo",
"NewCompoDir": "\\\\IIS04\\WebDoorSync\\CurrentComp\\Compo"
}
}