401 lines
20 KiB
C#
401 lines
20 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using ceTe.DynamicPDF;
|
|
using ceTe.DynamicPDF.Text;
|
|
using PDFGenerator.Presentation.Section.Tables;
|
|
using PDFGenerator.BusinessLayer.DataSection;
|
|
using PDFGenerator.BusinessLayer;
|
|
using ContrattoSei.Utilities;
|
|
using ceTe.DynamicPDF.PageElements;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
|
|
namespace PDFGenerator.Presentation.Section
|
|
{
|
|
public class S182 : ISezione
|
|
{
|
|
string Titolo = string.Empty;
|
|
string _testotitolo;
|
|
string _testointroduttivo;
|
|
string _testoAlternativo;
|
|
public int widthImporti = 60;
|
|
public int widthData = 50;
|
|
public int fontsize = 6;
|
|
public int headerFontSize = 5;
|
|
NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
|
|
|
|
/// <summary>
|
|
/// Testo introduttivo della sezione.
|
|
/// </summary>
|
|
public string TestoIntroduttivo
|
|
{
|
|
get
|
|
{
|
|
return _testointroduttivo;
|
|
}
|
|
set
|
|
{
|
|
_testointroduttivo = value;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Testo del titolo della sezione.
|
|
/// </summary>
|
|
public string TestoTitolo
|
|
{
|
|
get
|
|
{
|
|
return _testotitolo;
|
|
}
|
|
set
|
|
{
|
|
_testotitolo = value;
|
|
}
|
|
}
|
|
|
|
public string TestoAlternativo
|
|
{
|
|
get { return _testoAlternativo; }
|
|
set { _testoAlternativo = value; }
|
|
}
|
|
|
|
public void setTitolo(string label)
|
|
{
|
|
Titolo = label;
|
|
}
|
|
|
|
public S182()
|
|
{
|
|
//
|
|
// TODO: Add constructor logic here
|
|
//
|
|
}
|
|
|
|
#region ISezione Members
|
|
public void writeSezione(DataThread dataThread)
|
|
{
|
|
DocumentPDF document = dataThread.DocumentPDF;
|
|
DataSetS182DettaglioProdottiESG set = (DataSetS182DettaglioProdottiESG)dataThread.Data.DatiSezione;
|
|
DatiTabella datitab = new DatiTabella();
|
|
|
|
//datitab.table = set.Tables["dtDettaglioProdottiESG"];
|
|
|
|
set.Tables["Prodotti"].Columns.Add("Immagine");
|
|
datitab.table = set.Tables["Prodotti"];
|
|
|
|
#region Titolo Seconda tabella
|
|
// Titolo della sezione
|
|
|
|
switch (dataThread.Rete)
|
|
{
|
|
case "F":
|
|
{
|
|
_testointroduttivo = _testointroduttivo.Replace("$/Banca/$", "Fideuram");
|
|
break;
|
|
}
|
|
case "S":
|
|
{
|
|
_testointroduttivo = _testointroduttivo.Replace("$/Banca/$", "Fideuram S.p.A., commercializzati tramite la rete di private banker Sanpaolo Invest,");
|
|
break;
|
|
}
|
|
case "W":
|
|
{
|
|
_testointroduttivo = _testointroduttivo.Replace("$/Banca/$", "IW Private Investments");
|
|
break;
|
|
}
|
|
}
|
|
|
|
logger.Info("Titolo della sezione " + _testointroduttivo);
|
|
document.setLastPos(-40);
|
|
document.setChapterHeader(string.Concat(_testointroduttivo, "<br>"), 0, 520, 8);
|
|
#endregion
|
|
|
|
|
|
#region Tabella
|
|
|
|
/***** Disegno la tabella con oggetti della solution trimestrale *************/
|
|
int widthTotaleAltre = calculateWidth();
|
|
int widthNomeProdotto = 520 - widthTotaleAltre + 25;
|
|
|
|
/** Creo una tabella solo per header **/
|
|
#region Tabella Header non usata
|
|
//Tabella tabellaHeader = null;
|
|
//tabellaHeader = new Tabella(document.getMargineLeft(), document.getLastPos());
|
|
//tabellaHeader.HeaderFont = 6;
|
|
//tabellaHeader.AltezzaCella = 30;
|
|
//tabellaHeader.Header = true; // la gestione dell'header viene fatta manualmente.
|
|
//tabellaHeader.SaltoPagina = false;
|
|
|
|
//DataView viewHeader = new DataView(datitab.table);
|
|
//viewHeader.RowFilter = ("CodArea = 'xxx'");
|
|
//datitab.table = viewHeader.ToTable();
|
|
//datitab.table.Rows.Add(datitab.table.NewRow()); // serve per far scrivere l'intestazione.
|
|
|
|
//tabellaHeader.Colonne.Add(new Colonna("Immagine", string.Empty, 10, TipoAllineamento.SINISTRA, false, 6, false, TipoColonna.TESTO));
|
|
//tabellaHeader.Colonne.Add(new Colonna("NomeProdotto", "Prodotto", widthNomeProdotto, TipoAllineamento.SINISTRA, false, tabellaHeader.HeaderFont, false, TipoColonna.TESTO));
|
|
////tabellaDati.Colonne.Add(new Colonna("Descrizione", string.Empty, widthData+10, TipoAllineamento.SINISTRA, false, fontsize, false, TipoColonna.TESTO));
|
|
//tabellaHeader.Colonne.Add(new Colonna("preferenzaE", string.Empty, widthData, TipoAllineamento.SINISTRA, false, tabellaHeader.HeaderFont, false, TipoColonna.TESTO));
|
|
//tabellaHeader.Colonne.Add(new Colonna("preferenzaS", string.Empty, widthData, TipoAllineamento.SINISTRA, false, tabellaHeader.HeaderFont, false, TipoColonna.TESTO));
|
|
//tabellaHeader.Colonne.Add(new Colonna("preferenzaG", string.Empty, widthData, TipoAllineamento.SINISTRA, false, tabellaHeader.HeaderFont, false, TipoColonna.TESTO));
|
|
|
|
//tabellaHeader.Colonne.Add(new Colonna("CatSFDR", "Categoria.<br>SFDR", widthData, TipoAllineamento.CENTRATO, false, tabellaHeader.HeaderFont, false, TipoColonna.TESTO));
|
|
//tabellaHeader.Colonne.Add(new Colonna("ESGRating", "ESG<br>Rating", widthData, TipoAllineamento.CENTRATO, false, tabellaHeader.HeaderFont, false, TipoColonna.IMMAGINE));
|
|
//tabellaHeader.Colonne.Add(new Colonna("TrendESGRating", "Trend ESG<br>Rating", widthData, TipoAllineamento.CENTRATO, false, tabellaHeader.HeaderFont, false, TipoColonna.IMMAGINE));
|
|
//tabellaHeader.Colonne.Add(new Colonna("Controvalore", "Controvalore (€)", widthImporti, TipoAllineamento.SINISTRA, false, tabellaHeader.HeaderFont, false, TipoColonna.TESTO));
|
|
|
|
//tabellaHeader.DrawESG(datitab, document);
|
|
|
|
#endregion
|
|
|
|
Tabella tabellaDati = new Tabella(document.getMargineLeft(), document.getLastPos(), 2, 0, 0.02F);
|
|
tabellaDati.Header = true;
|
|
tabellaDati.HeaderFont = 8;
|
|
tabellaDati.Datasource = datitab.table;
|
|
tabellaDati.AltezzaCella = 23; //15;
|
|
tabellaDati.LineaFineTabella = false;
|
|
|
|
tabellaDati.WithImage = true;
|
|
|
|
//int widthTotaleAltre = calculateWidth();
|
|
//int widthNomeProdotto = 520 - widthTotaleAltre + 25;
|
|
|
|
|
|
//tabellaDati.Colonne.Add(new Colonna("Immagine", string.Empty, 15, TipoAllineamento.SINISTRA, false, 6, false, TipoColonna.TESTO));
|
|
//tabellaDati.Colonne.Add(new Colonna("Descrizione", "Prodotto", widthNomeProdotto, TipoAllineamento.SINISTRA, false, fontsize, false, TipoColonna.TESTO));
|
|
|
|
//tabellaDati.Colonne.Add(new Colonna("ESG_E", string.Empty, widthData, TipoAllineamento.SINISTRA, false, fontsize,false, TipoColonna.TESTO));
|
|
//tabellaDati.Colonne.Add(new Colonna("ESG_S", string.Empty, widthData, TipoAllineamento.SINISTRA, false, fontsize, false, TipoColonna.TESTO));
|
|
//tabellaDati.Colonne.Add(new Colonna("ESG_G", string.Empty, widthData, TipoAllineamento.SINISTRA, false, fontsize, false, TipoColonna.TESTO));
|
|
|
|
//tabellaDati.Colonne.Add(new Colonna("CatSFDR", "Categoria.<br>SFDR*", widthData, TipoAllineamento.SINISTRA, false, fontsize, false, TipoColonna.TESTO));
|
|
//tabellaDati.Colonne.Add(new Colonna("ESGRating", "ESG<br>Rating**", widthData, TipoAllineamento.SINISTRA, false, fontsize, false, TipoColonna.IMMAGINE));
|
|
//tabellaDati.Colonne.Add(new Colonna("TrendESGRating", "Trend ESG<br>Rating", widthData, TipoAllineamento.CENTRATO, false, fontsize, false, TipoColonna.IMMAGINE));
|
|
//tabellaDati.Colonne.Add(new Colonna("Controvalore", "Controvalore (€)", widthImporti, TipoAllineamento.SINISTRA, false, fontsize, false, TipoColonna.TESTO));
|
|
|
|
//tabellaDati.Colonne.Add(new Colonna("Saving", string.Empty, 10, TipoAllineamento.SINISTRA, false, 6, true));
|
|
//tabellaDati.Colonne.Add(new Colonna("Immagine", string.Empty, 10, TipoAllineamento.SINISTRA, false, 6, false));
|
|
/***** ESG - Distanziare la colonna NomeProdotto dalle altre 26/09/2022 - Pino *************/
|
|
//tabellaDati.Colonne.Add(new Colonna("NomeProdotto", "Prodotto", widthNomeProdotto-2, TipoAllineamento.SINISTRA, false, tabellaDati.HeaderFont, false, TipoColonna.TESTO));
|
|
tabellaDati.Colonne.Add(new Colonna("NomeProdotto", "Prodotto", widthNomeProdotto, TipoAllineamento.SINISTRA, false, tabellaDati.HeaderFont, false));
|
|
tabellaDati.Colonne.Add(new Colonna("Nome_Progetto", string.Empty, 0, TipoAllineamento.SINISTRA, false, tabellaDati.HeaderFont, false));
|
|
/********************************************************************************************/
|
|
//tabellaDati.Colonne.Add(new Colonna("Descrizione", string.Empty, widthData+10, TipoAllineamento.SINISTRA, false, fontsize, false, TipoColonna.TESTO));
|
|
tabellaDati.Colonne.Add(new Colonna("preferenzaE", string.Empty, widthData - 5, TipoAllineamento.SINISTRA, false, tabellaDati.HeaderFont, false, TipoColonna.TESTO));
|
|
tabellaDati.Colonne.Add(new Colonna("preferenzaS", string.Empty, widthData - 5, TipoAllineamento.SINISTRA, false, tabellaDati.HeaderFont, false, TipoColonna.TESTO));
|
|
tabellaDati.Colonne.Add(new Colonna("preferenzaG", string.Empty, widthData - 5, TipoAllineamento.SINISTRA, false, tabellaDati.HeaderFont, false, TipoColonna.TESTO));
|
|
|
|
tabellaDati.Colonne.Add(new Colonna("CatSFDR", "Categoria SFDR", widthData + 35, TipoAllineamento.SINISTRA, false, tabellaDati.HeaderFont, false, TipoColonna.TESTO));
|
|
tabellaDati.Colonne.Add(new Colonna("ESGRating", "ESG Rating", widthData + 10, TipoAllineamento.SINISTRA, false, tabellaDati.HeaderFont, false, TipoColonna.IMMAGINE));
|
|
//tabellaDati.Colonne.Add(new Colonna("TrendESGRating", "Trend ESG<br>Rating", widthData + 10, TipoAllineamento.SINISTRA, false, tabellaDati.HeaderFont, false, TipoColonna.IMMAGINE));
|
|
tabellaDati.Colonne.Add(new Colonna("Controvalore", "Controvalore (€)", widthImporti + 50, TipoAllineamento.DESTRA, false, tabellaDati.HeaderFont, false, TipoColonna.TESTO));
|
|
|
|
tabellaDati.DrawESG(datitab, document);
|
|
/**********************************************************************************************/
|
|
|
|
/************* provo ad inserire le immagini dopo aver disegnato la tabell. Problema si posizione sull'ultima pagina. **************/
|
|
//ceTe.DynamicPDF.Merger.ImportedPage page = document.getCurrentPage();
|
|
//System.Reflection.Assembly thisExe;
|
|
//thisExe = System.Reflection.Assembly.GetExecutingAssembly();
|
|
//System.IO.Stream fileE = thisExe.GetManifestResourceStream(UtilityManager.getAppSetting("FrecciaS80"));
|
|
//System.IO.Stream fileS = thisExe.GetManifestResourceStream(UtilityManager.getAppSetting("logo-sociale"));
|
|
//System.IO.Stream fileG = thisExe.GetManifestResourceStream(UtilityManager.getAppSetting("logo-governance"));
|
|
|
|
//page.Elements.Add(new ceTe.DynamicPDF.PageElements.Image(fileE, document.getMargineLeft()+150, tabellaDati.Y - 6, 0.57F));
|
|
/**************************************************************************************************************************************/
|
|
|
|
#region Vecchia versione Tabella Totale
|
|
//DataRow[] found = set.Tables["Prodotti"].Select("Area <> ' '");
|
|
//double _totale = 0.0;
|
|
//if (found.Length > 0)
|
|
//{
|
|
// for (int i=0; i<=found.Length-1;i++)
|
|
// {
|
|
// _totale += Convert.ToDouble(found[i].Field<string>("Controvalore"));
|
|
// }
|
|
//}
|
|
|
|
//string _importo = _totale.ToString("#,##0.00"); ;
|
|
|
|
//DataSet _ds = new DataSet();
|
|
//DataTable _dt = new DataTable();
|
|
//_dt.Columns.Add("PatrimonioFideuram", typeof(System.String));
|
|
//_dt.Columns.Add("Totale", typeof(System.String));
|
|
|
|
//_ds.Tables.Add(_dt);
|
|
//DataRow dr = _dt.NewRow();
|
|
//dr[0] = "Totale Risorse Allocate*";
|
|
//dr[1] = _importo;
|
|
|
|
//_dt.Rows.Add(dr);
|
|
|
|
//datitab = new DatiTabella();
|
|
//datitab.table = _dt;
|
|
|
|
//Tabella tabellaTotali_OUT = new Tabella(document.getMargineLeft(), document.getLastPos() + tabellaDati.AltezzaTabella + 27);
|
|
//tabellaTotali_OUT.HeaderFont = 8;
|
|
//tabellaTotali_OUT.Header = false;
|
|
//tabellaTotali_OUT.SaltoPagina = false;
|
|
|
|
//tabellaTotali_OUT.Colonne.Add(new Colonna("PatrimonioFideuram", "",150, TipoAllineamento.SINISTRA, true, 8, true));
|
|
//tabellaTotali_OUT.Colonne.Add(new Colonna("Totale", "", 365, TipoAllineamento.DESTRA, true, 8, true));
|
|
|
|
//// Scrive la tabella Totali
|
|
//tabellaTotali_OUT.Draw(datitab, document);
|
|
#endregion
|
|
|
|
#region Nuova versione Tabella Totale Risorse Finanziarie
|
|
// Recupero le altezze delle tabelle
|
|
float dim = tabellaDati.AltezzaTabella + 27;
|
|
|
|
Tabella tabellaTotali_OUT = null;
|
|
|
|
|
|
if (dataThread.Periodico)
|
|
{
|
|
if (set.Tables["ProdottiTRF"].Rows[0][1].Equals("TOTALE RISORSE FINANZIARIE"))
|
|
{
|
|
DataSet _ds = new DataSet();
|
|
DataTable _dt = new DataTable();
|
|
_dt.Columns.Add("PatrimonioFideuram", typeof(System.String));
|
|
_dt.Columns.Add("Totale", typeof(System.String));
|
|
|
|
_ds.Tables.Add(_dt);
|
|
DataRow dr = _dt.NewRow();
|
|
dr[0] = "Totale Risorse Finanziarie";
|
|
dr[1] = set.Tables["ProdottiTRF"].Rows[0]["Controvalore"];
|
|
|
|
_dt.Rows.Add(dr);
|
|
|
|
datitab = new DatiTabella();
|
|
datitab.table = _dt;
|
|
|
|
tabellaTotali_OUT = new Tabella(document.getMargineLeft(), document.getLastPos() + dim);
|
|
tabellaTotali_OUT.HeaderFont = 8;
|
|
tabellaTotali_OUT.Header = false;
|
|
tabellaTotali_OUT.SaltoPagina = false;
|
|
|
|
tabellaTotali_OUT.Colonne.Add(new Colonna("PatrimonioFideuram", "", 150, TipoAllineamento.SINISTRA, true, 8, true));
|
|
tabellaTotali_OUT.Colonne.Add(new Colonna("Totale", "", 365, TipoAllineamento.DESTRA, true, 8, true));
|
|
|
|
// Scrive la tabella Totale Risorse Finanziari
|
|
tabellaTotali_OUT.Draw(datitab, document);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region Tabella Dettaglio Risorse Finanziarie
|
|
Tabella tabellaDettTRF = null;
|
|
if (dataThread.Periodico)
|
|
{
|
|
if (set.Tables["ProdottiTRF"].Rows[0][1].Equals("TOTALE RISORSE FINANZIARIE"))
|
|
{
|
|
dim = dim + tabellaTotali_OUT.AltezzaTabella;
|
|
#region Dettaglio
|
|
// Tabella Dettaglio risorse Finanziarie
|
|
DataTable _dtDettTRF = new DataTable();
|
|
_dtDettTRF.Columns.Add("PatrimonioFideuramDett", typeof(System.String));
|
|
_dtDettTRF.Columns.Add("TotaleDett", typeof(System.String));
|
|
|
|
var ListaDettTrf = set.Tables["ProdottiTRF"].AsEnumerable().Where(f => f.Field<string>("Descrizione") == string.Empty).Select(s => s).ToList();
|
|
|
|
foreach (var itemDetTRF in ListaDettTrf)
|
|
{
|
|
DataRow drDettTRF = _dtDettTRF.NewRow();
|
|
|
|
drDettTRF[0] = itemDetTRF[5].ToString();
|
|
drDettTRF[1] = itemDetTRF["Controvalore"].ToString();
|
|
|
|
_dtDettTRF.Rows.Add(drDettTRF);
|
|
}
|
|
|
|
datitab = new DatiTabella();
|
|
datitab.table = _dtDettTRF;
|
|
|
|
tabellaDettTRF = new Tabella(document.getMargineLeft(), document.getLastPos() + dim);
|
|
tabellaDettTRF.HeaderFont = 8;
|
|
tabellaDettTRF.Header = false;
|
|
tabellaDettTRF.SaltoPagina = false;
|
|
|
|
tabellaDettTRF.Colonne.Add(new Colonna("PatrimonioFideuramDett", "", 150, TipoAllineamento.SINISTRA, false, 8, false));
|
|
tabellaDettTRF.Colonne.Add(new Colonna("TotaleDett", "", 365, TipoAllineamento.DESTRA, false, 8, false));
|
|
|
|
// Scrive la tabella Totale Risorse Finanziari
|
|
tabellaDettTRF.Draw(datitab, document);
|
|
#endregion
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region Tabella Totale Patrimonio
|
|
if (set.Tables["ProdottiTRF"].Rows[0][1].Equals("TOTALE RISORSE FINANZIARIE"))
|
|
dim = dim + tabellaDettTRF.AltezzaTabella;
|
|
|
|
DataTable _dtTotalePatrimonio = new DataTable();
|
|
_dtTotalePatrimonio.Columns.Add("DescrizioneTP", typeof(System.String));
|
|
_dtTotalePatrimonio.Columns.Add("TotalePatrimonio", typeof(System.String));
|
|
|
|
var listaTotalePatrimonio = set.Tables["ProdottiTRF"].AsEnumerable().Where(f => f.Field<string>("Descrizione").Equals("TOTALE PATRIMONIO")).Select(s => s).ToList();
|
|
|
|
foreach (var itemTP in listaTotalePatrimonio)
|
|
{
|
|
DataRow drTotP = _dtTotalePatrimonio.NewRow();
|
|
drTotP[0] = itemTP["Descrizione"].ToString();
|
|
drTotP[1] = itemTP["Controvalore"].ToString();
|
|
|
|
_dtTotalePatrimonio.Rows.Add(drTotP);
|
|
}
|
|
|
|
datitab = new DatiTabella();
|
|
datitab.table = _dtTotalePatrimonio;
|
|
|
|
Tabella tabellaTotP = new Tabella(document.getMargineLeft(), document.getLastPos() + dim);
|
|
tabellaTotP.HeaderFont = 8;
|
|
tabellaTotP.Header = false;
|
|
tabellaTotP.SaltoPagina = false;
|
|
|
|
tabellaTotP.Colonne.Add(new Colonna("DescrizioneTP", "", 150, TipoAllineamento.SINISTRA, true, 8, true));
|
|
tabellaTotP.Colonne.Add(new Colonna("TotalePatrimonio", "", 365, TipoAllineamento.DESTRA, true, 8, true));
|
|
|
|
// Scrive la tabella Totale Risorse Finanziari
|
|
tabellaTotP.Draw(datitab, document);
|
|
#endregion
|
|
|
|
#region Nota tabella
|
|
//string nota = "*Il controvalore non considera i saldi negativi di conto corrente e/o le operazioni in corso.";
|
|
|
|
//document.setSezFooter(nota, tabellaDati.AltezzaTabella + tabellaTotali_OUT.AltezzaTabella + tabellaTotali_OUT.AltezzaCella, 0, 7);
|
|
//tabellaTotali_OUT.NotaTabella.Add(nota);
|
|
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
/*** ATTENZIONE Forzatura - Pino ************************/
|
|
//dataThread.Periodico = true;
|
|
//dataThread.CodiceFiscale = "DGSMHL70H08Z404F";
|
|
//dataThread.Rete = "S";
|
|
/********************************************************/
|
|
}
|
|
|
|
protected int calculateWidth()
|
|
{
|
|
int tot = 0;
|
|
tot += widthImporti;
|
|
tot += widthImporti;
|
|
tot += widthImporti;
|
|
tot += widthImporti;
|
|
tot += widthImporti;
|
|
tot += widthImporti;
|
|
tot += widthImporti;
|
|
return tot;
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
}
|
|
}
|