399 lines
17 KiB
C#
399 lines
17 KiB
C#
using System;
|
|
using System.Data;
|
|
using System.Configuration;
|
|
using System.Web;
|
|
using System.Web.Security;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
using System.Web.UI.WebControls.WebParts;
|
|
using System.Web.UI.HtmlControls;
|
|
using System.Collections;
|
|
using ceTe.DynamicPDF;
|
|
using ceTe.DynamicPDF.Text;
|
|
using PDFGenerator.Presentation.Section.Tables;
|
|
using PDFGenerator.BusinessLayer.DataSection;
|
|
using PDFGenerator.BusinessLayer;
|
|
using System.Resources;
|
|
using System.Reflection;
|
|
using System.Collections.Generic;
|
|
|
|
namespace PDFGenerator.Presentation.Section
|
|
{
|
|
public class FD133BIS : SIstogramma, ISezione
|
|
{
|
|
NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
|
|
private string _header = "";
|
|
private string _testointroduttivo;
|
|
private string Titolo = string.Empty;
|
|
|
|
public string Header
|
|
{
|
|
get { return _header; }
|
|
set { _header = value; }
|
|
}
|
|
|
|
private TipoReport _tipologiaReport;
|
|
public TipoReport TipologiaReport
|
|
{
|
|
get { return _tipologiaReport; }
|
|
set { _tipologiaReport = value; }
|
|
}
|
|
|
|
/// <summary>
|
|
/// Testo introduttivo della sezione.
|
|
/// </summary>
|
|
public string TestoIntroduttivo
|
|
{
|
|
get
|
|
{
|
|
return _testointroduttivo;
|
|
}
|
|
set
|
|
{
|
|
_testointroduttivo = value;
|
|
}
|
|
}
|
|
|
|
public void setTitolo(string label)
|
|
{
|
|
Titolo = label;
|
|
}
|
|
|
|
public FD133BIS()
|
|
{
|
|
//
|
|
// TODO: Add constructor logic here
|
|
//
|
|
}
|
|
|
|
#region ISezione Members
|
|
|
|
public void writeSezione(DataThread dataThread)
|
|
{
|
|
DocumentPDF document = dataThread.DocumentPDF;
|
|
|
|
DataSetS133BIS set = (DataSetS133BIS)dataThread.Data.DatiSezione;
|
|
DatiTabella datitab = new DatiTabella();
|
|
|
|
// Titolo della sezione
|
|
logger.Info("Titolo della sezione " + _testointroduttivo);
|
|
document.setLastPos(-40);
|
|
document.setSezTitolo(dataThread.SezioneReport.Titolo);
|
|
document.setChapterHeader(string.Concat(_testointroduttivo, "<br>"), 0, 520, 8);
|
|
|
|
|
|
datitab.table = set.Tables["PrincipaliProdotti"];
|
|
|
|
if (document.checkMargin(180))
|
|
document.addPage();
|
|
|
|
//Disegno la tabella
|
|
|
|
Tabella tabellaDati = new Tabella(document.getMargineLeft(), document.getLastPos());
|
|
tabellaDati.Header = true;
|
|
tabellaDati.HeaderFont = 8;
|
|
tabellaDati.Datasource = datitab.table;
|
|
tabellaDati.AltezzaCella = 15;
|
|
//tabellaDati.Colonne.Add(new Colonna("DescrProdotto", "Prodotto", 262, TipoAllineamento.SINISTRA, false, 8, false, TipoColonna.IMMAGINE_E_TESTO));
|
|
tabellaDati.Colonne.Add(new Colonna("DescrProdotto", "Prodotto", 262, TipoAllineamento.SINISTRA, false, 8, false, TipoColonna.TESTO));
|
|
tabellaDati.Colonne.Add(new Colonna("VaRProdotto", "Rischio<BR>(VaR%)", 60, TipoAllineamento.DESTRA, false, 8, false));
|
|
tabellaDati.Colonne.Add(new Colonna("pesoRelativo", "Peso relativo %", 95, TipoAllineamento.DESTRA, false, 8, false));
|
|
tabellaDati.Colonne.Add(new Colonna("rischioRelativo", "Rischio relativo %", 95, TipoAllineamento.SINISTRA, false, 8, false));
|
|
|
|
#region Simboli del patrimonio
|
|
|
|
//int numSimboli = 13;
|
|
//string testoLetteraSimboloPatrimonio = string.Empty;
|
|
|
|
//foreach (DataRow row in tabellaDati.Datasource.Rows)
|
|
//{
|
|
// document.getCurrentPage().Elements.Add(RecuperaSimboloAreaBisogno(document.getMargineLeft(), document.getLastPos() + numSimboli, row["codiceAreaBisogno"].ToString()));
|
|
// document.getCurrentPage().Elements.Add(new ceTe.DynamicPDF.PageElements.Label((RecuperaLetteraSimboloAreaBisogno(row["codiceAreaBisogno"].ToString())), GetX(row["codiceAreaBisogno"].ToString(), document.getMargineLeft() + 2), document.getLastPos() + numSimboli, 5, 10, Globals.OpenTypeFontVerdana, 10, ceTe.DynamicPDF.TextAlign.Center, CmykColor.White));
|
|
// numSimboli += 15;
|
|
//}
|
|
|
|
#endregion
|
|
|
|
tabellaDati.ColoreDirectBankB = "green";
|
|
|
|
tabellaDati.Draw(datitab, document);
|
|
|
|
|
|
|
|
#region Grafico a farfalla per Prodotti
|
|
|
|
#region Recupero i valori da assegnare alle serie del grafico
|
|
|
|
List<IValoriSerie> listaValoriPesoRelativo = new List<IValoriSerie>();
|
|
List<IValoriSerie> listaValoriRischioRelativo = new List<IValoriSerie>();
|
|
|
|
foreach (DataRow row in set.Tables["PrincipaliProdotti"].Rows)
|
|
{
|
|
IValoriSerie IvaloriSeriePesoRelativo = new IValoriSerie();
|
|
IvaloriSeriePesoRelativo.chiave = row["DescrProdotto"].ToString();
|
|
IvaloriSeriePesoRelativo.valore = Convert.ToDecimal(row["pesoRelativo"]);
|
|
listaValoriPesoRelativo.Add(IvaloriSeriePesoRelativo);
|
|
|
|
IValoriSerie IvaloriSerieRischioRelativo = new IValoriSerie();
|
|
IvaloriSerieRischioRelativo.chiave = row["DescrProdotto"].ToString();
|
|
IvaloriSerieRischioRelativo.valore = Convert.ToDecimal(row["rischioRelativo"]);
|
|
listaValoriRischioRelativo.Add(IvaloriSerieRischioRelativo);
|
|
}
|
|
|
|
#endregion
|
|
|
|
double altezzaGraficoPesoRischio_Prodotto = 15 * (tabellaDati.Datasource.Rows.Count + 0.01); //0.5
|
|
IstoFarfallaS133BIS graficoPesoRischio_Prodotto = new IstoFarfallaS133BIS((double)200, altezzaGraficoPesoRischio_Prodotto);
|
|
graficoPesoRischio_Prodotto.DocumentPDF = document;
|
|
graficoPesoRischio_Prodotto.PositionX = 365;
|
|
graficoPesoRischio_Prodotto.PositionY = Convert.ToInt32(document.getLastPos() + 14); //542;
|
|
graficoPesoRischio_Prodotto.AxisY_LineColor = false;
|
|
graficoPesoRischio_Prodotto.AxisY_Hide = true;
|
|
graficoPesoRischio_Prodotto.AxysX_Increment = Convert.ToDecimal(1);
|
|
|
|
SerieIstoFarfallaS133BIS seriePesoRelativo = new SerieIstoFarfallaS133BIS();
|
|
SerieIstoFarfallaS133BIS serieRischioRelativo = new SerieIstoFarfallaS133BIS();
|
|
|
|
seriePesoRelativo = new SerieIstoFarfallaS133BIS();
|
|
seriePesoRelativo.Name = "pesoRelativo";
|
|
seriePesoRelativo.Values = listaValoriPesoRelativo;
|
|
//seriePesoRelativo.ElementPosition = new Dundas.Charting.WebControl.ElementPosition(1F, -5F, 50.7F, 105F);
|
|
seriePesoRelativo.ElementPosition = new Dundas.Charting.WebControl.ElementPosition(1F, -2.5F, 50.7F, 105F);
|
|
seriePesoRelativo.AxisY_CustumizedByValues = true;
|
|
seriePesoRelativo.ReverseAxisY = true;
|
|
|
|
|
|
serieRischioRelativo.Name = "rischioRelativo";
|
|
serieRischioRelativo.Values = listaValoriRischioRelativo;
|
|
//serieRischioRelativo.ElementPosition = new Dundas.Charting.WebControl.ElementPosition(49.3F, -5, 50.7F, 105F);
|
|
serieRischioRelativo.ElementPosition = new Dundas.Charting.WebControl.ElementPosition(49.3F, -2.5F, 50.7F, 105F);
|
|
serieRischioRelativo.AxisY_CustumizedByValues = true;
|
|
|
|
|
|
graficoPesoRischio_Prodotto.SerieList.Add(seriePesoRelativo);
|
|
graficoPesoRischio_Prodotto.SerieList.Add(serieRischioRelativo);
|
|
|
|
// Disegno il grafico
|
|
graficoPesoRischio_Prodotto.Draw();
|
|
|
|
#endregion
|
|
|
|
|
|
#region Legenda
|
|
//float xLegenda = document.getMargineLeft();
|
|
//float yLegenda = document.getLastPos() + tabellaDati.AltezzaTabella;
|
|
|
|
//if (set.Tables["PrincipaliProdotti"].Select("codiceAreaBisogno='Ext'").Length > 0)
|
|
//{
|
|
// document.getCurrentPage().Elements.Add(RecuperaSimboloAreaBisogno(xLegenda, yLegenda, "Ext"));
|
|
// document.getCurrentPage().Elements.Add(new ceTe.DynamicPDF.PageElements.Label("E", GetX("Ext", xLegenda + 2), yLegenda, 5, 10, Globals.OpenTypeFontVerdana, 10, ceTe.DynamicPDF.TextAlign.Center, ceTe.DynamicPDF.CmykColor.White));
|
|
// document.writeText(xLegenda + 15, yLegenda + 2, "Extra Rendimento", 8);
|
|
// xLegenda += 100;
|
|
//}
|
|
|
|
//if (set.Tables["PrincipaliProdotti"].Select("codiceAreaBisogno='Inv'").Length > 0)
|
|
//{
|
|
// document.getCurrentPage().Elements.Add(RecuperaSimboloAreaBisogno(xLegenda, yLegenda, "Inv"));
|
|
// document.getCurrentPage().Elements.Add(new ceTe.DynamicPDF.PageElements.Label("I", GetX("Inv", xLegenda + 2), yLegenda, 5, 10, Globals.OpenTypeFontVerdana, 10, ceTe.DynamicPDF.TextAlign.Center, ceTe.DynamicPDF.CmykColor.White));
|
|
// document.writeText(xLegenda + 15, yLegenda + 2, "Investimento", 8);
|
|
// xLegenda += 81;
|
|
//}
|
|
|
|
//if ((set.Tables["PrincipaliProdotti"].Select("codiceAreaBisogno='Pre'").Length > 0) ||
|
|
// (set.Tables["PrincipaliProdotti"].Select("codiceAreaBisogno='Pre1'").Length > 0) ||
|
|
// (set.Tables["PrincipaliProdotti"].Select("codiceAreaBisogno='Pre2'").Length > 0))
|
|
//{
|
|
// document.getCurrentPage().Elements.Add(RecuperaSimboloAreaBisogno(xLegenda, yLegenda, "Pre"));
|
|
// document.getCurrentPage().Elements.Add(new ceTe.DynamicPDF.PageElements.Label("P", GetX("Pre", xLegenda + 2), yLegenda, 5, 10, Globals.OpenTypeFontVerdana, 10, ceTe.DynamicPDF.TextAlign.Center, ceTe.DynamicPDF.CmykColor.White));
|
|
// document.writeText(xLegenda + 15, yLegenda + 2, "Previdenza", 8);
|
|
// xLegenda += 71;
|
|
//}
|
|
|
|
//if (set.Tables["PrincipaliProdotti"].Select("codiceAreaBisogno='Ris'").Length > 0)
|
|
//{
|
|
// document.getCurrentPage().Elements.Add(RecuperaSimboloAreaBisogno(xLegenda, yLegenda, "Ris"));
|
|
// document.getCurrentPage().Elements.Add(new ceTe.DynamicPDF.PageElements.Label("R", GetX("Ris", xLegenda + 2), yLegenda, 5, 10, Globals.OpenTypeFontVerdana, 10, ceTe.DynamicPDF.TextAlign.Center, ceTe.DynamicPDF.CmykColor.White));
|
|
// document.writeText(xLegenda + 15, yLegenda + 2, "Riserva", 8);
|
|
// xLegenda += 57;
|
|
//}
|
|
|
|
//if (set.Tables["PrincipaliProdotti"].Select("codiceAreaBisogno='Liq'").Length > 0)
|
|
//{
|
|
// document.getCurrentPage().Elements.Add(RecuperaSimboloAreaBisogno(xLegenda, yLegenda, "Liq"));
|
|
// document.getCurrentPage().Elements.Add(new ceTe.DynamicPDF.PageElements.Label("L", GetX("Liq", xLegenda + 2), yLegenda, 5, 10, Globals.OpenTypeFontVerdana, 10, ceTe.DynamicPDF.TextAlign.Center, ceTe.DynamicPDF.CmykColor.White));
|
|
// document.writeText(xLegenda + 15, yLegenda + 2, "Liquidità", 8);
|
|
// xLegenda += 61;
|
|
//}
|
|
|
|
//if (set.Tables["PrincipaliProdotti"].Select("codiceAreaBisogno='Na'").Length > 0)
|
|
//{
|
|
// document.getCurrentPage().Elements.Add(RecuperaSimboloAreaBisogno(xLegenda, yLegenda, "Na"));
|
|
// document.getCurrentPage().Elements.Add(new ceTe.DynamicPDF.PageElements.Label("!", GetX("Na", xLegenda + 2), yLegenda, 5, 10, Globals.OpenTypeFontVerdana, 10, ceTe.DynamicPDF.TextAlign.Center, ceTe.DynamicPDF.CmykColor.White));
|
|
// document.writeText(xLegenda + 15, yLegenda + 2, "Non Allocate", 8);
|
|
//}
|
|
#endregion
|
|
|
|
document.setLastPos(600);
|
|
}
|
|
|
|
///// <summary>
|
|
///// Aggiungo il simbolo dell'area di bisogno del prodotto
|
|
///// </summary>
|
|
///// <param name="x"></param>
|
|
///// <param name="y"></param>
|
|
///// <param name="area"></param>
|
|
///// <returns></returns>
|
|
private ceTe.DynamicPDF.PageElements.Rectangle RecuperaSimboloAreaBisogno(float x, float y, string area)
|
|
{
|
|
System.Drawing.Color color = GetColors(area);
|
|
|
|
ceTe.DynamicPDF.PageElements.Rectangle simbolo = new ceTe.DynamicPDF.PageElements.Rectangle(x, y, 13, 13, 1, new RgbColor(color.R, color.G, color.B));
|
|
simbolo.CornerRadius = 1;
|
|
simbolo.BorderWidth = 0;
|
|
|
|
return simbolo;
|
|
}
|
|
|
|
///// <summary>
|
|
///// Recupera la lettera simbolo dell'area di bisogno passata in input
|
|
///// </summary>
|
|
///// <param name="area"></param>
|
|
///// <returns></returns>
|
|
private string RecuperaLetteraSimboloAreaBisogno(string area)
|
|
{
|
|
string testoLetteraSimboloPatrimonio = string.Empty;
|
|
|
|
#region Recupero la lettera simbolo di area di bisogno
|
|
|
|
switch (area.ToString().ToUpper())
|
|
{
|
|
case "INV":
|
|
testoLetteraSimboloPatrimonio = "I";
|
|
break;
|
|
case "EXT":
|
|
testoLetteraSimboloPatrimonio = "E";
|
|
break;
|
|
case "RIS":
|
|
testoLetteraSimboloPatrimonio = "R";
|
|
break;
|
|
case "LIQ":
|
|
testoLetteraSimboloPatrimonio = "L";
|
|
break;
|
|
case "PRE":
|
|
testoLetteraSimboloPatrimonio = "P";
|
|
break;
|
|
case "PRE1":
|
|
testoLetteraSimboloPatrimonio = "P";
|
|
break;
|
|
case "PRE2":
|
|
testoLetteraSimboloPatrimonio = "P";
|
|
break;
|
|
case "NA":
|
|
testoLetteraSimboloPatrimonio = "!";
|
|
break;
|
|
default:
|
|
testoLetteraSimboloPatrimonio = "";
|
|
break;
|
|
}
|
|
|
|
#endregion
|
|
|
|
return testoLetteraSimboloPatrimonio;
|
|
}
|
|
|
|
///// <summary>
|
|
///// Recupera i colori a partire dal codice area.
|
|
///// </summary>
|
|
///// <param name="area"></param>
|
|
///// <returns></returns>
|
|
private System.Drawing.Color GetColors(string area)
|
|
{
|
|
System.Drawing.Color c = System.Drawing.Color.FromArgb(0, 0, 0);
|
|
|
|
switch (area.ToLower())
|
|
{
|
|
case "inv":
|
|
c = System.Drawing.Color.FromArgb(229, 119, 43);
|
|
break;
|
|
case "ext":
|
|
c = System.Drawing.Color.FromArgb(222, 21, 44);
|
|
break;
|
|
case "ris":
|
|
c = System.Drawing.Color.FromArgb(137, 142, 184);
|
|
break;
|
|
case "liq":
|
|
c = System.Drawing.Color.FromArgb(57, 65, 132);
|
|
break;
|
|
case "pre":
|
|
c = System.Drawing.Color.FromArgb(237, 180, 20);
|
|
break;
|
|
case "pre1":
|
|
c = System.Drawing.Color.FromArgb(237, 180, 20);
|
|
break;
|
|
case "pre2":
|
|
c = System.Drawing.Color.FromArgb(237, 180, 20);
|
|
break;
|
|
case "na":
|
|
c = System.Drawing.Color.FromArgb(192, 192, 216);
|
|
break;
|
|
default:
|
|
c = System.Drawing.Color.FromArgb(166, 166, 166);
|
|
break;
|
|
}
|
|
return c;
|
|
}
|
|
|
|
///// <summary>
|
|
///// Recupera la X, in modo da centrare il simbolo dell'area all'interno del tuo contenitore.
|
|
///// </summary>
|
|
///// <param name="area"></param>
|
|
///// <param name="x"></param>
|
|
///// <returns></returns>
|
|
private float GetX(string area, float x)
|
|
{
|
|
float returnX = x;
|
|
|
|
switch (area.ToLower())
|
|
{
|
|
case "inv":
|
|
returnX = x + 2;
|
|
break;
|
|
case "ext":
|
|
returnX = x + 1;
|
|
break;
|
|
case "ris":
|
|
returnX = x + 1;
|
|
break;
|
|
case "liq":
|
|
returnX = x + 1;
|
|
break;
|
|
case "pre":
|
|
returnX = x + 1;
|
|
break;
|
|
case "pre1":
|
|
returnX = x + 1;
|
|
break;
|
|
case "pre2":
|
|
returnX = x + 1;
|
|
break;
|
|
case "na":
|
|
returnX = x + 2;
|
|
break;
|
|
default:
|
|
returnX = x;
|
|
break;
|
|
}
|
|
return returnX;
|
|
}
|
|
|
|
|
|
//ceTe.DynamicPDF.Merger.ImportedPage page = document.getCurrentPage();
|
|
|
|
//document.setHeaderSpace(78);
|
|
|
|
|
|
//document.setLastPos(tabellaDati.AltezzaTabella);
|
|
#endregion
|
|
}
|
|
}
|