using System; using System.Collections.Generic; using System.Linq; using Consulenza.ExternalServices; using Consulenza.ReportWriter.Business; using Consulenza.ReportWriter.Business.Entity; using Consulenza.ReportWriter.Business.OBJ_PDF; using System.Data; using Consulenza.ReportCommon; namespace Consulenza.ReportWriter.Manager.Section.Immobiliare.Monitoraggio { /// /// Glossario (id 42) /// public class S10 : Entity.Section { public S10(EnvironmentFacade environmentFacade, int idSection) : base(environmentFacade, idSection) { try { Draw(); } catch (Exception ex) { SectionLogger.Write("S10", 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() { string titolo = ""; string paragrafoSx = ""; string paragrafoDx = ""; FormattedTextAreaPDF testoSx = null; FormattedTextAreaPDF testoDx = null; FormattedTextAreaPDF testoTitolo = null; FormattedTextAreaPDF notaTabella = null; int x1Linea, x2Linea; var dataset = GetDataSet(); var _text = dataset.Tables[0]; var data = dataset.Tables[1]; var width = 340; List indiciPagina = _text.AsEnumerable() .Select(z => z.Field("idREP_IMM_MON_Pagina")).Distinct().ToList(); int j = 1; foreach (var indice in indiciPagina) { #region Text 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(); switch (j) { #region Case 1 case 1: AddElement(new SpacePDF(30)); foreach (var row in testo) { paragrafoSx = paragrafoDx = ""; //string str = row.Field("posizione").ToString(); if (row.Field("titolo").Contains("IMU e TARI")) { #region IMU e TARI + Tabella titolo = row.Field("titolo") + "
"; for (int i = 1; i <= 15; i++) paragrafoSx += row.Field("testo" + i) != null ? "

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


" : ""; if (paragrafoSx.Contains("SPLITPARAGRAPH")) { var listaSplit = StringExtensions.SplitAtOccurence(paragrafoSx, "SPLITPARAGRAPH", 1); paragrafoSx = listaSplit[0] + "

"; paragrafoDx += "

"; listaSplit.RemoveRange(0, 1); foreach (var stringa in listaSplit) paragrafoDx += stringa; } testoTitolo = new FormattedTextAreaPDF(titolo, 35, width) { FontSize = 13, FontColor = ColorPDF.Immobiliare_Grigio_TitoloPiccolo, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Left }; x1Linea = 35; x2Linea = 40 + (600 / 2) + 35; var lineaVerticaleSeparazione = new LinePDF(x1Linea, x2Linea, 0.5F, ColorPDF.Immobiliare_Grigio_TitoloPiccolo) { AutoIncrementYWritable = true }; var _titolo = new FormattedTextAreaPDF(titolo, 35, width) { FontSize = 13, FontColor = ColorPDF.Immobiliare_Grigio_TitoloPiccolo, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Left }; testoSx = new FormattedTextAreaPDF(paragrafoSx, 35, width) { AutoIncrementYWritable = false, FontSize = 9, FontColor = ColorPDF.Immobiliare_Grigio_TestoStandard, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Justify }; //testoDx = new FormattedTextAreaPDF(paragrafoDx, 410, width) { FontSize = 9, FontColor = ColorPDF.Immobiliare_Grigio_TestoStandard, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Justify }; AddElement(_titolo); AddElement(new SpacePDF(5)); AddElement(lineaVerticaleSeparazione); AddElement(new SpacePDF(1)); AddElement(testoSx); //AddElement(new SpacePDF(-5)); //AddElement(testoDx); //AddElement(new SpacePDF(220)); #region tabella di destra Tassazione immobiliare if (data.AsEnumerable().Where(x => x.Field("idREP_IMM_MON_Pagina") == indice && x.Field("row1") != "").Count() > 0) { DataTable tabella = new DataTable(); for (int index = 1; index <= 5; index++) tabella.Columns.Add("column" + index); List columnName = new List(); for (int index = 1; index <= 5; index++) columnName.Add(data.Rows[0].Field("column" + index)); columnName.RemoveAll(item => item == null); foreach (var _row in data.AsEnumerable().Where(x => x.Field("idREP_IMM_MON_Pagina") == indice)) { titolo = "
" + _row.Field("descrizione"); if (_row["row1"] != null && _row["row1"].ToString() != "") tabella.Rows.Add(_row["row1"], _row["row2"], _row["row3"], _row["row4"], _row["row5"]); } foreach (var column in tabella.Columns.Cast().ToArray()) if (tabella.AsEnumerable().All(dr => dr.IsNull(column))) tabella.Columns.Remove(column); AddElement(new ResetterYPDF()); testoTitolo = new FormattedTextAreaPDF(titolo, 410, 300) { AutoIncrementYWritable = true, FontSize = 13, FontColor = ColorPDF.Immobiliare_Grigio_TitoloPiccolo, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Left }; TablePDF table = new TablePDF(410, tabella) { Style = Style.Immobiliare, AlternateRow = false, HeaderHeight = 25, RowHeight = 10, Footer = false, ShowBorderLastLine = true, HeaderTextVerticalAlign = VerticalAlignmentType.Basso }; for (int idColumn = 1; idColumn <= tabella.Columns.Count; idColumn++) table.Columns.Add(new ColumnPDF(tabella.Rows[0].Field("column" + idColumn), idColumn == 1 ? 190 : 80, idColumn != 1 ? HorizontalAlignmentType.Centrato : HorizontalAlignmentType.Sinistra, false, false, 8, ColumnType.Testo, "column" + idColumn, columnName[idColumn - 1]) { HeaderFontColor = new ColorPDF(92, 89, 81), HeaderFontSize = 8, DeltaYContent = 1 }); AddElement(new ResetterYPDF(15)); //30 AddElement(new SpacePDF(20)); //20 AddElement(testoTitolo); AddElement(new SpacePDF(1)); //5 AddElement(table); if (getNota(data.AsEnumerable().Where(x => x.Field("idREP_IMM_MON_Pagina") == indice).ToList()[0]).Length > 0) notaTabella = new FormattedTextAreaPDF(getNota(data.AsEnumerable().Where(x => x.Field("idREP_IMM_MON_Pagina") == indice).ToList()[0]), 410, table.Width - 10) { AutoIncrementYWritable = true, FontSize = 7, FontColor = ColorPDF.Immobiliare_Grigio_TestoStandard, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Justify, DeltaX = 5, DeltaY = 5 }; ////AddElement(new ResetterYPDF(47)); //AddElement(new ResetterYPDF(15)); //30 //AddElement(new SpacePDF(20)); //20 //AddElement(testoTitolo); //AddElement(new SpacePDF(1)); //5 //AddElement(table); if (getNota(data.AsEnumerable().Where(x => x.Field("idREP_IMM_MON_Pagina") == indice).ToList()[0]).Length > 0) AddElement(notaTabella); //AddElement(new SpacePDF(20)); //15 } #endregion #endregion } else { #region Cedolare Secca titolo = row.Field("titolo") + "
"; for (int i = 1; i <= 15; i++) paragrafoSx += row.Field("testo" + i) != null ? "

" + row.Field("testo" + i) + "


" : ""; if (paragrafoSx.Contains("SPLITPARAGRAPH")) { var listaSplit = StringExtensions.SplitAtOccurence(paragrafoSx, "SPLITPARAGRAPH", 1); paragrafoSx = listaSplit[0] + "

"; paragrafoDx += "

"; listaSplit.RemoveRange(0, 1); foreach (var stringa in listaSplit) paragrafoDx += stringa; } testoTitolo = new FormattedTextAreaPDF(titolo, 35, width) { FontSize = 13, FontColor = ColorPDF.Immobiliare_Grigio_TitoloPiccolo, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Left }; x1Linea = 35; x2Linea = 750; var lineaVerticaleSeparazione = new LinePDF(x1Linea, x2Linea, 0.5F, ColorPDF.Immobiliare_Grigio_TitoloPiccolo) { AutoIncrementYWritable = true }; var _titolo = new FormattedTextAreaPDF(titolo, 35, width) { FontSize = 13, FontColor = ColorPDF.Immobiliare_Grigio_TitoloPiccolo, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Left }; testoSx = new FormattedTextAreaPDF(paragrafoSx, 35, width) { AutoIncrementYWritable = false, FontSize = 9, FontColor = ColorPDF.Immobiliare_Grigio_TestoStandard, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Justify }; testoDx = new FormattedTextAreaPDF(paragrafoDx, 410, width) { FontSize = 9, FontColor = ColorPDF.Immobiliare_Grigio_TestoStandard, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Justify }; AddElement(new SpacePDF(35)); //50 AddElement(_titolo); AddElement(new SpacePDF(5)); AddElement(lineaVerticaleSeparazione); AddElement(new SpacePDF(10)); AddElement(testoSx); AddElement(new SpacePDF(-8)); AddElement(testoDx); #endregion } //break; /* Versione Originale */ //paragrafoSx = paragrafoDx = ""; //titolo = row.Field("titolo") + "
"; //for (int i = 1; i <= 15; i++) // paragrafoSx += row.Field("testo" + i) != null ? "

" + row.Field("testo" + i) + "


" : ""; //// SPLIT PARAGRAFO //if (paragrafoSx.Contains("SPLITPARAGRAPH")) //{ // var listaSplit = StringExtensions.SplitAtOccurence(paragrafoSx, "SPLITPARAGRAPH", 1); // paragrafoSx = listaSplit[0] + "

"; // paragrafoDx += "

"; // listaSplit.RemoveRange(0, 1); // foreach (var stringa in listaSplit) // paragrafoDx += stringa; // testoTitolo = new FormattedTextAreaPDF(titolo, 35, width) { FontSize = 13, FontColor = ColorPDF.Immobiliare_Grigio_TitoloPiccolo, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Left }; // x1Linea = 35; // x2Linea = 750; // var lineaVerticaleSeparazione = new LinePDF(x1Linea, x2Linea, 0.5F, ColorPDF.Immobiliare_Grigio_TitoloPiccolo) { AutoIncrementYWritable = true }; // var _titolo = new FormattedTextAreaPDF(titolo, 35, width) { FontSize = 13, FontColor = ColorPDF.Immobiliare_Grigio_TitoloPiccolo, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Left }; // testoSx = new FormattedTextAreaPDF(paragrafoSx, 35, width) { AutoIncrementYWritable = false, FontSize = 9, FontColor = ColorPDF.Immobiliare_Grigio_TestoStandard, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Justify }; // testoDx = new FormattedTextAreaPDF(paragrafoDx, 410, width) { FontSize = 9, FontColor = ColorPDF.Immobiliare_Grigio_TestoStandard, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Justify }; // // Dati Statici 20181005 // //AddElement(new SpacePDF(15)); // //AddElement(_titolo); // //AddElement(new SpacePDF(5)); // //AddElement(lineaVerticaleSeparazione); // //AddElement(new SpacePDF(10)); // //AddElement(testoSx); // //AddElement(new SpacePDF(-5)); // //AddElement(testoDx); // //AddElement(new SpacePDF(10)); // AddElement(_titolo); // AddElement(new SpacePDF(5)); // AddElement(lineaVerticaleSeparazione); // AddElement(new SpacePDF(10)); // AddElement(testoSx); // AddElement(new SpacePDF(-5)); // AddElement(testoDx); // AddElement(new SpacePDF(-5)); // // End //} //else //{ // testoTitolo = new FormattedTextAreaPDF(titolo, 35, 40 + (600 / 2)) { FontSize = 13, FontColor = ColorPDF.Immobiliare_Grigio_TitoloPiccolo, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Left }; // x1Linea = 35; // x2Linea = 40 + (600 / 2) + 35; // var lineaVerticaleSeparazione = new LinePDF(x1Linea, x2Linea, 0.5F, ColorPDF.Immobiliare_Grigio_TitoloPiccolo) { AutoIncrementYWritable = true }; // //testoSx = new FormattedTextAreaPDF(paragrafoSx, 35, width) { FontSize = 9, FontColor = ColorPDF.Immobiliare_Grigio_TestoStandard, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Justify }; // testoSx = new FormattedTextAreaPDF(string.Concat(paragrafoSx, "

"), 35, width) { FontSize = 9, FontColor = ColorPDF.Immobiliare_Grigio_TestoStandard, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Justify }; // AddElement(new SpacePDF(-5)); // AddElement(testoTitolo); // AddElement(new SpacePDF(5)); // AddElement(lineaVerticaleSeparazione); // AddElement(new SpacePDF(5)); // AddElement(testoSx); // AddElement(new SpacePDF(20)); //10 // if (data.AsEnumerable().Where(x => x.Field("idREP_IMM_MON_Pagina") == indice // && x.Field("row1") != "").Count() > 0) // { // DataTable tabella = new DataTable(); // for (int index = 1; index <= 5; index++) // tabella.Columns.Add("column" + index); // List columnName = new List(); // for (int index = 1; index <= 5; index++) // columnName.Add(data.Rows[0].Field("column" + index)); // columnName.RemoveAll(item => item == null); // foreach (var _row in data.AsEnumerable().Where(x => x.Field("idREP_IMM_MON_Pagina") == indice)) // { // titolo = "
" + _row.Field("descrizione"); // if (_row["row1"] != null && _row["row1"].ToString() != "") // tabella.Rows.Add(_row["row1"], _row["row2"], _row["row3"], _row["row4"], _row["row5"]); // } // foreach (var column in tabella.Columns.Cast().ToArray()) // if (tabella.AsEnumerable().All(dr => dr.IsNull(column))) // tabella.Columns.Remove(column); // AddElement(new ResetterYPDF()); // testoTitolo = new FormattedTextAreaPDF(titolo, 410, 300) { AutoIncrementYWritable = true, FontSize = 13, FontColor = ColorPDF.Immobiliare_Grigio_TitoloPiccolo, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Left }; // TablePDF table = new TablePDF(410, tabella) // { // Style = Style.Immobiliare, // AlternateRow = false, // HeaderHeight = 25, // RowHeight = 10, // Footer = false, // ShowBorderLastLine = true, // HeaderTextVerticalAlign = VerticalAlignmentType.Basso // }; // for (int idColumn = 1; idColumn <= tabella.Columns.Count; idColumn++) // table.Columns.Add(new ColumnPDF(tabella.Rows[0].Field("column" + idColumn), idColumn == 1 ? 190 : 80, idColumn != 1 ? HorizontalAlignmentType.Centrato : HorizontalAlignmentType.Sinistra, false, false, 8, ColumnType.Testo, "column" + idColumn, columnName[idColumn - 1]) { HeaderFontColor = new ColorPDF(92, 89, 81), HeaderFontSize = 8, DeltaYContent = 1 }); // if (getNota(data.AsEnumerable().Where(x => x.Field("idREP_IMM_MON_Pagina") == indice).ToList()[0]).Length > 0) // notaTabella = new FormattedTextAreaPDF(getNota(data.AsEnumerable().Where(x => x.Field("idREP_IMM_MON_Pagina") == indice).ToList()[0]), 410, table.Width - 10) { AutoIncrementYWritable = true, FontSize = 7, FontColor = ColorPDF.Immobiliare_Grigio_TestoStandard, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Justify, DeltaX = 5, DeltaY = 5 }; // //AddElement(new ResetterYPDF(47)); // AddElement(new ResetterYPDF(15)); //30 // AddElement(new SpacePDF(20)); //20 // AddElement(testoTitolo); // AddElement(new SpacePDF(1)); //5 // AddElement(table); // if (getNota(data.AsEnumerable().Where(x => x.Field("idREP_IMM_MON_Pagina") == indice).ToList()[0]).Length > 0) // AddElement(notaTabella); // AddElement(new SpacePDF(20)); //15 // } //} /* Fine Versione Originale */ } j++; break; #endregion #region Case 2 - Seconda pagina case 2: AddElement(new PagePDF(PagePDF.PagePDFType.Generic)); int element = 0; foreach (var row in testo) { paragrafoSx = paragrafoDx = ""; element++; titolo = row.Field("titolo") + "
"; if (row["posizione"].Equals("L")) testoTitolo = new FormattedTextAreaPDF(titolo, 35, width) { FontSize = 13, FontColor = ColorPDF.Immobiliare_Grigio_TitoloPiccolo, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Left }; else testoTitolo = new FormattedTextAreaPDF(titolo, 410, width + 15) { FontSize = 13, FontColor = ColorPDF.Immobiliare_Grigio_TitoloPiccolo, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Left }; //x1Linea = row["posizione"].Equals("L") ? 35 : 410; ////x2Linea = row["posizione"].Equals("L") ? 340 : 765; //x2Linea = row["posizione"].Equals("L") ? 340 : 750; x1Linea = row["posizione"].Equals("L") ? 35 : 410; x2Linea = row["posizione"].Equals("L") ? 375 : 750; var lineaVerticaleSeparazione = new LinePDF(x1Linea, x2Linea, 0.5F, ColorPDF.Immobiliare_Grigio_TitoloPiccolo) { AutoIncrementYWritable = element > 2 ? false : true }; 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 (row["posizione"].Equals("L")) testoSx = new FormattedTextAreaPDF(paragrafoSx, 35, width) { AutoIncrementYWritable = false, FontSize = 9, FontColor = ColorPDF.Immobiliare_Grigio_TestoStandard, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Justify }; else //testoDx = new FormattedTextAreaPDF(paragrafoDx, 410, width + 10) { AutoIncrementYWritable = true, FontSize = 9, FontColor = ColorPDF.Immobiliare_Grigio_TestoStandard, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Justify }; testoDx = new FormattedTextAreaPDF(paragrafoDx, 410, width) { AutoIncrementYWritable = true, FontSize = 9, FontColor = ColorPDF.Immobiliare_Grigio_TestoStandard, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Justify }; if (element <= 2) { AddElement(new ResetterYPDF()); //AddElement(new SpacePDF(45)); AddElement(new SpacePDF(30)); } if (element == 3) // si riferisce alla sezione "Ecobonus e Superbonus 110% AddElement(new SpacePDF(2)); if (element == 4) // Si riferisce alla sezione "Interventi relativi all'adozione di misure antisismiche" /****************************************** Modifica per parti statiche semestrale 10/2020 - Pino ********************************/ AddElement(new SpacePDF(-22)); //-32 -20 /*********************************************************************************************************************************/ AddElement(testoTitolo); AddElement(new SpacePDF(5)); AddElement(lineaVerticaleSeparazione); //AddElement(new SpacePDF(5)); //AddElement(row["posizione"].Equals("L") ? testoSx : testoDx); //AddElement(new SpacePDF(10)); AddElement(new SpacePDF(1)); AddElement(row["posizione"].Equals("L") ? testoSx : testoDx); //AddElement(new SpacePDF(10)); } break; #endregion } } #endregion } } /// /// Recupera i dati necessari alla Section restituendo un DataTable. /// /// protected override DataTable GetDataTable() { return null; } public virtual string getNota(DataRow row) { string nota = ""; for (int i = 1; i <= 3; i++) nota += "

" + row["notaGrafico" + i] + "
"; if (nota != "") nota += "

"; return nota; } /// /// 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_S10_Legge_Bilancio", parametri); } } public static class StringExtensions { public static List SplitAtOccurence(this string input, string separator, int occurence) { var parts = input.Split(new string[] { separator }, StringSplitOptions.RemoveEmptyEntries); var partlist = new List(); var result = new List(); for (int i = 0; i < parts.Length; i++) { if (partlist.Count == occurence) { result.Add(string.Join(separator.ToString(), partlist)); partlist.Clear(); } partlist.Add(parts[i]); if (i == parts.Length - 1) result.Add(string.Join(separator.ToString(), partlist)); // if no more parts, add the rest } return result; } } }