From eb08eeb7d827bc73726d64cb0cc15bc9675b975a Mon Sep 17 00:00:00 2001 From: "zaccaria.majid" Date: Wed, 17 May 2023 10:13:40 +0200 Subject: [PATCH] ok bulk gen richieste ddf --- WebDoorCreator.UI/Pages/ResetDdfReq.razor | 8 ++ WebDoorCreator.UI/Pages/ResetDdfReq.razor.cs | 118 +++++++++++++++++++ 2 files changed, 126 insertions(+) create mode 100644 WebDoorCreator.UI/Pages/ResetDdfReq.razor create mode 100644 WebDoorCreator.UI/Pages/ResetDdfReq.razor.cs diff --git a/WebDoorCreator.UI/Pages/ResetDdfReq.razor b/WebDoorCreator.UI/Pages/ResetDdfReq.razor new file mode 100644 index 0000000..9e4883a --- /dev/null +++ b/WebDoorCreator.UI/Pages/ResetDdfReq.razor @@ -0,0 +1,8 @@ +@page "/ResetDdfReq" + + + +@if (done) +{ +

DONE!!!!

+} diff --git a/WebDoorCreator.UI/Pages/ResetDdfReq.razor.cs b/WebDoorCreator.UI/Pages/ResetDdfReq.razor.cs new file mode 100644 index 0000000..08e6890 --- /dev/null +++ b/WebDoorCreator.UI/Pages/ResetDdfReq.razor.cs @@ -0,0 +1,118 @@ +using Microsoft.AspNetCore.Components; +using System.Collections.Generic; +using WebDoorCreator.Data.DbModels; +using WebDoorCreator.Data.Services; +using WebDoorCreator.UI.Data; +using static Org.BouncyCastle.Math.EC.ECCurve; + +namespace WebDoorCreator.UI.Pages +{ + public partial class ResetDdfReq + { + protected List? DoorOpsList { get; set; } + + protected List DoorsList { get; set; } = new List(); + + protected List? OrdersList { get; set; } + + protected List ordListVal { get; set; } = new List(); + protected List listOp { get; set; } = new List(); + protected List listOpAll { get; set; } = new List(); + + [Inject] + protected QueueDataService QDataServ { get; set; } = null!; + + [Inject] + protected WebDoorCreatorService WDCService { get; set; } = null!; + protected async Task doorsGetAll() + { + await ordersGetAll(); + if (OrdersList != null) + { + foreach (var item in OrdersList) + { + var doors2Add = await WDCService.DoorGetByOrderId(item.OrderId); + if (doors2Add != null) + { + foreach (var door in doors2Add) + { + DoorsList.Add(door); + } + } + } + } + + } + protected bool done { get; set; } = false; + + [Inject] + protected IConfiguration config { get; set; } = null!; + + 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); + } + + protected WebDoorCreator.Data.DDF.Converter currDdfConv { get; set; } = null!; + /// + /// Effettua salvataggio record e generazione DDF + /// + /// + protected async Task doSave() + { + await doorsGetAll(); + + if (DoorsList != null) + { + foreach (var door in DoorsList) + { + await Task.Delay(50); + listOpAll = await WDCService.DoorOpGetByDoorId(door.DoorId); + if (listOpAll != null) + { + listOp = listOpAll.Where(x => x.userConfirm != "" && x.DtConfirm != null).ToList(); + if (listOp != null) + { + // chiamo metodo x avewre DDF serializzato + //var list2Ord = ; + var CurrentCompoOrder = await WDCService.ListValuesGetAll("*", "Hardware"); + if (CurrentCompoOrder != null) + { + foreach (var item in CurrentCompoOrder.OrderBy(x => x.Ordinal).ToList()) + { + ordListVal.Add(item.TableName); + } + } + + listOp = listOp.OrderBy(d => ordListVal.IndexOf(d.ObjectId)).ToList(); + + if (listOp.Count != 0 && listOp != null) + { + string currDdf = currDdfConv.GetSerialized(listOp); + // FIXME TODO: si potrebbe eliminare in futuro che va su REDIS + //await SaveYaml(currDdf); + // versione corrente del DDF generato + int currVers = await QDataServ.SendCalcReq(door.DoorId, currDdf); + } + + } + } + } + } + + done = true; + } + + protected async Task ordersGetAll() + { + DateTime adesso = DateTime.Today; + + OrdersList = await WDCService.OrderStatusGetFilt(0, 0, adesso.AddYears(-200), adesso.AddYears(200)); + } + } +} \ No newline at end of file