using System; using System.Collections.Generic; using Consulenza.ReportArchive.Entity; using Consulenza.ReportArchive; namespace Consulenza.Unica.Business { public class ReportArchiveService { public long SetDocumentPdf(DocumentoPdf documentoPdf, string idProvenienza) { ReportArchiveManager reportArchiveManager = new ReportArchiveManager(); long idPdf = 0; try { idPdf = reportArchiveManager.SetDocumentPdf(documentoPdf, idProvenienza); } catch (Exception ex) { insertLog(idPdf.ToString(), "SetDocumentPdf", ex); return -1; } return idPdf; } public int DelPdf(long idPdf, string idProvenienza) { ReportArchiveManager reportArchiveManager = new ReportArchiveManager(); int err = -1; try { err = reportArchiveManager.DelPdf(idPdf, idProvenienza); } catch (Exception ex) { insertLog(idPdf.ToString(), "DelPdf", ex); return -1; } if (err == -1) insertLog(idPdf.ToString(), "DelPdf", "reportArchiveManager.DelPdf(..) return -1"); return err; } public int SetStato(long idPdf, string idstato, string idProvenienza) { ReportArchiveManager reportArchiveManager = new ReportArchiveManager(); int err = -1; try { err = reportArchiveManager.SetStato(idPdf, idstato, idProvenienza); } catch (Exception ex) { insertLog(idPdf.ToString(), "SetStato", ex); return -1; } if (err == -1) insertLog(idPdf.ToString(), "SetStato", "reportArchiveManager.SetStato(..) return -1"); return err; } public List GetlogPdf(long idPdf) { ReportArchiveManager reportArchiveManager = new ReportArchiveManager(); List logPdfs = new List(); try { logPdfs = reportArchiveManager.GetlogPdf(idPdf); } catch (Exception ex) { logPdfs = new List(); insertLog(idPdf.ToString(), "GetlogPdf", ex); } return logPdfs; } public List GetPdfs(RicercaPdf ricercaPdf) { ReportArchiveManager reportArchiveManager = new ReportArchiveManager(); List documentoPdfs = new List(); try { documentoPdfs = reportArchiveManager.GetPdfs(ricercaPdf); } catch (Exception ex) { documentoPdfs = new List(); long idPdf = ricercaPdf != null ? ricercaPdf.IdPdf : 0; insertLog(idPdf.ToString(), "GetPdfs", ex); } return documentoPdfs; } public DocumentoPdf GetPdf(long idPdf) { ReportArchiveManager reportArchiveManager = new ReportArchiveManager(); DocumentoPdf documentoPdf = new DocumentoPdf(); try { documentoPdf = reportArchiveManager.GetPdf(idPdf); } catch (Exception ex) { documentoPdf = new DocumentoPdf(); insertLog(idPdf.ToString(), "GetPdf", ex); } return documentoPdf; } private void insertLog(string idPdf, string metodo, string message) { try { List param = new List(); param.Add(new Parametro { Value = idPdf, ParameterName = "idPdf" }); param.Add(new Parametro { Value = metodo, ParameterName = "metodo" }); param.Add(new Parametro { Value = message, ParameterName = "message" }); DataAccess.ExecuteNonQueryStoredProcedure(DBProvider.SqlServerReportArchive, "INSERTERROR", param); } catch { } } private void insertLog(string idPdf, string metodo, Exception exception) { if (exception is DataBaseException) insertLog(idPdf, metodo, ((DataBaseException)exception).Eccezione.Message); else insertLog(idPdf, metodo, exception.Message); } } }