Merge branch 'release/AddCacheOnSheetLoadState01'

This commit is contained in:
Samuele Locatelli
2023-10-27 17:12:01 +02:00
4 changed files with 91 additions and 8 deletions
+68 -5
View File
@@ -872,9 +872,14 @@ namespace AppData
}
else
{
// 2023.10.27 passaggio versione cached
#if false
// recupero sheet corrente da Bunk...
DataLayer DLMan = new DataLayer();
tabSheets = DLMan.taSHL.getByMLStatus(BatchID, 5, 5, machine);
#endif
tabSheets = SheetTabGet(machine, BatchID, 5, 5);
// salvo in redis
setCurrSheetTab(machine, tabSheets);
}
@@ -1726,14 +1731,17 @@ namespace AppData
memLayer.ML.redFlushKey(redCurrBunkTabKey(machine));
}
/// <summary>
/// resetto curr sheets
/// </summary>
/// <param name="machine"></param>
public static void resetCurrSheet(string machine = "WRK001")
{
// svuoto"
// svuoto sheet speciali
memLayer.ML.redFlushKey(redCurrSheetTabKey(machine));
// svuoto tutti i fogli in cache x LOAD page
memLayer.ML.redFlushKey(redCurrSheetTabKey(machine, -1, 0, 0));
}
/// <summary>
@@ -3085,7 +3093,7 @@ namespace AppData
}
/// <summary>
/// Recupero da redis tab fogli correnti
/// Recupero da redis tab fogli correnti (5:5)
/// </summary>
protected static DS_App.SheetListDataTable getCurrSheetTab(string machine)
{
@@ -3104,6 +3112,36 @@ namespace AppData
return answ;
}
/// <summary>
/// Recupero dati sheet da Redis/DB
/// </summary>
public static DS_App.SheetListDataTable SheetTabGet(string Machine, int BatchId, int StMin, int StMax)
{
DS_App.SheetListDataTable answ = null;
string redKey = redCurrSheetTabKey(Machine, BatchId, StMin, StMax);
string rawData = memLayer.ML.getRSV(redKey);
if (!string.IsNullOrEmpty(rawData))
{
try
{
// deserializzo...
answ = JsonConvert.DeserializeObject<DS_App.SheetListDataTable>(rawData);
}
catch
{ }
}
else
{
// leggo DB
DataLayer DLMan = new DataLayer();
answ = DLMan.taSHL.getByMLStatus(BatchId, StMin, StMax, Machine);
rawData = JsonConvert.SerializeObject(answ);
// salvo in cache x 30 sec
memLayer.ML.setRSV(redKey, rawData, 30);
}
return answ;
}
/// <summary>
/// Chiave BATCH corrente su redis
/// </summary>
@@ -3198,6 +3236,27 @@ namespace AppData
}
return answ;
}
/// <summary>
/// Chiave sheets correnti su redis
/// </summary>
/// <param name="Machine"></param>
/// <param name="BatchId">BatchId, se fosse <= 0 --> chiave parent utile x reset</param>
/// <param name="StMin"></param>
/// <param name="StMax"></param>
/// <returns></returns>
protected static string redCurrSheetTabKey(string Machine, int BatchId, int StMin, int StMax)
{
string answ = "";
if (BatchId > 0)
{
answ = $"{redProdReq}:SheetByMBS:{Machine}:{BatchId}:{StMin}:{StMax}";
}
else
{
answ = $"{redProdReq}:SheetByMBS:{Machine}";
}
return answ;
}
/// <summary>
/// Chiave primo bunk su redis
@@ -3227,7 +3286,7 @@ namespace AppData
protected static void setCurrSheetTab(string machine, DS_App.SheetListDataTable tabella)
{
string rawData = JsonConvert.SerializeObject(tabella);
// TTL 5 sec
// TTL 2 sec
memLayer.ML.setRSV(redCurrSheetTabKey(machine), rawData, 2);
}
@@ -3252,7 +3311,7 @@ namespace AppData
}
/// <summary>
/// Recupera SHEET da batch e sstati permessi...
/// Recupera PRIMO SHEET da batch e stati permessi...
/// </summary>
/// <param name="BatchID"></param>
/// <param name="minVal"></param>
@@ -3266,8 +3325,12 @@ namespace AppData
{
try
{
// 2023.10.27 passaggio versione cached
#if false
DataLayer DLMan = new DataLayer();
var tabSheet = DLMan.taSHL.getByMLStatus(BatchID, minVal, maxVal, machine);
var tabSheet = DLMan.taSHL.getByMLStatus(BatchID, minVal, maxVal, machine);
#endif
var tabSheet = SheetTabGet(machine, BatchID, minVal, maxVal);
if (tabSheet.Count > 0)
{
answ = tabSheet[0].SheetID;
+11 -2
View File
@@ -80,11 +80,20 @@
</ItemTemplate>
</asp:FormView>
<asp:ObjectDataSource ID="ods" runat="server" OldValuesParameterFormatString="original_{0}" SelectMethod="getByMLStatus" TypeName="AppData.DS_AppTableAdapters.SheetListTableAdapter">
<asp:ObjectDataSource ID="ods" runat="server" SelectMethod="SheetTabGet" TypeName="AppData.ComLib">
<SelectParameters>
<asp:ControlParameter ControlID="hfBatchID" DefaultValue="0" Name="BatchId" PropertyName="Value" Type="Int32" />
<asp:ControlParameter ControlID="hfStatus" DefaultValue="-1" Name="StMin" PropertyName="Value" Type="Int32" />
<asp:ControlParameter ControlID="hfStatusEnd" DefaultValue="-1" Name="StMax" PropertyName="Value" Type="Int32" />
<asp:ControlParameter ControlID="hfMachine" DefaultValue="" Name="Machine" PropertyName="Value" Type="String" />
</SelectParameters>
</asp:ObjectDataSource>
<%--<asp:ObjectDataSource ID="ods" runat="server" OldValuesParameterFormatString="original_{0}" SelectMethod="getByMLStatus" TypeName="AppData.DS_AppTableAdapters.SheetListTableAdapter">
<SelectParameters>
<asp:ControlParameter ControlID="hfBatchID" DefaultValue="0" Name="BatchID" PropertyName="Value" Type="Int32" />
<asp:ControlParameter ControlID="hfStatus" DefaultValue="-1" Name="ShStatusStart" PropertyName="Value" Type="Int32" />
<asp:ControlParameter ControlID="hfStatusEnd" DefaultValue="-1" Name="ShStatusEnd" PropertyName="Value" Type="Int32" />
<asp:ControlParameter ControlID="hfMachine" DefaultValue="" Name="Machine" PropertyName="Value" Type="String" />
</SelectParameters>
</asp:ObjectDataSource>
</asp:ObjectDataSource>--%>
@@ -66,9 +66,15 @@ namespace NKC_WF.WebUserControls
{
if (BatchID > 0)
{
// 2023.10.27 passaggio versione cached
// FORSE 5/5?!?
#if false
DataLayer DLMan = new DataLayer();
var sheetList = DLMan.taSHL.getByMLStatus(BatchID, 3, 5, MachineSel);
#endif
var sheetList = ComLib.SheetTabGet(MachineSel, BatchID, 3, 5);
if (sheetList.Count > 0)
{
SheetID = sheetList[0].SheetID;
@@ -856,9 +856,14 @@ namespace NKC_WF.WebUserControls
{
if (BatchId > 0)
{
// 2023.10.27 passaggio versione cached
// FORSE 5/5?!?
#if false
DataLayer DLMan = new DataLayer();
var sheetList = DLMan.taSHL.getByMLStatus(BatchId, 3, 5, PlaceCodFix);
var sheetList = DLMan.taSHL.getByMLStatus(BatchId, 3, 5, PlaceCodFix);
#endif
var sheetList = ComLib.SheetTabGet(PlaceCodFix, BatchId, 3, 5);
if (sheetList.Count > 0)
{
SheetID = sheetList[0].SheetID;