using System;
using Consulenza.ReportWriter.Business;
using Consulenza.ReportWriter.Business.OBJ_PDF;
using System.Data;
using Consulenza.ReportCommon;
using System.Linq;
using System.Collections.Generic;
using Consulenza.ReportWriter.Business.Entity;
using Consulenza.DataServices.fideuram.data.service;
namespace Consulenza.ReportWriter.Manager.Section.Unica
{
public class S41 : Entity.Section
{
///
///S41.ContributoalRischioAreeProgettiDettaglioProdotti idSezione = 84
///
public S41(EnvironmentFacade environmentFacade, int idSection)
: base(environmentFacade, idSection)
{
try
{
Draw();
}
catch (Exception ex)
{
SectionLogger.Write("S41", ex.Message, SectionLoggerMessageLevel.E, EnvironmentFacade.ReportEnvironment);
}
}
protected override sealed void Draw()
{
var dati = GetDataSet();
if (TestoIntroduttivo().Length > 0)
{
AddElement(new SpacePDF(20));
AddElement(new FormattedTextAreaPDF(TestoIntroduttivo(), EnvironmentFacade.RendererFacade.XLeftLimit) { FontSize = 7, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Justify });
AddElement(new SpacePDF(10));
}
int i = 0;
if (dati.Tables["piramide"].Rows.Count > 0)
{
#region Tabella delle Aree di Bisogno
#region Definizione e Creazione
var tabellaAree = new TablePDF(EnvironmentFacade.RendererFacade.XLeftLimit, dati.Tables["piramide"])//, dati.Tables["piramideFooter"])
{
Style = Style.ConsulenzaUnica,
AlternateRow = false,
ShowSeparationLines = false,
RowsPadding = 10,
HideLastSeparationLine = false,
Footer = false
};
tabellaAree.Columns.Add(new ColumnPDF("Area2", 125, HorizontalAlignmentType.Sinistra, false, false, 7, ColumnType.Objectpdf, "Area", "Area di bisogno") { HeaderFontSize = 7, FontSize = 7, DeltaYContent = 2, ScaleColumnTypeImage = 0.5F });
tabellaAree.Columns.Add(new ColumnPDF("ControvaloreAttuale", 77, HorizontalAlignmentType.Sinistra, false, false, 7, ColumnType.Decimale, "ControvaloreAttuale", "Controvalore
attuale (€)") { HeaderFontSize = 7, FontSize = 7, DeltaYContent = 4, HeaderPaddingLeft = 25 });
tabellaAree.Columns.Add(new ColumnPDF("VaR", 50, HorizontalAlignmentType.Sinistra, false, false, 7, ColumnType.Testo, "Var", "VaR (%)") { HeaderFontSize = 7, FontSize = 7, DeltaYContent = 4, PaddingRight = 11, HeaderPaddingLeft = 10 });
tabellaAree.Columns.Add(new ColumnPDF("PesoRelativoObject", 135, HorizontalAlignmentType.Destra, false, false, 7, ColumnType.Objectpdf, "PesoRelativo", "Peso relativo (%)") { HeaderFontSize = 7, FontSize = 7, DeltaYContent = 4, HeaderPaddingRight = 5 });
tabellaAree.Columns.Add(new ColumnPDF("RischioRelativoObject", 135, HorizontalAlignmentType.Sinistra, false, false, 7, ColumnType.Objectpdf, "RischioRelativo", "Rischio relativo (%)") { HeaderFontSize = 7, FontSize = 7, DeltaYContent = 4, PaddingLeft = 10, HeaderPaddingLeft = 10 });
#endregion
#region Allineamento Celle Numeriche a destra
int a = 0;
foreach (var item in dati.Tables["piramide"].Rows)
{
tabellaAree.Cells[1, a].HorizontalAlignment = HorizontalAlignmentType.Destra;
tabellaAree.Cells[2, a].HorizontalAlignment = HorizontalAlignmentType.Destra;
//tabellaAree.Cells[3, a].HorizontalAlignment = HorizontalAlignmentType.Destra;
tabellaAree.Cells[0, a].ValueObjectList.Add(new ImagePDF(0, 1, dati.Tables["piramide"].Rows[a].ItemArray[0].ToString())
{
DeltaX = 3,
DeltaY = 0,
Scale = 0.66f,
Height = 27,
Width = 145
});
var textArea = new FormattedTextAreaPDF(dati.Tables["piramide"].Rows[a].ItemArray[1].ToString(), 0)
{
DeltaY = 8f,
FontSize = 8f
};
var labelSize = Helper.GetNumericStringWidth(textArea.Text);
float addition = 0;
switch (textArea.Text)
{
case "Investimento":
case "Previdenza":
addition = 3;
break;
case "Riserva":
addition = 2;
break;
case "Liquidità":
addition = 1;
break;
case "Extra Rendimento":
addition = 6;
break;
}
textArea.DeltaX = 76 + addition - labelSize;
textArea.Text = Helper.FirstCharToUpper(textArea.Text);
tabellaAree.Cells[0, a].ValueObjectList.Add(textArea);
a++;
}
#endregion
#region Creazione Stacked Bar
var list = new List();
list.Add(Convert.ToDouble(dati.Tables["piramide"].AsEnumerable().Max(x => x["PesoRelativo"])));
list.Add(Convert.ToDouble(dati.Tables["piramide"].AsEnumerable().Max(x => x["RischioRelativo"])));
var valoreMassimo = (float)Helper.Round(list.Max());
float larghezzaBarra = 0;
float larghezzaSpazioTestoPercentuale = 0;
float larghezzaMinimaSpazioTestoPercentuale = 35;
float deltaXBarra = 0;
float width = tabellaAree.Columns[3].Width - 50;
foreach (DataRow row in dati.Tables["piramide"].Rows)
{
var colore = new ColorPDF(Convert.ToInt32(row["Red"]), Convert.ToInt32(row["Green"]), Convert.ToInt32(row["Blue"]));
#region barra colonna PesoRelativo
larghezzaBarra = Helper.GetWidthProportional((float)Convert.ToDecimal(row["PesoRelativo"]), valoreMassimo, tabellaAree.Columns[3].Width - 50);
larghezzaSpazioTestoPercentuale = tabellaAree.Columns[3].Width - larghezzaBarra;
deltaXBarra = -larghezzaBarra - 10;
if (larghezzaSpazioTestoPercentuale < larghezzaMinimaSpazioTestoPercentuale)
{
deltaXBarra = -(tabellaAree.Columns[3].Width - larghezzaMinimaSpazioTestoPercentuale);
larghezzaSpazioTestoPercentuale = larghezzaMinimaSpazioTestoPercentuale;
}
if (Convert.ToDouble(row["ControvaloreAttuale"]) == 0)
{
tabellaAree.Cells[3, i].ValueObjectList = new List()
{
new RectanglePDF(12, 1 , ColorPDF.Bianco),
new FormattedTextAreaPDF(row["PesoRelativo"].ToString()=="0.00"? "0.00" : Helper.FormatDecimal(Convert.ToDecimal(row["PesoRelativo"]).ToString(), 2),
0, larghezzaSpazioTestoPercentuale)
{
DeltaY = 2,
TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Right,
DeltaX = deltaXBarra,
FontSize = 7
}
};
}
else
{
tabellaAree.Cells[3, i].ValueObjectList = new List()
{
new RectanglePDF(12, larghezzaBarra , colore),
new FormattedTextAreaPDF(row["PesoRelativo"].ToString()=="0.00"? "0.00" : Helper.FormatDecimal(Convert.ToDecimal(row["PesoRelativo"]).ToString(), 2),
0, larghezzaSpazioTestoPercentuale)
{
DeltaY = 2,
TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Right,
DeltaX = deltaXBarra,
FontSize = 7
}
};
}
#endregion
#region barra colonna RischioRelativo
larghezzaBarra = Helper.GetWidthProportional((float)Convert.ToDecimal(row["RischioRelativo"]), valoreMassimo, tabellaAree.Columns[4].Width - 50);
larghezzaSpazioTestoPercentuale = tabellaAree.Columns[4].Width - larghezzaBarra;
deltaXBarra = larghezzaBarra + 10;
if (larghezzaSpazioTestoPercentuale < larghezzaMinimaSpazioTestoPercentuale)
{
deltaXBarra = (tabellaAree.Columns[4].Width - larghezzaMinimaSpazioTestoPercentuale);
larghezzaSpazioTestoPercentuale = larghezzaMinimaSpazioTestoPercentuale;
}
if (row["VaR"].ToString() == "n.c.")
{
tabellaAree.Cells[4, i].ValueObjectList = new List()
{
new RectanglePDF(12, 1, ColorPDF.Bianco),
new FormattedTextAreaPDF( "n.c.",
0,
30 )
{
DeltaY = 2,
TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Left,
DeltaX = deltaXBarra,
FontSize = 7
}
};
}
else
{
tabellaAree.Cells[4, i].ValueObjectList = new List()
{
new RectanglePDF(12, larghezzaBarra, colore),
new FormattedTextAreaPDF( Helper.FormatDecimal(Convert.ToDecimal(row["Rischiorelativo"]).ToString(), 2),
0,
larghezzaSpazioTestoPercentuale)
{
DeltaY = 2,
TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Left,
DeltaX = deltaXBarra,
FontSize = 7
}
};
}
#endregion
i++;
}
#endregion
AddElement(tabellaAree);
if (dati.Tables["piramideFooter"].Rows.Count > 0)
{
AddElement(new SpacePDF(2));
AddElement(new LinePDF(EnvironmentFacade.RendererFacade.XLeftLimit - 0.5F, EnvironmentFacade.RendererFacade.XLeftLimit + 252.5f, 0.9f, new ColorPDF(127, 127, 127)));
var tabellaCCN = new TablePDF(EnvironmentFacade.RendererFacade.XLeftLimit, dati.Tables["piramideFooter"])
{
Style = Style.ConsulenzaUnica,
Header = false,
AlternateRow = false,
HeaderHeight = 1,
HeaderMargin = 2,
HideLastSeparationLine = true,
ShowSeparationLines = false,
Footer = false
};
tabellaCCN.Columns.Add(new ColumnPDF("Patrimonio", 125, HorizontalAlignmentType.Sinistra, false, false, 7, ColumnType.Testo, "Area", "") { HeaderFontSize = 7, FontSize = 7 });
tabellaCCN.Columns.Add(new ColumnPDF("Controvalore", 77, HorizontalAlignmentType.Destra, false, false, 7, ColumnType.Decimale, "ControvaloreAttuale", "") { HeaderFontSize = 7, FontSize = 7, PaddingLeft = 2 });
tabellaCCN.Columns.Add(new ColumnPDF("VaR", 50, HorizontalAlignmentType.Destra, false, false, 7, ColumnType.Decimale, "Var", "") { HeaderFontSize = 7, FontSize = 7, PaddingRight = 7 });
AddElement(tabellaCCN);
#region Nota tabella 1
if (GetNota().Length > 0)
{
tabellaCCN.Notes.Add(
new TableNotePDF(TableNotePDF.TableNotePositionType.PièDiTabella,
GetNota(),
new[] { "VaR" },
string.Empty,
TableNotePDF.TableNoteAsteriskPositionType.PieDiTabella)
{ FontSize = 6, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Justify });
AddElement(new SpacePDF(10));
}
#endregion
}
#endregion
}
if (dati.Tables["prodotti"].Rows.Count > 0)
{
#region Tabella Prodotti
#region Definizione e Creazione
var tabellaProdotti = new TablePDF(EnvironmentFacade.RendererFacade.XLeftLimit, dati.Tables["prodotti"])
{
Style = Style.ConsulenzaUnica,
AlternateRow = false,
ShowSeparationLines = false,
Footer = false,
HideLastSeparationLine = true
//,RowHeight = 22
};
// 188
tabellaProdotti.Columns.Add(new ColumnPDF("Immagine", 188, HorizontalAlignmentType.Sinistra, false, false, 7, ColumnType.Objectpdf, string.Empty, "Prodotto") { HeaderFontSize = 7, FontSize = 7, DeltaYContent = 4, PaddingLeft = 2 });
// tabellaProdotti.Columns.Add(new ColumnPDF("Prodotto", 155, HorizontalAlignmentType.Sinistra, false, false, 7, ColumnType.Objectpdf, "", "Prodotto") { HeaderFontSize = 7, FontSize = 7, PaddingLeft = 5 });
// Modifica per Saving Map
//tabellaProdotti.Columns.Add(new ColumnPDF("SavingMap", 10, HorizontalAlignmentType.Destra, false, false, 6, ColumnType.Immagine, "SavingMap", string.Empty) { DeltaYContent = 6, ScaleColumnTypeImage = 0.50F, PaddingRight = 20 });
// Fine Modifica
tabellaProdotti.Columns.Add(new ColumnPDF("ControvaloreAttuale", 90, HorizontalAlignmentType.Sinistra, false, false, 7, ColumnType.Decimale, "ControvaloreAttuale", "Controvalore
attuale (€)") { HeaderFontSize = 7, FontSize = 7, HeaderPaddingLeft = 6 });
tabellaProdotti.Columns.Add(new ColumnPDF("VaR", 40, HorizontalAlignmentType.Sinistra, false, false, 7, ColumnType.Testo, "VaR", "VaR (%)") { HeaderFontSize = 7, FontSize = 7, PaddingRight = 6, HeaderPaddingLeft = 6 });
tabellaProdotti.Columns.Add(new ColumnPDF("PesoRelativoObject", 100, HorizontalAlignmentType.Destra, false, false, 7, ColumnType.Objectpdf, "PesoRelativo", "Peso relativo (%)") { HeaderFontSize = 7, FontSize = 7, HeaderPaddingRight = 10, DeltaYContent = 4 });
tabellaProdotti.Columns.Add(new ColumnPDF("RischioRelativoObject", 100, HorizontalAlignmentType.Sinistra, false, false, 7, ColumnType.Objectpdf, "RischioRelativo", "Rischio relativo (%)") { HeaderFontSize = 7, FontSize = 7, PaddingLeft = 10, HeaderPaddingLeft = 10, DeltaYContent = 4 });
#endregion
#region Allineamento Celle Numeriche a destra
int a = 0;
foreach (var item in dati.Tables["prodotti"].Rows)
{
tabellaProdotti.Cells[1, a].HorizontalAlignment = HorizontalAlignmentType.Destra;
tabellaProdotti.Cells[2, a].HorizontalAlignment = HorizontalAlignmentType.Destra;
//tabellaProdotti.Cells[4, a].HorizontalAlignment = HorizontalAlignmentType.Destra;
a++;
}
#endregion
#region Creazione Stacked Bar
i = 0;
var list = new List();
list.Add(Convert.ToDouble(dati.Tables["prodotti"].AsEnumerable().Max(x => x["PesoRelativo"])));
list.Add(Convert.ToDouble(dati.Tables["prodotti"].AsEnumerable().Max(x => x["RischioRelativo"])));
float valoreMassimo = (float)Helper.Round(list.Max());
float larghezzaBarra = 0;
float larghezzaSpazioTestoPercentuale = 0;
float larghezzaMinimaSpazioTestoPercentuale = 35;
float deltaXBarra = 0;
foreach (DataRow row in dati.Tables["prodotti"].Rows)
{
var colore = new ColorPDF(131, 188, 180);
#region simboli dell'area di bisogno nella prima colonna
float deltaXSwitch;
float deltaYSwitch;
switch (row["CodiceAreaBisogno"].ToString().ToUpper())
{
case "EXT":
deltaXSwitch = 1.5F;
deltaYSwitch = -0.3F;
break;
case "INV":
deltaXSwitch = 2.2F;
deltaYSwitch = -0.4F;
break;
case "PRE":
deltaXSwitch = 1.8F;
deltaYSwitch = -0.3F;
break;
case "RIS":
deltaXSwitch = 1.3F;
deltaYSwitch = -0.3F;
break;
case "LIQ":
deltaXSwitch = 1.5F;
deltaYSwitch = -0.2F;
break;
default:
deltaXSwitch = 2;
deltaYSwitch = 0;
break;
}
// tabellaProdotti.Cells[0, i].ColSpan = 2;
var listaOggetti = new List {
new RectanglePDF(8, 8, ColorPDF.GetBy_AreaBisogno(row["CodiceAreaBisogno"].ToString())),
new FormattedTextAreaPDF
{
Text = new AreaBisogno(row["CodiceAreaBisogno"].ToString()).Abbreviazione,
FontBold = true,
FontColor = ColorPDF.Bianco,
DeltaX = deltaXSwitch,
DeltaY = deltaYSwitch,
FontSize=7
},
new ImagePDF(0, 1, row["SavingMap"].ToString())
{
DeltaX = deltaXSwitch + 4,
DeltaY = deltaYSwitch + 10,
Scale = 0.7f
},
new FormattedTextAreaPDF
{
Text = row["Prodotto"].ToString(),
FontBold = false,
FontColor = ColorPDF.Nero,
DeltaX = 22,
FontSize=7,
Width=170
}
};
tabellaProdotti.Cells[0, i].ValueObjectList.AddRange(listaOggetti);
#endregion
#region barra colonna PesoRelativo
larghezzaBarra = Helper.GetWidthProportional((float)Convert.ToDecimal(row["PesoRelativo"]), valoreMassimo, tabellaProdotti.Columns[3].Width - 50);
larghezzaSpazioTestoPercentuale = tabellaProdotti.Columns[3].Width - larghezzaBarra;
deltaXBarra = -larghezzaBarra - 10;
if (larghezzaSpazioTestoPercentuale < larghezzaMinimaSpazioTestoPercentuale)
{
deltaXBarra = -(tabellaProdotti.Columns[3].Width - larghezzaMinimaSpazioTestoPercentuale);
larghezzaSpazioTestoPercentuale = larghezzaMinimaSpazioTestoPercentuale;
}
tabellaProdotti.Cells[3, i].ValueObjectList = new List()
{
new RectanglePDF(11, larghezzaBarra , colore),
new FormattedTextAreaPDF(row["PesoRelativo"].ToString()=="0.00"? "0.00" : Helper.FormatDecimal(Convert.ToDecimal(row["PesoRelativo"]).ToString(), 2),
0,
larghezzaSpazioTestoPercentuale)
{
TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Right,
DeltaX = deltaXBarra,
FontSize = 7
}
};
#endregion
#region barra colonna RischioRelativo
larghezzaBarra = Helper.GetWidthProportional((float)Convert.ToDecimal(row["RischioRelativo"]), valoreMassimo, tabellaProdotti.Columns[4].Width - 50);
larghezzaSpazioTestoPercentuale = tabellaProdotti.Columns[4].Width - larghezzaBarra;
deltaXBarra = larghezzaBarra + 10;
if (larghezzaSpazioTestoPercentuale < larghezzaMinimaSpazioTestoPercentuale)
{
deltaXBarra = (tabellaProdotti.Columns[4].Width - larghezzaMinimaSpazioTestoPercentuale);
larghezzaSpazioTestoPercentuale = larghezzaMinimaSpazioTestoPercentuale;
}
if (row["VaR"].ToString() == "n.c.")
{
tabellaProdotti.Cells[4, i].ValueObjectList = new List()
{
new RectanglePDF(11, 1, ColorPDF.Bianco),
new FormattedTextAreaPDF( "n.c.",
0,
30 )
{
TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Left,
DeltaX = deltaXBarra-5,
FontSize = 7
}
};
}
else
{
tabellaProdotti.Cells[4, i].ValueObjectList = new List()
{
new RectanglePDF(11,row["RischioRelativo"].ToString()=="0" ? 1 : larghezzaBarra,row["RischioRelativo"].ToString()=="0" ?ColorPDF.Bianco : colore),
new FormattedTextAreaPDF(row["RischioRelativo"].ToString()=="0"? "0,00" : Helper.FormatDecimal(Convert.ToDecimal(row["RischioRelativo"]).ToString(), 2),
0,
larghezzaSpazioTestoPercentuale )
{
TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Left,
DeltaX = deltaXBarra,
FontSize = 7
}
};
}
#endregion
i++;
}
AddElement(new SpacePDF(10));
#endregion
AddElement(tabellaProdotti);
#endregion
#region Legenda
AddElement(new SpacePDF(20));
float xLegenda = base.EnvironmentFacade.RendererFacade.XLeftLimit;
DataTable dtlegenda = new DataTable();
dtlegenda = dati.Tables["legenda"].AsEnumerable().OrderBy(r => r.Field("Ordinamento")).CopyToDataTable();
foreach (DataRow item in dtlegenda.Rows)
{
AddElement(new RectanglePDF(8, 8, ColorPDF.GetBy_AreaBisogno(item["CodiceAreaBisogno"].ToString())) { X = xLegenda, AutoIncrementYWritable = false });
AddElement(new FormattedTextAreaPDF
{
Text = new AreaBisogno(item["CodiceAreaBisogno"].ToString()).Abbreviazione,
FontBold = true,
FontColor = ColorPDF.Bianco,
DeltaX = 2F,
AutoIncrementYWritable = false,
X = xLegenda,
FontSize = 6
});
xLegenda += 10;
var ftaNomeAreaBisogno = new FormattedTextAreaPDF
{
Text = new AreaBisogno(item["CodiceAreaBisogno"].ToString()).Nome,
DeltaX = 2F,
AutoIncrementYWritable = false,
X = xLegenda,
FontSize = 6
};
xLegenda += (ftaNomeAreaBisogno.Text.Length * 5) + (10 - ftaNomeAreaBisogno.Text.Length);
//xLegenda += (string)Unit.Pixel(new AreaBisogno(item["CodiceAreaBisogno"].ToString()).Nome.Length + 10);
//xLegenda += Graphics.MeasureString(new AreaBisogno(item["CodiceAreaBisogno"].ToString()).Nome, 7);//ftaNomeAreaBisogno.Width + 10; //new AreaBisogno(item["CodiceAreaBisogno"].ToString()).Nome.Length + 50;//100;
AddElement(ftaNomeAreaBisogno);
}
#endregion
}
}//Draw
protected sealed override DataTable GetDataTable()
{
return null;
}//GetDataTable
protected sealed override DataSet GetDataSet()
{
#region Creazione Dataset
var ds = new DataSet();
ds.Tables.Add(new DataTable("piramide"));
ds.Tables.Add(new DataTable("piramideFooter"));
ds.Tables.Add(new DataTable("prodotti"));
ds.Tables.Add(new DataTable("legenda"));
#endregion
#region Estrazione dati
var pianificazioneVerticale = datiSeiUnico.pianificazioneUnit().pianificazioneVerticale;
var rischioAreeProgetti = datiSeiUnico.rischioUnit().rischio.areeProgetti.aree.ToList();
var totale = datiSeiUnico.rischioUnit().rischio.areeProgetti.total;
var financialResources = datiSeiUnico.rischioUnit().rischio.areeProgetti.financialResources;
var displayInfo = datiSeiUnico.displayInfos().areeDisplayInfos.ToList();
var posizioni = datiSeiUnico.patrimonioUnit().patrimonioCasa.dettaglioProdotti.dettaglioProdotti.ToList();
var rischioProdotti = datiSeiUnico.rischioUnit().rischio.prodotti.items;
//gestito per i nuclei
var rischioProdottiNucleo = datiSeiUnico.rischioUnit().rischio.rischioRelativoDistAsset.classes;
#endregion
//r model = EnvironmentFacade.ReportEnvironment.ReportType
#region *** dtPiramide
ds.Tables["piramide"].Columns.Add(new DataColumn("Area", typeof(string)));
ds.Tables["piramide"].Columns.Add(new DataColumn("Descirption", typeof(string)));
ds.Tables["piramide"].Columns.Add(new DataColumn("VaR", typeof(string)));
ds.Tables["piramide"].Columns.Add(new DataColumn("ControvaloreAttuale", typeof(decimal)));
ds.Tables["piramide"].Columns.Add(new DataColumn("PesoRelativo", typeof(decimal)));
ds.Tables["piramide"].Columns.Add(new DataColumn("RischioRelativo", typeof(decimal)));
ds.Tables["piramide"].Columns.Add(new DataColumn("Red", typeof(int)));
ds.Tables["piramide"].Columns.Add(new DataColumn("Green", typeof(int)));
ds.Tables["piramide"].Columns.Add(new DataColumn("Blue", typeof(int)));
if (presenzaGrafico())
{
foreach (var item in rischioAreeProgetti)
{
var colore = new ColorPDF(displayInfo.FirstOrDefault(o => o.key.Equals(item.area.ToUpper())).value.fill);
ds.Tables["piramide"].Rows.Add(
string.Format("{0}.png", new AreaBisogno(item.area).NomePerImmagine), //area
item.name, // description
item.var, //var
item.currentEquivalent, //controvalore attuale
item.relativeWeight,//peso relativo
item.relativeRisk, //rischio relativo
colore.Red,
colore.Green,
colore.Blue
);
}
}
#endregion
#region *** dtPiramideFooter
// 20181010 AC
//#region OC + CCN + Eligo
#region OC + CCN + Eligo + IlTuoFoglio
//--20181010 AC
var listReturn = new List();
if (datiSeiUnico.CASA_OC != 0)
listReturn.Add(new rsPosizione { prodotto = new rsProdotto() { nomeProdotto = "Operazioni in corso" }, ctv = datiSeiUnico.CASA_OC });
if (datiSeiUnico.CASA_CCN != 0)
listReturn.Add(new rsPosizione { prodotto = new rsProdotto() { nomeProdotto = "Conto corrente" }, ctv = datiSeiUnico.CASA_CCN });
if (datiSeiUnico.CASA_GPELIGO != 0)
listReturn.Add(new rsPosizione { prodotto = new rsProdotto() { nomeProdotto = "Liquidità negativa GP Eligo" }, ctv = datiSeiUnico.CASA_GPELIGO });
// 20181010 AC
if (datiSeiUnico.CASA_TUOFOGLIO != 0)
listReturn.Add(new rsPosizione { prodotto = new rsProdotto() { nomeProdotto = "Liquidità negativa Il Mio Foglio" }, ctv = datiSeiUnico.CASA_TUOFOGLIO });
//--20181010 AC
#endregion
ds.Tables["piramideFooter"].Columns.Add(new DataColumn("Area", typeof(string)));
ds.Tables["piramideFooter"].Columns.Add(new DataColumn("ControvaloreAttuale", typeof(decimal)));
ds.Tables["piramideFooter"].Columns.Add(new DataColumn("Var", typeof(string)));
ds.Tables["piramideFooter"].Columns.Add(new DataColumn("FontBold", typeof(bool)));
if (listReturn.Count > 0)
{
ds.Tables["piramideFooter"].Rows.Add(
"Totale risorse allocate",
datiSeiUnico.CASA_SUBTOTALE,
financialResources.var,
true
//true,
//true
);
foreach (var item in listReturn)
{
ds.Tables["piramideFooter"].Rows.Add(
item.prodotto.nomeProdotto, //Colonna1
item.ctv, //Colonna3
item.prodotto.nomeProdotto.Equals("Conto corrente") || item.prodotto.nomeProdotto.Contains("Operazioni") ? "n.c." : "-", //Colonna4
false
//false,
//false
);
}
}
ds.Tables["piramideFooter"].Rows.Add(
string.Format("Patrimonio {0}", Helper.ReplaceVariables("$/Banca/$", EnvironmentFacade.ReportEnvironment)),
datiSeiUnico.CASA_TOTALE,
totale.var + (GetNota().Length > 0 ? "*" : ""),
true
//true,
//true
);
#endregion
#region *** dtProdotti
ds.Tables["prodotti"].Columns.Add(new DataColumn("CodiceAreaBisogno", typeof(string)));
ds.Tables["prodotti"].Columns.Add(new DataColumn("SavingMap", typeof(string)));
ds.Tables["prodotti"].Columns.Add(new DataColumn("Prodotto", typeof(string)));
ds.Tables["prodotti"].Columns.Add(new DataColumn("ControvaloreAttuale", typeof(decimal)));
ds.Tables["prodotti"].Columns.Add(new DataColumn("VaR", typeof(string)));
ds.Tables["prodotti"].Columns.Add(new DataColumn("PesoRelativo", typeof(decimal)));
ds.Tables["prodotti"].Columns.Add(new DataColumn("RischioRelativo", typeof(decimal)));
// La gestione del rischio tra Nucelo e non Nucelo sono diverse i dati del rischio relativo sono su Unit Diverse
#region Prodotti per Nucleo
//if (EnvironmentFacade.ReportEnvironment.ReportType.ToString() == "Unica_Nucleo")
//{
// foreach (var item in rischioProdottiNucleo.Take(numeroProdotti() == ProdottiPatrimonio.PrimiDieci ? 10 : rischioProdottiNucleo.Length).OrderByDescending(o => o.relativeRisk))
// {
// if (presenzaTabella())
// {
// ds.Tables["prodotti"].Rows.Add(
// "",//posizioni.FirstOrDefault(o => o.chiavePosizionePortafoglio.Equals(item.id)).area,//area
// item.name,// prodotto
// item.currentEquivalent,// Controvalore attuale
// item.var,// var
// item.relativeWeight,//peso relativo
// //Convert.ToDouble(item.relativeRisk) == 0 ? 0.00 : Convert.ToDouble(item.relativeRisk)//rischio relativo
// item.relativeRisk * 100 // aggiunto * 100 09102017
// );
// }
// }
//}
//else
//{
#endregion
foreach (var item in rischioProdotti.Take(numeroProdotti() == ProdottiPatrimonio.PrimiDieci ? 10 : rischioProdotti.Length).OrderByDescending(o => o.relativeRisk))
{
if (presenzaTabella())
{
string sSavingMap = "";
// Modifica per Saving Map
if (posizioni.FirstOrDefault(o => o.chiavePosizionePortafoglio.Equals(item.aggregationId)).savingMap)//SavingMap
//if (dettaglioProdotto.prodotto.nomeProdotto.Substring(0, 2).ToUpper() =="FV")
sSavingMap = "SavingMap.png";
// Fine Modifica
ds.Tables["prodotti"].Rows.Add(
posizioni.FirstOrDefault(o => o.chiavePosizionePortafoglio.Equals(item.aggregationId)).area,//area
sSavingMap,
item.name,// prodotto
item.currentEquivalent,// Controvalore attuale
item.var,// var
item.relativeWeight,//peso relativo
//Convert.ToDouble(item.relativeRisk) == 0 ? 0.00 : Convert.ToDouble(item.relativeRisk)//rischio relativo
item.relativeRisk * 100 // aggiunto * 100 09102017
);
}
}
// }
#endregion
#region *** dtLegenda
ds.Tables["legenda"].Columns.Add(new DataColumn("CodiceAreaBisogno", typeof(string)));
ds.Tables["legenda"].Columns.Add(new DataColumn("Ordinamento", typeof(int)));
if (presenzaTabella())
{
foreach (DataRow item in ds.Tables["prodotti"].DefaultView.ToTable(true, "CodiceAreaBisogno").Rows)
{
ds.Tables["legenda"].Rows.Add(item["CodiceAreaBisogno"],
displayInfo.FirstOrDefault(o => o.key.Equals(item["CodiceAreaBisogno"].ToString().ToUpper())).value.order);
}
}
#endregion
return ds;
}
public virtual string TestoIntroduttivo()
{
string testo = "";
if (presenzaGrafico())
{
if (presenzaTabella())
testo = (numeroProdotti() == ProdottiPatrimonio.Tutti) ?
GetText().Rows[0]["testo2"].ToString() :
GetText().Rows[0]["testo1"].ToString();
else
testo = GetText().Rows[0]["testo3"].ToString();
}
else
{
if (presenzaTabella())
testo = (numeroProdotti() == ProdottiPatrimonio.Tutti) ?
GetText().Rows[0]["testo4"].ToString() :
GetText().Rows[0]["testo5"].ToString();
}
return Helper.ReplaceVariables(testo, base.EnvironmentFacade.ReportEnvironment);
}//TestoIntroduttivo
public virtual string GetNota()
{
string nota = "";
var totale = datiSeiUnico.rischioUnit().rischio.areeProgetti.total;
if (totale.coverage < 100)
{
nota = string.Format("Grado di copertura prodotti in termini di Rischio Mercato (VaR): {0}", Helper.FormatDecimal(totale.coverage.ToString(), 2));
}
return nota;
}//GetNota
public virtual bool presenzaGrafico()
{
return GetOption().Valore;
}
public virtual bool presenzaTabella()
{
return GetOption().Valore;
}
public virtual ProdottiPatrimonio numeroProdotti()
{
ProdottiPatrimonio numProdotti = GetOption().ProdottiPatrimonio;
return numProdotti;
}
}
}