243 lines
8.8 KiB
C#
243 lines
8.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using Consulenza.WebTemplateModeler;
|
|
using Consulenza.WebTemplateModeler.Entity;
|
|
using Newtonsoft.Json;
|
|
|
|
namespace Consulenza.Unica.Business
|
|
{
|
|
public class WebTemplateModelerService
|
|
{
|
|
private WebTemplateManager webTemplateManager = new WebTemplateManager();
|
|
|
|
public Template TestTemplate(Template template,string metodo) {
|
|
try
|
|
{
|
|
if (template.IdModello == -1)
|
|
{
|
|
template = JsonConvert.DeserializeObject<Template>(getlogTempalte(template.Nome));
|
|
}
|
|
else
|
|
{
|
|
string host = WebTemplateManager.GetIpHost();
|
|
string output = JsonConvert.SerializeObject(template);
|
|
insertLog(template.IdModello.ToString(), template.CodicePb, template.Id.ToString(), template.IsDefault, "TestTemplate(" + host + ") ", output, metodo);
|
|
}
|
|
}
|
|
catch { }
|
|
return template;
|
|
|
|
}
|
|
|
|
|
|
public List<Modello> GetModelli()
|
|
{
|
|
List<Modello> modelli = new List<Modello>();
|
|
try
|
|
{
|
|
modelli = webTemplateManager.GetModelli();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
modelli = new List<Modello>();
|
|
insertLog("", "", "", "", "GetModelli()", ex);
|
|
|
|
}
|
|
return modelli;
|
|
}
|
|
|
|
public Modello GetModello(int idModello)
|
|
{
|
|
Modello modello = new Modello();
|
|
try
|
|
{
|
|
modello = webTemplateManager.GetModello(idModello);
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
modello = new Modello();
|
|
insertLog(idModello.ToString(), "", "", "", "GetModello(...)", ex);
|
|
}
|
|
return modello;
|
|
}
|
|
|
|
public Modello GetModello(int idModello, string codicePb)
|
|
{
|
|
Modello modello = new Modello();
|
|
try
|
|
{
|
|
modello = webTemplateManager.GetModello(idModello, codicePb);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
modello = new Modello();
|
|
insertLog(idModello.ToString(), codicePb, "", "", "GetModello(......)", ex);
|
|
}
|
|
return modello;
|
|
}
|
|
|
|
public List<Vincolo> GetVincoliNoChiave(string codiceAgente, string codiceFiscale, string codiceMandato, string codiceRete, long proposta, string modello)
|
|
{
|
|
List<Vincolo> options = new List<Vincolo>();
|
|
try
|
|
{
|
|
options = webTemplateManager.GetVincoliNoChiave(codiceAgente, codiceFiscale, codiceMandato, codiceRete, proposta, modello);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
|
|
insertLog("", "", "", "", "getVincoliNoChiave(......)", ex);
|
|
}
|
|
return options;
|
|
}
|
|
|
|
public List<Vincolo> GetVincoli(long chiave,long proposta, string modello)
|
|
{
|
|
List<Vincolo> options = new List<Vincolo>();
|
|
try
|
|
{
|
|
options = webTemplateManager.GetVincoli(chiave,proposta, modello);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
|
|
insertLog("", "", "", "", "GetVincoli(......)", ex);
|
|
}
|
|
return options;
|
|
}
|
|
|
|
|
|
public List<Template> GetTemplates(int idModello, string codicePb)
|
|
{
|
|
List<Template> templates = new List<Template>();
|
|
try
|
|
{
|
|
templates = webTemplateManager.GetTemplates(idModello, codicePb);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
templates = new List<Template>();
|
|
insertLog(idModello.ToString(), codicePb, "", "", "GetTemplates(...)", ex);
|
|
}
|
|
return templates;
|
|
}
|
|
|
|
public Template GetTemplate(int idTemplate, string isDefault)
|
|
{
|
|
Template template = new Template();
|
|
try
|
|
{
|
|
template = webTemplateManager.GetTemplate(idTemplate, isDefault);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
template = new Template();
|
|
insertLog("", "", idTemplate.ToString(), isDefault, "GetTemplate(...)", ex);
|
|
}
|
|
return template;
|
|
|
|
}
|
|
|
|
public List<SchedaTemplate> GetSchedeTemplate(int idTemplate, string isDefault)
|
|
{
|
|
List<SchedaTemplate> schedaTemplate = new List<SchedaTemplate>();
|
|
try
|
|
{
|
|
schedaTemplate = webTemplateManager.GetSchedeTemplate(idTemplate, isDefault);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
schedaTemplate = new List<SchedaTemplate>();
|
|
insertLog("", "", idTemplate.ToString(), isDefault, "GetSchedeTemplate(...)", ex);
|
|
}
|
|
return schedaTemplate;
|
|
|
|
}
|
|
|
|
public int SetTemplate(int idModello, string codicePB, string nomeTemplate, List<Option> opzTemplate, List<SchedaTemplate> schede)
|
|
{
|
|
int idTemplate = -1;
|
|
try
|
|
{
|
|
idTemplate = webTemplateManager.SetTemplate(nomeTemplate, codicePB, idModello, opzTemplate, schede);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
idTemplate = -1;
|
|
insertLog(idModello.ToString(), codicePB, "", "", "SetTemplate(...)", ex);
|
|
}
|
|
return idTemplate;
|
|
}
|
|
|
|
public int DelTemplate(int idTemplate)
|
|
{
|
|
int err = -1;
|
|
try
|
|
{
|
|
err = webTemplateManager.DelTemplate(idTemplate);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
err = -1;
|
|
insertLog("", "", idTemplate.ToString(), "", "DelTemplate(...)", ex);
|
|
}
|
|
return err;
|
|
}
|
|
|
|
public void insertLog(string idModello, string codicePb, string idTemplate, string isDefault, string metodo, string message, List<DateTime> dateTime)
|
|
{
|
|
TimeSpan span1 = dateTime[3].Subtract(dateTime[0]);
|
|
TimeSpan span2 = dateTime[2].Subtract(dateTime[1]);
|
|
insertLog(
|
|
idModello,
|
|
codicePb,
|
|
idTemplate,
|
|
isDefault,
|
|
metodo,
|
|
message,
|
|
"tempo di elaborazione " + span1.Hours + ":" + span1.Minutes + ":" + span1.Seconds + " secondi di cui di chiamata a ReportManagerWS " + span2.Hours + ":" + span2.Minutes + ":" + span2.Seconds + " secondi "
|
|
);
|
|
}
|
|
public void insertLog(string idModello, string codicePb, string idTemplate, string isDefault, string metodo, string message, string stackTrace)
|
|
{
|
|
try
|
|
{
|
|
List<Parametro> param = new List<Parametro>();
|
|
param.Add(new Parametro { Value = idModello, ParameterName = "idModello" });
|
|
param.Add(new Parametro { Value = codicePb, ParameterName = "codicePb" });
|
|
param.Add(new Parametro { Value = idTemplate, ParameterName = "idTemplate" });
|
|
param.Add(new Parametro { Value = isDefault, ParameterName = "isDefault" });
|
|
param.Add(new Parametro { Value = metodo, ParameterName = "metodo" });
|
|
param.Add(new Parametro { Value = message, ParameterName = "message" });
|
|
param.Add(new Parametro { Value = stackTrace, ParameterName = "stackTrace" });
|
|
DataAccess.ExecuteNonQueryStoredProcedure(DBProvider.SqlServerWebTemplateReportModeler, "INSERTERROR", param);
|
|
}
|
|
catch { }
|
|
}
|
|
public void insertLog(string idModello, string codicePb, string idTemplate, string isDefault, string metodo, Exception exception)
|
|
{
|
|
if (exception is DataBaseException)
|
|
insertLog(idModello, codicePb, idTemplate, isDefault, metodo, ((DataBaseException)exception).Eccezione.Message, ((DataBaseException)exception).Eccezione.StackTrace);
|
|
else
|
|
insertLog(idModello, codicePb, idTemplate, isDefault, metodo, exception.Message,exception.StackTrace);
|
|
}
|
|
private string getlogTempalte(string nome)
|
|
{
|
|
string template = "";
|
|
try
|
|
{
|
|
List<Parametro> param = new List<Parametro>();
|
|
param.Add(new Parametro { Value = nome, ParameterName = "nome" });
|
|
System.Data.DataTable dt = DataAccess.ExecuteDataTableStoredProcedure(DBProvider.SqlServerWebTemplateReportModeler, "GETTEMPLTELOG", param);
|
|
template = dt.Rows[0][0].ToString();
|
|
}
|
|
catch { }
|
|
return template;
|
|
}
|
|
|
|
|
|
}
|
|
}
|