98 lines
2.9 KiB
C#
98 lines
2.9 KiB
C#
using AppData;
|
|
using Newtonsoft.Json;
|
|
using NKC_SDK;
|
|
using SteamWare;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
|
|
namespace NKC_WF.WebUserControls
|
|
{
|
|
public partial class cmp_orderStatus : System.Web.UI.UserControl
|
|
{
|
|
public orderStatus statoBatch = new orderStatus();
|
|
/// <summary>
|
|
/// Hash redis per il canale di comunicazione dei batch eseguiti/in esecuzione
|
|
/// </summary>
|
|
protected string batchInChannel = "NKC:IN:batchReq";
|
|
/// <summary>
|
|
/// Wrapper traduzione termini
|
|
/// </summary>
|
|
/// <param name="lemma"></param>
|
|
/// <returns></returns>
|
|
public string traduci(string lemma)
|
|
{
|
|
return SteamWare.user_std.UtSn.Traduci(lemma);
|
|
}
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
updateStatus();
|
|
}
|
|
/// <summary>
|
|
/// ID del batch corrente
|
|
/// </summary>
|
|
protected int currBatchID
|
|
{
|
|
get
|
|
{
|
|
int answ = 0;
|
|
if (memLayer.ML.isInSessionObject("BatchID"))
|
|
{
|
|
answ = memLayer.ML.IntSessionObj("BatchID");
|
|
}
|
|
return answ;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// Aggiorna visualizzazione status processo
|
|
/// </summary>
|
|
private void updateStatus()
|
|
{
|
|
// se trova batch non riportati in REDIS li scrive x richiedere processing
|
|
string batchKey = $"{batchInChannel}:{currBatchID}";
|
|
// per prima cosa recupero da REDIS lo stato...
|
|
bool statusPresent = !string.IsNullOrEmpty(memLayer.ML.getRSV(batchKey));
|
|
if (statusPresent)
|
|
{
|
|
string payload = memLayer.ML.getRSV(batchKey);
|
|
if (!string.IsNullOrEmpty(payload))
|
|
{
|
|
try
|
|
{
|
|
statoBatch = JsonConvert.DeserializeObject<orderStatus>(payload);
|
|
}
|
|
catch
|
|
{ }
|
|
// aggiorno componente...
|
|
lblStatusCode.Text = statoBatch.ProcessStatus.ToString();
|
|
lblProcNotes.Text = statoBatch.ProcessNotes;
|
|
lblNestingRuntime.Text = statoBatch.ProcessingRuntime.ToString();
|
|
lblWrktimeEst.Text = (statoBatch.EstimatedWorktime / 60).ToString();
|
|
// secondo status mostro barra...
|
|
divProgress.Visible = (statoBatch.ProcessStatus > procStatus.waiting && statoBatch.ProcessStatus < procStatus.error);
|
|
divButtons.Visible = (statoBatch.ProcessStatus > procStatus.error && statoBatch.ProcessStatus < procStatus.accepted);
|
|
}
|
|
}
|
|
TimerUpdateStatus.Enabled = statusPresent;
|
|
|
|
}
|
|
|
|
protected void TimerUpdateStatus_Tick(object sender, EventArgs e)
|
|
{
|
|
updateStatus();
|
|
}
|
|
|
|
protected void lbtConfirm_Click(object sender, EventArgs e)
|
|
{
|
|
// accettazione ordine: scrivo su DB e QUINDI su redis indico accepted
|
|
}
|
|
|
|
protected void lbtCancel_Click(object sender, EventArgs e)
|
|
{
|
|
// rifiuto ordine: ELIMINO su DB e QUINDI su redis indico refused
|
|
}
|
|
}
|
|
} |