Merge branch 'release/FixPagination'
This commit is contained in:
+1
-1
@@ -206,7 +206,7 @@ staging:
|
||||
# - *nuget-fix
|
||||
# - dotnet restore
|
||||
script:
|
||||
- dotnet publish -p:PublishProfile=IISProfile.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release MP.Stats/MP.Stats.csproj -p:output=publish/net5.0
|
||||
- dotnet publish -p:PublishProfile=IISProfile.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release MP.Stats/MP.Stats.csproj -o:publish
|
||||
# qui il deploy su nexus...
|
||||
- *hashBuild
|
||||
- *nexusUpload
|
||||
|
||||
@@ -167,10 +167,16 @@ namespace MP.Data.Controllers
|
||||
/// <summary>
|
||||
/// Elenco tabella DDB da filtro
|
||||
/// </summary>
|
||||
/// <param name="numRecord"></param>
|
||||
/// <param name="searchVal"></param>
|
||||
/// <param name="DataStart"></param>
|
||||
/// <param name="DataEnd"></param>
|
||||
/// <param name="IdxMacchina"></param>
|
||||
/// <param name="IdxODL"></param>
|
||||
/// <param name="KeyRichiesta"></param>
|
||||
/// <param name="CodArticolo"></param>
|
||||
/// <param name="FirstRecord"></param>
|
||||
/// <param name="NumRecord"></param>
|
||||
/// <returns></returns>
|
||||
public List<DatabaseModels.DdbTurni> StatDdbGetAll(DateTime DataStart, DateTime DataEnd, string IdxMacchina, int IdxODL, string KeyRichiesta, string CodArticolo)
|
||||
public List<DatabaseModels.DdbTurni> StatDdbGetAll(DateTime DataStart, DateTime DataEnd, string IdxMacchina, int IdxODL, string KeyRichiesta, string CodArticolo, int FirstRecord, int NumRecord)
|
||||
{
|
||||
List<DatabaseModels.DdbTurni> dbResult = new List<DatabaseModels.DdbTurni>();
|
||||
|
||||
@@ -180,15 +186,37 @@ namespace MP.Data.Controllers
|
||||
var idxODL = new SqlParameter("@IdxODL", IdxODL);
|
||||
var keyRichiesta = new SqlParameter("@KeyRichiesta", KeyRichiesta);
|
||||
var codArticolo = new SqlParameter("@CodArticolo", CodArticolo);
|
||||
var firstRecord = new SqlParameter("@FirstRecord", FirstRecord);
|
||||
var numRecord = new SqlParameter("@NumRecord", NumRecord);
|
||||
|
||||
dbResult = dbCtx
|
||||
.DbSetDdbTurni
|
||||
.FromSqlRaw("EXEC stp_UI_DDBTurni_GetByFilter @dataFrom,@dataTo,@idxMacchina,@IdxODL,@KeyRichiesta,@CodArticolo", dataFrom, dataTo, idxMacchina, idxODL, keyRichiesta, codArticolo)
|
||||
.FromSqlRaw("EXEC stp_UI_DDBTurni_GetByFilter @dataFrom,@dataTo,@idxMacchina,@IdxODL,@KeyRichiesta,@CodArticolo,@FirstRecord,@NumRecord", dataFrom, dataTo, idxMacchina, idxODL, keyRichiesta, codArticolo, firstRecord, numRecord)
|
||||
.ToList();
|
||||
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco tabella DDB da filtro
|
||||
/// </summary>
|
||||
/// <param name="DataStart"></param>
|
||||
/// <param name="DataEnd"></param>
|
||||
/// <param name="IdxMacchina"></param>
|
||||
/// <param name="IdxODL"></param>
|
||||
/// <param name="KeyRichiesta"></param>
|
||||
/// <param name="CodArticolo"></param>
|
||||
/// <returns></returns>
|
||||
public int StatDdbGetCount(DateTime DataStart, DateTime DataEnd, string IdxMacchina, int IdxODL, string KeyRichiesta, string CodArticolo)
|
||||
{
|
||||
var dbResult = dbCtx
|
||||
.DbSetDdbTurni
|
||||
.Where(x => (x.IdxMacchina == IdxMacchina || IdxMacchina == "*") && (x.IdxOdl == IdxODL || IdxODL == -999) && (x.KeyRichiesta == KeyRichiesta || KeyRichiesta == "*") && (x.CodArticolo == CodArticolo || CodArticolo == "*") && (x.InizioPeriodo >= DataStart && x.InizioPeriodo <= DataEnd))
|
||||
.Count();
|
||||
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco tabella ODL da filtro
|
||||
/// </summary>
|
||||
|
||||
@@ -91,6 +91,14 @@ namespace MP.Stats.Data
|
||||
}
|
||||
}
|
||||
|
||||
private DistributedCacheEntryOptions cacheOptLong
|
||||
{
|
||||
get
|
||||
{
|
||||
return new DistributedCacheEntryOptions().SetAbsoluteExpiration(DateTime.Now.AddMinutes(chAbsExp * 10)).SetSlidingExpiration(TimeSpan.FromMinutes(chSliExp));
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Private Properties
|
||||
|
||||
#region Protected Methods
|
||||
@@ -101,6 +109,12 @@ namespace MP.Stats.Data
|
||||
return answ;
|
||||
}
|
||||
|
||||
protected string getCacheKeyPaged(string TableName, SelectData CurrFilter)
|
||||
{
|
||||
string answ = $"{TableName}:M_{CurrFilter.IdxMacchina}:A_{CurrFilter.CodArticolo}:K_{CurrFilter.KeyRichiesta}:O_{CurrFilter.IdxOdl}:D_{CurrFilter.DateStart:yyMMddHHmm}_{CurrFilter.DateEnd:yyMMddHHmm}:R_{CurrFilter.FirstRecord}_{CurrFilter.FirstRecord + CurrFilter.NumRecord}";
|
||||
return answ;
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Public Methods
|
||||
@@ -212,7 +226,7 @@ namespace MP.Stats.Data
|
||||
{
|
||||
//return Task.FromResult(dbController.StatDdbGetAll(numRecord, searchVal).ToArray());
|
||||
List<MP.Data.DatabaseModels.DdbTurni> dbResult = new List<MP.Data.DatabaseModels.DdbTurni>();
|
||||
string cacheKey = getCacheKey("MP:STATS:DDBT", CurrFilter);
|
||||
string cacheKey = getCacheKeyPaged("MP:STATS:DDBT", CurrFilter);
|
||||
string rawData;
|
||||
var redisDataList = await distributedCache.GetAsync(cacheKey);
|
||||
if (redisDataList != null)
|
||||
@@ -224,7 +238,7 @@ namespace MP.Stats.Data
|
||||
{
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
dbResult = dbController.StatDdbGetAll(CurrFilter.DateStart, CurrFilter.DateEnd, CurrFilter.IdxMacchina, CurrFilter.IdxOdl, CurrFilter.KeyRichiesta, CurrFilter.CodArticolo);
|
||||
dbResult = dbController.StatDdbGetAll(CurrFilter.DateStart, CurrFilter.DateEnd, CurrFilter.IdxMacchina, CurrFilter.IdxOdl, CurrFilter.KeyRichiesta, CurrFilter.CodArticolo, CurrFilter.FirstRecord, CurrFilter.NumRecord);
|
||||
rawData = JsonConvert.SerializeObject(dbResult);
|
||||
redisDataList = Encoding.UTF8.GetBytes(rawData);
|
||||
await distributedCache.SetAsync(cacheKey, redisDataList, cacheOpt);
|
||||
@@ -235,6 +249,32 @@ namespace MP.Stats.Data
|
||||
return await Task.FromResult(dbResult);
|
||||
}
|
||||
|
||||
public async Task<int> StatDdbGetCount(SelectData CurrFilter, string searchVal = "")
|
||||
{
|
||||
int numRec = 0;
|
||||
string cacheKey = getCacheKeyPaged("MP:STATS:DDBT-COUNT", CurrFilter);
|
||||
string rawData;
|
||||
var redisDataList = await distributedCache.GetAsync(cacheKey);
|
||||
if (redisDataList != null)
|
||||
{
|
||||
rawData = Encoding.UTF8.GetString(redisDataList);
|
||||
int.TryParse(rawData, out numRec);
|
||||
}
|
||||
else
|
||||
{
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
numRec = dbController.StatDdbGetCount(CurrFilter.DateStart, CurrFilter.DateEnd, CurrFilter.IdxMacchina, CurrFilter.IdxOdl, CurrFilter.KeyRichiesta, CurrFilter.CodArticolo);
|
||||
rawData = $"{numRec}";
|
||||
redisDataList = Encoding.UTF8.GetBytes(rawData);
|
||||
await distributedCache.SetAsync(cacheKey, redisDataList, cacheOptLong);
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Info($"Effettuata lettura da DB + caching per DdbTurni: {ts.TotalMilliseconds} ms");
|
||||
}
|
||||
return await Task.FromResult(numRec);
|
||||
}
|
||||
|
||||
public async Task<List<MP.Data.DatabaseModels.ODL>> StatOdlGetAll(SelectData CurrFilter, string searchVal = "")
|
||||
{
|
||||
//return Task.FromResult(dbController.StatOdlGetAll(numRecord, searchVal));
|
||||
|
||||
@@ -12,10 +12,38 @@ namespace MP.Stats.Data
|
||||
public string CodArticolo { get; set; } = "*";
|
||||
public DateTime DateEnd { get; set; } = DateTime.Now.AddMinutes(1);
|
||||
public DateTime DateStart { get; set; } = DateTime.Now.AddDays(-7);
|
||||
|
||||
/// <summary>
|
||||
/// Primo record x selezione paginata, tipicamente primo della "decina" della pagina corrente
|
||||
/// </summary>
|
||||
public int FirstRecord
|
||||
{
|
||||
get
|
||||
{
|
||||
int primaPag = PageNum % 10;
|
||||
int decina = PageNum - primaPag;
|
||||
return PageSize * decina + 1;
|
||||
}
|
||||
}
|
||||
|
||||
public string IdxMacchina { get; set; } = "*";
|
||||
public int IdxOdl { get; set; } = -999;
|
||||
public string KeyRichiesta { get; set; } = "*";
|
||||
|
||||
/// <summary>
|
||||
/// Numero record da recuperare, tipicamente la decina della pag corrente (10 * PageSize)
|
||||
/// </summary>
|
||||
public int NumRecord
|
||||
{
|
||||
get
|
||||
{
|
||||
return PageSize * 10;
|
||||
}
|
||||
}
|
||||
|
||||
public int PageNum { get; set; } = 1;
|
||||
public int PageSize { get; set; } = 10;
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
#region Public Methods
|
||||
@@ -44,6 +72,10 @@ namespace MP.Stats.Data
|
||||
if (!(obj is SelectData item))
|
||||
return false;
|
||||
|
||||
if (PageSize != item.PageSize)
|
||||
return false;
|
||||
if (PageNum != item.PageNum)
|
||||
return false;
|
||||
if (CodArticolo != item.CodArticolo)
|
||||
return false;
|
||||
if (DateEnd != item.DateEnd)
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<RootNamespace>MP.Stats</RootNamespace>
|
||||
<UserSecretsId>826e877c-ba70-4253-84cb-d0b1cafd4440</UserSecretsId>
|
||||
<Version>1.0.2106.1716</Version>
|
||||
<Version>1.0.2106.1914</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -34,9 +34,31 @@ namespace MP.Stats.Pages
|
||||
}
|
||||
}
|
||||
|
||||
private int currPage { get; set; } = 1;
|
||||
private int currPage
|
||||
{
|
||||
get
|
||||
{
|
||||
return currFilter.PageNum;
|
||||
}
|
||||
set
|
||||
{
|
||||
currFilter.PageNum = value;
|
||||
}
|
||||
}
|
||||
|
||||
private bool isLoading { get; set; } = false;
|
||||
private int numRecord { get; set; } = 10;
|
||||
|
||||
private int numRecord
|
||||
{
|
||||
get
|
||||
{
|
||||
return currFilter.PageSize;
|
||||
}
|
||||
set
|
||||
{
|
||||
currFilter.PageSize = value;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Private Properties
|
||||
|
||||
@@ -54,18 +76,7 @@ namespace MP.Stats.Pages
|
||||
[Inject]
|
||||
protected MpStatsService StatService { get; set; }
|
||||
|
||||
protected int totalCount
|
||||
{
|
||||
get
|
||||
{
|
||||
int answ = 0;
|
||||
if (SearchRecords != null)
|
||||
{
|
||||
answ = SearchRecords.Count;
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
protected int totalCount { get; set; } = 0;
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
@@ -74,8 +85,10 @@ namespace MP.Stats.Pages
|
||||
private async Task reloadData()
|
||||
{
|
||||
isLoading = true;
|
||||
totalCount = await StatService.StatDdbGetCount(currFilter, MessageService.SearchVal);
|
||||
SearchRecords = await StatService.StatDdbGetAll(currFilter, MessageService.SearchVal);
|
||||
ListRecords = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList();
|
||||
// faccio paginazione SOLO NELLA DECINA attuale... (quindi non tutte le pagine ma solo subset)
|
||||
ListRecords = SearchRecords.Skip(numRecord * (currPage % 10 - 1)).Take(numRecord).ToList();
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<body>
|
||||
<i>Modulo statistiche MAPO</i>
|
||||
<h4>Versione: 1.0.2106.1716</h4>
|
||||
<h4>Versione: 1.0.2106.1914</h4>
|
||||
<br />
|
||||
Note di rilascio:
|
||||
<ul>
|
||||
|
||||
@@ -1 +1 @@
|
||||
1.0.2106.1716
|
||||
1.0.2106.1914
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<item>
|
||||
<version>1.0.2106.1716</version>
|
||||
<version>1.0.2106.1914</version>
|
||||
<url>http://nexus.steamware.net/repository/SWS/MP-STATS/stable/0/MP.Stats.zip</url>
|
||||
<changelog>http://nexus.steamware.net/repository/SWS/MP-STATS/stable/0/ChangeLog.html</changelog>
|
||||
<mandatory>false</mandatory>
|
||||
|
||||
Reference in New Issue
Block a user