Update x gestione metodi upsert
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace EgwCoreLib.Lux.Core
|
||||
{
|
||||
public static class CloneExtensions
|
||||
{
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Clone profondo tramite serializzazione/deserializzazione di obj generici
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="obj"></param>
|
||||
/// <returns></returns>
|
||||
public static T DeepClone<T>(this T obj)
|
||||
{
|
||||
// Configurazione serializzatore JSON per risolvere errore di loop circolare
|
||||
var JSSettings = new JsonSerializerSettings()
|
||||
{
|
||||
ReferenceLoopHandling = ReferenceLoopHandling.Ignore
|
||||
};
|
||||
var json = JsonConvert.SerializeObject(obj, JSSettings);
|
||||
return JsonConvert.DeserializeObject<T>(json)!;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Comparatore statico tra entità
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="original"></param>
|
||||
/// <param name="edited"></param>
|
||||
/// <returns></returns>
|
||||
public static bool IsChanged<T>(T original, T edited) => !EqualityComparer<T>.Default.Equals(original, edited);
|
||||
|
||||
#endregion Public Methods
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,19 @@
|
||||
{
|
||||
#region Public Enums
|
||||
|
||||
/// <summary>
|
||||
/// Stato compilazione offerta
|
||||
/// </summary>
|
||||
public enum CompileStep
|
||||
{
|
||||
Draft = 0,
|
||||
Header = 1,
|
||||
General,
|
||||
Rows,
|
||||
Delivery,
|
||||
FinalCheck
|
||||
}
|
||||
|
||||
public enum DisplayMode
|
||||
{
|
||||
Standard,
|
||||
@@ -44,6 +57,27 @@
|
||||
JobCycle
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tipologia immagine
|
||||
/// </summary>
|
||||
public enum ImageType
|
||||
{
|
||||
/// <summary>
|
||||
/// Non definita (da calcolare...)
|
||||
/// </summary>
|
||||
ND = 0,
|
||||
|
||||
/// <summary>
|
||||
/// Calcolata (es JWD, BTL)
|
||||
/// </summary>
|
||||
Calculated,
|
||||
|
||||
/// <summary>
|
||||
/// Fissa (tipicamente prodotto da rivendita/servizio)
|
||||
/// </summary>
|
||||
Fixed
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tipologia item (classe/natura articolo)
|
||||
/// </summary>
|
||||
@@ -77,25 +111,6 @@
|
||||
BomAlt
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tipologia immagine
|
||||
/// </summary>
|
||||
public enum ImageType
|
||||
{
|
||||
/// <summary>
|
||||
/// Non definita (da calcolare...)
|
||||
/// </summary>
|
||||
ND = 0,
|
||||
/// <summary>
|
||||
/// Calcolata (es JWD, BTL)
|
||||
/// </summary>
|
||||
Calculated,
|
||||
/// <summary>
|
||||
/// Fissa (tipicamente prodotto da rivendita/servizio)
|
||||
/// </summary>
|
||||
Fixed
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tipologia item per Source (modalità costruzione)
|
||||
/// </summary>
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace EgwCoreLib.Lux.Core.Generic
|
||||
{
|
||||
public class EditStepDto
|
||||
{
|
||||
public Enums.CompileStep SrcStep { get; set; }
|
||||
public bool Changed { get; set; } = false;
|
||||
}
|
||||
}
|
||||
@@ -184,7 +184,7 @@ namespace EgwCoreLib.Lux.Data.Repository.Utils
|
||||
{
|
||||
await using var dbCtx = await CreateContextAsync();
|
||||
// Recuperiamo l'entità tracciata dal context
|
||||
var trackedEntity = dbCtx.DbSetTemplate.Local.FirstOrDefault(x => x.TemplateID == entity.TemplateID);
|
||||
var trackedEntity = await dbCtx.DbSetTemplate.FirstOrDefaultAsync(x => x.TemplateID == entity.TemplateID);
|
||||
|
||||
if (trackedEntity != null)
|
||||
{
|
||||
|
||||
@@ -157,7 +157,7 @@ namespace EgwCoreLib.Lux.Data.Repository.Utils
|
||||
{
|
||||
await using var dbCtx = await CreateContextAsync();
|
||||
// Recuperiamo l'entità tracciata dal context
|
||||
var trackedEntity = dbCtx.DbSetTemplateRow.Local.FirstOrDefault(x => x.TemplateID == entity.TemplateID);
|
||||
var trackedEntity = await dbCtx.DbSetTemplateRow.FirstOrDefaultAsync(x => x.TemplateID == entity.TemplateID);
|
||||
|
||||
if (trackedEntity != null)
|
||||
{
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace EgwCoreLib.Lux.Data.Repository.Config
|
||||
public async Task<bool> UpdateAsync(GlassModel entity)
|
||||
{
|
||||
await using var dbCtx = await CreateContextAsync();
|
||||
var trackedEntity = dbCtx.DbSetConfGlass.Local.FirstOrDefault(x => x.GlassID == entity.GlassID);
|
||||
var trackedEntity = await dbCtx.DbSetConfGlass.FirstOrDefaultAsync(x => x.GlassID == entity.GlassID);
|
||||
|
||||
if (trackedEntity != null)
|
||||
{
|
||||
|
||||
@@ -46,21 +46,19 @@ namespace EgwCoreLib.Lux.Data.Repository.Config
|
||||
await using var dbCtx = await CreateContextAsync();
|
||||
return await dbCtx.DbSetConfProfile
|
||||
.FirstOrDefaultAsync(x => x.ProfileID == recId);
|
||||
//.Where(x => x.ProfileID == recId)
|
||||
}
|
||||
public async Task<ProfileModel?> GetByUidAsync(string uID)
|
||||
{
|
||||
await using var dbCtx = await CreateContextAsync();
|
||||
return await dbCtx.DbSetConfProfile
|
||||
.FirstOrDefaultAsync(x => x.Code == uID);
|
||||
//.FirstOrDefaultAsync();
|
||||
}
|
||||
|
||||
|
||||
public async Task<bool> UpdateAsync(ProfileModel entity)
|
||||
{
|
||||
await using var dbCtx = await CreateContextAsync();
|
||||
var trackedEntity = dbCtx.DbSetConfProfile.Local.FirstOrDefault(x => x.ProfileID == entity.ProfileID);
|
||||
var trackedEntity = await dbCtx.DbSetConfProfile.FirstOrDefaultAsync(x => x.ProfileID == entity.ProfileID);
|
||||
|
||||
if (trackedEntity != null)
|
||||
{
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace EgwCoreLib.Lux.Data.Repository.Config
|
||||
public async Task<bool> UpdateAsync(WoodModel entity)
|
||||
{
|
||||
await using var dbCtx = await CreateContextAsync();
|
||||
var trackedEntity = dbCtx.DbSetConfWood.Local.FirstOrDefault(x => x.WoodID == entity.WoodID);
|
||||
var trackedEntity = await dbCtx.DbSetConfWood.FirstOrDefaultAsync(x => x.WoodID == entity.WoodID);
|
||||
|
||||
if (trackedEntity != null)
|
||||
{
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace EgwCoreLib.Lux.Data.Repository.Cost
|
||||
{
|
||||
await using var dbCtx = await CreateContextAsync();
|
||||
// Recuperiamo l'entità tracciata dal context
|
||||
var trackedEntity = dbCtx.DbSetResource.Local.FirstOrDefault(x => x.ResourceID == entity.ResourceID);
|
||||
var trackedEntity = await dbCtx.DbSetResource.FirstOrDefaultAsync(x => x.ResourceID == entity.ResourceID);
|
||||
|
||||
if (trackedEntity != null)
|
||||
{
|
||||
|
||||
@@ -203,7 +203,7 @@ namespace EgwCoreLib.Lux.Data.Repository.Items
|
||||
{
|
||||
await using var dbCtx = await CreateContextAsync();
|
||||
// Recuperiamo l'entità tracciata dal context
|
||||
var trackedEntity = dbCtx.DbSetItem.Local.FirstOrDefault(x => x.ItemID == entity.ItemID);
|
||||
var trackedEntity = await dbCtx.DbSetItem.FirstOrDefaultAsync(x => x.ItemID == entity.ItemID);
|
||||
|
||||
if (trackedEntity != null)
|
||||
{
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace EgwCoreLib.Lux.Data.Repository.Items
|
||||
{
|
||||
await using var dbCtx = await CreateContextAsync();
|
||||
// Recuperiamo l'entità tracciata dal context
|
||||
var trackedEntity = dbCtx.DbSetSellItem.Local.FirstOrDefault(x => x.SellingItemID == entity.SellingItemID);
|
||||
var trackedEntity = await dbCtx.DbSetSellItem.FirstOrDefaultAsync(x => x.SellingItemID == entity.SellingItemID);
|
||||
|
||||
if (trackedEntity != null)
|
||||
{
|
||||
|
||||
@@ -52,10 +52,10 @@ namespace EgwCoreLib.Lux.Data.Repository.Job
|
||||
dbCtx.DbSetJobStep.Remove(dbResult);
|
||||
|
||||
bool done = await dbCtx.SaveChangesAsync() > 0;
|
||||
|
||||
|
||||
if (done)
|
||||
tx.Commit();
|
||||
|
||||
|
||||
return done;
|
||||
}
|
||||
catch
|
||||
@@ -124,10 +124,10 @@ namespace EgwCoreLib.Lux.Data.Repository.Job
|
||||
dbCtx.Entry(currRec).State = EntityState.Modified;
|
||||
|
||||
bool done = await dbCtx.SaveChangesAsync() > 0;
|
||||
|
||||
|
||||
if (done)
|
||||
tx.Commit();
|
||||
|
||||
|
||||
return done;
|
||||
}
|
||||
catch
|
||||
@@ -140,7 +140,7 @@ namespace EgwCoreLib.Lux.Data.Repository.Job
|
||||
public async Task<bool> UpdateAsync(JobStepModel entity)
|
||||
{
|
||||
await using var dbCtx = await CreateContextAsync();
|
||||
var trackedEntity = dbCtx.DbSetJobStep.Local.FirstOrDefault(x => x.JobStepID == entity.JobStepID);
|
||||
var trackedEntity = await dbCtx.DbSetJobStep.FirstOrDefaultAsync(x => x.JobStepID == entity.JobStepID);
|
||||
|
||||
if (trackedEntity != null)
|
||||
{
|
||||
|
||||
@@ -52,10 +52,10 @@ namespace EgwCoreLib.Lux.Data.Repository.Job
|
||||
dbCtx.DbSetJobTask.Remove(dbResult);
|
||||
|
||||
bool done = await dbCtx.SaveChangesAsync() > 0;
|
||||
|
||||
|
||||
if (done)
|
||||
tx.Commit();
|
||||
|
||||
|
||||
return done;
|
||||
}
|
||||
catch
|
||||
@@ -123,10 +123,10 @@ namespace EgwCoreLib.Lux.Data.Repository.Job
|
||||
dbCtx.Entry(currRec).State = EntityState.Modified;
|
||||
|
||||
bool done = await dbCtx.SaveChangesAsync() > 0;
|
||||
|
||||
|
||||
if (done)
|
||||
tx.Commit();
|
||||
|
||||
|
||||
return done;
|
||||
}
|
||||
catch
|
||||
@@ -163,7 +163,7 @@ namespace EgwCoreLib.Lux.Data.Repository.Job
|
||||
return false;
|
||||
|
||||
var otherRec = await dbCtx.DbSetJobTask
|
||||
.FirstOrDefaultAsync(x => x.Index == newPos);
|
||||
.FirstOrDefaultAsync(x => x.JobID == selRec.JobID && x.Index == newPos);
|
||||
|
||||
if (otherRec == null)
|
||||
return false;
|
||||
@@ -175,10 +175,10 @@ namespace EgwCoreLib.Lux.Data.Repository.Job
|
||||
dbCtx.Entry(currRec).State = EntityState.Modified;
|
||||
|
||||
bool done = await dbCtx.SaveChangesAsync() > 0;
|
||||
|
||||
|
||||
if (done)
|
||||
tx.Commit();
|
||||
|
||||
|
||||
return done;
|
||||
}
|
||||
catch
|
||||
@@ -191,7 +191,7 @@ namespace EgwCoreLib.Lux.Data.Repository.Job
|
||||
public async Task<bool> UpdateAsync(JobTaskModel entity)
|
||||
{
|
||||
await using var dbCtx = await CreateContextAsync();
|
||||
var trackedEntity = dbCtx.DbSetJobTask.Local.FirstOrDefault(x => x.JobID == entity.JobID);
|
||||
var trackedEntity = await dbCtx.DbSetJobTask.FirstOrDefaultAsync(x => x.JobID == entity.JobID);
|
||||
|
||||
if (trackedEntity != null)
|
||||
{
|
||||
|
||||
@@ -220,7 +220,7 @@ namespace EgwCoreLib.Lux.Data.Repository.Production
|
||||
public async Task<bool> UpdateAsync(ProductionODLModel entity)
|
||||
{
|
||||
await using var dbCtx = await CreateContextAsync();
|
||||
var trackedEntity = dbCtx.DbSetProdODL.Local.FirstOrDefault(x => x.ProdODLID == entity.ProdODLID);
|
||||
var trackedEntity = await dbCtx.DbSetProdODL.FirstOrDefaultAsync(x => x.ProdODLID == entity.ProdODLID);
|
||||
|
||||
if (trackedEntity != null)
|
||||
{
|
||||
|
||||
@@ -248,7 +248,7 @@ namespace EgwCoreLib.Lux.Data.Repository.Sales
|
||||
{
|
||||
await using var dbCtx = await CreateContextAsync();
|
||||
// Recuperiamo l'entità tracciata dal context
|
||||
var trackedEntity = dbCtx.DbSetOffer.Local.FirstOrDefault(x => x.OfferID == entity.OfferID);
|
||||
var trackedEntity = await dbCtx.DbSetOffer.FirstOrDefaultAsync(x => x.OfferID == entity.OfferID);
|
||||
|
||||
if (trackedEntity != null)
|
||||
{
|
||||
|
||||
@@ -55,10 +55,10 @@ namespace EgwCoreLib.Lux.Data.Repository.Sales
|
||||
|
||||
// 4. Salvo tutto
|
||||
bool done = await dbCtx.SaveChangesAsync() > 0;
|
||||
|
||||
|
||||
if (done)
|
||||
tx.Commit();
|
||||
|
||||
|
||||
return done;
|
||||
}
|
||||
catch
|
||||
@@ -123,10 +123,10 @@ namespace EgwCoreLib.Lux.Data.Repository.Sales
|
||||
dbCtx.Entry(row).State = EntityState.Modified;
|
||||
|
||||
bool done = await dbCtx.SaveChangesAsync() > 0;
|
||||
|
||||
|
||||
if (done)
|
||||
tx.Commit();
|
||||
|
||||
|
||||
return done;
|
||||
}
|
||||
catch
|
||||
@@ -140,7 +140,7 @@ namespace EgwCoreLib.Lux.Data.Repository.Sales
|
||||
{
|
||||
await using var dbCtx = await CreateContextAsync();
|
||||
// Recuperiamo l'entità tracciata dal context
|
||||
var trackedEntity = dbCtx.DbSetOfferRow.Local.FirstOrDefault(x => x.OfferRowID == entity.OfferRowID);
|
||||
var trackedEntity = await dbCtx.DbSetOfferRow.FirstOrDefaultAsync(x => x.OfferRowID == entity.OfferRowID);
|
||||
|
||||
if (trackedEntity != null)
|
||||
{
|
||||
|
||||
@@ -269,7 +269,7 @@ namespace EgwCoreLib.Lux.Data.Repository.Sales
|
||||
{
|
||||
await using var dbCtx = await CreateContextAsync();
|
||||
// Recuperiamo l'entità tracciata dal context
|
||||
var trackedEntity = dbCtx.DbSetOrder.Local.FirstOrDefault(x => x.OrderID == entity.OrderID);
|
||||
var trackedEntity = await dbCtx.DbSetOrder.FirstOrDefaultAsync(x => x.OrderID == entity.OrderID);
|
||||
|
||||
if (trackedEntity != null)
|
||||
{
|
||||
|
||||
@@ -161,7 +161,7 @@ namespace EgwCoreLib.Lux.Data.Repository.Sales
|
||||
{
|
||||
await using var dbCtx = await CreateContextAsync();
|
||||
// Recuperiamo l'entità tracciata dal context
|
||||
var trackedEntity = dbCtx.DbSetOrderRow.Local.FirstOrDefault(x => x.OrderRowID == entity.OrderRowID);
|
||||
var trackedEntity = await dbCtx.DbSetOrderRow.FirstOrDefaultAsync(x => x.OrderRowID == entity.OrderRowID);
|
||||
|
||||
if (trackedEntity != null)
|
||||
{
|
||||
|
||||
@@ -28,9 +28,9 @@ namespace EgwCoreLib.Lux.Data.Repository.Utils
|
||||
|
||||
await using var dbCtx = await CreateContextAsync();
|
||||
dbCtx.DbSetGenClass.Remove(entity);
|
||||
|
||||
|
||||
bool done = await dbCtx.SaveChangesAsync() > 0;
|
||||
|
||||
|
||||
return done;
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace EgwCoreLib.Lux.Data.Repository.Utils
|
||||
{
|
||||
await using var dbCtx = await CreateContextAsync();
|
||||
// Recuperiamo l'entità tracciata dal context
|
||||
var trackedEntity = dbCtx.DbSetGenClass.Local.FirstOrDefault(x => x.ClassCod == entity.ClassCod);
|
||||
var trackedEntity = await dbCtx.DbSetGenClass.FirstOrDefaultAsync(x => x.ClassCod == entity.ClassCod);
|
||||
|
||||
if (trackedEntity != null)
|
||||
{
|
||||
|
||||
@@ -56,10 +56,10 @@ namespace EgwCoreLib.Lux.Data.Repository.Utils
|
||||
|
||||
// 4. Salvo tutto
|
||||
bool done = await dbCtx.SaveChangesAsync() > 0;
|
||||
|
||||
|
||||
if (done)
|
||||
tx.Commit();
|
||||
|
||||
|
||||
return done;
|
||||
}
|
||||
catch
|
||||
@@ -129,10 +129,10 @@ namespace EgwCoreLib.Lux.Data.Repository.Utils
|
||||
|
||||
// 6. Salvo
|
||||
bool done = await dbCtx.SaveChangesAsync() > 0;
|
||||
|
||||
|
||||
if (done)
|
||||
tx.Commit();
|
||||
|
||||
|
||||
return done;
|
||||
}
|
||||
catch
|
||||
@@ -146,7 +146,7 @@ namespace EgwCoreLib.Lux.Data.Repository.Utils
|
||||
{
|
||||
await using var dbCtx = await CreateContextAsync();
|
||||
// Recuperiamo l'entità tracciata dal context
|
||||
var trackedEntity = dbCtx.DbSetGenVal.Local.FirstOrDefault(x => x.GenValID == entity.GenValID);
|
||||
var trackedEntity = dbCtx.DbSetGenVal.FirstOrDefaultAsync(x => x.GenValID == entity.GenValID);
|
||||
|
||||
if (trackedEntity != null)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,250 @@
|
||||
using EgwMultiEngineManager.Data;
|
||||
using StackExchange.Redis;
|
||||
|
||||
namespace EgwCoreLib.Lux.Data.Services
|
||||
{
|
||||
/// <summary>
|
||||
/// Interfaccia per ImageCacheService - caching e publishing immagini via Redis
|
||||
/// </summary>
|
||||
public interface IImageCacheService
|
||||
{
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Effettua una generica chiamata ApiRest GET
|
||||
/// </summary>
|
||||
/// <param name="ApiUrl">URL Api di base</param>
|
||||
/// <param name="ApiRequest">Richiesta completa</param>
|
||||
/// <returns>Risposta RestSharp</returns>
|
||||
Task<RestSharp.RestResponse> CallRestGet(string ApiUrl, string ApiRequest);
|
||||
|
||||
/// <summary>
|
||||
/// Effettua una generica chiamata ApiRest POST
|
||||
/// </summary>
|
||||
/// <param name="ApiUrl">URL Api di base</param>
|
||||
/// <param name="ApiRequest">Richiesta completa</param>
|
||||
/// <param name="rawBody">Corpo Json trasmesso con richiesta</param>
|
||||
/// <returns>Risposta RestSharp</returns>
|
||||
Task<RestSharp.RestResponse> CallRestPost(string ApiUrl, string ApiRequest, object rawBody);
|
||||
|
||||
/// <summary>
|
||||
/// Elimina da cache Redis SVG per il record richiesto
|
||||
/// </summary>
|
||||
/// <param name="imgId">UID immagine</param>
|
||||
/// <param name="env">Environment</param>
|
||||
/// <returns>True se eliminato con successo</returns>
|
||||
bool DeleteSvg(string imgId, Constants.EXECENVIRONMENTS env);
|
||||
|
||||
/// <summary>
|
||||
/// Elimina da cache Redis SVG per il record richiesto (async)
|
||||
/// </summary>
|
||||
/// <param name="imgId">UID immagine</param>
|
||||
/// <param name="env">Environment</param>
|
||||
/// <returns>True se eliminato con successo</returns>
|
||||
Task<bool> DeleteSvgAsync(string imgId, Constants.EXECENVIRONMENTS env);
|
||||
|
||||
/// <summary>
|
||||
/// Esegue flush memoria Redis dato pattern
|
||||
/// </summary>
|
||||
/// <param name="pat2Flush">Pattern di cancellazione</param>
|
||||
/// <returns>True se eseguito con successo</returns>
|
||||
Task<bool> ExecFlushRedisPatternAsync(RedisValue pat2Flush);
|
||||
|
||||
/// <summary>
|
||||
/// Genera URL immagine dato
|
||||
/// </summary>
|
||||
/// <param name="baseUrl">Base url IMG server</param>
|
||||
/// <param name="isLive">Live = in fase di calcolo (cache REDIS)</param>
|
||||
/// <param name="imgUID">UID elemento/immagine</param>
|
||||
/// <param name="envir">Environment item (opzionale)</param>
|
||||
/// <returns>URL immagine completa</returns>
|
||||
string ImageUrl(string baseUrl, bool isLive, string imgUID, Constants.EXECENVIRONMENTS envir = Constants.EXECENVIRONMENTS.WINDOW);
|
||||
|
||||
/// <summary>
|
||||
/// Rilettura risposta da debug in formato string
|
||||
/// </summary>
|
||||
/// <param name="uID">UID record</param>
|
||||
/// <param name="env">Environment</param>
|
||||
/// <returns>Contenuto da debug</returns>
|
||||
Task<string> LoadDebug(string uID, Constants.EXECENVIRONMENTS env);
|
||||
|
||||
/// <summary>
|
||||
/// Recupera immagine PNG x id item richiesto
|
||||
/// </summary>
|
||||
/// <param name="imgUid">UID item</param>
|
||||
/// <param name="envir">Environment item (opzionale)</param>
|
||||
/// <returns>Contenuto PNG come stringa base64</returns>
|
||||
string LoadPng(string imgUid, Constants.EXECENVIRONMENTS envir = Constants.EXECENVIRONMENTS.WINDOW);
|
||||
|
||||
/// <summary>
|
||||
/// Recupera immagine PNG x id item richiesto (async)
|
||||
/// </summary>
|
||||
/// <param name="imgUid">UID item</param>
|
||||
/// <param name="envir">Environment item (opzionale)</param>
|
||||
/// <returns>Contenuto PNG come stringa base64</returns>
|
||||
Task<string> LoadPngAsync(string imgUid, Constants.EXECENVIRONMENTS envir = Constants.EXECENVIRONMENTS.WINDOW);
|
||||
|
||||
/// <summary>
|
||||
/// Recupera immagine SVG x id item richiesto
|
||||
/// </summary>
|
||||
/// <param name="imgUid">UID item</param>
|
||||
/// <param name="envir">Environment item (opzionale)</param>
|
||||
/// <returns>Contenuto SVG come stringa XML</returns>
|
||||
string LoadSvg(string imgUid, Constants.EXECENVIRONMENTS envir = Constants.EXECENVIRONMENTS.WINDOW);
|
||||
|
||||
/// <summary>
|
||||
/// Recupera immagine SVG x id item richiesto (async)
|
||||
/// </summary>
|
||||
/// <param name="imgId">UID item</param>
|
||||
/// <param name="envir">Environment item (opzionale)</param>
|
||||
/// <returns>Contenuto SVG come stringa XML</returns>
|
||||
Task<string> LoadSvgAsync(string imgId, Constants.EXECENVIRONMENTS envir = Constants.EXECENVIRONMENTS.WINDOW);
|
||||
|
||||
/// <summary>
|
||||
/// Salva e invia su channel richiesto un update x UID
|
||||
/// È atteso un refresh per chi sottoscrive il canale
|
||||
/// </summary>
|
||||
/// <param name="uid">UID record</param>
|
||||
/// <param name="env">Environment</param>
|
||||
/// <returns>True se pubblicato con successo</returns>
|
||||
Task<bool> PublishUpdateAsync(string uid, Constants.EXECENVIRONMENTS env);
|
||||
|
||||
/// <summary>
|
||||
/// Calcola URL immagine per richiesta di update SVG
|
||||
/// </summary>
|
||||
/// <param name="baseUrl">Base url IMG server</param>
|
||||
/// <param name="imgUID">UID elemento/immagine</param>
|
||||
/// <param name="serJwd">JWD serializzato per calcolo</param>
|
||||
/// <returns>URL per richiesta update</returns>
|
||||
string ReqUpdateSvg(string baseUrl, string imgUID, string serJwd);
|
||||
|
||||
/// <summary>
|
||||
/// Salva e invia su channel BOM redis il doc richiesto
|
||||
/// </summary>
|
||||
/// <param name="uid">UID record</param>
|
||||
/// <param name="env">Environment</param>
|
||||
/// <param name="bomContent">Contenuto BOM serializzato</param>
|
||||
/// <returns>True se salvato e pubblicato con successo</returns>
|
||||
Task<bool> SaveBomAsync(string uid, Constants.EXECENVIRONMENTS env, string bomContent);
|
||||
|
||||
/// <summary>
|
||||
/// Salvataggio risposta x debug in formato RAW
|
||||
/// </summary>
|
||||
/// <param name="uID">UID record</param>
|
||||
/// <param name="env">Environment</param>
|
||||
/// <param name="rawData">Dati raw</param>
|
||||
/// <returns>True se salvato con successo</returns>
|
||||
Task<bool> SaveDebug(string uID, Constants.EXECENVIRONMENTS env, string rawData);
|
||||
|
||||
/// <summary>
|
||||
/// Salva e invia su channel dedicato HML l'elenco degli HardwareModel (conf preferiti) gestiti
|
||||
/// </summary>
|
||||
/// <param name="uid">UID record</param>
|
||||
/// <param name="env">Environment</param>
|
||||
/// <param name="rawData">Dati raw</param>
|
||||
/// <returns>True se salvato e pubblicato con successo</returns>
|
||||
Task<bool> SaveHmlAsync(string uid, Constants.EXECENVIRONMENTS env, string rawData);
|
||||
|
||||
/// <summary>
|
||||
/// Salva e invia su channel l'XML delle HW options per il doc richiesto
|
||||
/// </summary>
|
||||
/// <param name="uid">UID record</param>
|
||||
/// <param name="env">Environment</param>
|
||||
/// <param name="xmlContent">Contenuto XML</param>
|
||||
/// <returns>True se salvato e pubblicato con successo</returns>
|
||||
Task<bool> SaveHwOptAsync(string uid, Constants.EXECENVIRONMENTS env, string xmlContent);
|
||||
|
||||
/// <summary>
|
||||
/// Salva immagine PNG su Redis e pubblica notifica sul channel
|
||||
/// </summary>
|
||||
/// <param name="imgId">UID immagine</param>
|
||||
/// <param name="env">Environment</param>
|
||||
/// <param name="pngContent">Contenuto PNG come stringa base64</param>
|
||||
/// <returns>True se salvato e pubblicato con successo</returns>
|
||||
bool SavePng(string imgId, Constants.EXECENVIRONMENTS env, string pngContent);
|
||||
|
||||
/// <summary>
|
||||
/// Salva immagine PNG su Redis e pubblica notifica sul channel (async)
|
||||
/// </summary>
|
||||
/// <param name="imgId">UID immagine</param>
|
||||
/// <param name="env">Environment</param>
|
||||
/// <param name="pngContent">Contenuto PNG come stringa base64</param>
|
||||
/// <returns>True se salvato e pubblicato con successo</returns>
|
||||
Task<bool> SavePngAsync(string imgId, Constants.EXECENVIRONMENTS env, string pngContent);
|
||||
|
||||
/// <summary>
|
||||
/// Salva e invia su channel risultato balance per POR (UID.GroupId.Type) richiesto
|
||||
/// </summary>
|
||||
/// <param name="uid">UID record</param>
|
||||
/// <param name="env">Environment</param>
|
||||
/// <param name="estimContent">Contenuto stima serializzato</param>
|
||||
/// <returns>True se salvato e pubblicato con successo</returns>
|
||||
Task<bool> SaveProdBalanceAsync(string uid, Constants.EXECENVIRONMENTS env, string estimContent);
|
||||
|
||||
/// <summary>
|
||||
/// Salva e invia su channel risultato stima per POR (UID.GroupId) richiesto
|
||||
/// </summary>
|
||||
/// <param name="uid">UID record</param>
|
||||
/// <param name="env">Environment</param>
|
||||
/// <param name="estimContent">Contenuto stima serializzato</param>
|
||||
/// <returns>True se salvato e pubblicato con successo</returns>
|
||||
Task<bool> SaveProdEstimateAsync(string uid, Constants.EXECENVIRONMENTS env, string estimContent);
|
||||
|
||||
/// <summary>
|
||||
/// Salva e invia su channel areaProfElem ricevuta
|
||||
/// </summary>
|
||||
/// <param name="uID">UID record</param>
|
||||
/// <param name="env">Environment</param>
|
||||
/// <param name="areaProfElem">Contenuto areaProfElem serializzato</param>
|
||||
/// <returns>True se salvato e pubblicato con successo</returns>
|
||||
Task<bool> SaveProfileElemAsync(string uID, Constants.EXECENVIRONMENTS env, string areaProfElem);
|
||||
|
||||
/// <summary>
|
||||
/// Salva e invia su channel profile list gestiti
|
||||
/// </summary>
|
||||
/// <param name="uid">UID record</param>
|
||||
/// <param name="env">Environment</param>
|
||||
/// <param name="rawData">Dati raw</param>
|
||||
/// <returns>True se salvato e pubblicato con successo</returns>
|
||||
Task<bool> SaveProfileListAsync(string uid, Constants.EXECENVIRONMENTS env, string rawData);
|
||||
|
||||
/// <summary>
|
||||
/// Salva e invia su channel info Threshold e Data x profili gestiti
|
||||
/// </summary>
|
||||
/// <param name="uid">UID record</param>
|
||||
/// <param name="env">Environment</param>
|
||||
/// <param name="rawDataThresh">Info Threshold</param>
|
||||
/// <param name="rawProfData">Info generiche</param>
|
||||
/// <returns>True se salvato e pubblicato con successo</returns>
|
||||
Task<bool> SaveProfileThreshAsync(string uid, Constants.EXECENVIRONMENTS env, string rawDataThresh, string rawProfData);
|
||||
|
||||
/// <summary>
|
||||
/// Salva e invia su channel shape per item (UID.GroupId) richiesto
|
||||
/// </summary>
|
||||
/// <param name="uid">UID record</param>
|
||||
/// <param name="env">Environment</param>
|
||||
/// <param name="shapeContent">Contenuto shape serializzato</param>
|
||||
/// <returns>True se salvato e pubblicato con successo</returns>
|
||||
Task<bool> SaveShapeAsync(string uid, Constants.EXECENVIRONMENTS env, string shapeContent);
|
||||
|
||||
/// <summary>
|
||||
/// Salva immagine SVG su Redis e pubblica notifica sul channel
|
||||
/// </summary>
|
||||
/// <param name="imgId">UID immagine</param>
|
||||
/// <param name="env">Environment</param>
|
||||
/// <param name="svgContent">Contenuto SVG come stringa XML</param>
|
||||
/// <returns>True se salvato e pubblicato con successo</returns>
|
||||
bool SaveSvg(string imgId, Constants.EXECENVIRONMENTS env, string svgContent);
|
||||
|
||||
/// <summary>
|
||||
/// Salva immagine SVG su Redis e pubblica notifica sul channel (async)
|
||||
/// </summary>
|
||||
/// <param name="imgId">UID immagine</param>
|
||||
/// <param name="env">Environment</param>
|
||||
/// <param name="svgContent">Contenuto SVG come stringa XML</param>
|
||||
/// <returns>True se salvato e pubblicato con successo</returns>
|
||||
Task<bool> SaveSvgAsync(string imgId, Constants.EXECENVIRONMENTS env, string svgContent);
|
||||
|
||||
#endregion Public Methods
|
||||
}
|
||||
}
|
||||
@@ -7,11 +7,14 @@ using StackExchange.Redis;
|
||||
|
||||
namespace EgwCoreLib.Lux.Data.Services
|
||||
{
|
||||
public class ImageCacheService
|
||||
public class ImageCacheService : IImageCacheService
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public ImageCacheService(IConfiguration config, IRedisService redisService, IConnectionMultiplexer redisConn)
|
||||
public ImageCacheService(
|
||||
IConfiguration config,
|
||||
IRedisService redisService,
|
||||
IConnectionMultiplexer redisConn)
|
||||
{
|
||||
_config = config;
|
||||
_redisService = redisService;
|
||||
@@ -87,6 +90,34 @@ namespace EgwCoreLib.Lux.Data.Services
|
||||
return response;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elimina da cache Redis SVG per il doc richiesto
|
||||
/// </summary>
|
||||
/// <param name="imgId"></param>
|
||||
/// <param name="svgContent"></param>
|
||||
/// <returns></returns>
|
||||
public bool DeleteSvg(string imgId, Constants.EXECENVIRONMENTS env)
|
||||
{
|
||||
// salvo img in cache
|
||||
string currKey = $"{redisBaseKey}:{env}:Img:Svg:{imgId.Replace("/", ":")}";
|
||||
var done = _redisService.Delete(currKey);
|
||||
return done;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elimina da cache Redis SVG per il doc richiesto Async
|
||||
/// </summary>
|
||||
/// <param name="imgId"></param>
|
||||
/// <param name="env"></param>
|
||||
/// <param name="svgContent"></param>
|
||||
public async Task<bool> DeleteSvgAsync(string imgId, Constants.EXECENVIRONMENTS env)
|
||||
{
|
||||
// salvo img in cache
|
||||
string currKey = $"{redisBaseKey}:{env}:Img:Svg:{imgId.Replace("/", ":")}";
|
||||
var done = await _redisService.DeleteAsync(currKey);
|
||||
return done;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Esegue flush memoria redis dato pat2Flush
|
||||
/// </summary>
|
||||
@@ -160,7 +191,7 @@ namespace EgwCoreLib.Lux.Data.Services
|
||||
/// <param name="imgUID">UID elemento/immagine</param>
|
||||
/// <param name="envir">Environment item</param>
|
||||
/// <returns></returns>
|
||||
public string ImageUrl(string baseUrl, bool isLive, string imgUID, EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS envir = EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WINDOW)
|
||||
public string ImageUrl(string baseUrl, bool isLive, string imgUID, Constants.EXECENVIRONMENTS envir = Constants.EXECENVIRONMENTS.WINDOW)
|
||||
{
|
||||
string tag = isLive ? liveTag : cacheTag;
|
||||
string fType = "undef";
|
||||
@@ -215,7 +246,7 @@ namespace EgwCoreLib.Lux.Data.Services
|
||||
/// </summary>
|
||||
/// <param name="imgUid">UID item</param>
|
||||
/// <param name="envir">Environment item</param>
|
||||
public string LoadPng(string imgUid, EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS envir = EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WINDOW)
|
||||
public string LoadPng(string imgUid, Constants.EXECENVIRONMENTS envir = Constants.EXECENVIRONMENTS.WINDOW)
|
||||
{
|
||||
// recupero img da cache
|
||||
string currKey = $"{redisBaseKey}:{envir}:Img:Png:{imgUid.Replace("/", ":")}";
|
||||
@@ -228,7 +259,7 @@ namespace EgwCoreLib.Lux.Data.Services
|
||||
/// </summary>
|
||||
/// <param name="imgUid">UID item</param>
|
||||
/// <param name="envir">Environment item</param>
|
||||
public async Task<string> LoadPngAsync(string imgUid, EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS envir = EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WINDOW)
|
||||
public async Task<string> LoadPngAsync(string imgUid, Constants.EXECENVIRONMENTS envir = Constants.EXECENVIRONMENTS.WINDOW)
|
||||
{
|
||||
// recupero img da cache
|
||||
string currKey = $"{redisBaseKey}:{envir}:Img:Png:{imgUid.Replace("/", ":")}";
|
||||
@@ -241,7 +272,7 @@ namespace EgwCoreLib.Lux.Data.Services
|
||||
/// </summary>
|
||||
/// <param name="imgUid">UID item</param>
|
||||
/// <param name="envir">Environment item</param>
|
||||
public string LoadSvg(string imgUid, EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS envir = EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WINDOW)
|
||||
public string LoadSvg(string imgUid, Constants.EXECENVIRONMENTS envir = Constants.EXECENVIRONMENTS.WINDOW)
|
||||
{
|
||||
// recupero img da cache
|
||||
string currKey = $"{redisBaseKey}:{envir}:Img:Svg:{imgUid.Replace("/", ":")}";
|
||||
@@ -254,7 +285,7 @@ namespace EgwCoreLib.Lux.Data.Services
|
||||
/// </summary>
|
||||
/// <param name="imgId">UID item</param>
|
||||
/// <param name="envir">Environment item</param>
|
||||
public async Task<string> LoadSvgAsync(string imgId, EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS envir = EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WINDOW)
|
||||
public async Task<string> LoadSvgAsync(string imgId, Constants.EXECENVIRONMENTS envir = Constants.EXECENVIRONMENTS.WINDOW)
|
||||
{
|
||||
// recupero img da cache
|
||||
string currKey = $"{redisBaseKey}:{envir}:Img:Svg:{imgId.Replace("/", ":")}";
|
||||
@@ -353,7 +384,7 @@ namespace EgwCoreLib.Lux.Data.Services
|
||||
/// <param name="uid"></param>
|
||||
/// <param name="env"></param>
|
||||
/// <param name="xmlContent"></param>
|
||||
public async Task<bool> SaveHwOptAsync(string uid, EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS env, string xmlContent)
|
||||
public async Task<bool> SaveHwOptAsync(string uid, Constants.EXECENVIRONMENTS env, string xmlContent)
|
||||
{
|
||||
// salvo img in cache
|
||||
string currKey = $"{redisBaseKey}:{env}:HwOpt:{uid.Replace("/", ":")}";
|
||||
@@ -371,7 +402,7 @@ namespace EgwCoreLib.Lux.Data.Services
|
||||
/// <param name="imgId"></param>
|
||||
/// <param name="pngContent">contenuto PNG come string base64</param>
|
||||
/// <returns></returns>
|
||||
public bool SavePng(string imgId, EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS env, string pngContent)
|
||||
public bool SavePng(string imgId, Constants.EXECENVIRONMENTS env, string pngContent)
|
||||
{
|
||||
// salvo img in cache
|
||||
string currKey = $"{redisBaseKey}:{env}:Img:Png:{imgId.Replace("/", ":")}";
|
||||
@@ -388,7 +419,7 @@ namespace EgwCoreLib.Lux.Data.Services
|
||||
/// <param name="imgId"></param>
|
||||
/// <param name="env"></param>
|
||||
/// <param name="pngContent">contenuto PNG come string base64</param>
|
||||
public async Task<bool> SavePngAsync(string imgId, EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS env, string pngContent)
|
||||
public async Task<bool> SavePngAsync(string imgId, Constants.EXECENVIRONMENTS env, string pngContent)
|
||||
{
|
||||
// salvo img in cache
|
||||
string currKey = $"{redisBaseKey}:{env}:Img:Png:{imgId.Replace("/", ":")}";
|
||||
@@ -407,7 +438,7 @@ namespace EgwCoreLib.Lux.Data.Services
|
||||
/// <param name="uid"></param>
|
||||
/// <param name="env"></param>
|
||||
/// <param name="estimContent"></param>
|
||||
public async Task<bool> SaveProdBalanceAsync(string uid, EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS env, string estimContent)
|
||||
public async Task<bool> SaveProdBalanceAsync(string uid, Constants.EXECENVIRONMENTS env, string estimContent)
|
||||
{
|
||||
// salvo in cache
|
||||
string currKey = $"{redisBaseKey}:{env}:Balance:{uid}";
|
||||
@@ -424,7 +455,7 @@ namespace EgwCoreLib.Lux.Data.Services
|
||||
/// <param name="uid"></param>
|
||||
/// <param name="env"></param>
|
||||
/// <param name="estimContent"></param>
|
||||
public async Task<bool> SaveProdEstimateAsync(string uid, EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS env, string estimContent)
|
||||
public async Task<bool> SaveProdEstimateAsync(string uid, Constants.EXECENVIRONMENTS env, string estimContent)
|
||||
{
|
||||
// salvo in cache
|
||||
string currKey = $"{redisBaseKey}:{env}:Estimation:{uid}";
|
||||
@@ -493,7 +524,7 @@ namespace EgwCoreLib.Lux.Data.Services
|
||||
/// <param name="uid"></param>
|
||||
/// <param name="env"></param>
|
||||
/// <param name="shapeContent"></param>
|
||||
public async Task<bool> SaveShapeAsync(string uid, EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS env, string shapeContent)
|
||||
public async Task<bool> SaveShapeAsync(string uid, Constants.EXECENVIRONMENTS env, string shapeContent)
|
||||
{
|
||||
// salvo img in cache
|
||||
string currKey = $"{redisBaseKey}:{env}:Shape:{uid}";
|
||||
@@ -504,41 +535,13 @@ namespace EgwCoreLib.Lux.Data.Services
|
||||
return done;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elimina da cache Redis SVG per il doc richiesto
|
||||
/// </summary>
|
||||
/// <param name="imgId"></param>
|
||||
/// <param name="svgContent"></param>
|
||||
/// <returns></returns>
|
||||
public bool DeleteSvg(string imgId, EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS env)
|
||||
{
|
||||
// salvo img in cache
|
||||
string currKey = $"{redisBaseKey}:{env}:Img:Svg:{imgId.Replace("/", ":")}";
|
||||
var done = _redisService.Delete(currKey);
|
||||
return done;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elimina da cache Redis SVG per il doc richiesto Async
|
||||
/// </summary>
|
||||
/// <param name="imgId"></param>
|
||||
/// <param name="env"></param>
|
||||
/// <param name="svgContent"></param>
|
||||
public async Task<bool> DeleteSvgAsync(string imgId, EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS env)
|
||||
{
|
||||
// salvo img in cache
|
||||
string currKey = $"{redisBaseKey}:{env}:Img:Svg:{imgId.Replace("/", ":")}";
|
||||
var done = await _redisService.DeleteAsync(currKey);
|
||||
return done;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Salva e invia su channel img redis SVG per il doc richiesto
|
||||
/// </summary>
|
||||
/// <param name="imgId"></param>
|
||||
/// <param name="svgContent"></param>
|
||||
/// <returns></returns>
|
||||
public bool SaveSvg(string imgId, EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS env, string svgContent)
|
||||
public bool SaveSvg(string imgId, Constants.EXECENVIRONMENTS env, string svgContent)
|
||||
{
|
||||
// salvo img in cache
|
||||
string currKey = $"{redisBaseKey}:{env}:Img:Svg:{imgId.Replace("/", ":")}";
|
||||
@@ -555,7 +558,7 @@ namespace EgwCoreLib.Lux.Data.Services
|
||||
/// <param name="imgId"></param>
|
||||
/// <param name="env"></param>
|
||||
/// <param name="svgContent"></param>
|
||||
public async Task<bool> SaveSvgAsync(string imgId, EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS env, string svgContent)
|
||||
public async Task<bool> SaveSvgAsync(string imgId, Constants.EXECENVIRONMENTS env, string svgContent)
|
||||
{
|
||||
// salvo img in cache
|
||||
string currKey = $"{redisBaseKey}:{env}:Img:Svg:{imgId.Replace("/", ":")}";
|
||||
@@ -568,44 +571,6 @@ namespace EgwCoreLib.Lux.Data.Services
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
/// <summary>
|
||||
/// Oggetto per la connessione a Redis utilizzato per operazioni di lettura/scrittura.
|
||||
/// </summary>
|
||||
protected IConnectionMultiplexer _redisConn = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Database Redis utilizzato per le operazioni di lettura/scrittura
|
||||
/// nb: ottenuto tramite _redisConn.GetDatabase()
|
||||
/// </summary>
|
||||
protected IDatabase _redisDb = null!;
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
/// <summary>
|
||||
#if false
|
||||
/// Effettua una generica chiamata ApiRest
|
||||
/// </summary>
|
||||
/// <param name="ApiUrl">URL Api di base</param>
|
||||
/// <param name="ApiRequest">Richiesta completa</param>
|
||||
/// <param name="JsonBody">Corpo Json trasmesso con richiesta</param>
|
||||
/// <returns></returns>
|
||||
public async Task<RestResponse> CallRestPost(string ApiUrl, string ApiRequest, string JsonBody)
|
||||
{
|
||||
RestResponse response;
|
||||
// cerco online
|
||||
using (RestClient client = new RestClient(ApiUrl))
|
||||
{
|
||||
var request = new RestRequest(ApiRequest, Method.Post);
|
||||
string rawData = JsonConvert.SerializeObject(JsonBody);
|
||||
request.AddJsonBody(rawData);
|
||||
response = await client.ExecutePostAsync(request);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
#endif
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private static Logger Log = LogManager.GetCurrentClassLogger();
|
||||
@@ -615,23 +580,50 @@ namespace EgwCoreLib.Lux.Data.Services
|
||||
private readonly string apiUrl = "";
|
||||
|
||||
private readonly string cacheTag = "svgfile";
|
||||
|
||||
private readonly string calcTag = "svgpreview";
|
||||
|
||||
private readonly string chBom = "lux:bom";
|
||||
|
||||
private readonly string chEstimation = "estimation:curr";
|
||||
|
||||
private readonly string chHwList = "lux:hw:list";
|
||||
|
||||
private readonly string chHwOpt = "lux:hw:opt";
|
||||
|
||||
private readonly string chPng = "lux:png:img";
|
||||
|
||||
private readonly string chProd = "lux:prod";
|
||||
|
||||
private readonly string chProfElem = "lux:prof:elem";
|
||||
|
||||
private readonly string chProfList = "lux:prof:list";
|
||||
|
||||
private readonly string chProfThresh = "lux:prof:thresh";
|
||||
|
||||
private readonly string chShape = "shape:curr";
|
||||
|
||||
private readonly string chSvg = "lux:svg:img";
|
||||
|
||||
private readonly string chUpdate = "lux::update";
|
||||
|
||||
private readonly string imgBasePath = "";
|
||||
|
||||
private readonly string liveTag = "svg";
|
||||
|
||||
private IConfiguration _config;
|
||||
|
||||
/// <summary>
|
||||
/// Oggetto per la connessione a Redis utilizzato per operazioni di lettura/scrittura.
|
||||
/// </summary>
|
||||
private IConnectionMultiplexer _redisConn = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Database Redis utilizzato per le operazioni di lettura/scrittura
|
||||
/// nb: ottenuto tramite _redisConn.GetDatabase()
|
||||
/// </summary>
|
||||
private IDatabase _redisDb = null!;
|
||||
|
||||
private string imageBaseUrl = "";
|
||||
|
||||
private string redisBaseKey = "Lux";
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Version>1.1.2603.2309</Version>
|
||||
<Version>1.1.2603.2317</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
<div class="row">
|
||||
<div class="col-3">
|
||||
<div class="form-floating mb-3">
|
||||
<div class="form-floating mb-3 @(IsChanged(CurrRecord.CustomerID, OrigRecord?.CustomerID) ? "border border-info rounded shadow" : "")">
|
||||
<select @bind="@CurrRecord.CustomerID" class="form-select">
|
||||
@foreach (var item in CustomersList)
|
||||
{
|
||||
@@ -13,7 +13,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-3">
|
||||
<div class="form-floating mb-3">
|
||||
<div class="form-floating mb-3 @(IsChanged(CurrRecord.DealerID, OrigRecord?.DealerID) ? "border border-info rounded shadow" : "")">
|
||||
<select @bind="@CurrRecord.DealerID" class="form-select">
|
||||
@foreach (var item in DealersList)
|
||||
{
|
||||
@@ -24,7 +24,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-2">
|
||||
<div class="form-floating mb-3">
|
||||
<div class="form-floating mb-3 @(IsChanged(CurrRecord.OffertState, OrigRecord?.OffertState) ? "border border-info rounded shadow" : "")">
|
||||
<select @bind="@CurrRecord.OffertState" class="form-select">
|
||||
@foreach (var item in System.Enum.GetValues(typeof(EgwCoreLib.Lux.Core.Enums.OfferStates)))
|
||||
{
|
||||
@@ -35,27 +35,32 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-2">
|
||||
<div class="form-floating mb-3">
|
||||
<input @bind="@CurrRecord.Inserted" class="form-control" type="date">
|
||||
<div class="form-floating mb-3 @(IsChanged(CurrRecord.Inserted, OrigRecord?.Inserted) ? "border border-info rounded shadow" : "")">
|
||||
<input @bind="@CurrRecord.Inserted" class="form-control" type="date" />
|
||||
<label class="small">Data Ins.</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-2">
|
||||
<div class="form-floating mb-3">
|
||||
<input @bind="@CurrRecord.ValidUntil" class="form-control" type="date">
|
||||
<div class="form-floating mb-3 @(IsChanged(CurrRecord.ValidUntil, OrigRecord?.ValidUntil) ? "border border-info rounded shadow" : "")">
|
||||
<input @bind="@CurrRecord.ValidUntil" class="form-control" type="date" />
|
||||
<label class="small">Validità</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12">
|
||||
<div class="form-floating mb-3">
|
||||
<div class="form-floating mb-3 @(IsChanged(CurrRecord.Description, OrigRecord?.Description) ? "border border-info rounded shadow" : "")">
|
||||
<textarea @bind="@CurrRecord.Description" class="form-control" type="text"></textarea>
|
||||
<label class="small">Descrizione</label>
|
||||
</div>
|
||||
</div>
|
||||
@* <div class="col-6">
|
||||
<button class="btn btn-lg btn-success w-100" @onclick="DoSave"><i class="fa-solid fa-floppy-disk"></i> Save</button>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<button class="btn btn-lg btn-warning w-100" @onclick="DoCancel"><i class="fa-solid fa-ban"></i> Cancel</button>
|
||||
</div> *@
|
||||
</div>
|
||||
@if (HasChanged())
|
||||
{
|
||||
<div class="col-6">
|
||||
</div>
|
||||
<div class="col-3">
|
||||
<button class="btn btn-lg btn-success w-100" @onclick="DoSave"><i class="fa-solid fa-floppy-disk"></i> Save</button>
|
||||
</div>
|
||||
<div class="col-3">
|
||||
<button class="btn btn-lg btn-warning w-100" @onclick="DoCancel"><i class="fa-solid fa-ban"></i> Cancel</button>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
@@ -1,3 +1,5 @@
|
||||
using EgwCoreLib.Lux.Core;
|
||||
using EgwCoreLib.Lux.Core.Generic;
|
||||
using EgwCoreLib.Lux.Data.DbModel.Sales;
|
||||
using EgwCoreLib.Lux.Data.Services;
|
||||
using EgwCoreLib.Lux.Data.Services.Sales;
|
||||
@@ -18,6 +20,12 @@ namespace Lux.UI.Components.Compo
|
||||
[Parameter]
|
||||
public OfferModel CurrRecord { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Evento che indica variazione rispetto ai dati originali
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public EventCallback<EditStepDto> EC_Changed { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Callback invocato al chiusura della finestra (con valore <c>true</c> per cancellazione).
|
||||
/// </summary>
|
||||
@@ -25,7 +33,7 @@ namespace Lux.UI.Components.Compo
|
||||
public EventCallback<bool> EC_Close { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Callback invocato al salvataggio con l'offerta aggiornata.
|
||||
/// Callback invocato alla richiesta di salvataggio con l'offerta aggiornata.
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public EventCallback<OfferModel> EC_Updated { get; set; }
|
||||
@@ -39,10 +47,31 @@ namespace Lux.UI.Components.Compo
|
||||
/// </summary>
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
setOriginal();
|
||||
await ReloadData();
|
||||
await base.OnInitializedAsync();
|
||||
}
|
||||
|
||||
protected override void OnParametersSet()
|
||||
{
|
||||
//base.OnParametersSet();
|
||||
setOriginal();
|
||||
}
|
||||
|
||||
#if false
|
||||
protected override Task OnParametersSetAsync()
|
||||
{
|
||||
bool isChanged = HasChanged();
|
||||
var resData = new EditStepDto()
|
||||
{
|
||||
SrcStep = Enums.CompileStep.Header,
|
||||
Changed = isChanged
|
||||
};
|
||||
|
||||
return EC_Changed.InvokeAsync(resData);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Private Fields
|
||||
@@ -53,6 +82,7 @@ namespace Lux.UI.Components.Compo
|
||||
private List<CustomerModel> CustomersList = new List<CustomerModel>();
|
||||
|
||||
private List<DealerModel> DealersList = new List<DealerModel>();
|
||||
private OfferModel? OrigRecord = null;
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
@@ -85,12 +115,50 @@ namespace Lux.UI.Components.Compo
|
||||
return EC_Updated.InvokeAsync(CurrRecord);
|
||||
}
|
||||
|
||||
private bool HasChanged()
|
||||
{
|
||||
bool answ = false;
|
||||
if (OrigRecord != null && CurrRecord != null)
|
||||
{
|
||||
if (IsChanged(OrigRecord.CustomerID, CurrRecord.CustomerID))
|
||||
return true;
|
||||
if (IsChanged(OrigRecord.DealerID, CurrRecord.DealerID))
|
||||
return true;
|
||||
if (IsChanged(OrigRecord.OffertState, CurrRecord.OffertState))
|
||||
return true;
|
||||
if (IsChanged(OrigRecord.Inserted, CurrRecord.Inserted))
|
||||
return true;
|
||||
if (IsChanged(OrigRecord.ValidUntil, CurrRecord.ValidUntil))
|
||||
return true;
|
||||
if (IsChanged(OrigRecord.Description, CurrRecord.Description))
|
||||
return true;
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifica variazione tramite helper
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="original"></param>
|
||||
/// <param name="edited"></param>
|
||||
/// <returns></returns>
|
||||
private bool IsChanged<T>(T original, T edited) => CloneExtensions.IsChanged(original, edited);
|
||||
|
||||
private async Task ReloadData()
|
||||
{
|
||||
CustomersList = await CService.GetAllAsync();
|
||||
DealersList = await DService.GetAllAsync();
|
||||
}
|
||||
|
||||
private void setOriginal()
|
||||
{
|
||||
if (CurrRecord != null && OrigRecord == null)
|
||||
{
|
||||
OrigRecord = CurrRecord.DeepClone();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
}
|
||||
}
|
||||
@@ -13,28 +13,28 @@
|
||||
<div class="d-flex">
|
||||
<div class="px-0 row">
|
||||
<div class="col px-0">
|
||||
<span @onclick="() => AdvStep(CompileStep.Header)">
|
||||
<StepArrow ObjId="1" StepText="Testata" BlockStyle="@(ArrowBackCol(CompileStep.Header))" StrokeWidth="4" ObjW="360" ObjH="60" StrokeColors="@listBord01" TipAngle="90" TextStyle="@txtStyle"></StepArrow>
|
||||
<span @onclick="() => AdvStep(Enums.CompileStep.Header)">
|
||||
<StepArrow ObjId="1" StepText="Testata" BlockStyle="@(ArrowBackCol(Enums.CompileStep.Header))" StrokeWidth="4" ObjW="360" ObjH="60" StrokeColors="@listBord01" TipAngle="90" TextStyle="@txtStyle"></StepArrow>
|
||||
</span>
|
||||
</div>
|
||||
<div class="col px-0">
|
||||
<span @onclick="() => AdvStep(CompileStep.General)">
|
||||
<StepArrow ObjId="2" StepText="Generale" BlockStyle="@(ArrowBackCol(CompileStep.General))" StrokeWidth="4" ObjW="360" ObjH="60" StrokeColors="@listBord01" TipAngle="90" TextStyle="@txtStyle"></StepArrow>
|
||||
<span @onclick="() => AdvStep(Enums.CompileStep.General)">
|
||||
<StepArrow ObjId="2" StepText="Generale" BlockStyle="@(ArrowBackCol(Enums.CompileStep.General))" StrokeWidth="4" ObjW="360" ObjH="60" StrokeColors="@listBord01" TipAngle="90" TextStyle="@txtStyle"></StepArrow>
|
||||
</span>
|
||||
</div>
|
||||
<div class="col px-0">
|
||||
<span @onclick="() => AdvStep(CompileStep.Rows)">
|
||||
<StepArrow ObjId="3" StepText="Righe" BlockStyle="@(ArrowBackCol(CompileStep.Rows))" StrokeWidth="4" ObjW="360" ObjH="60" StrokeColors="@listBord01" TipAngle="90" TextStyle="@txtStyle"></StepArrow>
|
||||
<span @onclick="() => AdvStep(Enums.CompileStep.Rows)">
|
||||
<StepArrow ObjId="3" StepText="Righe" BlockStyle="@(ArrowBackCol(Enums.CompileStep.Rows))" StrokeWidth="4" ObjW="360" ObjH="60" StrokeColors="@listBord01" TipAngle="90" TextStyle="@txtStyle"></StepArrow>
|
||||
</span>
|
||||
</div>
|
||||
<div class="col px-0">
|
||||
<span @onclick="() => AdvStep(CompileStep.Delivery)">
|
||||
<StepArrow ObjId="4" StepText="Consegna" BlockStyle="@(ArrowBackCol(CompileStep.Delivery))" StrokeWidth="4" ObjW="360" ObjH="60" StrokeColors="@listBord01" TipAngle="90" TextStyle="@txtStyle"></StepArrow>
|
||||
<span @onclick="() => AdvStep(Enums.CompileStep.Delivery)">
|
||||
<StepArrow ObjId="4" StepText="Consegna" BlockStyle="@(ArrowBackCol(Enums.CompileStep.Delivery))" StrokeWidth="4" ObjW="360" ObjH="60" StrokeColors="@listBord01" TipAngle="90" TextStyle="@txtStyle"></StepArrow>
|
||||
</span>
|
||||
</div>
|
||||
<div class="col px-0">
|
||||
<span @onclick="() => AdvStep(CompileStep.FinalCheck)">
|
||||
<StepArrow ObjId="5" StepText="Controlli" BlockStyle="@(ArrowBackCol(CompileStep.FinalCheck))" StrokeWidth="4" ObjW="360" ObjH="60" StrokeColors="@listBord01" TipAngle="90" TextStyle="@txtStyle"></StepArrow>
|
||||
<span @onclick="() => AdvStep(Enums.CompileStep.FinalCheck)">
|
||||
<StepArrow ObjId="5" StepText="Controlli" BlockStyle="@(ArrowBackCol(Enums.CompileStep.FinalCheck))" StrokeWidth="4" ObjW="360" ObjH="60" StrokeColors="@listBord01" TipAngle="90" TextStyle="@txtStyle"></StepArrow>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@@ -50,23 +50,23 @@
|
||||
</div>
|
||||
<div class="card-body">
|
||||
|
||||
@if (currStep == CompileStep.Header)
|
||||
@if (currStep == Enums.CompileStep.Header)
|
||||
{
|
||||
<OfferMan CurrRecord="EditRecord" EC_Close="DoClose" EC_Updated="DoSave"></OfferMan>
|
||||
<OfferMan CurrRecord="EditRecord" EC_Close="DoClose" EC_Updated="DoSave" EC_Changed="SetDirty"></OfferMan>
|
||||
}
|
||||
else if (currStep == CompileStep.General)
|
||||
else if (currStep == Enums.CompileStep.General)
|
||||
{
|
||||
<OfferCommonPar CurrRecord="EditRecord" EC_Close="DoClose" EC_Updated="DoSave"></OfferCommonPar>
|
||||
}
|
||||
else if (currStep == CompileStep.Rows)
|
||||
else if (currStep == Enums.CompileStep.Rows)
|
||||
{
|
||||
<OfferRowMan CurrRecord="EditRecord" DisplayMode="EgwCoreLib.Lux.Core.Enums.DisplayMode.Edit"></OfferRowMan>
|
||||
}
|
||||
else if (currStep == CompileStep.Delivery)
|
||||
else if (currStep == Enums.CompileStep.Delivery)
|
||||
{
|
||||
<OfferDelivery CurrRecord="EditRecord" EC_Close="DoClose" EC_Updated="DoSave"></OfferDelivery>
|
||||
}
|
||||
else if (currStep == CompileStep.FinalCheck)
|
||||
else if (currStep == Enums.CompileStep.FinalCheck)
|
||||
{
|
||||
<OfferCheck CurrRecord="EditRecord" EC_Close="DoClose"></OfferCheck>
|
||||
}
|
||||
|
||||
@@ -15,23 +15,6 @@ namespace Lux.UI.Components.Pages
|
||||
{
|
||||
public partial class Offers
|
||||
{
|
||||
#region Protected Enums
|
||||
|
||||
/// <summary>
|
||||
/// Stato compilazione offerta
|
||||
/// </summary>
|
||||
protected enum CompileStep
|
||||
{
|
||||
Draft = 0,
|
||||
Header = 1,
|
||||
General,
|
||||
Rows,
|
||||
Delivery,
|
||||
FinalCheck
|
||||
}
|
||||
|
||||
#endregion Protected Enums
|
||||
|
||||
#region Protected Properties
|
||||
|
||||
/// <summary>
|
||||
@@ -96,6 +79,7 @@ namespace Lux.UI.Components.Pages
|
||||
|
||||
private List<OfferModel> ListRecords = new List<OfferModel>();
|
||||
|
||||
private List<CompileStep> ListtChanges = new();
|
||||
private int numRecord = 10;
|
||||
|
||||
/// <summary>
|
||||
@@ -345,6 +329,27 @@ namespace Lux.UI.Components.Pages
|
||||
UpdateTable();
|
||||
}
|
||||
|
||||
private void SetDirty(EditStepDto updData)
|
||||
{
|
||||
#if false
|
||||
// semodificato imposto colore variato x header
|
||||
if (updData.Changed)
|
||||
{
|
||||
if (!ListtChanges.Contains(updData.SrcStep))
|
||||
{
|
||||
ListtChanges.Add(updData.SrcStep);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ListtChanges.Contains(updData.SrcStep))
|
||||
{
|
||||
ListtChanges.Remove(updData.SrcStep);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Imposta periodo da filtro
|
||||
/// </summary>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<UserSecretsId>aspnet-Lux.UI-a758c101-a2f4-4e38-977d-1c4887dbbd50</UserSecretsId>
|
||||
<Version>1.1.2603.2310</Version>
|
||||
<Version>1.1.2603.2317</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<body>
|
||||
<i>LUX - Web Windows MES</i>
|
||||
<h4>Versione: 1.1.2603.2310</h4>
|
||||
<h4>Versione: 1.1.2603.2317</h4>
|
||||
<br /> Note di rilascio:
|
||||
<ul>
|
||||
<li>
|
||||
|
||||
@@ -1 +1 @@
|
||||
1.1.2603.2310
|
||||
1.1.2603.2317
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<item>
|
||||
<version>1.1.2603.2310</version>
|
||||
<version>1.1.2603.2317</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>
|
||||
|
||||
Reference in New Issue
Block a user