110 lines
2.7 KiB
C#
110 lines
2.7 KiB
C#
using AppData;
|
|
using Newtonsoft.Json;
|
|
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
|
|
{
|
|
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)
|
|
{
|
|
processPending();
|
|
checkVisibility();
|
|
}
|
|
cmp_batchList.eh_doRefresh += Cmp_batchList_eh_doRefresh;
|
|
}
|
|
|
|
private void Cmp_batchList_eh_doRefresh(object sender, EventArgs e)
|
|
{
|
|
checkVisibility();
|
|
}
|
|
|
|
private void processPending()
|
|
{
|
|
// 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;
|
|
if (currBatchID > 0)
|
|
{
|
|
hasBatch = true;
|
|
}
|
|
divStatus.Visible = hasBatch;
|
|
}
|
|
}
|
|
} |