273 lines
12 KiB
C#
273 lines
12 KiB
C#
using System;
|
|
using Consulenza.ReportWriter.Business;
|
|
using Consulenza.ReportWriter.Business.OBJ_PDF;
|
|
using System.Data;
|
|
using Consulenza.ReportCommon;
|
|
using Consulenza.ReportWriter.Business.CHART_PDF;
|
|
using Consulenza.ReportWriter.Business.Entity;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Consulenza.DataServices.fideuram.data.service;
|
|
|
|
namespace Consulenza.ReportWriter.Manager.Section.Unica
|
|
{
|
|
/// <summary>
|
|
/// S48.RischioMercatoMacroAssetClass idSezione = 91
|
|
/// </summary>
|
|
public class S48 : Entity.Section
|
|
{
|
|
ColorPDF coloreSeriePortafoglio = new ColorPDF(255,165,0);
|
|
ColorPDF coloreSerieMonetario = new ColorPDF(172,207,101);
|
|
ColorPDF coloreSerieObbligazionario = new ColorPDF(32, 114, 156);
|
|
ColorPDF coloreSerieAzionario = new ColorPDF(208, 66, 66);
|
|
public S48(EnvironmentFacade environmentFacade, int idSection)
|
|
: base(environmentFacade, idSection)
|
|
{
|
|
try
|
|
{
|
|
Draw();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
SectionLogger.Write("S48", ex.Message, SectionLoggerMessageLevel.E, EnvironmentFacade.ReportEnvironment);
|
|
}
|
|
}
|
|
|
|
protected override sealed void Draw()
|
|
{
|
|
var dati = GetDataTable();
|
|
|
|
#region Grafico Combination
|
|
var graficoCombination = new CombinationPDF(EnvironmentFacade.RendererFacade.XLeftLimit + 56, 1F)
|
|
{
|
|
Height = 200,
|
|
Width = 400,
|
|
|
|
MarginAxisY = 0,
|
|
LabelFormatAxisY = FormatType.Decimale0,
|
|
ShowLabelAxisY = true,
|
|
//IntervalNumberAxisY = 7,
|
|
|
|
LabelFormatAxisX = FormatType.DataShort,
|
|
ShowLineAxisX = true,
|
|
ShowLabelAxisX = true,
|
|
IntervalNumberAxisX = 6,
|
|
RemoveWhiteSpacesY = true,
|
|
EqualDateLabelDistanceAxisX = true,
|
|
AxisYMinimumValueOffset = 0,
|
|
CalculateCustomIntegerLabelsAxisY = true
|
|
};
|
|
|
|
#region Serie
|
|
// Creo le Serie
|
|
var serieCombination = new List<Serie>()
|
|
{
|
|
new Serie { Name = "Portafoglio", Type = Dundas.Charting.WebControl.SeriesChartType.Line, BorderWidth = 6 },
|
|
new Serie { Name = "Monetario", Type = Dundas.Charting.WebControl.SeriesChartType.Line, BorderWidth = 12 },
|
|
new Serie { Name = "Obbligazionario", Type = Dundas.Charting.WebControl.SeriesChartType.Line, BorderWidth = 6},
|
|
new Serie { Name = "Azionario", Type = Dundas.Charting.WebControl.SeriesChartType.Line, BorderWidth = 6}
|
|
};
|
|
|
|
//Valorizzo le Serie
|
|
EnumerableRowCollection datiSerie;
|
|
|
|
#region Serie Portafoglio
|
|
datiSerie = dati.AsEnumerable().Where(o => o.Field<string>("Riferimento").Equals("PTF"));
|
|
foreach (DataRow item in datiSerie)
|
|
{
|
|
serieCombination[0].Points.Add(new Point
|
|
{
|
|
Color = coloreSeriePortafoglio,
|
|
Values = new ValuesPointXY(Convert.ToDateTime(item["Data"]).ToOADate(), Convert.ToDouble(item["VaR"])),
|
|
|
|
ShowLabelAxisY = false,
|
|
LabelAxisY = "Portafoglio",
|
|
FontSizeLabelAxisY = 8,
|
|
FontBoldLabelAxisY = false,
|
|
|
|
ShowLabelAxisX = false
|
|
});
|
|
}
|
|
#endregion
|
|
|
|
#region Serie MercatoMonetario
|
|
datiSerie = dati.AsEnumerable().Where(o => o.Field<string>("Riferimento").Equals("MN"));
|
|
foreach (DataRow item in datiSerie)
|
|
{
|
|
serieCombination[1].Points.Add(new Point
|
|
{
|
|
Color = coloreSerieMonetario,
|
|
Values = new ValuesPointXY(Convert.ToDateTime(item["Data"]).ToOADate(), Convert.ToDouble(item["VaR"])),
|
|
|
|
ShowLabelAxisY = false,
|
|
LabelAxisY = "MercatoMonetario",
|
|
FontSizeLabelAxisY = 8,
|
|
FontBoldLabelAxisY = false,
|
|
|
|
ShowLabelAxisX = false
|
|
});
|
|
}
|
|
#endregion
|
|
|
|
#region Serie MercatoObbligazionario
|
|
datiSerie = dati.AsEnumerable().Where(o => o.Field<string>("Riferimento").Equals("OB"));
|
|
foreach (DataRow item in datiSerie)
|
|
{
|
|
serieCombination[2].Points.Add(new Point
|
|
{
|
|
Color = coloreSerieObbligazionario,
|
|
Values = new ValuesPointXY(Convert.ToDateTime(item["Data"]).ToOADate(), Convert.ToDouble(item["VaR"])),
|
|
|
|
ShowLabelAxisY = false,
|
|
LabelAxisY = "MercatoObbligazionario",
|
|
FontSizeLabelAxisY = 8,
|
|
FontBoldLabelAxisY = false,
|
|
|
|
ShowLabelAxisX = false
|
|
});
|
|
}
|
|
#endregion
|
|
|
|
#region Serie MercatoAzionario
|
|
datiSerie = dati.AsEnumerable().Where(o => o.Field<string>("Riferimento").Equals("AZ"));
|
|
foreach (DataRow item in datiSerie)
|
|
{
|
|
serieCombination[3].Points.Add(new Point
|
|
{
|
|
Color = coloreSerieAzionario,
|
|
Values = new ValuesPointXY(Convert.ToDateTime(item["Data"]).ToOADate(), Convert.ToDouble(item["VaR"])),
|
|
|
|
ShowLabelAxisY = false,
|
|
LabelAxisY = "MercatoAzionario",
|
|
FontSizeLabelAxisY = 8,
|
|
FontBoldLabelAxisY = false,
|
|
|
|
ShowLabelAxisX = false
|
|
});
|
|
}
|
|
#endregion
|
|
|
|
// aggiungo le Serie al grafico
|
|
graficoCombination.SeriesCollection = serieCombination;
|
|
|
|
#endregion
|
|
|
|
#region Etichetta Rischio Credito
|
|
AddElement(new FormattedTextAreaPDF("Rischio Mercato (VaR%)", EnvironmentFacade.RendererFacade.XLeftLimit + 14)
|
|
{
|
|
FontBold = true,
|
|
FontSize = 7,
|
|
TextVerticalDirection = true,
|
|
DeltaY = 155,
|
|
AutoIncrementYWritable = false
|
|
});
|
|
|
|
AddElement(new SpacePDF(10));
|
|
#endregion
|
|
//AddElement(new FormattedTextAreaPDF("Rischio Mercato (VaR%)", EnvironmentFacade.RendererFacade.XLeftLimit)
|
|
//{
|
|
// FontBold = true,
|
|
// TextVerticalDirection = true,
|
|
// AutoIncrementYWritable = false,
|
|
// DeltaY = 169,
|
|
// DeltaX = 45
|
|
//});
|
|
|
|
AddElement(graficoCombination);
|
|
AddElement(new SpacePDF(30));
|
|
|
|
// rettangolo della Legenda
|
|
AddElement(new CirclePDF(9, 9, coloreSeriePortafoglio, 3) { X = graficoCombination.X-40, DeltaY = 6, AutoIncrementYWritable = false });
|
|
AddElement(new FormattedTextAreaPDF(string.Format("Patrimonio {0}", Helper.ReplaceVariables("$/Banca/$", EnvironmentFacade.ReportEnvironment)).Replace("SIM", ""), graficoCombination.X-40 + 10 + 5, 100) {FontSize=7, DeltaY = 5, AutoIncrementYWritable = false });
|
|
|
|
AddElement(new CirclePDF(9, 9, coloreSerieMonetario, 3) { X = graficoCombination.X - 40 + 130, DeltaY = 6, AutoIncrementYWritable = false });
|
|
AddElement(new FormattedTextAreaPDF("Mercato monetario", graficoCombination.X - 40 + 140 + 5, 100) { FontSize = 7, DeltaY = 5, AutoIncrementYWritable = false });
|
|
|
|
AddElement(new CirclePDF(9, 9, coloreSerieObbligazionario, 3) { X = graficoCombination.X - 40 + 250, DeltaY = 6, AutoIncrementYWritable = false });
|
|
AddElement(new FormattedTextAreaPDF("Mercato obbligazionario", graficoCombination.X - 40 + 260 + 5, 120) { FontSize = 7, DeltaY = 5, AutoIncrementYWritable = false });
|
|
|
|
AddElement(new CirclePDF(9, 9, coloreSerieAzionario, 3) { X = graficoCombination.X - 40 + 390, DeltaY = 6, AutoIncrementYWritable = false });
|
|
AddElement(new FormattedTextAreaPDF("Mercato azionario", graficoCombination.X - 40 + 400 + 5, 100) { FontSize = 7, DeltaY = 5, AutoIncrementYWritable = false });
|
|
|
|
AddElement(new SpacePDF(25)); // pari all'altezza del rettangolo grigio + 5 per lasciare un piccolo margine$/Banca/$
|
|
if (datiSeiUnico.rischioUnit().rischio.mercatiFinanziariMacroAsset.flagfiduciariaPluriMandato)
|
|
{
|
|
AddElement(new SpacePDF(10));
|
|
string codicemandato = datiSeiUnico.getClienteReport().codiceMandato;
|
|
AddElement(new FormattedTextAreaPDF(datiSeiUnico.FormatBanca("L'indicatore «Rischio Mercato (VaR)» del patrimonio $/Banca/$ visualizzato nel grafico è calcolato considerando tutti i prodotti detenuti dai mandati fiduciari associati al medesimo fiduciante a cui appartiene il mandato "+ codicemandato+"."), EnvironmentFacade.RendererFacade.XLeftLimit) { FontSize = 6, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Justify });
|
|
}
|
|
#endregion
|
|
}
|
|
|
|
/// <summary>
|
|
/// Recupera i dati necessari alla Section restituendo un DataTable.
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
protected sealed override DataTable GetDataTable()
|
|
{
|
|
|
|
var mercatiFinanziatiMacroAsset = datiSeiUnico.rischioUnit().rischio.mercatiFinanziariMacroAsset;
|
|
|
|
var returnList = new List<VaRPerData>();
|
|
var listaMercatoAzionario = new List<rdrRmiStoricoBean>();
|
|
var listaMercatoMonetario = new List<rdrRmiStoricoBean>();
|
|
var listaMercatoObbligazionario = new List<rdrRmiStoricoBean>();
|
|
var listaVarPtfCliente = new List<varPtfClienteBean>();
|
|
|
|
listaMercatoAzionario = mercatiFinanziatiMacroAsset.listaMercatoAzionario.data.ToList();
|
|
|
|
listaMercatoMonetario = mercatiFinanziatiMacroAsset.listaMercatoMonetario.data.ToList();
|
|
listaMercatoObbligazionario = mercatiFinanziatiMacroAsset.listaMercatoObbligazionario.data.ToList();
|
|
if (mercatiFinanziatiMacroAsset.listaVarPtfCliente.data != null)
|
|
listaVarPtfCliente = mercatiFinanziatiMacroAsset.listaVarPtfCliente.data.ToList();
|
|
|
|
foreach (var item in listaMercatoAzionario)
|
|
returnList.Add(new VaRPerData { Data = item.dataRiferimento, VaR = item.var, Riferimento = "AZ" });
|
|
|
|
foreach (var item in listaMercatoMonetario)
|
|
returnList.Add(new VaRPerData { Data = item.dataRiferimento, VaR = item.var, Riferimento = "MN" });
|
|
|
|
foreach (var item in listaMercatoObbligazionario)
|
|
returnList.Add(new VaRPerData { Data = item.dataRiferimento, VaR = item.var, Riferimento = "OB" });
|
|
|
|
foreach (var item in listaVarPtfCliente)
|
|
returnList.Add(new VaRPerData { Data = item.dataRiferimento, VaR = item.var, Riferimento = "PTF" });
|
|
|
|
var dtMercati = new DataTable();
|
|
dtMercati.Columns.Add(new DataColumn("Riferimento", typeof(string)));
|
|
dtMercati.Columns.Add(new DataColumn("Data", typeof(DateTime)));
|
|
dtMercati.Columns.Add(new DataColumn("VaR", typeof(decimal)));
|
|
|
|
|
|
//coloreSeriePortafoglio = new ColorPDF(ptf.fill.);
|
|
foreach (var item in returnList)
|
|
{
|
|
|
|
dtMercati.Rows.Add(item.Riferimento, item.Data, item.VaR);
|
|
}
|
|
|
|
return dtMercati;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Recupera i dati necessari alla Section restituendo un DataSet.
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
protected sealed override DataSet GetDataSet()
|
|
{
|
|
return null;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Struttura
|
|
/// </summary>
|
|
private struct VaRPerData
|
|
{
|
|
public DateTime Data { get; set; }
|
|
public decimal VaR { get; set; }
|
|
public string Riferimento { get; set; }
|
|
}
|
|
|
|
}
|
|
}
|