diff --git a/WebDoorCreator.API/Controllers/QueueController.cs b/WebDoorCreator.API/Controllers/QueueController.cs index bf04d07..1dab00d 100644 --- a/WebDoorCreator.API/Controllers/QueueController.cs +++ b/WebDoorCreator.API/Controllers/QueueController.cs @@ -1,6 +1,6 @@ using Microsoft.AspNetCore.Mvc; using NLog; -using WebDoorCreator.API.Data; +using WebDoorCreator.Data.Services; namespace WebDoorCreator.API.Controllers { @@ -14,7 +14,7 @@ namespace WebDoorCreator.API.Controllers { Log.Info("Starting QueueController"); _configuration = configuration; - QDService = DataService; + QDataServ = DataService; Log.Info("Avviato QueueController"); } @@ -29,7 +29,7 @@ namespace WebDoorCreator.API.Controllers [HttpGet("ActPendingLenght")] public async Task ActPendingLenght() { - long numQueue = await QDService.NumRequestPending(); + long numQueue = await QDataServ.NumRequestPending(); return numQueue; } @@ -40,7 +40,7 @@ namespace WebDoorCreator.API.Controllers [HttpGet("ActProcessingLenght")] public async Task ActProcessingLenght() { - long numQueue = await QDService.NumRequestProcessing(); + long numQueue = await QDataServ.NumRequestProcessing(); return numQueue; } @@ -107,7 +107,7 @@ namespace WebDoorCreator.API.Controllers [HttpGet("ShowPending")] public async Task?> ShowPending() { - var actQueue = await QDService.RequestPending(); + var actQueue = await QDataServ.RequestPending(); return actQueue; } @@ -118,7 +118,7 @@ namespace WebDoorCreator.API.Controllers [HttpGet("ShowProcessing")] public async Task> ShowProcessing() { - var actQueue = await QDService.RequestProcessing(); + var actQueue = await QDataServ.RequestProcessing(); return actQueue; } @@ -131,7 +131,7 @@ namespace WebDoorCreator.API.Controllers [HttpGet("TakeProcessingItems")] public async Task> TakeProcessingItems(int numItems) { - var actQueue = await QDService.TakeProcessingItems(numItems); + var actQueue = await QDataServ.TakeProcessingItems(numItems); return actQueue; } @@ -147,7 +147,7 @@ namespace WebDoorCreator.API.Controllers #region Private Properties - private QueueDataService QDService { get; set; } = null!; + private QueueDataService QDataServ { get; set; } = null!; #endregion Private Properties } diff --git a/WebDoorCreator.API/Program.cs b/WebDoorCreator.API/Program.cs index e81b02e..ece0173 100644 --- a/WebDoorCreator.API/Program.cs +++ b/WebDoorCreator.API/Program.cs @@ -5,8 +5,8 @@ using StackExchange.Redis.Extensions.Core.Configuration; using StackExchange.Redis.Extensions.Newtonsoft; using System.Globalization; using System.Text.Json.Serialization; -using WebDoorCreator.API.Data; using WebDoorCreator.Data; +using WebDoorCreator.Data.Services; var builder = WebApplication.CreateBuilder(args); diff --git a/WebDoorCreator.API/appsettings.json b/WebDoorCreator.API/appsettings.json index c878c27..e32a2b4 100644 --- a/WebDoorCreator.API/appsettings.json +++ b/WebDoorCreator.API/appsettings.json @@ -7,7 +7,7 @@ }, "AllowedHosts": "*", "ConnectionStrings": { - "Redis": "localhost:6379,DefaultDatabase=11,connectTimeout=5000,syncTimeout=5000,asyncTimeout=5000,abortConnect=false,ssl=false", + "Redis": "nkcredis.steamware.net:6379, DefaultDatabase=11, connectTimeout=5000, syncTimeout=5000, asyncTimeout=5000, abortConnect=false, ssl=false, password=BtN9Py1wtLfLRvmzWnOPJ7RytDM+CLiVsJ/16zduNTlV8IOPGNrtzJSXPUnImA5PqmUMhKaUqo9NdHIG", "WDC.DB": "Server=SQL2016DEV;Database=WebDoorCreator; User ID=sa;Password=keyhammer16; integrated security=False; MultipleActiveResultSets=True; App=WebDoorCreator.UI;" }, "ExternalProviders": { diff --git a/WebDoorCreator.Data/DDF/Converter.cs b/WebDoorCreator.Data/DDF/Converter.cs new file mode 100644 index 0000000..5f93532 --- /dev/null +++ b/WebDoorCreator.Data/DDF/Converter.cs @@ -0,0 +1,87 @@ +using Newtonsoft.Json; +using WebDoorCreator.Data.DbModels; +using WebDoorCreator.Data.DTO; + +namespace WebDoorCreator.Data.DDF +{ + public class Converter + { + #region Public Constructors + + /// + /// Init del convertitore secondo impostazioni standard + /// + /// + /// + /// + /// + public Converter(string vers, bool remDoorOp, List headRows, List footRows) + { + FormatVers = vers; + RemDoorOp = remDoorOp; + HeadRows = headRows; + FootRows = footRows; + } + + #endregion Public Constructors + + #region Public Methods + + /// + /// Fornisce il DDF corrispondente all'elenco OP inviato, seocndo la conf del convertitore + /// + /// + /// + public string GetSerialized(List listOp) + { + string outDdf = ""; + try + { + DoorOpsDTO CurrentDoorOp = new DoorOpsDTO(); + DDFDto CurrentConf = new DDFDto(); + // per prima cosa popolo gli oggetti di appoggio... + dictDoorOP = new Dictionary>>(); + foreach (var item in listOp) + { + var deserialized = JsonConvert.DeserializeObject>(item.JsoncActVal!); + if (deserialized != null) + { + if (dictDoorOP.ContainsKey(item.ObjectId)) + { + var actList = dictDoorOP[item.ObjectId]; + actList.Add(deserialized.Where(x => x.Key != "Folder").ToDictionary(x => x.Key, x => x.Value)); + dictDoorOP[item.ObjectId] = actList; + } + else + { + var currList = new List>(); + currList.Add(deserialized.Where(x => x.Key != "Folder").ToDictionary(x => x.Key, x => x.Value)); + dictDoorOP.Add(item.ObjectId, currList); + } + } + } + CurrentDoorOp.doorOpsDict = dictDoorOP; + string doorOpSer = CurrentDoorOp.GetSerialized(RemDoorOp); + // ora popolo l'oggetto DTO principale + CurrentConf.version = FormatVers; + outDdf = CurrentConf.GetSerialized(HeadRows, FootRows, doorOpSer); + } + catch + { } + return outDdf; + } + + #endregion Public Methods + + #region Protected Properties + + protected Dictionary>> dictDoorOP { get; set; } = new Dictionary>>(); + protected List FootRows { get; set; } = new List(); + protected string FormatVers { get; set; } = "0"; + protected List HeadRows { get; set; } = new List(); + protected List> listDictDoorOP { get; set; } = new List>(); + protected bool RemDoorOp { get; set; } = false; + + #endregion Protected Properties + } +} \ No newline at end of file diff --git a/WebDoorCreator.Data/Services/QueueDataService.cs b/WebDoorCreator.Data/Services/QueueDataService.cs index fbec85f..e5b7e75 100644 --- a/WebDoorCreator.Data/Services/QueueDataService.cs +++ b/WebDoorCreator.Data/Services/QueueDataService.cs @@ -5,21 +5,12 @@ using NLog; using StackExchange.Redis; using System.Diagnostics; using WebDoorCreator.Core; -using WebDoorCreator.Data.DbModels; +using WebDoorCreator.Data; -namespace WebDoorCreator.API.Data +namespace WebDoorCreator.Data.Services { public class QueueDataService : IDisposable { - #region Public Fields - - /// - /// Classe Accesso metodi DB - /// - public static WebDoorCreator.Data.Controllers.WebDoorCreatorController dbController = null!; - - #endregion Public Fields - #region Public Constructors /// @@ -42,71 +33,116 @@ namespace WebDoorCreator.API.Data else { this.redisConn = ConnectionMultiplexer.Connect(redConnString); - this.redisDb = this.redisConn.GetDatabase(); - } - - // Conf DB - var connStrDB = _configuration.GetConnectionString("WDC.DB"); - if (string.IsNullOrEmpty(connStrDB)) - { - Log.Error("ConnString empty!"); - } - else - { - dbController = new WebDoorCreator.Data.Controllers.WebDoorCreatorController(configuration); - Log.Info("DbController OK"); + redisDb = this.redisConn.GetDatabase(); } + // setup canali pub/sub + calcReqPipe = new MessagePipe(redisConn, Constants.CALC_REQ_QUEUE); + calcDonePipe = new MessagePipe(redisConn, Constants.CALC_DONE_QUEUE); } #endregion Public Constructors + #region Public Properties + + /// + /// Message pipe esecuzione elaborazione CAM --> UI + /// + public MessagePipe calcDonePipe { get; set; } = null!; + + /// + /// Message pipe richieste elaborazione UI --> CAM + /// + public MessagePipe calcReqPipe { get; set; } = null!; + + #endregion Public Properties + #region Public Methods public void Dispose() { - // Clear database controller - dbController.Dispose(); + redisConn.Dispose(); } /// - /// Doors list by orderId + /// /// - public async Task?> DoorGetByOrderId(int orderId) + /// + /// Contenuto completo del DDF + /// indice/versione del calcolo DDF + public async Task sendCalcReq(int DoorId, string FullDDF) { - string source = "DB"; - List? dbResult = new List(); - // cerco da cache - string currKey = $"{Constants.rKeyOrderDetail}:{orderId}"; + int currVers = 1; Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); - string? rawData = await redisDb.StringGetAsync(currKey); - if (!string.IsNullOrEmpty(rawData)) + + // accumulo richieste di calcolo in HashTable redis + + + // per prima cosa controllo se ho GIA' in coda qualcosa come richeiste + var numPending = await NumRequestPending(); + // se coda vuota --> aggiungo e stop + if (numPending == 0) { - source = "REDIS"; - var tempResult = JsonConvert.DeserializeObject>(rawData); - if (tempResult == null) - { - dbResult = new List(); - } - else - { - dbResult = tempResult; - } } + // se coda non vuota: cerco la DoorId corrente, se c'è sovrascrivo versione altrimenti + // inserisco in coda else { - dbResult = dbController.DoorsGetByOrderId(orderId); - rawData = JsonConvert.SerializeObject(dbResult, JSSettings); - await redisDb.StringSetAsync(currKey, rawData, UltraLongCache); } - if (dbResult == null) + // salvo nell'archivio REDIS delle porte il DDF corrente (door+ vers numb), potrebbe + // venire buono anche x eventuale UNDO... + + // invio sul canale dei messaggi il numero di items in coda attuali x chiedere esecuzione... + +#if false + // cerco da cache + RedisKey currKey = new RedisKey(Constants.CALC_REQ_PEND); + currVers = redisDb.HashLength(currKey); + if (currVers > 0) { - dbResult = new List(); + var rawData = await redisDb.HashGetAllAsync(currKey); + foreach (var item in rawData) + { + dictResult.Add($"{item.Name}", $"{item.Value}"); + } } +#endif stopWatch.Stop(); TimeSpan ts = stopWatch.Elapsed; - Log.Debug($"DoorGetByOrderId | {source} in: {ts.TotalMilliseconds} ms"); - return dbResult; + Log.Debug($"EnqueueDoorDDF | DoorId: {DoorId} enqueued in: {ts.TotalMilliseconds} ms"); + + + + // to do + // calcolo quanti emssaggi ho in coda + string message = "999"; + // invio sul channel redis la richiesta, salvando il valore anche in cache + bool answ = calcReqPipe.saveAndSendMessage(Constants.LAST_CALC_REQ_KEY, message); + + // simulazione ritorno dati... + await Task.Delay(200); + + // invio il FINTO messaggio di ritorno... + string retMess = ""; + string fileName = Path.Combine("temp", $"Logo{idxSim:00}.svg"); + if (File.Exists(fileName)) + { + retMess = File.ReadAllText(fileName); + idxSim++; + idxSim = idxSim % 4; + } + calcDonePipe.saveAndSendMessage(Constants.LAST_CALC_DONE_KEY, retMess); + + return currVers; + } + + + public async Task FlushRedisCache() + { + await Task.Delay(1); + RedisValue pattern = new RedisValue($"{Constants.BASE_HASH}:Cache*"); + bool answ = await ExecFlushRedisPattern(pattern); + return answ; } /// @@ -202,7 +238,6 @@ namespace WebDoorCreator.API.Data Log.Debug($"RequestProcessing | {source} in: {ts.TotalMilliseconds} ms"); return dictResult; } - /// /// Get Queue request pending, removing from queue and putting on processing queue /// @@ -236,7 +271,9 @@ namespace WebDoorCreator.API.Data #region Protected Fields protected const string rKeyCalcOreFase = "Check:OreFasi"; + protected const string rKeyFasiAct = "Check:FasiAct"; + protected const string rKeyProjAct = "Check:ProjAct"; /// @@ -244,6 +281,8 @@ namespace WebDoorCreator.API.Data /// protected const int shortTTL = 60 * 5; + protected int idxSim = 0; + protected Random rnd = new Random(); #endregion Protected Fields @@ -313,7 +352,9 @@ namespace WebDoorCreator.API.Data #region Private Fields private static IConfiguration _configuration = null!; + private static JsonSerializerSettings? JSSettings; + private static Logger Log = LogManager.GetCurrentClassLogger(); private readonly IEmailSender _emailSender; @@ -372,5 +413,38 @@ namespace WebDoorCreator.API.Data } #endregion Private Properties + + #region Private Methods + + /// + /// Esegue flush memoria redis dato pattern + /// + /// + /// + private async Task ExecFlushRedisPattern(RedisValue pattern) + { + bool answ = false; + var listEndpoints = redisConn.GetEndPoints(); + foreach (var endPoint in listEndpoints) + { + //var server = redisConnAdmin.GetServer(listEndpoints[0]); + var server = redisConn.GetServer(endPoint); + if (server != null) + { + var keyList = server.Keys(redisDb.Database, pattern); + foreach (var item in keyList) + { + await redisDb.KeyDeleteAsync(item); + } + // brutalmente rimuovo intero contenuto DB... DANGER + //await server.FlushDatabaseAsync(); + answ = true; + } + } + + return answ; + } + + #endregion Private Methods } } \ No newline at end of file diff --git a/WebDoorCreator.UI/Components/Buttons/ButtonsDoorDef.razor.cs b/WebDoorCreator.UI/Components/Buttons/ButtonsDoorDef.razor.cs index 67455ee..c4d1fea 100644 --- a/WebDoorCreator.UI/Components/Buttons/ButtonsDoorDef.razor.cs +++ b/WebDoorCreator.UI/Components/Buttons/ButtonsDoorDef.razor.cs @@ -1,8 +1,10 @@ using Microsoft.AspNetCore.Components; using Microsoft.JSInterop; using Newtonsoft.Json; +using System.Configuration; using WebDoorCreator.Data.DbModels; using WebDoorCreator.Data.DTO; +using WebDoorCreator.Data.Services; using WebDoorCreator.UI.Data; namespace WebDoorCreator.UI.Components.Buttons @@ -28,7 +30,7 @@ namespace WebDoorCreator.UI.Components.Buttons protected WebDoorCreatorService WDCService { get; set; } = null!; [Inject] - protected WDCCurrDataService CamDataServ { get; set; } = null!; + protected QueueDataService QDataServ { get; set; } = null!; [Inject] @@ -57,12 +59,11 @@ namespace WebDoorCreator.UI.Components.Buttons } protected DDFDto CurrentConf { get; set; } = new DDFDto(); protected DoorOpsDTO CurrentDoorOp { get; set; } = new DoorOpsDTO(); - public async Task SaveYaml() + public async Task SaveYaml(string ddfContent) { await Task.Delay(1); - //string fileName = Path.Combine(baseDir, $"Conf.yml"); string fileName = Path.Combine("temp", $"Conf.yaml"); - +#if false string vers = config.GetValue("ConfDDF:VersNumber"); bool remDoorOp = config.GetValue("ConfDDF:RemoveDoorOps"); var headRows = config.GetSection("ConfDDF:Header").Get>(); @@ -71,29 +72,43 @@ namespace WebDoorCreator.UI.Components.Buttons string doorOpSer = CurrentDoorOp.GetSerialized(remDoorOp); CurrentConf.version = vers; - string fullData = CurrentConf.GetSerialized(headRows, footRows, doorOpSer); + string fullData = CurrentConf.GetSerialized(headRows, footRows, doorOpSer); +#endif if (File.Exists(fileName)) { File.Delete(fileName); } // scrivo! - File.WriteAllText(fileName, fullData); - - //CurrentConf.SaveYaml(fileName); + File.WriteAllText(fileName, ddfContent); } + + protected override void OnInitialized() + { + base.OnInitialized(); + string vers = config.GetValue("ConfDDF:VersNumber"); + bool remDoorOp = config.GetValue("ConfDDF:RemoveDoorOps"); + var headRows = config.GetSection("ConfDDF:Header").Get>(); + var footRows = config.GetSection("ConfDDF:Footer").Get>(); + currDdfConv = new WebDoorCreator.Data.DDF.Converter(vers, remDoorOp, headRows, footRows); + } + /// /// Effettua salvataggio record e generazione DDF /// /// protected async Task doSave() { - var listOpAll = await WDCService.DoorOpGetByDoorId(DoorId); + List? listOpAll = await WDCService.DoorOpGetByDoorId(DoorId); if (listOpAll != null) { - var listOp = listOpAll.Where(x => x.userConfirm != "" && x.DtConfirm != null).ToList(); + List listOp = listOpAll.Where(x => x.userConfirm != "" && x.DtConfirm != null).ToList(); if (listOp != null) { + // chiamo metodo x avewre DDF serializzato + string currDdf = currDdfConv.GetSerialized(listOp); + +#if false dictDoorOP = new Dictionary>>(); listDoorOp = listOp; foreach (var item in listDoorOp) @@ -122,13 +137,16 @@ namespace WebDoorCreator.UI.Components.Buttons //} } } + CurrentDoorOp.doorOpsDict = dictDoorOP; +#endif + // si potrebbe eliminare in futuro che va su REDIS + await SaveYaml(currDdf); + // versione corrente del DDF generato + int currVers = await QDataServ.sendCalcReq(DoorId, currDdf); } - CurrentDoorOp.doorOpsDict = dictDoorOP; - - await SaveYaml(); } - - await CamDataServ.sendCalcReq($"ORD{idOrd:00000}"); } + + protected WebDoorCreator.Data.DDF.Converter currDdfConv { get; set; } = null!; } } \ No newline at end of file diff --git a/WebDoorCreator.UI/Components/DoorDef/DoorDefSizingSI.razor.cs b/WebDoorCreator.UI/Components/DoorDef/DoorDefSizingSI.razor.cs index f6ff8c3..32889b5 100644 --- a/WebDoorCreator.UI/Components/DoorDef/DoorDefSizingSI.razor.cs +++ b/WebDoorCreator.UI/Components/DoorDef/DoorDefSizingSI.razor.cs @@ -2,6 +2,7 @@ using Microsoft.AspNetCore.Components; using Microsoft.JSInterop; using Newtonsoft.Json; using WebDoorCreator.Data.DbModels; +using WebDoorCreator.Data.Services; using WebDoorCreator.UI.Data; namespace WebDoorCreator.UI.Components.DoorDef @@ -80,7 +81,7 @@ namespace WebDoorCreator.UI.Components.DoorDef protected WDCVocabularyService WDVService { get; set; } = null!; [Inject] - protected WDCCurrDataService CamDataServ { get; set; } = null!; + protected QueueDataService QDataServ { get; set; } = null!; #endregion Protected Properties @@ -169,7 +170,10 @@ namespace WebDoorCreator.UI.Components.DoorDef DoorOpInst.JsoncActVal = serVal; // salvo! await WDCService.DoorOpUpdate(DoorOpInst); - await CamDataServ.sendCalcReq($"ORD{DoorOpInst.DoorId:00000}"); + // invio msg dato "salvabile" +#if false + await QDataServ.sendCalcReq($"ORD{DoorOpInst.DoorId:00000}"); +#endif // rileggo await FullReloadData(true); } diff --git a/WebDoorCreator.UI/Components/Hardware/HwSingleInstance.razor.cs b/WebDoorCreator.UI/Components/Hardware/HwSingleInstance.razor.cs index 68f7ff0..a9bcddd 100644 --- a/WebDoorCreator.UI/Components/Hardware/HwSingleInstance.razor.cs +++ b/WebDoorCreator.UI/Components/Hardware/HwSingleInstance.razor.cs @@ -2,6 +2,7 @@ using Microsoft.AspNetCore.Components; using Microsoft.JSInterop; using Newtonsoft.Json; using WebDoorCreator.Data.DbModels; +using WebDoorCreator.Data.Services; using WebDoorCreator.UI.Data; namespace WebDoorCreator.UI.Components.Hardware @@ -110,7 +111,7 @@ namespace WebDoorCreator.UI.Components.Hardware protected WDCVocabularyService WDVService { get; set; } = null!; [Inject] - protected WDCCurrDataService CamDataServ { get; set; } = null!; + protected QueueDataService QDataServ { get; set; } = null!; #endregion Protected Properties @@ -199,7 +200,11 @@ namespace WebDoorCreator.UI.Components.Hardware DoorOpInst.JsoncActVal = serVal; // salvo! await WDCService.DoorOpUpdate(DoorOpInst); - await CamDataServ.sendCalcReq($"ORD{DoorOpInst.DoorId:00000}"); + // invio msg dato "salvabile" +#if false + // invio richiesta calcolo + await QDataServ.sendCalcReq($"ORD{DoorOpInst.DoorId:00000}"); +#endif // rileggo await FullReloadData(true); } diff --git a/WebDoorCreator.UI/Data/WDCCurrDataService.cs b/WebDoorCreator.UI/Data/WDCCurrDataService.cs deleted file mode 100644 index 8f98220..0000000 --- a/WebDoorCreator.UI/Data/WDCCurrDataService.cs +++ /dev/null @@ -1,167 +0,0 @@ -using NLog; -using StackExchange.Redis; -using WebDoorCreator.Core; -using WebDoorCreator.Data; - -namespace WebDoorCreator.UI.Data -{ - public class WDCCurrDataService : IDisposable - { - #region Public Constructors - - public WDCCurrDataService(IConfiguration configuration, IConnectionMultiplexer redisConn) - { - _configuration = configuration; - - // setup compoenti REDIS - this.redisConn = ConnectionMultiplexer.Connect(_configuration.GetConnectionString("Redis")); - this.redisDb = this.redisConn.GetDatabase(); - // setup canali pub/sub - calcReqPipe = new MessagePipe(redisConn, Constants.CALC_REQ_QUEUE); - calcDonePipe = new MessagePipe(redisConn, Constants.CALC_DONE_QUEUE); - } - - #endregion Public Constructors - - #region Public Properties - - /// - /// Message pipe esecuzione elaborazione CAM --> UI - /// - public MessagePipe calcDonePipe { get; set; } = null!; - - /// - /// Message pipe richieste elaborazione UI --> CAM - /// - public MessagePipe calcReqPipe { get; set; } = null!; - - #endregion Public Properties - - #region Public Methods - - public void Dispose() - { - redisConn.Dispose(); - } - - public async Task FlushRedisCache() - { - await Task.Delay(1); - RedisValue pattern = new RedisValue($"{Constants.BASE_HASH}:Cache*"); - bool answ = await ExecFlushRedisPattern(pattern); - return answ; - } - - public async Task sendCalcReq(string message) - { - // accumulo richieste di calcolo in HashTable redis - - // to do - - // invio sul channel redis la richiesta, salvando il valore anche in cache - bool answ = calcReqPipe.saveAndSendMessage(Constants.LAST_CALC_REQ_KEY, message); - - // simulazione ritorno dati... - await Task.Delay(200); - - // invio il FINTO messaggio di ritorno... - string retMess = ""; - string fileName = Path.Combine("temp", $"Logo{idxSim:00}.svg"); - if (File.Exists(fileName)) - { - retMess = File.ReadAllText(fileName); - idxSim++; - idxSim = idxSim % 4; - } - calcDonePipe.saveAndSendMessage(Constants.LAST_CALC_DONE_KEY, retMess); - - return answ; - } - - #endregion Public Methods - - #region Protected Fields - - protected int idxSim = 0; - - #endregion Protected Fields - - #region Private Fields - - private static IConfiguration _configuration = null!; - private static Logger Log = LogManager.GetCurrentClassLogger(); -#if false - /// - /// Conf allarmi (BankBit) IMPOSTATA con valori silenziati - /// - /// - public async Task> getAlarmBankBitSetup() - { - List? redResult = new List(); - string rawData = await redisDb.StringGetAsync(Constants.ALARMS_SETT_BBIT_KEY); - //se non avessi trovato valori cerco quelli di setup... - if (string.IsNullOrEmpty(rawData)) - { - rawData = await redisDb.StringGetAsync(Constants.ALARMS_CONF_KEY); - } - // ora provo a deserializzare - if (!string.IsNullOrEmpty(rawData)) - { - redResult = JsonConvert.DeserializeObject>(rawData); - } - // altrimenti imposto vuoto - if (redResult == null) - { - redResult = new List(); - } - return await Task.FromResult(redResult); - } -#endif - - /// - /// Oggetto per connessione a REDIS - /// - private ConnectionMultiplexer redisConn = null!; - - //ISubscriber sub = redis.GetSubscriber(); - /// - /// Oggetto DB redis da impiegare x chiamate R/W - /// - private IDatabase redisDb = null!; - - #endregion Private Fields - - #region Private Methods - - /// - /// Esegue flush memoria redis dato pattern - /// - /// - /// - private async Task ExecFlushRedisPattern(RedisValue pattern) - { - bool answ = false; - var listEndpoints = redisConn.GetEndPoints(); - foreach (var endPoint in listEndpoints) - { - //var server = redisConnAdmin.GetServer(listEndpoints[0]); - var server = redisConn.GetServer(endPoint); - if (server != null) - { - var keyList = server.Keys(redisDb.Database, pattern); - foreach (var item in keyList) - { - await redisDb.KeyDeleteAsync(item); - } - // brutalmente rimuovo intero contenuto DB... DANGER - //await server.FlushDatabaseAsync(); - answ = true; - } - } - - return answ; - } - - #endregion Private Methods - } -} \ No newline at end of file diff --git a/WebDoorCreator.UI/Pages/DoorDefinition.razor.cs b/WebDoorCreator.UI/Pages/DoorDefinition.razor.cs index 68f7734..bfd0417 100644 --- a/WebDoorCreator.UI/Pages/DoorDefinition.razor.cs +++ b/WebDoorCreator.UI/Pages/DoorDefinition.razor.cs @@ -4,6 +4,7 @@ using Microsoft.JSInterop; using NLog; using WebDoorCreator.Data; using WebDoorCreator.Data.DbModels; +using WebDoorCreator.Data.Services; using WebDoorCreator.UI.Data; namespace WebDoorCreator.UI.Pages @@ -15,7 +16,7 @@ namespace WebDoorCreator.UI.Pages public void Dispose() { WDCUService.EA_CurrLanguage -= WDUService_EA_CurrLanguage; - CamDataServ.calcDonePipe.EA_NewMessage -= CalcDonePipe_EA_NewMessage; + QDataServ.calcDonePipe.EA_NewMessage -= CalcDonePipe_EA_NewMessage; } #endregion Public Methods @@ -23,7 +24,7 @@ namespace WebDoorCreator.UI.Pages #region Protected Properties [Inject] - protected WDCCurrDataService CamDataServ { get; set; } = null!; + protected QueueDataService QDataServ { get; set; } = null!; protected string DoorSvgContent { get; set; } = ""; protected int idDoor { get; set; } = 0; @@ -71,7 +72,7 @@ namespace WebDoorCreator.UI.Pages } userLang = WDCUService.currLanguage ?? "EN"; WDCUService.EA_CurrLanguage += WDUService_EA_CurrLanguage; - CamDataServ.calcDonePipe.EA_NewMessage += CalcDonePipe_EA_NewMessage; + QDataServ.calcDonePipe.EA_NewMessage += CalcDonePipe_EA_NewMessage; } protected async Task ReloadData() diff --git a/WebDoorCreator.UI/Program.cs b/WebDoorCreator.UI/Program.cs index f261c06..ec59993 100644 --- a/WebDoorCreator.UI/Program.cs +++ b/WebDoorCreator.UI/Program.cs @@ -11,6 +11,7 @@ using Microsoft.EntityFrameworkCore; using StackExchange.Redis; using System.Globalization; using WebDoorCreator.Data; +using WebDoorCreator.Data.Services; using WebDoorCreator.UI.Areas.Identity; using WebDoorCreator.UI.Data; @@ -52,7 +53,7 @@ builder.Services.AddServerSideBlazor(); builder.Services.AddSingleton(); builder.Services.AddScoped(); builder.Services.AddSingleton(); -builder.Services.AddSingleton(); +builder.Services.AddSingleton(); builder.Services.AddScoped>(); builder.Services.AddHttpContextAccessor(); builder.Services.AddSingleton(redisMultiplexer); diff --git a/WebDoorCreator.UI/appsettings.json b/WebDoorCreator.UI/appsettings.json index 10f97a8..95096f3 100644 --- a/WebDoorCreator.UI/appsettings.json +++ b/WebDoorCreator.UI/appsettings.json @@ -8,7 +8,7 @@ "AllowedHosts": "*", "ConnectionStrings": { "Identity.DB": "Server=SQL2016DEV;Database=WebDoorCreator; User ID=sa;Password=keyhammer16; integrated security=False; MultipleActiveResultSets=True; App=WebDoorCreator.UI;", - "Redis": "localhost:6379,DefaultDatabase=11,connectTimeout=5000,syncTimeout=5000,asyncTimeout=5000,abortConnect=false,ssl=false", + "Redis": "nkcredis.steamware.net:6379, DefaultDatabase=11, connectTimeout=5000, syncTimeout=5000, asyncTimeout=5000, abortConnect=false, ssl=false, password=BtN9Py1wtLfLRvmzWnOPJ7RytDM+CLiVsJ/16zduNTlV8IOPGNrtzJSXPUnImA5PqmUMhKaUqo9NdHIG", "WDC.DB": "Server=SQL2016DEV;Database=WebDoorCreator; User ID=sa;Password=keyhammer16; integrated security=False; MultipleActiveResultSets=True; App=WebDoorCreator.UI;" }, "ExternalProviders": { diff --git a/WebDoorCreator.UI/temp/Conf.yaml b/WebDoorCreator.UI/temp/Conf.yaml index 52df938..aab7221 100644 --- a/WebDoorCreator.UI/temp/Conf.yaml +++ b/WebDoorCreator.UI/temp/Conf.yaml @@ -12,8 +12,8 @@ order: project: pO: line: -date: 2023-04-19T10:46:38.5109185+02:00 -piece: DO_1< +date: 2023-04-19T12:03:17.7578859+02:00 +piece: DO_1 size: width: 33.8125 height: 81.25 @@ -38,15 +38,20 @@ profiles: type: BV machining: ON overmaterial: 0.1 -1: - - Swing: RH - Width: 33333 - Height: 81.25 - Thickness: 1.75 -2: - - Hinge Edge: SQ - Top Edge: SQ - Bottom Edge: SQ - Lock Edge: SQ +edge_pulls: + - template: Generic\EdgePull230B + position: 45 +flush_pulls: + - template: Generic\Circle + position: 35 + back_set: 5 + depth: 1 + face: secure +locks: + - template: Generic\DocMyTest5Bore + position: 45.875 + back_set: 2.0 + offset_WS: 0.0 + side: lock_top ---