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.ReportWriter.Business.Headers; using Consulenza.ReportCommon; namespace Consulenza.ReportWriter.Manager.Section.Immobiliare.Monitoraggio { /// /// Patrimonio Immobiliare Stima delle imposte (id 41) Fabbricati /// public class S9 : Entity.Section { public S9(EnvironmentFacade environmentFacade, int idSection) : base(environmentFacade, idSection) { try { Draw(); } catch (Exception ex) { SectionLogger.Write("S9", 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() { //MonitoraggioImmobiliarePageHeaderManager.DrawIndexPage(Elements, 210); var width = 345; int xSx = 35; int xDx = 400; var dataset = GetDataSet(); var _text = dataset.Tables[0]; var _data = dataset.Tables[1]; List indiciPagina = _data.AsEnumerable() .Select(z => z.Field("idREP_IMM_MON_Pagina")).Distinct().ToList(); foreach (var indice in indiciPagina) { string paragrafoSx = ""; string paragrafoDx = ""; string labelSx = ""; string labelDx = ""; string testo = ""; AddElement(new PagePDF(PagePDF.PagePDFType.Generic)); FormattedTextAreaPDF testoSx = null; FormattedTextAreaPDF testoDx = null; if (_text.AsEnumerable().Where(x => x.Field("idREP_IMM_MON_Pagina") == indice).Count() > 0) { foreach (var row in _text.AsEnumerable().Where(x => x.Field("idREP_IMM_MON_Pagina") == indice).ToList()) { testo = ""; labelSx = ""; labelDx = ""; testo = "" + row.Field("titolo") + "

"; for (int i = 1; i <= 15; i++) { //if (i == 2) //{ // List _Zone = new List() { "Zona 1:", "Zona 2:", "Zona 3:", "Zona 4:" }; // testo = SplitTestoPuntato(row.Field("testo" + i).ToString(), _Zone); //} //else // testo += row.Field("testo" + i) != null ? "

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


" : ""; #region Sezione testo puntato vecchia versione // Gestione elenco puntato if ((i == 2) || (i == 3) || (i == 4) || (i == 5)) { //testo += row.Field("testo" + i) != null ? "

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

" : ""; if ((testo.Contains("Zona 1:")) || (testo.Contains("Zona 2:")) || (testo.Contains("Zona 3:")) || (testo.Contains("Zona 4:"))) { /***************************** Modifica per parti statiche semestrale 10/2020 - Pino *****************************/ //testo += row.Field("testo" + i) != null ? "

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

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

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

" : ""; /*****************************************************************************************************************/ if (row.Field("testo" + i).Contains("Zona 4:")) testo += "
"; } else { if (row.Field("testo" + i) != null) { string str = row.Field("testo" + i).ToString(); if (str.Contains("Zona 1:")) { /***************************** Modifica per parti statiche semestrale 10/2020 - Pino *****************************/ //testo += row.Field("testo" + i) != null ? "

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

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

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

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

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


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

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


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

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


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

"; labelDx += "

"; listaSplit.RemoveRange(0, 1); foreach (var stringa in listaSplit) labelDx += stringa; paragrafoSx += labelSx; paragrafoDx += labelDx; } else { if (row.Field("posizione").Equals("R")) paragrafoDx += testo; else paragrafoSx += testo; } } AddElement(new ResetterYPDF(60)); testoSx = new FormattedTextAreaPDF(paragrafoSx, 35, width) { 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(testoSx); AddElement(new ResetterYPDF(65)); AddElement(testoDx); if(getNota(_text.Rows[0]).Length > 0) { var nota = new FormattedTextAreaPDF(getNota(_text.Rows[0]), 60, width) { Y = EnvironmentFacade.RendererFacade.YLowerLimit - 18, FontSize = 6, FontColor = ColorPDF.Nero, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Justify }; AddElement(nota); } } if (_data.AsEnumerable().Where(x => x.Field("idREP_IMM_MON_Pagina") == indice).Count() > 0 && _data.AsEnumerable().Where(x => x.Field("idREP_IMM_MON_Pagina") == indice && x.Field("descrizioneImage") != null).Count() > 0) { foreach (var image in _data.AsEnumerable().Where(x => x.Field("idREP_IMM_MON_Pagina") == indice).ToList()) { string titoloStatico = image.Field("descrizioneImage") +"
"; var titoloGrafico = new FormattedTextAreaPDF(titoloStatico, 50, width*2) { FontSize = 10, FontColor = ColorPDF.Immobiliare_Grigio_TitoloPiccolo, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Justify }; var cartina = new ImagePDF(35, 0.465F, image.Field("bytesImage") + ".jpeg"); AddElement(new ResetterYPDF(50)); AddElement(titoloGrafico); AddElement(cartina); if (getNota(image).Length > 0) { string testoNota = getNota(image); IEnumerable rows = _data.AsEnumerable() .Where(x => x.Field("nota1") != null); int count = testoNota.Replace("
", "\t").Count(x => x == '\t'); var nota = new FormattedTextAreaPDF(testoNota, 60, width) { Y = EnvironmentFacade.RendererFacade.YLowerLimit - 13 - (5 * count), FontSize = 6, FontColor = ColorPDF.Nero, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Justify }; AddElement(nota); } } } } } protected string SplitTestoPuntato(string testo, List testoCercato) { string testoNuovo = string.Empty; try { foreach(string item in testoCercato) { string[] testoDiviso = testo.Split(new[] { item }, 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; } 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() { #region Definizione dei parametri 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 } }; #endregion return DataAccess.ExecuteDataSetStoredProcedure(DBProvider.SqlServerReportModeler, "REP_Monitoraggio_Immobiliare_S9_Mappa_Rischio_Sismico", parametri); } } }