diff --git a/AppData/ComLib.cs b/AppData/ComLib.cs index 7f24a1e..fd83ae9 100644 --- a/AppData/ComLib.cs +++ b/AppData/ComLib.cs @@ -533,7 +533,7 @@ namespace AppData currOrder = new Order() { OrderId = rigaOrd.OrdID, - OrderCod = rigaOrd.OrdCodOrig, + OrderCod = rigaOrd.FamilyCode, OrderExtCode = rigaOrd.OrderExtCode, DestPlant = rigaOrd.DestPlant, KitList = listKit diff --git a/AppData/DS_Report.Designer.cs b/AppData/DS_Report.Designer.cs index 8a6e758..f7ddef2 100644 --- a/AppData/DS_Report.Designer.cs +++ b/AppData/DS_Report.Designer.cs @@ -2258,7 +2258,7 @@ SELECT IdxPrintJob, TipoReport, KeyParam, prtName, dtStart, dtEnd, stato, dtLast [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] private void InitCommandCollection() { - this._commandCollection = new global::System.Data.SqlClient.SqlCommand[7]; + this._commandCollection = new global::System.Data.SqlClient.SqlCommand[9]; this._commandCollection[0] = new global::System.Data.SqlClient.SqlCommand(); this._commandCollection[0].Connection = this.Connection; this._commandCollection[0].CommandText = "SELECT IdxPrintJob, TipoReport, KeyParam, prtName, dtStart, dtEnd, stato, dtLastT" + @@ -2272,36 +2272,48 @@ SELECT IdxPrintJob, TipoReport, KeyParam, prtName, dtStart, dtEnd, stato, dtLast this._commandCollection[1].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@dtLastTryMax", global::System.Data.SqlDbType.DateTime, 8, global::System.Data.ParameterDirection.Input, 23, 3, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); this._commandCollection[2] = new global::System.Data.SqlClient.SqlCommand(); this._commandCollection[2].Connection = this.Connection; - this._commandCollection[2].CommandText = "dbo.stp_PJQ_getFirtsByUdc"; + this._commandCollection[2].CommandText = "dbo.stp_PJQ_getByQueue"; this._commandCollection[2].CommandType = global::System.Data.CommandType.StoredProcedure; this._commandCollection[2].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@RETURN_VALUE", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.ReturnValue, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); - this._commandCollection[2].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@keyParam", global::System.Data.SqlDbType.VarChar, 50, global::System.Data.ParameterDirection.Input, 0, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._commandCollection[2].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@queue", global::System.Data.SqlDbType.VarChar, 50, global::System.Data.ParameterDirection.Input, 0, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); this._commandCollection[3] = new global::System.Data.SqlClient.SqlCommand(); this._commandCollection[3].Connection = this.Connection; - this._commandCollection[3].CommandText = "dbo.stp_PJQ_getNext"; + this._commandCollection[3].CommandText = "dbo.stp_PJQ_getByQueueAll"; this._commandCollection[3].CommandType = global::System.Data.CommandType.StoredProcedure; this._commandCollection[3].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@RETURN_VALUE", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.ReturnValue, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._commandCollection[3].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@queue", global::System.Data.SqlDbType.VarChar, 50, global::System.Data.ParameterDirection.Input, 0, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); this._commandCollection[4] = new global::System.Data.SqlClient.SqlCommand(); this._commandCollection[4].Connection = this.Connection; - this._commandCollection[4].CommandText = "dbo.stp_PJQ_insert"; + this._commandCollection[4].CommandText = "dbo.stp_PJQ_getFirtsByUdc"; this._commandCollection[4].CommandType = global::System.Data.CommandType.StoredProcedure; this._commandCollection[4].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@RETURN_VALUE", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.ReturnValue, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); - this._commandCollection[4].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@TipoReport", global::System.Data.SqlDbType.VarChar, 250, global::System.Data.ParameterDirection.Input, 0, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); this._commandCollection[4].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@keyParam", global::System.Data.SqlDbType.VarChar, 50, global::System.Data.ParameterDirection.Input, 0, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); - this._commandCollection[4].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@prtName", global::System.Data.SqlDbType.VarChar, 500, global::System.Data.ParameterDirection.Input, 0, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); this._commandCollection[5] = new global::System.Data.SqlClient.SqlCommand(); this._commandCollection[5].Connection = this.Connection; - this._commandCollection[5].CommandText = "dbo.stp_PJQ_updateLastTry"; + this._commandCollection[5].CommandText = "dbo.stp_PJQ_getNext"; this._commandCollection[5].CommandType = global::System.Data.CommandType.StoredProcedure; this._commandCollection[5].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@RETURN_VALUE", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.ReturnValue, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); - this._commandCollection[5].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@keyParam", global::System.Data.SqlDbType.VarChar, 50, global::System.Data.ParameterDirection.Input, 0, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); this._commandCollection[6] = new global::System.Data.SqlClient.SqlCommand(); this._commandCollection[6].Connection = this.Connection; - this._commandCollection[6].CommandText = "dbo.stp_PJQ_updateStato"; + this._commandCollection[6].CommandText = "dbo.stp_PJQ_insert"; this._commandCollection[6].CommandType = global::System.Data.CommandType.StoredProcedure; this._commandCollection[6].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@RETURN_VALUE", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.ReturnValue, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); - this._commandCollection[6].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@IdxPrintJob", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.Input, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); - this._commandCollection[6].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@stato", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.Input, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._commandCollection[6].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@TipoReport", global::System.Data.SqlDbType.VarChar, 250, global::System.Data.ParameterDirection.Input, 0, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._commandCollection[6].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@keyParam", global::System.Data.SqlDbType.VarChar, 50, global::System.Data.ParameterDirection.Input, 0, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._commandCollection[6].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@prtName", global::System.Data.SqlDbType.VarChar, 500, global::System.Data.ParameterDirection.Input, 0, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._commandCollection[7] = new global::System.Data.SqlClient.SqlCommand(); + this._commandCollection[7].Connection = this.Connection; + this._commandCollection[7].CommandText = "dbo.stp_PJQ_updateLastTry"; + this._commandCollection[7].CommandType = global::System.Data.CommandType.StoredProcedure; + this._commandCollection[7].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@RETURN_VALUE", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.ReturnValue, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._commandCollection[7].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@keyParam", global::System.Data.SqlDbType.VarChar, 50, global::System.Data.ParameterDirection.Input, 0, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._commandCollection[8] = new global::System.Data.SqlClient.SqlCommand(); + this._commandCollection[8].Connection = this.Connection; + this._commandCollection[8].CommandText = "dbo.stp_PJQ_updateStato"; + this._commandCollection[8].CommandType = global::System.Data.CommandType.StoredProcedure; + this._commandCollection[8].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@RETURN_VALUE", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.ReturnValue, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._commandCollection[8].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@IdxPrintJob", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.Input, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._commandCollection[8].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@stato", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.Input, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] @@ -2332,8 +2344,42 @@ SELECT IdxPrintJob, TipoReport, KeyParam, prtName, dtStart, dtEnd, stato, dtLast [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] [global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")] [global::System.ComponentModel.DataObjectMethodAttribute(global::System.ComponentModel.DataObjectMethodType.Select, false)] - public virtual DS_Report.PrintJobQueueDataTable getFirstByParam(string keyParam) { + public virtual DS_Report.PrintJobQueueDataTable getByQueue(string queue) { this.Adapter.SelectCommand = this.CommandCollection[2]; + if ((queue == null)) { + this.Adapter.SelectCommand.Parameters[1].Value = global::System.DBNull.Value; + } + else { + this.Adapter.SelectCommand.Parameters[1].Value = ((string)(queue)); + } + DS_Report.PrintJobQueueDataTable dataTable = new DS_Report.PrintJobQueueDataTable(); + this.Adapter.Fill(dataTable); + return dataTable; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] + [global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")] + [global::System.ComponentModel.DataObjectMethodAttribute(global::System.ComponentModel.DataObjectMethodType.Select, false)] + public virtual DS_Report.PrintJobQueueDataTable getByQueueAll(string queue) { + this.Adapter.SelectCommand = this.CommandCollection[3]; + if ((queue == null)) { + this.Adapter.SelectCommand.Parameters[1].Value = global::System.DBNull.Value; + } + else { + this.Adapter.SelectCommand.Parameters[1].Value = ((string)(queue)); + } + DS_Report.PrintJobQueueDataTable dataTable = new DS_Report.PrintJobQueueDataTable(); + this.Adapter.Fill(dataTable); + return dataTable; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] + [global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")] + [global::System.ComponentModel.DataObjectMethodAttribute(global::System.ComponentModel.DataObjectMethodType.Select, false)] + public virtual DS_Report.PrintJobQueueDataTable getFirstByParam(string keyParam) { + this.Adapter.SelectCommand = this.CommandCollection[4]; if ((keyParam == null)) { this.Adapter.SelectCommand.Parameters[1].Value = global::System.DBNull.Value; } @@ -2350,7 +2396,7 @@ SELECT IdxPrintJob, TipoReport, KeyParam, prtName, dtStart, dtEnd, stato, dtLast [global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")] [global::System.ComponentModel.DataObjectMethodAttribute(global::System.ComponentModel.DataObjectMethodType.Select, false)] public virtual DS_Report.PrintJobQueueDataTable getNext() { - this.Adapter.SelectCommand = this.CommandCollection[3]; + this.Adapter.SelectCommand = this.CommandCollection[5]; DS_Report.PrintJobQueueDataTable dataTable = new DS_Report.PrintJobQueueDataTable(); this.Adapter.Fill(dataTable); return dataTable; @@ -2643,7 +2689,7 @@ SELECT IdxPrintJob, TipoReport, KeyParam, prtName, dtStart, dtEnd, stato, dtLast [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] [global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")] public virtual int insertQuery(string TipoReport, string keyParam, string prtName) { - global::System.Data.SqlClient.SqlCommand command = this.CommandCollection[4]; + global::System.Data.SqlClient.SqlCommand command = this.CommandCollection[6]; if ((TipoReport == null)) { command.Parameters[1].Value = global::System.DBNull.Value; } @@ -2683,7 +2729,7 @@ SELECT IdxPrintJob, TipoReport, KeyParam, prtName, dtStart, dtEnd, stato, dtLast [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] [global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")] public virtual int updateLastTry(string keyParam) { - global::System.Data.SqlClient.SqlCommand command = this.CommandCollection[5]; + global::System.Data.SqlClient.SqlCommand command = this.CommandCollection[7]; if ((keyParam == null)) { command.Parameters[1].Value = global::System.DBNull.Value; } @@ -2711,7 +2757,7 @@ SELECT IdxPrintJob, TipoReport, KeyParam, prtName, dtStart, dtEnd, stato, dtLast [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] [global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")] public virtual int updateStato(global::System.Nullable IdxPrintJob, global::System.Nullable stato) { - global::System.Data.SqlClient.SqlCommand command = this.CommandCollection[6]; + global::System.Data.SqlClient.SqlCommand command = this.CommandCollection[8]; if ((IdxPrintJob.HasValue == true)) { command.Parameters[1].Value = ((int)(IdxPrintJob.Value)); } diff --git a/AppData/DS_Report.xsd b/AppData/DS_Report.xsd index 0acc929..e4dabd3 100644 --- a/AppData/DS_Report.xsd +++ b/AppData/DS_Report.xsd @@ -126,6 +126,28 @@ SELECT IdxPrintJob, TipoReport, KeyParam, prtName, dtStart, dtEnd, stato, dtLast + + + + dbo.stp_PJQ_getByQueue + + + + + + + + + + + dbo.stp_PJQ_getByQueueAll + + + + + + + @@ -262,7 +284,7 @@ SELECT codPostazione, stampante, note FROM ElencoPostazioni WHERE (codPostazione - + @@ -290,7 +312,7 @@ SELECT codPostazione, stampante, note FROM ElencoPostazioni WHERE (codPostazione - + @@ -322,7 +344,7 @@ SELECT codPostazione, stampante, note FROM ElencoPostazioni WHERE (codPostazione - + diff --git a/NKC_WF/Controllers/PrintController.cs b/NKC_WF/Controllers/PrintController.cs deleted file mode 100644 index 25c0305..0000000 --- a/NKC_WF/Controllers/PrintController.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net; -using System.Net.Http; -using System.Web.Http; -using Newtonsoft.Json; -using SteamWare; -using System.IO; -using System.Web; - -namespace NKC_WF.Controllers -{ - public class PrintController : ApiController - { - // GET: api/Print - public IEnumerable Get() - { - return new string[] { "value1", "value2" }; - } - - // GET: api/Print/5 - public string Get(string id) - { - return $"requested id is {id}"; - } - -#if false - // POST: api/Print - public void Post([FromBody]string value) - { - } - - // PUT: api/Print/5 - public void Put(int id, [FromBody]string value) - { - } - - // DELETE: api/Print/5 - public void Delete(int id) - { - } -#endif - - } -} diff --git a/NKC_WF/Controllers/PrintQueueController.cs b/NKC_WF/Controllers/PrintQueueController.cs new file mode 100644 index 0000000..f508c21 --- /dev/null +++ b/NKC_WF/Controllers/PrintQueueController.cs @@ -0,0 +1,165 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Web.Http; +using Newtonsoft.Json; +using SteamWare; +using System.IO; +using System.Web; +using AppData; +using System.Data; +using NKC_SDK; + +namespace NKC_WF.Controllers +{ + public class PrintQueueController : ApiController + { + + public static string redQueueCount = "NKC:SERV:PJQ"; + + /// + /// Restituisce numero jobs aperti (stato = 0...), se 0 = NESSUNO + /// GET: api/PrintQueue + /// + /// + public int Get() + { + // restituisco... + int answ = 0; + string redVal = memLayer.ML.getRSV(redQueueCount); + // cerco in redis se ci sia chiave.. + if (!string.IsNullOrEmpty(redVal)) + { + // recupero + int.TryParse(redVal, out answ); + } + else + { + // recupero da db + DS_Report.PrintJobQueueDataTable nextJob = DataLayer.man.taPJQ.getNext(); + // salvo + answ = nextJob.Count; + memLayer.ML.setRSV(redQueueCount, answ.ToString(), 30); + } + return answ; + } + + /// + /// Elenco dei jobs aperti per la coda indicata + /// GET: api/PrintQueue/queue_01 + /// + /// + /// + public List Get(string id) + { + List answ = new List(); + // recupero da DB... + DS_Report.PrintJobQueueDataTable tabPJQ = DataLayer.man.taPJQ.getByQueue(id); + if (tabPJQ.Count > 0) + { + reportData currReport = new reportData(); + DataTable currTab; + // ciclo! + foreach (var pjReq in tabPJQ) + { + currTab = caricaDati(reportByTipo(pjReq.TipoReport), pjReq.KeyParam); + // in base alla coda --> recupero i dati + currReport = new reportData() + { + ticketNum = pjReq.IdxPrintJob.ToString(), + rdsTable = currTab + }; + answ.Add(currReport); + } + } + // compongo risposta... + return answ; + } + +#if false + // POST: api/PrintQueue + public void Post([FromBody]string value) + { + } + + // PUT: api/PrintQueue/5 + public void Put(int id, [FromBody]string value) + { + } + + // DELETE: api/PrintQueue/5 + public void Delete(int id) + { + } +#endif + + + + /// + /// carica i dati richiesti dal report dalla StoredProcedure (filtrando quindi...) + /// + /// + /// cod UDC + /// tabella dati + private DataTable caricaDati(reportRichiesto tipoReport, string keyParam) + { + int intIdx = 0; + DataTable tab = new DataTable(); + switch (tipoReport) + { + case reportRichiesto.cartLabel: + // int.TryParse(keyParam, out intIdx); + // tab = (DataTable)DataLayer.man.taRepStack.GetData(intIdx); + break; + case reportRichiesto.paintLabelPre: + // int.TryParse(keyParam, out intIdx); + // tab = (DataTable)DataLayer.man.taRepStack.GetData(intIdx); + break; + case reportRichiesto.paintLabelPost: + // int.TryParse(keyParam, out intIdx); + // tab = (DataTable)DataLayer.man.taRepStack.GetData(intIdx); + break; + case reportRichiesto.partLabel: + int.TryParse(keyParam, out intIdx); + tab = (DataTable)DataLayer.man.taIL.getByKey(intIdx); + break; + case reportRichiesto.stackLabel: + int.TryParse(keyParam, out intIdx); + tab = (DataTable)DataLayer.man.taRepStack.GetData(intIdx); + break; + default: + break; + } + return tab; + } + + + protected reportRichiesto reportByTipo(string tipo) + { + reportRichiesto report = reportRichiesto.stackLabel; + switch (tipo) + { + case "DocPaint": + report = reportRichiesto.paintLabelPre; + break; + case "DocPaintPost": + report = reportRichiesto.paintLabelPost; + break; + case "DocCart": + report = reportRichiesto.cartLabel; + break; + case "DocPart": + report = reportRichiesto.partLabel; + break; + case "DocStack": + report = reportRichiesto.stackLabel; + break; + default: + break; + } + return report; + } + } +} diff --git a/NKC_WF/NKC_WF.csproj b/NKC_WF/NKC_WF.csproj index 3987756..a5cdb09 100644 --- a/NKC_WF/NKC_WF.csproj +++ b/NKC_WF/NKC_WF.csproj @@ -476,7 +476,7 @@ - + @@ -513,7 +513,7 @@ VersGen.cs - + diff --git a/NKC_WF/Reports/queueConf.json b/NKC_WF/Reports/queueConf.json index 8d6fb7e..4f2b17c 100644 --- a/NKC_WF/Reports/queueConf.json +++ b/NKC_WF/Reports/queueConf.json @@ -46,5 +46,21 @@ "xmlParam": "EMF8.5in11in0.5in0.5in0.5in0.5in" }, "rdsName": "stp_prt_CartLabel" + }, + { + "name": "queuePart", + "template": "PartLabel.rdlc", + "printerName": "Microsoft Print to PDF", + "deviceInfoParam": { + "OutputFormat": "EMF", + "PageHeight": "11in", + "PageWidth": "8.5in", + "MarginLeft": "0.5in", + "MarginRight": "0.5in", + "MarginTop": "0.5in", + "MarginBottom": "0.5in", + "xmlParam": "EMF8.5in11in0.5in0.5in0.5in0.5in" + }, + "rdsName": "stp_prt_PartLabel" } ] \ No newline at end of file