Aggiunta pagina download jwd

aggiunta parziale test ricalcolo balance
This commit is contained in:
Samuele Locatelli
2026-01-13 11:06:07 +01:00
parent 15675aa6f7
commit 034e263c92
15 changed files with 387 additions and 12 deletions
@@ -2503,7 +2503,7 @@ namespace EgwCoreLib.Lux.Data.Controllers
{
DateTime adesso = DateTime.Now;
// recupero ordine...
var currRec = dbCtx
dbRec = dbCtx
.DbSetOrder
.Where(x => x.OrderID == orderId)
.Include(x => x.OrderRowNav)
@@ -3146,7 +3146,7 @@ namespace EgwCoreLib.Lux.Data.Controllers
* - i successivi calcoli di balance/stima saranno fatti x questo SPECIFICO ID GROUP così da fare prima... a sto punto GroupIP potrebbe essere un int 0...n oppure l'id del record... forse meglio il counter 0..n
*
* */
int grpIdx = 0;
int grpIdx = 1;
// preparo x add nuovi ProductionGroup da analisi ritorno stime
List<ProductionGroupModel> listProdGroup2Add = new List<ProductionGroupModel>();
// 1: non lavorabili...
@@ -1276,7 +1276,7 @@ namespace EgwCoreLib.Lux.Data.Services
// cerco in redis...
string currKey = $"{redisBaseKey}:Orders:ById:{orderId}";
RedisValue rawData = await redisDb.StringGetAsync(currKey);
if (rawData.HasValue && !doForce)
if (rawData.HasValue && rawData.Length() > 2 && !doForce)
{
result = JsonConvert.DeserializeObject<OrderModel>($"{rawData}");
source = "REDIS";
+1 -1
View File
@@ -4,7 +4,7 @@
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<Version>0.9.2601.1219</Version>
<Version>0.9.2601.1311</Version>
</PropertyGroup>
<ItemGroup>
+9 -1
View File
@@ -193,6 +193,14 @@ else
<span class="small">@fSize(item.FileSize)</span>
</li>
}
@if (PreparedFile.Contains(item.OfferRowUID))
{
<li class="list-group-item px-2 py-1 small"><a href="@($"download?fileName={item.OfferRowUID}.jwd")" target="_blank" class="btn btn-sm btn-success">Download <i class="fa-solid fa-download"></i></a></li>
}
else
{
<li class="list-group-item px-2 py-1 small"><button class="btn btn-sm btn-info" @onclick="() => PrepareFile(item)">Prepare <i class="fa-solid fa-download"></i></button></li>
}
</ul>
</td>
@if (CurrEditMode == EditMode.RecData && EditRecord != null && EditRecord.OfferRowID == item.OfferRowID)
@@ -376,7 +384,7 @@ else
}
}
@if(reqSellingItem)
@if (reqSellingItem)
{
<div class="modal" tabindex="-1" style="display:block; background-color: rgba(10,10,10,.6);" role="dialog">
<div class="modal-dialog modal-xl">
@@ -121,6 +121,9 @@ namespace Lux.UI.Components.Compo
[Inject]
protected DataLayerServices DLService { get; set; } = null!;
[Inject]
protected IWebHostEnvironment CurrEnv { get; set; } = null!;
/// <summary>
/// Costo totale calcolato x offerta
/// </summary>
@@ -642,6 +645,32 @@ namespace Lux.UI.Components.Compo
await reqBomUpdate(currRec);
}
/// <summary>
/// Esegue preparazione del file file:
/// - legge dal DB il contenuto
/// - salva in area temp
/// </summary>
/// <param name="currRec"></param>
/// <returns></returns>
protected async Task PrepareFile(OfferRowModel currRec)
{
// verifico sia un JWD x ora...
if (currRec.Envir == EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WINDOW)
{
string fName = $"{currRec.OfferRowUID}";
var filePath = Path.Combine(CurrEnv.ContentRootPath, "temp\\", $"{fName}.jwd");
// salvo il contenuto
File.WriteAllText(filePath, currRec.SerStruct);
// aggiungo a lista preparati se non ci fosse...
if(!PreparedFile.Contains(fName))
{
PreparedFile.Add(fName);
}
}
}
private List<string> PreparedFile = new();
/// <summary>
/// Css di verifica riga selezionata
/// </summary>
+5
View File
@@ -0,0 +1,5 @@
@page "/Download"
@model Lux.UI.Components.Pages.DownloadModel
@{
}
@@ -0,0 +1,49 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using System.IO;
namespace Lux.UI.Components.Pages
{
/// <summary>
/// Gestione download file csv
///
/// da valutare eventualmente xlsx con https://github.com/closedxml/closedxml
/// </summary>
public class DownloadModel : PageModel
{
#region Public Constructors
public DownloadModel(IWebHostEnvironment env)
{
_env = env;
}
#endregion Public Constructors
#region Public Methods
public IActionResult OnGet()
{
string fileName = "file.txt";
if (Request.Query.ContainsKey("fileName"))
{
fileName = Request.Query["fileName"];
}
var filePath = Path.Combine(_env.ContentRootPath, "temp\\", fileName);
//var filePath = Path.Combine(_env.WebRootPath, "..\\temp\\", fileName);
byte[] fileBytes = System.IO.File.ReadAllBytes(filePath);
return File(fileBytes, "application/force-download", fileName);
}
#endregion Public Methods
#region Private Fields
private readonly IWebHostEnvironment _env;
#endregion Private Fields
}
}
@@ -72,7 +72,7 @@ namespace Lux.UI.Components.Pages
private async Task DoBalance(int OrderRowID)
{
if (!await JSRuntime.InvokeAsync<bool>("confirm", $"Sicuro di voler Bilanciare la riga d'orinde?"))
if (!await JSRuntime.InvokeAsync<bool>("confirm", $"Sicuro di voler Bilanciare la riga d'ordine?"))
return;
// verifico se mancassero le righe di ProdGroup e rigenero...
@@ -122,7 +122,15 @@ namespace Lux.UI.Components.Pages
};
var currPOR = ListEstimRecords?.FirstOrDefault(x => x.OrderRowID == prodGroupItem.OrderRowID) ?? new OrderRowModel();
var currRec = await DLService.OrderById(currPOR.OrderID, true);
#if false
var currRec = currPOR.OrderNav;
if (currRec == null)
{
currRec = await DLService.OrderById(currPOR.OrderID, true);
}
#endif
var dictReq = new Dictionary<string, double>();
// verifico se ho 1 sola macchina o molte...
@@ -143,6 +151,7 @@ namespace Lux.UI.Components.Pages
tagList.AddRange(cMacc.Value.TagList);
}
// verifico tags distinct
balData.MachineBalance = dictReq;
balData.TagList = tagList.Distinct().ToList();
}
@@ -165,8 +174,8 @@ namespace Lux.UI.Components.Pages
// preparo richiesta serializzata e la accodo (viene inviata richiesta calcolo)
Dictionary<string, string> dictArgs = new Dictionary<string, string>();
// creo registrazione richiesta...
var ruid = await CRService.AddRequestAsync($"{currPOR.Envir}", $"{(int)cMode}-{(int)cSubMode}", currRec.OrderCode);
dictArgs.Add("UID", currRec.OrderCode);
var ruid = await CRService.AddRequestAsync($"{currPOR.Envir}", $"{(int)cMode}-{(int)cSubMode}", currPOR.OrderRowUID);
dictArgs.Add("UID", currPOR.OrderRowUID);
dictArgs.Add("Group", $"{prodGroupItem.GrpIdx}");
// aggiungo RUID effettivo
dictArgs.Add("RUID", ruid);
+2 -1
View File
@@ -5,7 +5,7 @@
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>aspnet-Lux.UI-a758c101-a2f4-4e38-977d-1c4887dbbd50</UserSecretsId>
<Version>0.9.2601.1219</Version>
<Version>0.9.2601.1311</Version>
</PropertyGroup>
<ItemGroup>
@@ -46,6 +46,7 @@
</ItemGroup>
<ItemGroup>
<Folder Include="temp\" />
<Folder Include="unsafe_uploads\" />
<Folder Include="wwwroot\images\textures\" />
</ItemGroup>
+16
View File
@@ -156,6 +156,22 @@ app.MapRazorComponents<App>()
.AddInteractiveWebAssemblyRenderMode()
.AddAdditionalAssemblies(typeof(Lux.UI.Client._Imports).Assembly);
app.MapGet("/download", (HttpContext ctx, IWebHostEnvironment env) =>
{
var fileName = ctx.Request.Query["fileName"].ToString() ?? "file.txt";
var filePath = Path.Combine(env.ContentRootPath, "temp", fileName);
if (!File.Exists(filePath))
return Results.NotFound();
return Results.File(
File.ReadAllBytes(filePath),
"application/octet-stream",
fileName
);
});
// Add additional endpoints required by the Identity /Account Razor components.
app.MapAdditionalIdentityEndpoints();
+93
View File
@@ -0,0 +1,93 @@
{
"ProfilePath": "Profilo78",
"Material": "Pino",
"ColorMaterial": "Black",
"Glass": "Vetro BE 2S 4T/16/4T",
"AreaList": [
{
"Shape": "RECTANGLE",
"DimensionList": [
{
"Index": 1,
"Name": "Width",
"Value": 800.0
},
{
"Index": 2,
"Name": "Height",
"Value": 1400.0
}
],
"JointList": [
{
"Index": 1,
"JointType": "FULL_H"
},
{
"Index": 2,
"JointType": "FULL_H"
},
{
"Index": 3,
"JointType": "FULL_H"
},
{
"Index": 4,
"JointType": "FULL_H"
}
],
"Threshold": "Bottom",
"BottomRail": false,
"BottomRailQty": 0,
"GroupId": 1,
"AreaList": [
{
"IsSashVertical": true,
"SashList": [
{
"SashId": 1,
"OpeningType": "TILTTURN_LEFT",
"MeasureType": "PERCENTAGE",
"Dimension": 100.0,
"HasHandle": true,
"JointList": [
{
"Index": 1,
"JointType": "FULL_V"
},
{
"Index": 2,
"JointType": "FULL_V"
},
{
"Index": 3,
"JointType": "FULL_V"
},
{
"Index": 4,
"JointType": "FULL_V"
}
]
}
],
"SashType": "NULL",
"BottomRail": false,
"BottomRailQty": 0,
"Hardware": "000545",
"HwOptionList": [],
"GroupId": 4,
"AreaList": [
{
"FillType": "GLASS",
"GroupId": 3,
"AreaList": [],
"AreaType": "FILL"
}
],
"AreaType": "SASH"
}
],
"AreaType": "FRAME"
}
]
}
+165
View File
@@ -0,0 +1,165 @@
{
"ProfilePath": "Profilo78",
"Material": "Pino",
"ColorMaterial": "Black",
"Glass": "Vetro BE 2S 4T/16/4T",
"AreaList": [
{
"Shape": "RECTANGLE",
"DimensionList": [
{
"Index": 1,
"Name": "Width",
"Value": 1800.0
},
{
"Index": 2,
"Name": "Height",
"Value": 2100.0
}
],
"JointList": [
{
"Index": 1,
"JointType": "FULL_H"
},
{
"Index": 2,
"JointType": "FULL_H"
},
{
"Index": 3,
"JointType": "FULL_H"
},
{
"Index": 4,
"JointType": "FULL_H"
}
],
"Threshold": "Bottom",
"BottomRail": false,
"BottomRailQty": 0,
"GroupId": 1,
"AreaList": [
{
"IsSashVertical": true,
"SashList": [
{
"SashId": 1,
"OpeningType": "TILTTURN_LEFT",
"MeasureType": "PERCENTAGE",
"Dimension": 50.0,
"HasHandle": true,
"JointList": [
{
"Index": 1,
"JointType": "FULL_V"
},
{
"Index": 2,
"JointType": "FULL_V"
},
{
"Index": 3,
"JointType": "FULL_V"
},
{
"Index": 4,
"JointType": "FULL_V"
}
]
},
{
"SashId": 2,
"OpeningType": "TURNONLY_RIGHT",
"MeasureType": "PERCENTAGE",
"Dimension": 50.0,
"HasHandle": false,
"JointList": [
{
"Index": 1,
"JointType": "FULL_V"
},
{
"Index": 2,
"JointType": "FULL_V"
},
{
"Index": 3,
"JointType": "FULL_V"
},
{
"Index": 4,
"JointType": "FULL_V"
}
]
}
],
"SashType": "NULL",
"BottomRail": false,
"BottomRailQty": 0,
"Hardware": "000548",
"HwOptionList": [
{
"Name": "Entrata",
"Value": "15"
},
{
"Name": "LavManigliaPassante",
"Value": "false"
},
{
"Name": "PosizioneForoCilindro",
"Value": "sopra"
},
{
"Name": "Deviatore",
"Value": "false"
},
{
"Name": "ModelloCilindro",
"Value": "c999"
},
{
"Name": "LavCilindroPassante",
"Value": "false"
},
{
"Name": "HMan",
"Value": "500"
}
],
"GroupId": 4,
"AreaList": [
{
"GroupId": 5,
"AreaList": [
{
"FillType": "GLASS",
"GroupId": 3,
"AreaList": [],
"AreaType": "FILL"
}
],
"AreaType": "SPLITTED"
},
{
"GroupId": 6,
"AreaList": [
{
"FillType": "GLASS",
"GroupId": 7,
"AreaList": [],
"AreaType": "FILL"
}
],
"AreaType": "SPLITTED"
}
],
"AreaType": "SASH"
}
],
"AreaType": "FRAME"
}
]
}
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>LUX - Web Windows MES</i>
<h4>Versione: 0.9.2601.1219</h4>
<h4>Versione: 0.9.2601.1311</h4>
<br /> Note di rilascio:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
0.9.2601.1219
0.9.2601.1311
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>0.9.2601.1219</version>
<version>0.9.2601.1311</version>
<url>http://nexus.steamware.net/repository/SWS/GPW/stable/GPW.UI.zip</url>
<changelog>http://nexus.steamware.net/repository/SWS/GPW/stable/ChangeLog.html</changelog>
<mandatory>false</mandatory>