Completata scrittura api REST x chiusura stampa

This commit is contained in:
Samuele E. Locatelli
2020-02-12 17:20:02 +01:00
parent 0d8db6418d
commit b5a01a632d
6 changed files with 164 additions and 92 deletions
+28 -12
View File
@@ -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[9];
this._commandCollection = new global::System.Data.SqlClient.SqlCommand[10];
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" +
@@ -2295,25 +2295,30 @@ SELECT IdxPrintJob, TipoReport, KeyParam, prtName, dtStart, dtEnd, stato, dtLast
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[6] = new global::System.Data.SqlClient.SqlCommand();
this._commandCollection[6].Connection = this.Connection;
this._commandCollection[6].CommandText = "dbo.stp_PJQ_insert";
this._commandCollection[6].CommandText = "dbo.stp_PJQ_getWaiting";
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("@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].CommandText = "dbo.stp_PJQ_insert";
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("@TipoReport", global::System.Data.SqlDbType.VarChar, 250, global::System.Data.ParameterDirection.Input, 0, 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[7].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[8] = new global::System.Data.SqlClient.SqlCommand();
this._commandCollection[8].Connection = this.Connection;
this._commandCollection[8].CommandText = "dbo.stp_PJQ_updateStato";
this._commandCollection[8].CommandText = "dbo.stp_PJQ_updateLastTry";
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, "", "", ""));
this._commandCollection[8].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[9] = new global::System.Data.SqlClient.SqlCommand();
this._commandCollection[9].Connection = this.Connection;
this._commandCollection[9].CommandText = "dbo.stp_PJQ_updateStato";
this._commandCollection[9].CommandType = global::System.Data.CommandType.StoredProcedure;
this._commandCollection[9].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[9].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[9].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()]
@@ -2402,6 +2407,17 @@ SELECT IdxPrintJob, TipoReport, KeyParam, prtName, dtStart, dtEnd, stato, dtLast
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 getWaiting() {
this.Adapter.SelectCommand = this.CommandCollection[6];
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")]
@@ -2689,7 +2705,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[6];
global::System.Data.SqlClient.SqlCommand command = this.CommandCollection[7];
if ((TipoReport == null)) {
command.Parameters[1].Value = global::System.DBNull.Value;
}
@@ -2729,7 +2745,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[7];
global::System.Data.SqlClient.SqlCommand command = this.CommandCollection[8];
if ((keyParam == null)) {
command.Parameters[1].Value = global::System.DBNull.Value;
}
@@ -2757,7 +2773,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<int> IdxPrintJob, global::System.Nullable<int> stato) {
global::System.Data.SqlClient.SqlCommand command = this.CommandCollection[8];
global::System.Data.SqlClient.SqlCommand command = this.CommandCollection[9];
if ((IdxPrintJob.HasValue == true)) {
command.Parameters[1].Value = ((int)(IdxPrintJob.Value));
}
+10
View File
@@ -169,6 +169,16 @@ SELECT IdxPrintJob, TipoReport, KeyParam, prtName, dtStart, dtEnd, stato, dtLast
</DbCommand>
</SelectCommand>
</DbSource>
<DbSource ConnectionRef="Sauder_NKCConnectionString (Settings)" DbObjectName="Sauder_NKC.dbo.stp_PJQ_getWaiting" DbObjectType="StoredProcedure" GenerateMethods="Get" GenerateShortCommands="true" GeneratorGetMethodName="getWaiting" GetMethodModifier="Public" GetMethodName="getWaiting" QueryType="Rowset" ScalarCallRetval="System.Object, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" UseOptimisticConcurrency="true" UserGetMethodName="getWaiting" UserSourceName="getWaiting">
<SelectCommand>
<DbCommand CommandType="StoredProcedure" ModifiedByUser="false">
<CommandText>dbo.stp_PJQ_getWaiting</CommandText>
<Parameters>
<Parameter AllowDbNull="true" AutogeneratedName="" DataSourceName="" DataTypeServer="int" DbType="Int32" Direction="ReturnValue" ParameterName="@RETURN_VALUE" Precision="10" ProviderType="Int" Scale="0" Size="4" SourceColumnNullMapping="false" SourceVersion="Current" />
</Parameters>
</DbCommand>
</SelectCommand>
</DbSource>
<DbSource ConnectionRef="Sauder_NKCConnectionString (Settings)" DbObjectName="Sauder_NKC.dbo.stp_PJQ_insert" DbObjectType="StoredProcedure" GenerateShortCommands="true" GeneratorSourceName="insertQuery" Modifier="Public" Name="insertQuery" QueryType="NoData" ScalarCallRetval="System.Object, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" UseOptimisticConcurrency="true" UserGetMethodName="GetDataBy1" UserSourceName="insertQuery">
<SelectCommand>
<DbCommand CommandType="StoredProcedure" ModifiedByUser="false">
Vendored
+1 -1
View File
@@ -11,7 +11,7 @@ pipeline {
steps {
/* calcolo numero versione... diverso x branch MASTER/DEVELOP */
script {
withEnv(['NEXT_BUILD_NUMBER=258']) {
withEnv(['NEXT_BUILD_NUMBER=259']) {
// env.versionNumber = VersionNumber(versionNumberString : '0.9.${BUILD_DATE_FORMATTED, "yyMM"}.${BUILDS_ALL_TIME}', projectStartDate : '2019-07-01', skipFailedBuilds: true)
env.versionNumber = VersionNumber(versionNumberString : '0.9.${BUILD_DATE_FORMATTED, "yyMM"}.${BUILDS_ALL_TIME}', projectStartDate : '2019-07-01', skipFailedBuilds: true, overrideBuildsAllTime: '${NEXT_BUILD_NUMBER}')
env.versionNumberBeta = VersionNumber(versionNumberString : '0.9.${BUILD_DATE_FORMATTED, "yyMM"}-beta.${BUILDS_ALL_TIME}', projectStartDate : '2019-07-01', skipFailedBuilds: true, overrideBuildsAllTime: '${NEXT_BUILD_NUMBER}')
+122 -76
View File
@@ -16,87 +16,29 @@ namespace NKC_WF.Controllers
{
public class PrintQueueController : ApiController
{
#region classi gestione PJQ
/// <summary>
/// chaive redis x cache conteggio coda PJQ
/// </summary>
public static string redQueueCount = "NKC:SERV:PJQ";
/// <summary>
/// Restituisce numero jobs aperti (stato = 0...), se 0 = NESSUNO
/// GET: api/PrintQueue
/// Conteggio elementi in attesa stsampa da DB
/// </summary>
/// <returns></returns>
public int Get()
protected int countWaitingDb
{
// restituisco...
int answ = 0;
string redVal = memLayer.ML.getRSV(redQueueCount);
// cerco in redis se ci sia chiave..
if (!string.IsNullOrEmpty(redVal))
get
{
// 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;
}
/// <summary>
/// Elenco dei jobs aperti per la coda indicata
/// GET: api/PrintQueue/queue_01
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public List<reportData> Get(string id)
{
List<reportData> answ = new List<reportData>();
// 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)
int answ = 0;
// resetto conteggio in redis...
DS_Report.PrintJobQueueDataTable nextJob = DataLayer.man.taPJQ.getWaiting();
if (nextJob != null)
{
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);
answ = nextJob.Count;
}
return answ;
}
// 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
/// <summary>
/// carica i dati richiesti dal report dalla StoredProcedure (filtrando quindi...)
/// </summary>
@@ -141,19 +83,19 @@ namespace NKC_WF.Controllers
reportRichiesto report = reportRichiesto.stackLabel;
switch (tipo)
{
case "DocPaint":
case "docPaint":
report = reportRichiesto.paintLabelPre;
break;
case "DocPaintPost":
case "docPaintPost":
report = reportRichiesto.paintLabelPost;
break;
case "DocCart":
case "docCart":
report = reportRichiesto.cartLabel;
break;
case "DocPart":
case "docPart":
report = reportRichiesto.partLabel;
break;
case "DocStack":
case "docStack":
report = reportRichiesto.stackLabel;
break;
default:
@@ -161,5 +103,109 @@ namespace NKC_WF.Controllers
}
return report;
}
#endregion
#region REST api call
/// <summary>
/// Restituisce numero jobs aperti (stato = 0...), se 0 = NESSUNO
/// GET: api/PrintQueue
/// </summary>
/// <returns></returns>
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 dbe e salvo
answ = countWaitingDb;
memLayer.ML.setRSV(redQueueCount, answ.ToString(), 30);
}
return answ;
}
/// <summary>
/// Elenco dei jobs aperti per la coda indicata
/// GET: api/PrintQueue/queue_01
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public List<reportData> Get(string id)
{
List<reportData> answ = new List<reportData>();
// 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;
}
/// <summary>
/// Processa una chiamata POST per l'invio in blocco del risultato dell'elaborazione
/// POST: api/PrintQueue
/// </summary>
/// <returns></returns>
[HttpPost]
public string Post()
{
string answ = "UNKN";
// questa classe è derivata da Controller.Response... x cui recupero lo stream in altro modo...
string content = "";
System.Web.HttpContext.Current.Request.InputStream.Position = 0;
using (var reader = new StreamReader(System.Web.HttpContext.Current.Request.InputStream, System.Text.Encoding.UTF8, true, 4096, true))
{
content = reader.ReadToEnd();
}
//Rest
System.Web.HttpContext.Current.Request.InputStream.Position = 0;
// procedo a deserializzare in blocco l'oggetto...
try
{
// deserializzo.
printTask printAnsw = JsonConvert.DeserializeObject<printTask>(content);
// verifico se mi abbia dato esito 1 --> aggiorno DB!
if (printAnsw != null)
{
int idxPJQ = 0;
int.TryParse(printAnsw.ticketNum, out idxPJQ);
DataLayer.man.taPJQ.updateStato(idxPJQ, printAnsw.newStatus);
// resetto conteggio in redis...
memLayer.ML.setRSV(redQueueCount, countWaitingDb.ToString(), 30);
answ = "OK";
}
}
catch
{ }
// restituisco esito!
return answ;
}
#endregion
}
}
+2 -2
View File
@@ -125,8 +125,8 @@
<Reference Include="StackExchange.Redis, Version=2.0.0.0, Culture=neutral, PublicKeyToken=c219ff1ca8c2ce46, processorArchitecture=MSIL">
<HintPath>..\packages\StackExchange.Redis.2.0.601\lib\net461\StackExchange.Redis.dll</HintPath>
</Reference>
<Reference Include="SteamWare, Version=3.5.2002.718, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\SteamWare.3.5.2002.718\lib\net462\SteamWare.dll</HintPath>
<Reference Include="SteamWare, Version=3.5.2002.719, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\SteamWare.3.5.2002.719\lib\net462\SteamWare.dll</HintPath>
</Reference>
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Buffers.4.5.0\lib\netstandard2.0\System.Buffers.dll</HintPath>
+1 -1
View File
@@ -56,7 +56,7 @@
<package id="SharpZipLib" version="1.2.0" targetFramework="net462" />
<package id="Snappy.NET" version="1.1.1.8" targetFramework="net462" />
<package id="StackExchange.Redis" version="2.0.601" targetFramework="net462" />
<package id="SteamWare" version="3.5.2002.718" targetFramework="net462" />
<package id="SteamWare" version="3.5.2002.719" targetFramework="net462" />
<package id="System.Buffers" version="4.5.0" targetFramework="net462" />
<package id="System.Diagnostics.PerformanceCounter" version="4.7.0" targetFramework="net462" />
<package id="System.IO.Pipelines" version="4.7.0" targetFramework="net462" />