aggiunti metodo e controller x db arca
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Data.SqlClient;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using MP.Data.DatabaseModels;
|
||||
using NLog;
|
||||
@@ -27,12 +28,44 @@ namespace MP.Data.Controllers
|
||||
{
|
||||
_configuration = null;
|
||||
}
|
||||
|
||||
#region gestione lotti esterni
|
||||
/// <summary>
|
||||
/// Elenco lotti esterni presenti sul db di ARCA
|
||||
/// </summary>
|
||||
/// <param name="codArt">Codice articolo</param>
|
||||
/// <param name="codLotto">Codice lotto</param>
|
||||
/// <param name="codMagazzino">Codice magazzino</param>
|
||||
/// <param name="onlyTest">proprietà per definire scopo stored</param>
|
||||
/// <returns></returns>
|
||||
public List<AnagLottiArca> ListLottiEsterni(string codArt, string codLotto, string codMagazzino, bool onlyTest)
|
||||
{
|
||||
List<AnagLottiArca> dbResult = new List<AnagLottiArca>();
|
||||
using (var dbCtx = new MoonPro_InveContext(_configuration))
|
||||
{
|
||||
var DataGiac = new SqlParameter("@DataGiac", null);
|
||||
var CodArt = new SqlParameter("@CodArt", codArt);
|
||||
var CodLotto = new SqlParameter("@CodLotto", codLotto);
|
||||
var CodMagaz = new SqlParameter("@CodMagaz", codMagazzino);
|
||||
var OnlyTest = new SqlParameter("@OnlyTest", onlyTest);
|
||||
|
||||
dbResult = dbCtx
|
||||
.DbLottoArca
|
||||
.FromSqlRaw("exec dbo.stp_GIAC_getByDate @DataGiac,@CodArt,@CodLotto,@CodMagaz,@OnlyTest", DataGiac, CodArt, CodLotto, CodMagaz, OnlyTest)
|
||||
.AsNoTracking()
|
||||
//.AsEnumerable()
|
||||
.ToList();
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
#endregion gestione lotti esterni
|
||||
|
||||
#region gestione articoli
|
||||
|
||||
/// <summary>
|
||||
/// articolo MAG corrispondente all' articolo selezionato
|
||||
/// </summary>
|
||||
/// <param name="artSearch"></param>
|
||||
/// <param name="artSearch"></param>
|
||||
/// <returns></returns>
|
||||
public AnagArticoli_MAG artBySearch(string artSearch)
|
||||
{
|
||||
|
||||
@@ -53,6 +53,7 @@ namespace MP.Data
|
||||
public virtual DbSet<AnagUdcModel> DbUdcData { get; set; }
|
||||
public virtual DbSet<AnagLottoModel> DbLottoData { get; set; }
|
||||
public virtual DbSet<AnagArticoli_MAG> DbArtMag { get; set; }
|
||||
public virtual DbSet<AnagLottiArca> DbLottoArca { get; set; }
|
||||
#endregion PER INVE
|
||||
|
||||
#region PER SPEC
|
||||
|
||||
@@ -297,6 +297,39 @@ namespace MP.INVE.Data
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public List<AnagLottiArca> ListLottiEsterni()
|
||||
{
|
||||
string source = "";
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
List<AnagLottiArca>? result = new List<AnagLottiArca>();
|
||||
// cerco in redis...
|
||||
RedisValue rawData = redisDb.StringGet(redisLottiEsterni);
|
||||
if (!string.IsNullOrEmpty($"{rawData}"))
|
||||
{
|
||||
result = JsonConvert.DeserializeObject<List<AnagLottiArca>>($"{rawData}");
|
||||
|
||||
source = "REDIS";
|
||||
}
|
||||
else
|
||||
{
|
||||
result = dbController.ListLottiEsterni();
|
||||
// serializzo e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
redisDb.StringSetAsync(redisLottiEsterni, rawData, getRandTOut(redisLongTimeCache));
|
||||
source = "DB";
|
||||
}
|
||||
if (result == null)
|
||||
{
|
||||
result = new List<AnagLottiArca>();
|
||||
}
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Debug($"ListLottiEsterni Read from {source}: {ts.TotalMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<ScanDataModel> ScanList()
|
||||
{
|
||||
string source = "";
|
||||
@@ -413,7 +446,7 @@ namespace MP.INVE.Data
|
||||
stopWatch.Start();
|
||||
List<AnagLottoModel>? result = new List<AnagLottoModel>();
|
||||
// cerco in redis...
|
||||
RedisValue rawData = redisDb.StringGet(redisLottiBaseAddr);
|
||||
RedisValue rawData = redisDb.StringGet(redisLottiInterni);
|
||||
if (!string.IsNullOrEmpty($"{rawData}"))
|
||||
{
|
||||
result = JsonConvert.DeserializeObject<List<AnagLottoModel>>($"{rawData}");
|
||||
@@ -425,7 +458,7 @@ namespace MP.INVE.Data
|
||||
result = dbController.ElencoLotti();
|
||||
// serializzo e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
redisDb.StringSetAsync(redisLottiBaseAddr, rawData, getRandTOut(redisLongTimeCache));
|
||||
redisDb.StringSetAsync(redisLottiInterni, rawData, getRandTOut(redisLongTimeCache));
|
||||
source = "DB";
|
||||
}
|
||||
if (result == null)
|
||||
@@ -599,8 +632,10 @@ namespace MP.INVE.Data
|
||||
private const string redisBaseAddr = "MP:INVE";
|
||||
private const string redisSessionBaseAddr = ":Session";
|
||||
private const string redisOperatoriBaseAddr = ":Operatore";
|
||||
private const string redisUdcBaseAddr = ":UDC";
|
||||
private const string redisLottiBaseAddr = ":Lotti";
|
||||
private const string redisUdcBaseAddr = ":UDC";
|
||||
private const string redisLottiInterni = redisLottiBaseAddr + ":LottiInterni";
|
||||
private const string redisLottiEsterni = redisLottiBaseAddr + ":LottiEsterni";
|
||||
private const string redisConfigBaseAddr = ":Config";
|
||||
private const string redisScanBaseAddr = redisBaseAddr + ":Scan";
|
||||
private const string redisElencoOperatori = redisBaseAddr + redisOperatoriBaseAddr + ":ListOperatori";
|
||||
|
||||
Reference in New Issue
Block a user