166 lines
4.3 KiB
C#
166 lines
4.3 KiB
C#
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";
|
|
|
|
/// <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 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)
|
|
{
|
|
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
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// carica i dati richiesti dal report dalla StoredProcedure (filtrando quindi...)
|
|
/// </summary>
|
|
/// <param name="tipoReport"></param>
|
|
/// <param name="keyParam">cod UDC</param>
|
|
/// <returns>tabella dati</returns>
|
|
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;
|
|
}
|
|
}
|
|
}
|