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 { /// /// Restituisce un array JSon x le conf dei report /// GET: api/PrintQueueConf /// /// lista oggetto Json in formato SteamwareSDK.queueConf public List Get() { List answ = reportConfJson; // se vuoto... creo! if (answ.Count == 0) { reportConf currConf = new reportConf() { name = "none", template = "none.rdlc" }; answ.Add(currConf); } return answ; } /// /// Restituisce un array JSon x le conf dei report/template di stampa leggendo dal file /// /// lista oggetto Json in formato SteamwareSDK.templateConf protected List reportConfJson { get { List answ = new List(); 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>(rawData); } catch (Exception exc) { SteamWare.Logger.Logging.Instance.Error(exc, "Eccezione in decodifica file conf reportConfJson"); } } } return answ; } } } }