using System; using System.Linq; using Consulenza.ReportWriter.Business; using Consulenza.ReportWriter.Business.OBJ_PDF; using ceTe.DynamicPDF; using System.Data; using Consulenza.ReportCommon; using System.Collections.Generic; using Consulenza.ExternalServices; using Consulenza.ReportWriter.Manager.Integration; namespace Consulenza.ReportWriter.Manager.Section.Immobiliare.Monitoraggio { /// /// Scheda di stima parametrica del valore (id 39) /// public class S7 : Entity.Section { //private bool _assenzaTipologiaDiritto; //private bool _assenzaQuotaDiritto; public S7(EnvironmentFacade environmentFacade, int idSection) : base(environmentFacade, idSection) { try { Draw(); } catch (Exception ex) { SectionLogger.Write("S7", ex.Message, SectionLoggerMessageLevel.E, EnvironmentFacade.ReportEnvironment); } } /// /// Scheda2. Patrimonio immobiliare –Sintesi (distribuzione del patrimonio complessivo del cliente diviso per tipologia e cointestatari) /// protected override sealed void Draw() { var dataset = GetDataSet(); var _text = dataset.Tables[0]; var data = dataset.Tables[1]; List indiciPagina = _text.AsEnumerable() .Select(z => z.Field("idREP_IMM_MON_Pagina")).Distinct().ToList(); foreach (var indice in indiciPagina) { #region Text string paragrafoSx = ""; string paragrafoDx = ""; if (_text.AsEnumerable().Where(x => x.Field("idREP_IMM_MON_Pagina") == indice).Count() > 0) { var testo = _text.AsEnumerable().Where(x => x.Field("idREP_IMM_MON_Pagina") == indice).ToList(); foreach (var row in testo) { if (row["posizione"].Equals("L")) paragrafoSx += "" + row.Field("titolo") + "

"; else paragrafoDx = "" + row.Field("titolo") + "

"; for (int i = 1; i <= 15; i++) if (row["posizione"].Equals("L")) paragrafoSx += row.Field("testo" + i) != null ? "

" + row.Field("testo" + i).Replace("<br/>","
") + "


" : ""; else paragrafoDx += row.Field("testo" + i) != null ? "

" + row.Field("testo" + i).Replace("<br/>", "
") + "


" : ""; } if (paragrafoSx != string.Empty) paragrafoSx = SplitTesto(paragrafoSx, "Le principali città"); //var testoSx = new FormattedTextAreaPDF(paragrafoSx, 35, 370) { AutoIncrementYWritable = false, Y = 55, FontSize = 9, FontColor = ColorPDF.Immobiliare_Grigio_TestoStandard, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Justify }; var testoSx = new FormattedTextAreaPDF(paragrafoSx, 35, 370) { AutoIncrementYWritable = false, Y = 40, FontSize = 9, FontColor = ColorPDF.Immobiliare_Grigio_TestoStandard, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Justify }; //var testoDx = new FormattedTextAreaPDF(paragrafoDx, 430, 320) { AutoIncrementYWritable = false, FontSize = 9, FontColor = ColorPDF.Immobiliare_Grigio_TestoStandard, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Justify }; var testoDx = new FormattedTextAreaPDF(paragrafoDx, 35, 370) { AutoIncrementYWritable = false, FontSize = 9, FontColor = ColorPDF.Immobiliare_Grigio_TestoStandard, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Justify }; if (data.AsEnumerable().Where(x => x.Field("idREP_IMM_MON_Pagina") == indice).Count() > 0) { TablePDF table = null; FormattedTextAreaPDF titolo = null; foreach (var row in data.AsEnumerable()) { DataTable tabella = new DataTable(); tabella.Columns.Add("Key"); tabella.Columns.Add("Value"); for (int i = 1; i <= 10; i++) { if (row["keyItem" + i] != null && row["keyItem" + i].ToString() != "") { tabella.Rows.Add(row["keyItem" + i], row["valueItem" + i]); } } switch (row["idTipologia"].ToString()) { case "1": titolo = new FormattedTextAreaPDF("
" + row.Field("descrizione") + "
", 430, 300) { AutoIncrementYWritable = true, FontSize = 12, FontColor = ColorPDF.Immobiliare_Grigio_TitoloPiccolo, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Justify }; table = new TablePDF(430, tabella) { Style = Style.Immobiliare, AlternateRow = false, HeaderHeight = 25, RowHeight = 15, Footer = false, ShowBorderLastLine = true, //AdditionalSpaceBetweenHeadersAndTable = 5.0F, HeaderTextVerticalAlign = VerticalAlignmentType.Basso }; table.Columns.Add(new ColumnPDF("Key1", 120, HorizontalAlignmentType.Sinistra, false, false, 8, ColumnType.Testo, "Key", "") { HeaderFontColor = new ColorPDF(92, 89, 81), HeaderFontSize = 8, DeltaYContent = 1 }); table.Columns.Add(new ColumnPDF("Value1", 80, HorizontalAlignmentType.Centrato, false, false, 8, ColumnType.Objectpdf, "Value", "Aspettativa") { HeaderFontColor = new ColorPDF(92, 89, 81), HeaderFontSize = 9, DeltaYContent = 1 }); AddElement(testoSx); int i = 0; foreach (DataRow r in tabella.Rows) { ImagePDF imageSymbol = new ImagePDF(0, 1, tabella.Rows[i]["Value"].ToString()) { DeltaY = 3, //DeltaY = tabella.Rows[i]["Value"].ToString().Contains("horizontal") ? -2 : -3, Scale = 0.1f }; table.Cells[1, i].ValueObjectList.Add(imageSymbol); i++; } //AddElement(new SpacePDF(48));//TO-DO con aggiunta di note e legenda //AddElement(titolo); //AddElement(new SpacePDF(10)); //AddElement(table); //addLegend(row); //AddElement(new SpacePDF(-8)); AddElement(new SpacePDF(18)); //29 //TO-DO con aggiunta di note e legenda AddElement(titolo); AddElement(new SpacePDF(20)); //35 12 18 - 28 AddElement(table); AddElement(new SpacePDF(10)); //10 11 -5 addLegend(row); AddElement(new SpacePDF(-18)); //-8 -18 break; case "2": //titolo = new FormattedTextAreaPDF("
" + row.Field("descrizione"), 35, 330) { Y = EnvironmentFacade.RendererFacade.YUpperLimit + 195, FontSize = 12, FontColor = ColorPDF.Immobiliare_Grigio_TitoloPiccolo, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Justify }; //table = new TablePDF(35, tabella) ////titolo = new FormattedTextAreaPDF("
" + row.Field("descrizione"), 430, 320) { Y = EnvironmentFacade.RendererFacade.YUpperLimit + 195, FontSize = 12, FontColor = ColorPDF.Immobiliare_Grigio_TitoloPiccolo, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Justify }; titolo = new FormattedTextAreaPDF("
" + row.Field("descrizione"), 430, 320) { Y = EnvironmentFacade.RendererFacade.YUpperLimit + 200, FontSize = 12, FontColor = ColorPDF.Immobiliare_Grigio_TitoloPiccolo, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Justify }; table = new TablePDF(430, tabella) { Style = Style.Immobiliare, AlternateRow = false, HeaderHeight = 15, RowHeight = 5, Footer = false, ShowBorderLastLine = true, HeaderTextVerticalAlign = VerticalAlignmentType.Basso }; table.Columns.Add(new ColumnPDF("Key2", 120, HorizontalAlignmentType.Sinistra, false, false, 8, ColumnType.Testo, "Key", "Città") { HeaderFontColor = new ColorPDF(92, 89, 81), HeaderFontSize = 9, HeaderVerticalAlignment = VerticalAlignmentType.Centrato, DeltaYContent = 5 }); table.Columns.Add(new ColumnPDF("Value2", 80, HorizontalAlignmentType.Centrato, false, false, 8, ColumnType.Objectpdf, "Value", "Aspettativa") { HeaderFontColor = new ColorPDF(92, 89, 81), HeaderFontSize = 9, HeaderVerticalAlignment = VerticalAlignmentType.Centrato }); int j = 0; foreach (DataRow r in tabella.Rows) { ImagePDF imageSymbol = new ImagePDF(0, 1, tabella.Rows[j]["Value"].ToString()) { DeltaY = 3, //DeltaY = tabella.Rows[i]["Value"].ToString().Contains("horizontal") ? -2 : -3, Scale = 0.1f }; table.Cells[1, j].ValueObjectList.Add(imageSymbol); j++; } var x1Linea = 30; var x2Linea = 750; var lineaVerticaleSeparazione = new LinePDF(x1Linea, x2Linea, 0.5F, ColorPDF.Immobiliare_Marrone); //AddElement(new SpacePDF(5)); //AddElement(titolo); //AddElement(new SpacePDF(10)); //AddElement(testoDx); //AddElement(new SpacePDF(-20)); //AddElement(lineaVerticaleSeparazione); //AddElement(new SpacePDF(38)); //AddElement(table); //addLegend(row); //AddElement(new SpacePDF(1)); // Modifica ES su direttiva Carnevali del 03.10.2018 AddElement(new SpacePDF(-25)); //-25 AddElement(titolo); ////AddElement(new SpacePDF(22)); ////AddElement(testoDx); ////AddElement(lineaVerticaleSeparazione); AddElement(new SpacePDF(22)); // 22 AddElement(lineaVerticaleSeparazione); AddElement(new SpacePDF(2)); //2 AddElement(testoDx); AddElement(new SpacePDF(58)); //38 AddElement(table); addLegend(row); AddElement(new SpacePDF(-5)); // End //if (getNota(_text.Rows[0]).Length > 0) //{ // string testoNota = getNota(_text.Rows[0]); // int count = testoNota.Replace("
", "\t").Count(x => x == '\t'); // //var nota = new FormattedTextAreaPDF(getNota(_text.Rows[0]), 430, 300) { AutoIncrementYWritable = false, Y = 212, FontSize = 6, FontColor = ColorPDF.Nero, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Left }; // var nota = new FormattedTextAreaPDF(getNota(_text.Rows[0]),60, 300) { AutoIncrementYWritable = false, Y = 212, FontSize = 6, FontColor = ColorPDF.Nero, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Left }; // AddElement(nota); //} break; default: break; } } } if (getNota(_text.Rows[0]).Length > 0) { string testoNota = getNota(_text.Rows[0]); int count = testoNota.Replace("
", "\t").Count(x => x == '\t'); //var nota = new FormattedTextAreaPDF(getNota(_text.Rows[0]), 60, 680) { Y = EnvironmentFacade.RendererFacade.YLowerLimit - 17 - (5 * count), FontSize = 6, FontColor = ColorPDF.Nero, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Justify }; var nota = new FormattedTextAreaPDF(getNota(_text.Rows[0]), 60, 300) { Y = EnvironmentFacade.RendererFacade.YLowerLimit - 13 - (5 * count), FontSize = 6, FontColor = ColorPDF.Nero, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Justify }; AddElement(nota); } #endregion } } } protected void addLegend(DataRow data) { //int xLegenda = data.Field("posizione").Equals("R") ? 680 : 320; //int xLegenda2 = data.Field("posizione").Equals("R") ? 672 : 312; //int xLegendaTesto = data.Field("posizione").Equals("R") ? 690 : 330; //int yLegenda = data.Field("posizione").Equals("R") ? 134 : 400; // Inversione Carnevali 20181003 int xLegenda = 680; int xLegenda2 = 672; int xLegendaTesto = 690; //int yLegenda = data.Field("posizione").Equals("R") ? 134 : 400; int yLegenda = data.Field("posizione").Equals("R") ? 115 : 400; int legendWidth = 90; int legendHeight = 60; if (!data.Field("posizione").Equals("R")) AddElement(new ResetterYPDF(300)); //AddElement(new RectanglePDF(legendHeight, legendWidth, new ColorPDF(217, 217, 217)) { X = xLegenda, AutoIncrementYWritable = false, DeltaY = 2 }); // Sfondo Bianco AddElement(new SpacePDF(1)); AddElement(new RectanglePDF(legendHeight, legendWidth, new ColorPDF(255, 255, 255)) { X = xLegenda, AutoIncrementYWritable = false, Y = yLegenda, DeltaY = 2, BorderColor = ColorPDF.Immobiliare_Grigio_TitoloPiccolo }); List columnName = new List(); for (int index = 1; index <= 10; index++) { columnName.Add(data.Field("keyLegenda" + index)); columnName.Add(data.Field("valueLegenda" + index)); } columnName.RemoveAll(item => item == null); foreach (string name in columnName) { if (name.Contains(".png")) { if (name.Contains("2")) AddElement(new ImagePDF(xLegenda2, 0.15F, name) { DeltaY = 5F, Y = yLegenda, AutoIncrementYWritable = false }); else AddElement(new ImagePDF(xLegenda, 0.15F, name) { DeltaY = 5F, Y = yLegenda, AutoIncrementYWritable = false }); //xLegenda += name.Contains("2") ? 20 : 10; //xLegenda += 10 ; } else { var ftaNomeLabel = new FormattedTextAreaPDF { Text = name, FontColor = new ColorPDF(92, 89, 81), DeltaY = 4F, AutoIncrementYWritable = false, X = xLegendaTesto, Y = yLegenda, FontSize = 7, FontBold = true }; //xLegenda += (ftaNomeLabel.Text.Length * 5) + (10 - ftaNomeLabel.Text.Length); yLegenda += 9; //9; //xLegenda -= 10; //xLegenda -= name.Contains("2") ? 20 : 10; AddElement(ftaNomeLabel); } } // Original //foreach (string name in columnName) { // if (name.Contains(".png")) { // AddElement(new ImagePDF(xLegenda, 0.15F, name) { DeltaY = 5F, AutoIncrementYWritable = false }); // xLegenda += name.Contains("2") ? 20 : 10; // } // else // { // var ftaNomeLabel = new FormattedTextAreaPDF // { // Text = name, // FontColor = new ColorPDF(92, 89, 81), // DeltaY = 4F, // AutoIncrementYWritable = false, // X = xLegenda, // FontSize = 7, // FontBold = true // }; // xLegenda += (ftaNomeLabel.Text.Length * 5) + (10 - ftaNomeLabel.Text.Length); // AddElement(ftaNomeLabel); // } //} } protected string getNota(DataRow row) { string nota = ""; for (int i = 1; i <= 5; i++) if (row.Field("nota" + i) != null) nota += row.Field("nota" + i) + "
"; return nota; } /// /// Recupera i dati necessari alla Section restituendo un DataTable. /// /// protected override DataTable GetDataTable() { return null; } /// /// Recupera i dati necessari alla Section restituendo un DataSet. /// /// protected override DataSet GetDataSet() { var parametri = new List { new Parametro { Direction = ParameterDirection.Input, DbType = DbType.Int32, ParameterName = "IdReport", Value = EnvironmentFacade.ReportEnvironment.ReportId }, new Parametro { Direction = ParameterDirection.Input, DbType = DbType.Int32, ParameterName = "IdSezione", Value = IdSection } }; return DataAccess.ExecuteDataSetStoredProcedure(DBProvider.SqlServerReportModeler, "REP_Monitoraggio_Immobiliare_S7_Aspettative_Future", parametri); } private string SplitTesto(string testo, string testoCercato) { string testoNuovo = string.Empty; try { string[] testoDiviso = testo.Split(new[] { testoCercato }, StringSplitOptions.None); testoNuovo = string.Concat(testoDiviso[0].ToString(), "



", testoCercato, testoDiviso[1].ToString()); } catch (Exception ex) { throw new Exception("Errore in SplitTesto - S4 " + ex.Message); } return testoNuovo; } } }