Avanzamento x OrderStatus
This commit is contained in:
+25
-16
@@ -10,35 +10,33 @@ namespace AppData
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Classe che rappresenta la richiesta di AZIONI al NESTING
|
||||
/// </summary>
|
||||
public struct commRequest
|
||||
public struct commandRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// ID del processo richiesto (generato in fase di import)
|
||||
/// </summary>
|
||||
public string BatchID { get; set; }
|
||||
public int BatchID { get; set; }
|
||||
/// <summary>
|
||||
/// Richiesta per il nesting: DoNesting / HaltNesting
|
||||
/// </summary>
|
||||
public string ActionRequested { get; set; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Classe che rappresenta la richiesta di processing di NESTING da inserire in REDIS
|
||||
/// </summary>
|
||||
public struct batchRequest
|
||||
/// <summary>
|
||||
/// Classe che rappresenta la richiesta di processing di NESTING da inserire in REDIS
|
||||
/// </summary>
|
||||
public struct batchRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// ID del processo richiesto (generato in fase di import)
|
||||
/// </summary>
|
||||
public string BatchID { get; set; }
|
||||
public int BatchID { get; set; }
|
||||
/// <summary>
|
||||
/// Elenco ordini richeisti da processare / nestare
|
||||
/// </summary>
|
||||
public Order Orders { get; set; }
|
||||
public List<Order> Orders { get; set; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Struttura Ordine passata a NESTING
|
||||
@@ -74,7 +72,7 @@ namespace AppData
|
||||
/// <summary>
|
||||
/// Cod ITEM di NKC
|
||||
/// </summary>
|
||||
public string ItemId { get; set; }
|
||||
public int ItemId { get; set; }
|
||||
/// <summary>
|
||||
/// Codice ITEM esterno da cliente (HFA)
|
||||
/// </summary>
|
||||
@@ -93,10 +91,10 @@ namespace AppData
|
||||
public string CadFilePath { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Classe che rappresenta stato ordine ricevutovia REDIS da NESTING
|
||||
/// </summary>
|
||||
public struct orderStatus
|
||||
/// <summary>
|
||||
/// Classe che rappresenta stato ordine ricevutovia REDIS da NESTING
|
||||
/// </summary>
|
||||
public class orderStatus
|
||||
{
|
||||
/// <summary>
|
||||
/// ID del processo di Nesting in corso (generato in fase di import)
|
||||
@@ -105,7 +103,7 @@ namespace AppData
|
||||
/// <summary>
|
||||
/// Status del procesos di nesting
|
||||
/// </summary>
|
||||
public string ProcessStatus { get; set; }
|
||||
public procStatus ProcessStatus { get; set; }
|
||||
/// <summary>
|
||||
/// Note libere del nesting
|
||||
/// </summary>
|
||||
@@ -119,4 +117,15 @@ namespace AppData
|
||||
/// </summary>
|
||||
public double EstimatedWorktime { get; set; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Enum degli stati ammessi epr il Nesting
|
||||
/// </summary>
|
||||
public enum procStatus
|
||||
{
|
||||
waiting = 0,
|
||||
running,
|
||||
completed,
|
||||
aborted,
|
||||
error
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using SteamWare;
|
||||
using AppData;
|
||||
using Newtonsoft.Json;
|
||||
using SteamWare;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -10,9 +12,22 @@ namespace NKC_WF
|
||||
{
|
||||
public partial class OrderManager : System.Web.UI.Page
|
||||
{
|
||||
/// <summary>
|
||||
/// Hash redis per il canale di comunicazione dei comandi
|
||||
/// </summary>
|
||||
protected string batchCmdChannel = "NKC:CMD:batchReq";
|
||||
/// <summary>
|
||||
/// Hash redis per il canale di comunicazione dei batch da eseguire
|
||||
/// </summary>
|
||||
protected string batchOutChannel = "NKC:OUT:batchReq";
|
||||
/// <summary>
|
||||
/// Hash redis per il canale di comunicazione dei batch eseguiti/in esecuzione
|
||||
/// </summary>
|
||||
protected string batchInChannel = "NKC:IN:batchReq";
|
||||
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if(!Page.IsPostBack)
|
||||
if (!Page.IsPostBack)
|
||||
{
|
||||
processPending();
|
||||
checkVisibility();
|
||||
@@ -21,20 +36,69 @@ namespace NKC_WF
|
||||
|
||||
private void processPending()
|
||||
{
|
||||
// se trova batch no riportati in REDIS li scrive x richiedere processing
|
||||
// se trova batch non riportati in REDIS li scrive x richiedere processing
|
||||
string batchKey = $"{batchOutChannel}:{currBatchID}";
|
||||
bool reqPresent = !string.IsNullOrEmpty(memLayer.ML.getRSV(batchKey));
|
||||
if (!reqPresent)
|
||||
{
|
||||
// !!!FIXME!!! leggere da DB!!!
|
||||
|
||||
var articoli = new List<Item>();
|
||||
var articolo = new Item()
|
||||
{
|
||||
ItemId = 1,
|
||||
ItemExtCode = "abc.2345",
|
||||
MatID = 2,
|
||||
ItemrQty = 2,
|
||||
CadFilePath = @"c:\temp\prova.dxf"
|
||||
};
|
||||
articoli.Add(articolo);
|
||||
|
||||
var ordini = new List<Order>();
|
||||
Order ordine = new Order()
|
||||
{
|
||||
OrderCod = "abcde",
|
||||
OrderExtCode = "HFA_123456",
|
||||
DestPlant = "Striker",
|
||||
OrderQty = 1,
|
||||
Items = articoli
|
||||
};
|
||||
ordini.Add(ordine);
|
||||
|
||||
var currBatch = new batchRequest
|
||||
{
|
||||
BatchID = currBatchID,
|
||||
Orders = ordini
|
||||
}
|
||||
;
|
||||
string payload = JsonConvert.SerializeObject(currBatch);
|
||||
memLayer.ML.setRSV(batchKey, payload);
|
||||
}
|
||||
}
|
||||
/// <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;
|
||||
}
|
||||
}
|
||||
|
||||
private void checkVisibility()
|
||||
{
|
||||
bool hasBatch = false;
|
||||
bool isBatchCompleted = false;
|
||||
int BatchID = 0;
|
||||
if (memLayer.ML.isInSessionObject("BatchID"))
|
||||
if (currBatchID > 0)
|
||||
{
|
||||
hasBatch = true;
|
||||
BatchID = memLayer.ML.IntSessionObj("BatchID");
|
||||
}
|
||||
|
||||
// !!!FIXME!!! fare lettura
|
||||
// leggo da REDIS se è stato COMPLETATO il Batch...
|
||||
if (true)
|
||||
|
||||
@@ -1,17 +1,39 @@
|
||||
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="cmp_orderStatus.ascx.cs" Inherits="NKC_WF.WebUserControls.cmp_orderStatus" %>
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
Stiamo processando il batch <b><%: Session["BatchID"] %></b>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
Status + note
|
||||
</div>
|
||||
<div class="col-6">
|
||||
Nesting runtime (sec)
|
||||
</div>
|
||||
<div class="col-6">
|
||||
Working estimated time (sec)
|
||||
</div>
|
||||
</div>
|
||||
<asp:UpdatePanel ID="updPanelStatus" runat="server">
|
||||
<ContentTemplate>
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
Stiamo processando il batch <b><%: Session["BatchID"] %></b>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<h3>
|
||||
<asp:Label runat="server" ID="lblStatusCode" /></h3>
|
||||
<asp:Label runat="server" ID="lblProcNotes" />
|
||||
</div>
|
||||
<div class="col-12" runat="server" id="divProgress" visible="false">
|
||||
<div class="progress">
|
||||
<div class="progress-bar progress-bar-striped progress-bar-animated" role="progressbar" aria-valuenow="75" aria-valuemin="0" aria-valuemax="100" style="width: 75%"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<dl class="row">
|
||||
<dd class="col-sm-6"><%: traduci("NestingRuntime") %></dd>
|
||||
<dt class="col-sm-6 text-right">
|
||||
<asp:Label runat="server" ID="lblNestingRuntime" />
|
||||
(sec)</dt>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<dl class="row">
|
||||
<dd class="col-sm-6"><%: traduci("WorkingEstTime") %></dd>
|
||||
<dt class="col-sm-6 text-right">
|
||||
<asp:Label runat="server" ID="lblWrktimeEst" />
|
||||
(minutes)</dt>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
<asp:Timer ID="TimerUpdateStatus" runat="server" Enabled="false" Interval="500" OnTick="TimerUpdateStatus_Tick"></asp:Timer>
|
||||
</ContentTemplate>
|
||||
</asp:UpdatePanel>
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
using System;
|
||||
using AppData;
|
||||
using Newtonsoft.Json;
|
||||
using SteamWare;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
@@ -9,9 +12,75 @@ 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.completed);
|
||||
}
|
||||
}
|
||||
TimerUpdateStatus.Enabled = statusPresent;
|
||||
|
||||
}
|
||||
|
||||
protected void TimerUpdateStatus_Tick(object sender, EventArgs e)
|
||||
{
|
||||
updateStatus();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,5 +11,68 @@ namespace NKC_WF.WebUserControls {
|
||||
|
||||
|
||||
public partial class cmp_orderStatus {
|
||||
|
||||
/// <summary>
|
||||
/// Controllo updPanelStatus.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Campo generato automaticamente.
|
||||
/// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.UpdatePanel updPanelStatus;
|
||||
|
||||
/// <summary>
|
||||
/// Controllo lblStatusCode.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Campo generato automaticamente.
|
||||
/// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.Label lblStatusCode;
|
||||
|
||||
/// <summary>
|
||||
/// Controllo lblProcNotes.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Campo generato automaticamente.
|
||||
/// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.Label lblProcNotes;
|
||||
|
||||
/// <summary>
|
||||
/// Controllo divProgress.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Campo generato automaticamente.
|
||||
/// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.HtmlControls.HtmlGenericControl divProgress;
|
||||
|
||||
/// <summary>
|
||||
/// Controllo lblNestingRuntime.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Campo generato automaticamente.
|
||||
/// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.Label lblNestingRuntime;
|
||||
|
||||
/// <summary>
|
||||
/// Controllo lblWrktimeEst.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Campo generato automaticamente.
|
||||
/// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.Label lblWrktimeEst;
|
||||
|
||||
/// <summary>
|
||||
/// Controllo TimerUpdateStatus.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Campo generato automaticamente.
|
||||
/// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.Timer TimerUpdateStatus;
|
||||
}
|
||||
}
|
||||
|
||||
+25431
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user