Bozza update x gestione rispsote da REDIS

This commit is contained in:
Samuele E. Locatelli
2019-10-21 19:28:02 +02:00
parent c75363d4e0
commit 17cf09243d
5 changed files with 149 additions and 57 deletions
+138 -17
View File
@@ -1,4 +1,5 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using SteamWare;
using System;
using System.Collections.Generic;
@@ -25,13 +26,30 @@ namespace AppData
protected static string redOutPath = "NKC:SERV:BREQ";
protected static string redMsgCount = "NKC:SERV:BREQ:MCount";
protected static string redMsgList = "NKC:SERV:BREQ:MList";
protected static string redMLCurrStack = "NKC:SERV:TAKT:CurrStack";
protected static string redNestAnsw = "NKC:NEST:BANSW";
#endregion
#region definizione classi impiegate con PROD
/// <summary>
/// Tipologia di macchina
/// </summary>
public enum mType
{
Multiax = 0,
Offline
}
/// <summary>
/// TIpologia di ordine
/// </summary>
public enum oType
{
BatchRequest = 0,
OfflineOrder
}
/// <summary>
/// Stati degli oggetti TAKT e Stack
@@ -401,19 +419,6 @@ namespace AppData
public int Qty { get; set; }
}
/// <summary>
/// Classe gestione richeiste di processing per il NESTING
/// </summary>
public class Ordine
{
public string OrdCod { get; set; }
public string DestPlant { get; set; }
public string DataMatrix { get; set; }
public string ExtCode { get; set; }
public string Model { get; set; }
public int Qty { get; set; }
public List<Parte> Items { get; set; }
}
public class Batch
{
/// <summary>
@@ -429,9 +434,15 @@ namespace AppData
/// </summary>
public int procType { get; set; }
/// <summary>
/// Elenco degli ordini
/// Codice della amcchina x cui si effettua richeista
/// </summary>
public List<Ordine> Orders { get; set; }
[JsonConverter(typeof(StringEnumConverter))]
public mType machineType { get; set; }
/// <summary>
/// Tipo di ordine richeisto
/// </summary>
[JsonConverter(typeof(StringEnumConverter))]
public oType orderType { get; set; }
}
/// <summary>
/// Salva su redis l'oggetto dei materiali serializzato
@@ -468,6 +479,15 @@ namespace AppData
// ritorno
return answ;
}
/// <summary>
/// Restituisce elenco KVP delle buste ancora "pending" (quando processate le elimina da elenco...)
/// </summary>
/// <returns></returns>
public static KeyValuePair<string, string>[] getEnvList()
{
KeyValuePair<string, string>[] answ = memLayer.ML.redGetHash(redMsgList);
return answ;
}
/// <summary>
/// Invia una richiesta di esecuzione di Nesting x un Batch
@@ -517,7 +537,9 @@ namespace AppData
{
BatchId = BatchID,
maxTime = mTime,
procType = pType
procType = pType,
machineType = mType.Multiax,
orderType = oType.BatchRequest
};
// serializzo
redVal = JsonConvert.SerializeObject(currBatch);
@@ -538,6 +560,105 @@ namespace AppData
return answ;
}
/// <summary>
/// Invia una richiesta di esecuzione di CAM x un ordine offline
/// </summary>
/// <param name="OffOrderID">OfflineOrder di cui si chiede processing</param>
/// <param name="note">note opzionali</param>
/// <returns></returns>
public static bool sendOfflineOrderReq(int OffOrderID, string note)
{
bool answ = false;
// per prima cosa mi serve una "nuova busta" per inviare i messaggi
string nextEnv = getNextEnv(OffOrderID, note);
// preparo il contenuto della busta ed invio i messaggi...
try
{
int mTime = 5;
int pType = 1;
// serializzo ordini come ARRAY VUOTO
string redVal = "[]";
// salvo
string redKey = $"{redOutPath}:{nextEnv}:ORDERS";
// scrivo su REDIS
memLayer.ML.setRSV(redKey, redVal);
// ora ITEMS
var tblItm = DataLayer.man.taIL.getByOfflineOrder(OffOrderID);
// serializzo
redVal = JsonConvert.SerializeObject(tblItm);
// salvo
redKey = $"{redOutPath}:{nextEnv}:ITEMS";
// scrivo su REDIS
memLayer.ML.setRSV(redKey, redVal);
// ora versione gerarchica
var currBatch = new Batch()
{
BatchId = OffOrderID,
maxTime = mTime,
procType = pType,
machineType = mType.Offline,
orderType = oType.OfflineOrder
};
// serializzo
redVal = JsonConvert.SerializeObject(currBatch);
// salvo
redKey = $"{redOutPath}:{nextEnv}:DATA";
// scrivo su REDIS
memLayer.ML.setRSV(redKey, redVal);
// invio notifica che c'è una busta da processare
redKey = $"{redOutPath}:CURR";
// scrivo su REDIS
memLayer.ML.setRSV(redKey, nextEnv);
answ = true;
}
catch (Exception exc)
{
logger.lg.scriviLog($"Eccezione in sendOfflineOrderReq:{Environment.NewLine}{exc}");
}
// restituisco ok
return answ;
}
/// <summary>
/// Verifica lo stato di una richiesta di esecuzione
/// </summary>
/// <param name="OffOrderID">OfflineOrder di cui si chiede processing</param>
/// <param name="note">note opzionali</param>
/// <returns></returns>
public static bool checkOfflineOrderReq(int OffOrderID)
{
bool answ = false;
string typeSearch = "OffOrdCalculation";
string keyEnv = "";
// recupero lista dei vari task APERTI...
KeyValuePair<string, string>[] comAperte = getEnvList();
// processo x cercare ordine...
foreach (var item in comAperte)
{
// cerco dove sia quello richiesto
if (item.Value.Contains(typeSearch))
{
// controllo SE sia quello richiesto
if (item.Value == $"{OffOrderID}|{typeSearch}")
{
keyEnv = item.Key;
break;
}
}
}
// controllo e se c'è risposta --> update DB
string rawAnsw = memLayer.ML.getRSV($"{redNestAnsw}:FULL:{keyEnv}");
if (rawAnsw != "")
{
// cerco risposta coem stack --> disegno...
answ = true;
}
// restituisco ok
return answ;
}
#endregion
#region metodi helper di conversione
-25
View File
@@ -1,25 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<svg xmlns="http://www.w3.org/2000/svg">
<path id="Sheet" d="M 10,710 L 1010,710 L 1010,10 L 10,10 L 10,710" fill="none" stroke="rgb(0,0,0)" stroke-width="1" />
<path id="IT000001" d="M 100,610 L 70,410 L 160,250 L 340,230 L 470,410 L 360,570 L 230,670 L 100,610" fill="none" stroke="rgb(255,0,0)" stroke-width="1" />
<text id="Name1" x="120" y="500" font-size="50" fill="rgb(255,0,0)">IT000002</text>
<path id="_13" d="M 220,310 A 10,10 0 0,0 200,310 A 10,10 0 0,0 220,310" fill="nonzero" stroke="rgb(255,0,0)" stroke-width="1" />
<path id="_14" d="M 320,310 A 10,10 0 0,0 300,310 A 10,10 0 0,0 320,310" fill="nonzero" stroke="rgb(255,0,0)" stroke-width="1" />
<path id="_15" d="M 220,410 A 10,10 0 0,0 200,410 A 10,10 0 0,0 220,410" fill="nonzero" stroke="rgb(255,0,0)" stroke-width="1" />
<path id="_16" d="M 320,410 A 10,10 0 0,0 300,410 A 10,10 0 0,0 320,410" fill="nonzero" stroke="rgb(255,0,0)" stroke-width="1" />
<path id="IT000002" d="M 420,660 L 550,420 A 213.678,213.678 0 0,1 920,410 L 860,530 A 271.523,271.523 0 0,1 610,680 L 420,660" fill="none" stroke="rgb(0,255,0)" stroke-width="1" />
<text id="Name2" x="590" y="530" font-size="50" fill="rgb(0,255,0)">IT000002</text>
<path id="_19" d="M 610,410 A 15,15 0 0,1 610,380 L 860,380 A 15,15 0 0,1 860,410 L 610,410" fill="nonzero" stroke="rgb(0,255,0)" stroke-width="1" />
<path id="IT000003" d="M 160,80 L 910,60 L 920,320 L 710,280 L 540,340 L 380,210 L 20,250 L 160,80" />
<text id="Name3" x="520" y="190" font-size="50" fill="rgb(0,0,255)">IT000003</text>
<path id="_20" d="M 800,110 A 10,10 0 0,0 780,110 A 10,10 0 0,0 800,110" fill="nonzero" stroke="rgb(0,0,255)" stroke-width="1" />
<path id="_21" d="M 900,110 A 10,10 0 0,0 880,110 A 10,10 0 0,0 900,110" fill="nonzero" stroke="rgb(0,0,255)" stroke-width="1" />
<path id="_22" d="M 800,210 A 10,10 0 0,0 780,210 A 10,10 0 0,0 800,210" fill="nonzero" stroke="rgb(0,0,255)" stroke-width="1" />
<path id="_23" d="M 900,210 A 10,10 0 0,0 880,210 A 10,10 0 0,0 900,210" fill="nonzero" stroke="rgb(0,0,255)" stroke-width="1" />
<path id="_24" d="M 470,110 A 15,15 0 0,1 470,80 L 720,80 A 15,15 0 0,1 720,110 L 470,110" fill="nonzero" stroke="rgb(0,0,255)" stroke-width="1" />
<path id="_25" d="M 470,260 A 15,15 0 0,1 470,230 L 720,230 A 15,15 0 0,1 720,260 L 470,260" fill="nonzero" stroke="rgb(0,0,255)" stroke-width="1" />
<path id="_26" d="M 180,200 A 10,10 0 0,0 160,200 A 10,10 0 0,0 180,200" fill="nonzero" stroke="rgb(0,0,255)" stroke-width="1" />
<path id="_27" d="M 280,200 A 10,10 0 0,0 260,200 A 10,10 0 0,0 280,200" fill="nonzero" stroke="rgb(0,0,255)" stroke-width="1" />
<path id="_28" d="M 180,100 A 10,10 0 0,0 160,100 A 10,10 0 0,0 180,100" fill="nonzero" stroke="rgb(0,0,255)" stroke-width="1" />
<path id="_29" d="M 280,100 A 10,10 0 0,0 260,100 A 10,10 0 0,0 280,100" fill="nonzero" stroke="rgb(0,0,255)" stroke-width="1" />
</svg>

