fix scansione cartella B
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
using Microsoft.AspNetCore.Identity.UI.Services;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.IdentityModel.Protocols;
|
||||
using Microsoft.Reporting.Map.WebForms.BingMaps;
|
||||
using Newtonsoft.Json;
|
||||
using NLog;
|
||||
@@ -12,6 +13,7 @@ using System.Text;
|
||||
using WebDoorCreator.Core;
|
||||
using WebDoorCreator.Data.Controllers;
|
||||
using WebDoorCreator.Data.DbModels;
|
||||
using WebDoorCreator.Data.DTO;
|
||||
|
||||
namespace WebDoorCreator.Data.Services
|
||||
{
|
||||
@@ -62,6 +64,8 @@ namespace WebDoorCreator.Data.Services
|
||||
Log.Info("Avviata classe WebDoorCreatorService");
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Properties
|
||||
@@ -1859,14 +1863,18 @@ namespace WebDoorCreator.Data.Services
|
||||
}
|
||||
|
||||
|
||||
public async Task<bool> scanDirA()
|
||||
public async Task<bool> scanDirB()
|
||||
{
|
||||
bool answ = false;
|
||||
string rootPathNew = _configuration.GetValue<string>("CompoBaseDirs:NewCompoDir");
|
||||
string rootPathNew = _configuration.GetValue<string>("CompoBaseDirs:NewCompoDir");
|
||||
List<DoorOpTypeModel> doorOpTypesList = new List<DoorOpTypeModel>();
|
||||
List<FileDTO> originalFiles = new List<FileDTO>();
|
||||
List<FileDTO> newFiles = new List<FileDTO>();
|
||||
string[] dirs = Directory.GetDirectories(rootPathNew);
|
||||
|
||||
//Cerco quali sono i componenti da scansionare
|
||||
List<string> listActiveCompo = await CompoGetAllActive(Path.Combine(rootPathNew, @"Default.ini"));
|
||||
System.Security.Cryptography.MD5 md5 = System.Security.Cryptography.MD5.Create();
|
||||
//Ciclo in tutte le cartelle ed estraggo le cartelle dei componenti
|
||||
foreach (string dir in dirs)
|
||||
{
|
||||
@@ -1898,13 +1906,35 @@ namespace WebDoorCreator.Data.Services
|
||||
};
|
||||
doorOpTypesList.Add(tempHwType);
|
||||
}
|
||||
|
||||
foreach(var tplDir in templateDirectories)
|
||||
foreach (var tplDir in templateDirectories)
|
||||
{
|
||||
string[] tpls = Directory.GetFiles(tplDir, "*");
|
||||
foreach(var tpl in tpls)
|
||||
var archiviedFiles = dbController.DoorOpTypeGetByPath(tplDir);
|
||||
foreach (var tpl in tpls)
|
||||
{
|
||||
var fileName = Path.GetFileName(tpl).Split("\\")[Path.GetFileName(tpl).Split("\\").Length-1];
|
||||
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();
|
||||
|
||||
var path2Search = archiviedFiles
|
||||
.Where(x => x.OpCode == tpl)
|
||||
.FirstOrDefault();
|
||||
|
||||
if(path2Search == null)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//FileDTO currFileInfo = new FileDTO()
|
||||
//{
|
||||
// FilePath = fileName,
|
||||
// FileDim = fi.Length,
|
||||
// FileMD5 = newMD5,
|
||||
// lastModTime = fi.LastWriteTime
|
||||
//};
|
||||
//newFiles.Add()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1920,6 +1950,7 @@ namespace WebDoorCreator.Data.Services
|
||||
List<DoorOpTypeModel> HwsList = new List<DoorOpTypeModel>();
|
||||
bool hwAdded = false;
|
||||
List<string> listActiveCompo = await CompoGetAllActive(Path.Combine(rootPath, @"Default.ini"));
|
||||
System.Security.Cryptography.MD5 md5 = System.Security.Cryptography.MD5.Create();
|
||||
//ciclo nelle directrory per beccare tutti gli hw e le relatice path del file di origine
|
||||
foreach (string dir in dirs)
|
||||
{
|
||||
@@ -2011,6 +2042,7 @@ namespace WebDoorCreator.Data.Services
|
||||
|
||||
foreach (string templateFile in templateFiles)
|
||||
{
|
||||
FileInfo fi = new FileInfo(templateFile);
|
||||
string defGpNum = "";
|
||||
var lines = File.ReadAllLines(templateFile).ToList();
|
||||
|
||||
@@ -2049,7 +2081,9 @@ namespace WebDoorCreator.Data.Services
|
||||
DefaultVal = defGpNum,
|
||||
InputType = " ",
|
||||
};
|
||||
|
||||
var fileContent = File.ReadAllBytes(templateFile);
|
||||
var hash = md5.ComputeHash(fileContent);
|
||||
var oldMD5 = BitConverter.ToString(hash).Replace("-", "").ToLowerInvariant();
|
||||
DoorOpTypeModel tempType = new DoorOpTypeModel()
|
||||
{
|
||||
ParentId = item.DoorOpTypId,
|
||||
@@ -2057,7 +2091,10 @@ namespace WebDoorCreator.Data.Services
|
||||
OpCode = @$"{dir}\{tName[tName.Length - 1]}\{Path.GetFileName(templateFile)}",
|
||||
HasHw = true,
|
||||
IsConcrete = true,
|
||||
HwCode = $"{compoCode}".Replace(" ", "_")
|
||||
HwCode = $"{compoCode}".Replace(" ", "_"),
|
||||
FileDim = fi.Length,
|
||||
FileMD5 = oldMD5,
|
||||
LastMod = fi.LastWriteTime
|
||||
};
|
||||
doorOpTypesList.Add(tempType);
|
||||
if (values.Where(x => x.TableName == temp.TableName && x.FieldName == temp.FieldName && x.Value == temp.Value).Count() == 0 && temp.TableName != null && temp.FieldName != null && temp.Value != null)
|
||||
|
||||
Reference in New Issue
Block a user