134 lines
4.0 KiB
C#
134 lines
4.0 KiB
C#
using Microsoft.AspNetCore.Components;
|
|
using WebDoorCreator.Data.DbModels;
|
|
using WebDoorCreator.Data.DTO;
|
|
using WebDoorCreator.Data.Services;
|
|
|
|
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>();
|
|
|
|
[Inject]
|
|
protected IConfiguration configuration { get; set; } = null!;
|
|
|
|
[Inject]
|
|
protected WebDoorCreatorService WDCService { get; set; } = null!;
|
|
|
|
private string rootPathNew
|
|
{
|
|
get => configuration.GetValue<string>("CompoBaseDirs:NewCompoDir");
|
|
}
|
|
|
|
private string rootPathOld
|
|
{
|
|
get => configuration.GetValue<string>("CompoBaseDirs:CurrCompoDir");
|
|
}
|
|
|
|
protected string btnCssClass(Core.Enum.fileStatus fStat, bool doAct)
|
|
{
|
|
string answ = "";
|
|
if (fStat == Core.Enum.fileStatus.add && doAct)
|
|
{
|
|
answ = "btn-success";
|
|
}
|
|
else if (fStat == Core.Enum.fileStatus.mod && doAct)
|
|
{
|
|
answ = "btn-warning";
|
|
}
|
|
else if (fStat == Core.Enum.fileStatus.rem && doAct)
|
|
{
|
|
answ = "btn-danger";
|
|
}
|
|
else
|
|
{
|
|
answ = "btn-secondary";
|
|
}
|
|
return answ;
|
|
}
|
|
|
|
protected string btnIcon(Core.Enum.fileStatus fStat)
|
|
{
|
|
string answ = "";
|
|
if (fStat == Core.Enum.fileStatus.add)
|
|
{
|
|
answ = "fa-solid fa-circle-arrow-right";
|
|
}
|
|
else if (fStat == Core.Enum.fileStatus.mod)
|
|
{
|
|
answ = "fa-solid fa-code-pull-request";
|
|
}
|
|
else if (fStat == Core.Enum.fileStatus.rem)
|
|
{
|
|
answ = "fa-solid fa-square-minus";
|
|
}
|
|
return answ;
|
|
}
|
|
|
|
protected async Task selectAll()
|
|
{
|
|
await Task.Delay(1);
|
|
foreach(var item in files2Chk)
|
|
{
|
|
item.Value.action = true;
|
|
}
|
|
}
|
|
protected async Task unselectAll()
|
|
{
|
|
await Task.Delay(1);
|
|
foreach (var item in files2Chk)
|
|
{
|
|
item.Value.action = false;
|
|
}
|
|
}
|
|
|
|
protected async Task save()
|
|
{
|
|
await WDCService.DoorOpTypeAddRange(tempDOT);
|
|
}
|
|
|
|
protected async Task scanB()
|
|
{
|
|
files2Chk = new Dictionary<string, FileDTO>();
|
|
tempDOT.Clear();
|
|
await WDCService.populateHws();
|
|
var oldFiles = await WDCService.scanSrcDestDir(rootPathOld);
|
|
var newFiles = await WDCService.scanSrcDestDir(rootPathNew);
|
|
//tempDOT = await WDCService.scanAndCompare();
|
|
|
|
foreach (var item in newFiles)
|
|
{
|
|
if (oldFiles.ContainsKey(item.Key))
|
|
{
|
|
if (oldFiles[item.Key].FileMD5 != item.Value.FileMD5)
|
|
{
|
|
item.Value.status = Core.Enum.fileStatus.mod;
|
|
}
|
|
oldFiles.Remove(item.Key);
|
|
//files2Chk.Add(item.Key, item.Value);
|
|
}
|
|
else
|
|
{
|
|
item.Value.status = Core.Enum.fileStatus.add;
|
|
}
|
|
files2Chk.Add(item.Key, item.Value);
|
|
}
|
|
|
|
|
|
foreach (var item in oldFiles)
|
|
{
|
|
item.Value.status = Core.Enum.fileStatus.rem;
|
|
files2Chk.Add(item.Key, item.Value);
|
|
}
|
|
|
|
files2Chk = files2Chk.Where(x => x.Value.status > 0).ToDictionary(x => x.Key, x => x.Value);
|
|
}
|
|
protected async Task changeDoAct(KeyValuePair<string, FileDTO> currObj)
|
|
{
|
|
await Task.Delay(1);
|
|
files2Chk[currObj.Key].action = !files2Chk[currObj.Key].action;
|
|
}
|
|
}
|
|
} |