Before

Width:  |  Height:  |  Size: 2.9 KiB

-1
View File
@@ -208,7 +208,6 @@
</Content>
<Content Include="DevUtils.aspx" />
<Content Include="Images\MT0006110.jpg" />
<Content Include="Images\test - Copia %282%29.svg" />
<Content Include="Images\test_b.svg" />
<Content Include="Images\test.svg" />
<Content Include="Images\Test11.svg" />
@@ -82,7 +82,7 @@ namespace NKC_WF.WebUserControls
protected void lbtSendEstim_Click(object sender, EventArgs e)
{
// invia a redis a a richiesta...
// invia a redis una richiesta...
ComLib.sendMaterials();
ComLib.sendBatchReq(BatchId, "Estimation");
@@ -54,19 +54,16 @@ namespace NKC_WF.WebUserControls
protected void lbtMakeCnc_Click(object sender, EventArgs e)
{
bool allOk = true;
/* ************************************************
* cerco su redis la richiesta corrente:
* - se NON C'E' ricreo richiesta
* - se c'è senza risposta --> non faccio nulla
* - se c'è e ho risposta --> update DB (status + file)
* *************************************************/
// !!!FIXME!!! mandare su redis richiesta CREAZIONE CNC
// ...x ora registro richiesta di CNC COME GIA' FATTA
//DataLayer.man.taOffOL.
// invio tramite redis...
try
{
// ...inizio dai materiali
ComLib.sendMaterials();
// invio VERA richeista come OFFLINE ORDER...
allOk = ComLib.sendOfflineOrderReq(OffOrdId, "OffOrdCalculation");
}
catch (Exception exc)
{ }
if (allOk)
{