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 System.Collections.Generic; using Consulenza.ReportWriter.Business.Entity; using System.Linq; using Consulenza.DataServices.fideuram.data.service; using Dundas.Charting.WebControl; namespace Consulenza.ReportWriter.Manager.Section.Unica { public class S67 : Entity.Section { /// /// S67.MonitoraggioAreaLiquidita idSezione = 110 /// public S67(EnvironmentFacade environmentFacade, int idSection) : base(environmentFacade, idSection) { try { Draw(); } catch (Exception ex) { SectionLogger.Write("S67", ex.Message, SectionLoggerMessageLevel.E, EnvironmentFacade.ReportEnvironment); } } protected override sealed void Draw() { var dati = GetDataSet(); // 1st table var dati1 = dati.Tables["risorseApportate"].Clone(); var dati2 = dati.Tables["risorseApportate"].Clone(); var dati3 = dati.Tables["risorseApportate"].Clone(); dati1.Rows.Clear(); dati2.Rows.Clear(); dati3.Rows.Clear(); for (int i = 0; i < 3; i++) { dati1.Rows.Add(dati.Tables["risorseApportate"].Rows[i].ItemArray); } for (int i = 3; i < 5; i++) { dati2.Rows.Add(dati.Tables["risorseApportate"].Rows[i].ItemArray); } for (int i = 5; i < dati.Tables["risorseApportate"].Rows.Count; i++) { dati3.Rows.Add(dati.Tables["risorseApportate"].Rows[i].ItemArray); } var serieCombination = new List(); #region Tabella delle Risorse Apportate var tabellaRisorseApportate = new TablePDF(EnvironmentFacade.RendererFacade.XLeftLimit, dati1) { Style = Style.ConsulenzaUnica, Header = false, Footer = false, AlternateRow = false, RowHeight = 25, ID = "d1", HeaderMargin = 3 }; //BugFix #3741 - distanziamento da destra tabellaRisorseApportate.Columns.Add(new ColumnPDF("descrizione", 145, HorizontalAlignmentType.Sinistra, true, false,7, ColumnType.Testo, "descrizione", string.Empty) { PaddingRight = 5 }); tabellaRisorseApportate.Columns.Add(new ColumnPDF("valore", 75, HorizontalAlignmentType.Destra, false, false, 7, ColumnType.Testo, "valore", string.Empty) { PaddingLeft = 5 }); tabellaRisorseApportate.Row[0].BackgroundGray = true; //BugFix #3733 prolungamento riga bianca tabellaRisorseApportate.Cells[0, 0].ColSpan = 2; //BugFix #3729 concatenazione prima riga tabellaRisorseApportate.Cells[0, 0].Value = dati.Tables["risorseApportate"].Rows[0].ItemArray[0].ToString() + " " + dati.Tables["risorseApportate"].Rows[0].ItemArray[1].ToString(); AddElement(tabellaRisorseApportate); var rectangleGray1 = new RectanglePDF(EnvironmentFacade.RendererFacade.XLeftLimit + 145, 1, 75, new ColorPDF(232, 236, 237)) { AutoIncrementYWritable = false, DeltaY = -1 }; var rectangleGray2 = new RectanglePDF(EnvironmentFacade.RendererFacade.XLeftLimit + 145, 1, 75, new ColorPDF(232, 236, 237)) { AutoIncrementYWritable = false, DeltaY = 53.3f }; AddElement(rectangleGray1); AddElement(rectangleGray2); var tabellaRisorseApportate2 = new TablePDF(EnvironmentFacade.RendererFacade.XLeftLimit + 45, dati2) { Style = Style.ConsulenzaUnica, Header = false, Footer = false, AlternateRow = false, RowHeight = 25, ID = "d2", YOffset = 1f }; tabellaRisorseApportate2.ShowSeparationLines = true; tabellaRisorseApportate2.WidthSeparationLines = 0.2f; tabellaRisorseApportate2.Columns.Add(new ColumnPDF("descrizione", 100, HorizontalAlignmentType.Sinistra, true, false, 7, ColumnType.Testo, "descrizione", string.Empty)); tabellaRisorseApportate2.Columns.Add(new ColumnPDF("valore", 75, HorizontalAlignmentType.Destra, false, false, 7, ColumnType.Testo, "valore", string.Empty) { PaddingLeft = 5 }); AddElement(tabellaRisorseApportate2); var tabellaRisorseApportate3 = new TablePDF(EnvironmentFacade.RendererFacade.XLeftLimit, dati3) { Style = Style.ConsulenzaUnica, Header = false, Footer = false, AlternateRow = false, RowHeight = 25, ID = "d3", YOffset = 2f }; tabellaRisorseApportate3.Columns.Add(new ColumnPDF("descrizione", 145, HorizontalAlignmentType.Sinistra, true, false, 7, ColumnType.Testo, "descrizione", string.Empty)); tabellaRisorseApportate3.Columns.Add(new ColumnPDF("valore", 75, HorizontalAlignmentType.Destra, false, false, 7, ColumnType.Testo, "valore", string.Empty) { PaddingLeft = 5 }); AddElement(tabellaRisorseApportate3); if (GetNote1().Length > 0) { AddElement(new SpacePDF(7)); AddElement(new FormattedTextAreaPDF(GetNote1(), EnvironmentFacade.RendererFacade.XLeftLimit, 520) {FontSize=6, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Justify }); AddElement(new SpacePDF(15)); } #endregion AddElement(new ResetterYPDF()); AddElement(new SpacePDF(90)); #region Grafico Risorse Apportate AddElement(new FormattedTextAreaPDF("Valori espressi in migliaia di euro", EnvironmentFacade.RendererFacade.XLeftLimit, 520) {FontSize=7, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Right }); AddElement(new SpacePDF(7)); var coloreSerieRisorseApportate = new ColorPDF(95, 215, 95); //TODO var coloreSerieControvaloreMonetario = ColorPDF.Nero; //TODO var graficoCombination = new CombinationPDF(EnvironmentFacade.RendererFacade.XLeftLimit + 260, 1F) { Height = 190, Width = 260, MinorGridAxisY = true, ShowLegend = true, LegendWidthColumns = new List { 20, 5, 100 }, LegendSymbolHeight = 1, LegendDeltaX = 50, LegendFontSizeText = 7, LegendSymbolDeltaY = 9, MarginAxisY = 0, ShowLineAxisY = true, ShowLabelAxisY = true, LabelFormatAxisY = FormatType.Intero, IntervalNumberAxisY = 5, StartFromZeroAxisY = true, //LegendYOffset = 10, LegendYOffset = 4, LabelFormatAxisX = FormatType.DataSenzaOra, ShowLineAxisX = true, ShowLabelAxisX = true, IntervalNumberAxisX = 4 }; serieCombination = new List() { new Serie { Name = "RisorseApportate", Type = Dundas.Charting.WebControl.SeriesChartType.Area, Text = "Risorse apportate", Color = coloreSerieRisorseApportate }, new Serie { Name = "ControvaloreMonitorato", Type = Dundas.Charting.WebControl.SeriesChartType.Line, BorderWidth = 3, Text = "Controvalore monitorato", Color = coloreSerieControvaloreMonetario } }; foreach (DataRow item in dati.Tables["risorseApportateMonitorato"].Rows) { #region Serie ControvaloreMonitorato serieCombination[1].Points.Add(new Point { Color = coloreSerieControvaloreMonetario, Values = new ValuesPointXY(Convert.ToDateTime(item["Data"]).ToOADate(), Convert.ToDouble(item["ControvaloreMonitorato"])), ShowLabelAxisY = false, LabelAxisY = "ControvaloreMonitorato", FontSizeLabelAxisY = 7, FontBoldLabelAxisY = false, ShowLabelAxisX = false }); #endregion #region Serie RisorseApportate serieCombination[0].Points.Add(new Point { Color = coloreSerieRisorseApportate, Values = new ValuesPointXY(Convert.ToDateTime(item["Data"]).ToOADate(), Convert.ToDouble(item["RisorseApportate"])), ShowLabelAxisY = false, LabelAxisY = "RisorseApportate", FontSizeLabelAxisY =7, FontBoldLabelAxisY = false, ShowLabelAxisX = false }); #endregion } graficoCombination.SeriesCollection = serieCombination; AddElement(graficoCombination); #endregion if (GraficoRendimentoCumulato()) { #region Grafico Rendimento Cumulato AddElement(new SpacePDF(20)); AddElement(new FormattedTextAreaPDF(getTesto2(), EnvironmentFacade.RendererFacade.XLeftLimit) { FontSize = 7, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Justify }); AddElement(new SpacePDF(20)); //BugFix #3761 - Rimuovere il % e aggiungerlo alla destra dei valori numerici //AddElement(new FormattedTextAreaPDF("%", EnvironmentFacade.RendererFacade.XLeftLimit) { TextVerticalDirection = true, DeltaY = 100 }); var coloreSerieRendimentoCumulato = ColorPDF.Nero; var coloreSerieScenarioPessimistico = ColorPDF.Rosso; var coloreSerieScenarioOttimistico = ColorPDF.Blu; var graficoCombination_RendimentoCumulato = new CombinationPDF(EnvironmentFacade.RendererFacade.XLeftLimit + 30, 1F) { Height = 185, Width = 470, MinorGridAxisY = true, //BugFix #3757 - Distanziamento voci legenda LegendWidthColumns = new List { 12, 5, 110 }, LegendSymbolHeight = 1, ShowLegend = true, LegendFontSizeText = 7, LegendSymbolDeltaY = 9, LegendDeltaX = !ConoEvoluzione() ? 230 : RendimentoCumulanto() ? 130 : 180, showZeroInLabel = true, MarginAxisY = 0, ShowLineAxisY = true, ShowLabelAxisY = true, LabelFormatAxisY = FormatType.Decimale2, ShowLineAxisX = true, ShowLabelAxisX = true, LabelFormatAxisX = FormatType.DataShort, SeriesCollection = new List(), LegendYOffset = 10, ChartBaseWidth = 840, ChartBaseHeight = 350 }; //graficoCombination_RendimentoCumulato.ChartBaseWidth = 550; #region Serie RendimentoCumulato_Punto Serie RendimentoCumulato_Punto = new Serie() { Name = "RendimentoCumulato_Punto", Type = Dundas.Charting.WebControl.SeriesChartType.Point, Text = "", Color = coloreSerieRendimentoCumulato, ShowInLegend = false, BorderWidth = 2, AutoCalculateLastPointLabelPosition = true }; graficoCombination_RendimentoCumulato.SeriesCollection.Add(RendimentoCumulato_Punto); #endregion #region Serie RendimentoCumulato_Linea Serie RendimentoCumulato_Linea = new Serie() { Name = "RendimentoCumulato_Linea", Type = Dundas.Charting.WebControl.SeriesChartType.Line, Color = coloreSerieRendimentoCumulato, BorderWidth = 2, Text = "Rendimento cumulato ", ShowInLegend = RendimentoCumulanto() }; graficoCombination_RendimentoCumulato.SeriesCollection.Add(RendimentoCumulato_Linea); #endregion #region Serie ScenarioPessimistico Serie ScenarioPessimistico = new Serie() { Name = "ScenarioPessimistico", Type = Dundas.Charting.WebControl.SeriesChartType.Line, Color = coloreSerieScenarioPessimistico, BorderWidth = 2, Text = "Scenario pessimistico", ShowInLegend = ConoEvoluzione(), AutoCalculateLastPointLabelPosition = true }; graficoCombination_RendimentoCumulato.SeriesCollection.Add(ScenarioPessimistico); #endregion #region Serie ScenarioOttimistico Serie ScenarioOttimistico = new Serie() { Name = "ScenarioOttimistico", Type = Dundas.Charting.WebControl.SeriesChartType.Line, Color = coloreSerieScenarioOttimistico, BorderWidth = 2, Text = "Scenario ottimistico ", ShowInLegend = ConoEvoluzione() }; graficoCombination_RendimentoCumulato.SeriesCollection.Add(ScenarioOttimistico); #endregion foreach (DataRow item in dati.Tables["rendimentoCumulato"].Rows) { #region Serie RendimentoCumulato_Punto RendimentoCumulato_Punto.Points.Add(new Point { Color = coloreSerieRendimentoCumulato, Values = new ValuesPointXY(Convert.ToDateTime(item["Data"]).ToOADate(), Convert.ToDouble(item["Percentuale"])), Visible = false, Label = string.Format("Rend. cumulato {0}", Helper.FormatPercentage(Convert.ToDecimal(item["Percentuale"]), 2)), Font = new System.Drawing.Font("verdana", 8.8F), Marker = new PointMarker() { MarkerStyle = MarkerStyle.Circle, MarkerColor = System.Drawing.Color.Black, MarkerSize = 2.5f } }); #endregion #region Serie RendimentoCumulato_Linea RendimentoCumulato_Linea.Points.Add(new Point { Color = coloreSerieRendimentoCumulato, Values = new ValuesPointXY(Convert.ToDateTime(item["Data"]).ToOADate(), Convert.ToDouble(item["Percentuale"])), Visible = RendimentoCumulanto() }); #endregion } var punto = RendimentoCumulato_Punto.Points.Last(); if (punto != null) { punto.Visible = true; } foreach (DataRow item in dati.Tables["Cono"].Rows) { #region Serie Scenario pessimistico ScenarioPessimistico.Points.Add(new Point { Color = coloreSerieScenarioPessimistico, Values = new ValuesPointXY(Convert.ToDateTime(item["Data"]).ToOADate(), Convert.ToDouble(item["ScenarioPessimistico"])), Visible = ConoEvoluzione() }); #endregion #region Serie Scenario ottimistico ScenarioOttimistico.Points.Add(new Point { Color = coloreSerieScenarioOttimistico, Values = new ValuesPointXY(Convert.ToDateTime(item["Data"]).ToOADate(), Convert.ToDouble(item["ScenarioOttimistico"])), Visible = ConoEvoluzione() }); #endregion } AddElement(graficoCombination_RendimentoCumulato); #region Legenda #endregion #endregion } } protected sealed override DataTable GetDataTable() { return null; } protected sealed override DataSet GetDataSet() { var ds = new DataSet(); ds.Tables.Add(new DataTable("risorseApportate")); ds.Tables.Add(new DataTable("risorseApportateMonitorato")); ds.Tables.Add(new DataTable("rendimentoCumulato")); ds.Tables.Add(new DataTable("Cono")); ds.Tables["risorseApportate"].Columns.Add(new DataColumn("Descrizione", typeof(string))); ds.Tables["risorseApportate"].Columns.Add(new DataColumn("Valore", typeof(string))); ds.Tables["risorseApportateMonitorato"].Columns.Add(new DataColumn("Data", typeof(DateTime))); ds.Tables["risorseApportateMonitorato"].Columns.Add(new DataColumn("ControvaloreMonitorato", typeof(decimal))); ds.Tables["risorseApportateMonitorato"].Columns.Add(new DataColumn("RisorseApportate", typeof(decimal))); ds.Tables["rendimentoCumulato"].Columns.Add(new DataColumn("Data", typeof(DateTime))); ds.Tables["rendimentoCumulato"].Columns.Add(new DataColumn("Percentuale", typeof(decimal))); ds.Tables["Cono"].Columns.Add(new DataColumn("Data", typeof(DateTime))); ds.Tables["Cono"].Columns.Add(new DataColumn("ScenarioOttimistico", typeof(decimal))); ds.Tables["Cono"].Columns.Add(new DataColumn("ScenarioPessimistico", typeof(decimal))); var rendimentiCumulati = new andamentoRendimento[0]; var progetto = new progettoMon(); var rendimento = new rendimentoProgetto(); var controvaloreMonitorato_RisorseApportate = new ctvRisorse[0]; var conoPianificazione = new conoBean[0]; try { var areaMonitorata = datiSeiUnico.monitoraggioUnit().monitoraggio.FirstOrDefault(o => o.area.Equals("Liq")); progetto = areaMonitorata.progetti[0]; rendimento = progetto.rendimentoProgetto; controvaloreMonitorato_RisorseApportate = progetto.ctvRisorse != null ? progetto.ctvRisorse : new ctvRisorse[0]; rendimentiCumulati = progetto.andamentiRedimenti != null ? progetto.andamentiRedimenti : new andamentoRendimento[0]; conoPianificazione = new conoBean[0]; }catch { } #region Tabella e Grafico delle risorse apportate ds.Tables["risorseApportate"].Rows.Add("MONITORAGGIO ATTIVATO IL", string.Format("{0}", rendimento.dtAvvio.ToShortDateString())); ds.Tables["risorseApportate"].Rows.Add(string.Format("Controvalore (€){0}
(Aggiornato il {1})", GetNote1().Length > 0 ? "*" : "", rendimento.dtCtv.ToShortDateString()), string.Format("{0}", Helper.FormatCurrency(rendimento.ctvMonitorato.ToString()))); ds.Tables["risorseApportate"].Rows.Add("Risorse apportate (€)", string.Format("{0}", Helper.FormatCurrency(rendimento.risorseApportate.ToString()))); ds.Tables["risorseApportate"].Rows.Add("Apporti iniziali", Helper.FormatCurrency(rendimento.apportoIniziale.ToString())); ds.Tables["risorseApportate"].Rows.Add("Movimenti successivi", Helper.FormatCurrency(rendimento.movimentiSuccessivi.ToString())); ds.Tables["risorseApportate"].Rows.Add("Plus/Minusvalenza (€)", Helper.FormatCurrency(rendimento.minusPlusAreaProgetto.ToString())); ds.Tables["risorseApportate"].Rows.Add("Cedole/Dividendi (€)", Helper.FormatCurrency(rendimento.cedoleDividendi.ToString())); ds.Tables["risorseApportate"].Rows.Add("Guadagno/Perdita totale (€)", Helper.FormatCurrency((rendimento.minusPlusAreaProgetto + rendimento.cedoleDividendi).ToString())); string rendimentoAnnualizzato = rendimento.rendimentoAnnualizzato != 0 ? "
(" + Helper.FormatDecimal(rendimento.rendimentoAnnualizzato.ToString(), 2) + " % su base annua)" : ""; if (FlagBaseAnnua()) ds.Tables["risorseApportate"].Rows.Add("Rendimento cumulato (%)", Helper.FormatDecimal(rendimento.rendAvvio.ToString(), 2) + rendimentoAnnualizzato); else ds.Tables["risorseApportate"].Rows.Add("Rendimento cumulato (%)", Helper.FormatDecimal(rendimento.rendAvvio.ToString(), 2)); foreach (var item in from o in controvaloreMonitorato_RisorseApportate orderby o.dtValorizzazione select o) { ds.Tables["risorseApportateMonitorato"].Rows.Add( item.dtValorizzazione, item.ctv / 1000, item.risorseAssociate / 1000); } #endregion if (GraficoRendimentoCumulato()) { #region Grafico del rendimento cumulato foreach (var item in from o in rendimentiCumulati orderby o.dtRendimento select o) { ds.Tables["rendimentoCumulato"].Rows.Add( item.dtRendimento, item.percentuale ); }; foreach (var item in from o in conoPianificazione orderby o.dtRiferimento select o) { ds.Tables["Cono"].Rows.Add( item.dtRiferimento, item.quantileSup * 100, item.quantileInf * 100 ); } #endregion } return ds; } public virtual bool GraficoRendimentoCumulato() { return GetOption().Valore; } public virtual bool FlagBaseAnnua() { return GetOption().Valore; } public virtual bool ConoEvoluzione() { return false; } public virtual bool RendimentoCumulanto() { return true; } public virtual string GetNote1() { string nota = ""; var areaMonitorata = datiSeiUnico.monitoraggioUnit().monitoraggio.FirstOrDefault(o => o.area.Equals("Liq")); var progetto = areaMonitorata.progetti[0]; if(progetto.scarti!=null && progetto.scarti.Length>0) nota += "(*) Il controvalore esclude alcuni prodotti che non è stato possibile considerare nel calcolo dei rendimenti."; return nota; } public virtual string getTesto2() { string testo = "Il grafico riporta l'evoluzione del rendimento cumulato delle risorse da lei apportate all'area Liquidità, a partire dalla data di avvio del monitoraggio."; return testo; } } }