f9d6f4846d
- NON necessario (serve a MAG) - inserita classe, NON da errore in download
71 lines
2.3 KiB
C#
71 lines
2.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Net;
|
|
using System.Net.Http;
|
|
using System.Web.Http;
|
|
using static NKC_WF.WebUserControls.cmp_OOIL_drawings;
|
|
using SteamWare;
|
|
using SteamWare.Reports;
|
|
using System.Web;
|
|
using System.IO;
|
|
using Newtonsoft.Json;
|
|
|
|
namespace NKC_WF.Controllers
|
|
{
|
|
public class ReportConfController : ApiController
|
|
{
|
|
/// <summary>
|
|
/// Restituisce un array JSon x le conf dei report
|
|
/// GET: api/PrintQueueConf
|
|
/// </summary>
|
|
/// <returns>lista oggetto Json in formato SteamwareSDK.queueConf</returns>
|
|
public List<reportConf> Get()
|
|
{
|
|
List<reportConf> answ = reportConfJson;
|
|
// se vuoto... creo!
|
|
if (answ.Count == 0)
|
|
{
|
|
reportConf currConf = new reportConf()
|
|
{
|
|
name = "none",
|
|
template = "none.rdlc"
|
|
};
|
|
answ.Add(currConf);
|
|
}
|
|
return answ;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Restituisce un array JSon x le conf dei report/template di stampa leggendo dal file
|
|
/// </summary>
|
|
/// <returns>lista oggetto Json in formato SteamwareSDK.templateConf</returns>
|
|
protected List<reportConf> reportConfJson
|
|
{
|
|
get
|
|
{
|
|
List<reportConf> answ = new List<reportConf>();
|
|
string dirPath = HttpContext.Current.Server.MapPath("~/Reports/");
|
|
string nomeFile = "reportConf.json";
|
|
bool fileExist = fileMover.obj.fileExist(dirPath, nomeFile);
|
|
if (fileExist)
|
|
{
|
|
string rawData = File.ReadAllText($"{dirPath}\\{nomeFile}");
|
|
if (!string.IsNullOrEmpty(rawData))
|
|
{
|
|
try
|
|
{
|
|
answ = JsonConvert.DeserializeObject<List<reportConf>>(rawData);
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
SteamWare.Logger.Logging.Instance.Error(exc, "Eccezione in decodifica file conf reportConfJson");
|
|
}
|
|
}
|
|
}
|
|
return answ;
|
|
}
|
|
}
|
|
}
|
|
}
|