ok bulk gen richieste ddf
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
@page "/ResetDdfReq"
|
||||
|
||||
<button class="btn btn-lg btn-primary" @onclick="()=>doSave()">DO RESET</button>
|
||||
|
||||
@if (done)
|
||||
{
|
||||
<h1>DONE!!!!</h1>
|
||||
}
|
||||
@@ -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<DoorOpModel>? DoorOpsList { get; set; }
|
||||
|
||||
protected List<DoorModel> DoorsList { get; set; } = new List<DoorModel>();
|
||||
|
||||
protected List<OrderStatusViewModel>? OrdersList { get; set; }
|
||||
|
||||
protected List<string> ordListVal { get; set; } = new List<string>();
|
||||
protected List<DoorOpModel> listOp { get; set; } = new List<DoorOpModel>();
|
||||
protected List<DoorOpModel> listOpAll { get; set; } = new List<DoorOpModel>();
|
||||
|
||||
[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<string>("ConfDDF:VersNumber");
|
||||
bool remDoorOp = config.GetValue<bool>("ConfDDF:RemoveDoorOps");
|
||||
var headRows = config.GetSection("ConfDDF:Header").Get<List<string>>();
|
||||
var footRows = config.GetSection("ConfDDF:Footer").Get<List<string>>();
|
||||
currDdfConv = new WebDoorCreator.Data.DDF.Converter(vers, remDoorOp, headRows, footRows);
|
||||
}
|
||||
|
||||
protected WebDoorCreator.Data.DDF.Converter currDdfConv { get; set; } = null!;
|
||||
/// <summary>
|
||||
/// Effettua salvataggio record e generazione DDF
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user