From 86c4f577c853b9f278bebb00bfa00d3afed9dc28 Mon Sep 17 00:00:00 2001 From: "Samuele E. Locatelli" Date: Mon, 17 Aug 2020 16:49:22 +0200 Subject: [PATCH] Qualche ottimizzazione + FIX x stampa --- Jenkinsfile | 2 +- LPA/MainForm.cs | 100 +++++++++++++++++++++++++++++++----------------- 2 files changed, 66 insertions(+), 36 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 84e496b..7a1ea7d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -7,7 +7,7 @@ pipeline { steps { /* calcolo numero versione... diverso x branch MASTER/DEVELOP */ script { - withEnv(['NEXT_BUILD_NUMBER=86']) { + withEnv(['NEXT_BUILD_NUMBER=87']) { // env.versionNumber = VersionNumber(versionNumberString : '1.1.${BUILD_DATE_FORMATTED, "yyMM"}.${BUILDS_ALL_TIME}', projectStartDate : '2019-01-01', skipFailedBuilds: true) env.versionNumber = VersionNumber(versionNumberString : '1.1.${BUILD_DATE_FORMATTED, "yyMM"}.${BUILDS_ALL_TIME}', projectStartDate : '2019-01-01', skipFailedBuilds: true, overrideBuildsAllTime: '${NEXT_BUILD_NUMBER}') env.APP_NAME = 'LPA' diff --git a/LPA/MainForm.cs b/LPA/MainForm.cs index 50bfeb7..de7e594 100644 --- a/LPA/MainForm.cs +++ b/LPA/MainForm.cs @@ -76,7 +76,7 @@ namespace LPA /// /// Variabile appoggio semaforo divieto print x evitare accodamenti... 15 sec da last check... /// - protected DateTime vetoPrint; + protected static DateTime vetoPrint; /// /// Modalità demo/test printing locale /// @@ -132,7 +132,7 @@ namespace LPA /// private void checkShowTray() { - if(memLayer.ML.CRB("startOnTray")) + if (memLayer.ML.CRB("startOnTray")) { WindowState = FormWindowState.Minimized; @@ -878,7 +878,8 @@ namespace LPA { // verifico ed aggiorno quantità coda int numTot = 0; - string urlApiQueue = $"{serverBaseAddr}/api/PrintQueueLen"; + string urlApiQueue = $"{serverBaseAddr}/api/PrintQueue"; + string urlApiQueueLen = $"{serverBaseAddr}/api/PrintQueueLen"; // verifico il modo di controllo code: SE è signle --> chiamo metodo con le SOLE code gestite... if (!string.IsNullOrEmpty(memLayer.ML.CRS("queueCheckMode"))) { @@ -895,10 +896,10 @@ namespace LPA // aggiungo "|" finale; listManQueue += "|"; } - urlApiQueue = $"{serverBaseAddr}/api/PrintQueueLen?queueList={listManQueue}"; + urlApiQueueLen = $"{serverBaseAddr}/api/PrintQueueLen?queueList={listManQueue}"; } } - string rawData = callUrl(urlApiQueue); + string rawData = callUrl(urlApiQueueLen); if (!string.IsNullOrEmpty(rawData)) { try @@ -911,7 +912,7 @@ namespace LPA // se ho stampe in coda --> verifico code gestite foreach (var coda in queueSetupConf) { - string urlSingleQueue = $"{serverBaseAddr}/api/PrintQueue/{coda.Key}"; + string urlSingleQueue = $"{urlApiQueue}/{coda.Key}"; rawData = callUrl(urlSingleQueue); if (!string.IsNullOrEmpty(rawData)) { @@ -928,35 +929,8 @@ namespace LPA DateTime adesso = DateTime.Now; if (vetoPrint < adesso) { - vetoPrint = adesso.AddSeconds(300); - foreach (var item in report2print) - { - reportPrinter rPrint = new reportPrinter(); - bool fatto = false; - bool fattoPdf = false; - // se ho almeno 1 stampa --> lancio! - queueConf confCoda = listQueue.Find(conf => conf.name == coda.Key); - if (confCoda != null) - { - fatto = rPrint.printReport(confCoda.template, localReportPath, coda.Value.Printer, item.rdsData, confCoda.deviceInfoParam, true); - } - // fatta stampa aggiorno server con indicazione ceh ho stampato - if (fatto) - { - coda.Value.NumWaiting--; - coda.Value.NumDone++; - // compongo payload... - printTask printResult = new printTask() - { - ticketNum = item.ticketNum, - newStatus = 1, - message = "" - }; - string payload = JsonConvert.SerializeObject(printResult); - // chiamo in put print result! - postUrl(urlApiQueue, payload); - } - } + vetoPrint = adesso.AddSeconds(20); + printSingleQueue(urlApiQueue, coda, report2print); vetoPrint = adesso; } } @@ -972,6 +946,62 @@ namespace LPA } } + + + + + + + /// + /// Effettua la stampa di una singola coda... + /// + /// + /// + /// + private void printSingleQueue(string urlApiQueue, KeyValuePair coda, List report2print) + { + // metodi thread da rivedere... ma si "Pestano i piedi" in scarico + ////Task.Run(() => Method1()).Wait(); + ////t.Wait(); + /// + //List tasks = new List(); + //Task t = Task.Run(() => printSingleQueue(urlApiQueue, coda, report2print)); + //tasks.Add(t); + //Task.WaitAll(tasks.ToArray()); + + + // oggetto x stampa report... + reportPrinter rPrint = new reportPrinter(); + // array dei task di stampa... + List tasks = new List(); + foreach (var item in report2print) + { + bool fatto = false; + // se ho almeno 1 stampa --> lancio! + queueConf confCoda = listQueue.Find(conf => conf.name == coda.Key); + if (confCoda != null) + { + fatto = rPrint.printReport(confCoda.template, localReportPath, coda.Value.Printer, item.rdsData, confCoda.deviceInfoParam, true); + } + // fatta stampa aggiorno server con indicazione che ho stampato + if (fatto) + { + coda.Value.NumWaiting--; + coda.Value.NumDone++; + // compongo payload... + printTask printResult = new printTask() + { + ticketNum = item.ticketNum, + newStatus = 1, + message = "" + }; + string payload = JsonConvert.SerializeObject(printResult); + // chiamo in put print result! + postUrl(urlApiQueue, payload); + } + } + } + #endregion private void MainForm_FormClosing(object sender, FormClosingEventArgs e)