using System; using System.Collections.Generic; using System.Linq; using Consulenza.ExternalServices; using Consulenza.ReportWriter.Business; using Consulenza.ReportWriter.Business.OBJ_PDF; using System.Data; using Consulenza.ReportWriter.Business.CHART_PDF; using Consulenza.ReportCommon; using Consulenza.ReportWriter.Business.Entity; using System.Text; using System.Drawing; namespace Consulenza.ReportWriter.Manager.Section.Immobiliare.Monitoraggio { /// /// Scheda 17 /// public class S17 : Entity.Section { public S17(EnvironmentFacade environmentFacade, int idSection) : base(environmentFacade, idSection) { try { Draw(); } catch (Exception ex) { SectionLogger.Write("S17", ex.Message, SectionLoggerMessageLevel.E, EnvironmentFacade.ReportEnvironment); } } private Color GetColor(double value) { value = value * 100; if (value >= 80) return Color.FromArgb(0, 109, 45);//(117, 255, 0); if (value >= 60) return Color.FromArgb(162, 216, 154);//(202, 255, 0); if (value >= 40) return Color.FromArgb(242, 221, 68);//(255, 234, 0); if (value >= 20) return Color.FromArgb(233, 148, 33);//(255, 121, 0); else return Color.FromArgb(213, 38, 7);//(255, 5, 0); } private CustomChartPDF DrawPieChart(double value, float currentDeltaY, Color colorRest, Color backgroundColor, double posX, double deltaY, double size, int widthPercentage) { CustomChartPDF pieChart = new CustomChartPDF() { X = (float)posX, DeltaY = currentDeltaY }; var baseChart = pieChart.ChartBase; baseChart.ChartAreas.Add("Default"); baseChart.Legends[0].Enabled = false; baseChart.ChartAreas[0].BackColor = backgroundColor; baseChart.BackColor = backgroundColor; baseChart.Width = new System.Web.UI.WebControls.Unit(size); baseChart.Height = new System.Web.UI.WebControls.Unit(size); baseChart.ChartAreas["Default"].Area3DStyle.Enable3D = false; var colorValue = GetColor(value); baseChart.PaletteCustomColors = new Color[] { colorValue, backgroundColor, colorRest, backgroundColor }; var serie = baseChart.Series.Add("SerieName"); //serie.Type = Dundas.Charting.WebControl.SeriesChartType.Pie; serie.Type = Dundas.Charting.WebControl.SeriesChartType.Doughnut; serie["DoughnutRadius"] = "40"; serie["PieStartAngle"] = "270"; serie.Points.AddXY(1, value - 0.01d); serie.Points.AddXY(1, 0.005d); serie.Points.AddXY(1, 1 - value); serie.Points.AddXY(1, 0.005d); var image = pieChart.GetImage(); Graphics g = Graphics.FromImage(image); SolidBrush brush = new SolidBrush(backgroundColor); int width = image.Width * (100 - widthPercentage) / 100; int height = image.Height * (100 - widthPercentage) / 100; int x = (image.Width - width) / 2; int y = (image.Height - height) / 2; g.DrawEllipse(new Pen(Color.White), new Rectangle(x, y, width, height)); g.FillEllipse(brush, new Rectangle(x, y, width, height)); g.Save(); g.DrawImage(image, new Rectangle(0, 0, image.Width, image.Height)); pieChart.SetCustomImage(image); //image.RotateFlip(RotateFlipType.Rotate270FlipNone); return pieChart; } private string UppercaseFirst(string s) { if (string.IsNullOrEmpty(s)) { return string.Empty; } char[] a = s.ToCharArray(); a[0] = char.ToUpper(a[0]); return new string(a); } /// /// Scheda2. Patrimonio immobiliare –Sintesi (distribuzione del patrimonio complessivo del cliente diviso per tipologia e cointestatari) /// /// private static int counter = -1; protected override sealed void Draw() { counter++; var dataset = GetDataSet(); FormattedTextAreaPDF testoPagina = new FormattedTextAreaPDF(getTesto1(), 35) { FontSize = 10, FontColor = ColorPDF.Immobiliare_Grigio_TitoloPiccolo, AutoIncrementYWritable = false, Width = 740, FixedHeight = 30 }; FormattedTextAreaPDF notaTabella = new FormattedTextAreaPDF("Nota(*): variazione percentuale del prezzo €/mq nel semestre di riferimento rispetto al semestre precedente.
", 60, 680) { AutoIncrementYWritable = false, Y = EnvironmentFacade.RendererFacade.YLowerLimit - 23, FontSize = 6, FontColor = ColorPDF.Nero, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Justify, DeltaX = 5, DeltaY = 5 }; var listaOggettiDaRipetere = new List { new SpacePDF(30), testoPagina, new SpacePDF(10), notaTabella }; addLegend(listaOggettiDaRipetere); int cont = 0; bool usoAbitativoStrumentale = dataset.Tables["1"].Rows.Count > 0 && dataset.Tables["2"].Rows.Count > 0; int contatore = 0; int contatoreDiversificazione = 0; //float spaceTakenByTables = 0; //float spaceAvailableForOneTable = 338; //float spaceNeededBetweenTables = 25; foreach (DataTable table in dataset.Tables) { if (table != null && table.Rows.Count > 0 && contatore > 0 && contatore <= 4) { // patryk ---------- // making sure that NEW PAGE is being added when its needed //float newTableHeight = 0; float rowHeight = 20; float headerHeight = 25; float footerHeight = 15; float tableTitleHeight = 25; //for (int j = 0; j < table.Rows.Count; j++) //{ // var tempPositioneText = new FormattedTextAreaPDF(table.Rows[j]["posizione"].ToString(), 0, 170) { FontSize = 7 }; // var positioneHeight = tempPositioneText.GetHeight(EnvironmentFacade.ReportEnvironment.FontFamily, false); // var currentRowHeight = rowHeight > positioneHeight ? rowHeight : positioneHeight; // newTableHeight += currentRowHeight; //} //// here we have height of entire table calculated //newTableHeight = newTableHeight + headerHeight + footerHeight + tableTitleHeight; //// we dont care if it goes for multiple pages and its big //newTableHeight = newTableHeight % spaceAvailableForOneTable; // Commentare questa if per Salto pagina personalizzato //if (cont == 0 || !usoAbitativoStrumentale) AddElement(new PagePDF(PagePDF.PagePDFType.Generic)); if (cont == 0) { //AddElement(listaOggettiDaRipetere); AddElement(new RepeaterPDF(listaOggettiDaRipetere)); } double pieChartValue = Convert.ToDouble(dataset.Tables[0].Rows[contatoreDiversificazione]["valoreDiversificazione"]); string text = UppercaseFirst(dataset.Tables[0].Rows[contatoreDiversificazione]["classeDiversificazione"].ToString().ToLower()); if (text == "") text = "n.c."; contatoreDiversificazione++; var tablePDF = new TablePDF(35, table, dataset.Tables[contatore + "footer"]) { Style = Style.Immobiliare, AlternateRow = false, HeaderHeight = headerHeight, RowHeight = rowHeight, FooterHeight = footerHeight, Footer = true, PageBreak = true, ShowBorderLastLine = false, ShowBorderLastLineInPageBreak = false, TableTitleDeltaX = 5, TableTitleFontSize = 12, TableTitleFontBold = true, TableTitleHeight = tableTitleHeight, DrawLineHeaderUP = true, TableTitle = getTitle(contatore.ToString()), HeaderTextDrawJustOnce = false, TableTitleFontColor = ColorPDF.Immobiliare_Grigio_TitoloPiccolo, TableCantReachThisYPosition = 420, ShowBorderHeader = false, HeadersObjectsHeight = 25, AddSpaceBeforeTableAfterEntireTableIsMovedToNextPage = false, RowsIndexesThatCantEndPageYLimit = 260 //RowsIndexesThatCantEndPageYLimit = 300 }; //tablePDF.HeaderNoteObjects.Add(new SpacePDF(-25)); // Original //float topChartDeltaY = 3; //tablePDF.HeaderNoteObjects.Add(new RectanglePDF(16, 160, new ColorPDF(Color.FromArgb(239, 240, 237))) //{ // X = 575, // AutoIncrementYWritable = false, // DeltaY = topChartDeltaY //}); //tablePDF.HeaderNoteObjects.Add(new FormattedTextAreaPDF("Diversificazione:", 575) //{ // DeltaY = 3 + topChartDeltaY, // DeltaX = 3, // FontColor = new ColorPDF(Color.FromArgb(92, 89, 81)), // AutoIncrementYWritable = false //}); //tablePDF.HeaderNoteObjects.Add(new FormattedTextAreaPDF(text, 685) //{ // DeltaY = 3 + topChartDeltaY, // DeltaX = 3, // FontColor = new ColorPDF(Color.FromArgb(92, 89, 81)), // AutoIncrementYWritable = false, // FontBold = true //}); //var pieChart = DrawPieChart(pieChartValue, topChartDeltaY, Color.FromArgb(196, 196, 186), Color.FromArgb(239, 240, 237), 651, 252, 16, 45); //tablePDF.HeaderNoteObjects.Add(pieChart); // Sfondo Bianco float topChartDeltaY = 3; tablePDF.HeaderNoteObjects.Add(new RectanglePDF(19, 188, new ColorPDF(Color.FromArgb(255, 255, 255))) { X = 545, AutoIncrementYWritable = false, DeltaY = topChartDeltaY, BorderColor = ColorPDF.Immobiliare_Grigio_TitoloPiccolo, BorderWidth = 0.2f }); tablePDF.HeaderNoteObjects.Add(new FormattedTextAreaPDF("Diversificazione fabbricati:", 545) { DeltaY = 4 + topChartDeltaY, DeltaX = 3, FontColor = new ColorPDF(Color.FromArgb(92, 89, 81)), AutoIncrementYWritable = false }); tablePDF.HeaderNoteObjects.Add(new FormattedTextAreaPDF(text, 684) { DeltaY = 4 + topChartDeltaY, DeltaX = 3, FontColor = new ColorPDF(Color.FromArgb(92, 89, 81)), AutoIncrementYWritable = false, FontBold = true }); var pieChart = DrawPieChart(pieChartValue, topChartDeltaY + 1, Color.FromArgb(196, 196, 186), Color.FromArgb(255, 255, 255), 666, 252, 16, 45); tablePDF.HeaderNoteObjects.Add(pieChart); //tablePDF.Columns.Add(new ColumnPDF("comune", 140, HorizontalAlignmentType.Sinistra, false, false, 7, ColumnType.Testo, "comune", "Comune/Tipologia") { FontBold = false, HeaderFontBold = true, HeaderFontSize = 7, DeltaYContent = 1, HeaderFontColor = ColorPDF.Nero, VerticalAlignment = VerticalAlignmentType.Centrato }); //tablePDF.Columns.Add(new ColumnPDF("posizione", 170, HorizontalAlignmentType.Sinistra, false, false, 7, ColumnType.Testo, "posizione", "Posizione urbana/Micro-zona") { FontBold = false, HeaderFontBold = true, HeaderFontSize = 7, DeltaYContent = 1, HeaderFontColor = ColorPDF.Nero, VerticalAlignment = VerticalAlignmentType.Centrato }); //tablePDF.Columns.Add(new ColumnPDF("numeroImmobili", 50, HorizontalAlignmentType.Centrato, false, false, 7, ColumnType.Testo, "numeroImmobili", "Numero
immobili") { FontBold = false, HeaderFontBold = true, HeaderFontSize = 7, DeltaYContent = 1, HeaderFontColor = ColorPDF.Nero, VerticalAlignment = VerticalAlignmentType.Centrato }); //tablePDF.Columns.Add(new ColumnPDF("rischioV", 60, HorizontalAlignmentType.Centrato, false, false, 7, ColumnType.Objectpdf, "rischioValore", "Rischio
valore") { FontBold = false, HeaderFontBold = true, HeaderFontSize = 7, HeaderFontColor = ColorPDF.Nero, VerticalAlignment = VerticalAlignmentType.Centrato }); //tablePDF.Columns.Add(new ColumnPDF("rischioL", 60, HorizontalAlignmentType.Destra, false, false, 7, ColumnType.Objectpdf, "rischioLiquidita", "Rischio
liquidabilità") { FontBold = false, HeaderFontBold = true, HeaderFontSize = 7, HeaderFontColor = ColorPDF.Nero, VerticalAlignment = VerticalAlignmentType.Centrato }); //tablePDF.Columns.Add(new ColumnPDF("trendV", 60, HorizontalAlignmentType.Destra, false, false, 7, ColumnType.Objectpdf, "trendValore", "Trend
valore*") { FontBold = false, HeaderFontBold = true, HeaderFontSize = 7, HeaderFontColor = ColorPDF.Nero, VerticalAlignment = VerticalAlignmentType.Centrato }); //tablePDF.Columns.Add(new ColumnPDF("ProQuota", 80, HorizontalAlignmentType.Destra, false, false, 7, ColumnType.Testo, "ProQuota", "Valore stimato
pro quota (€)") { FontBold = false, HeaderFontBold = true, HeaderFontSize = 7, DeltaYContent = 1, HeaderFontColor = ColorPDF.Nero, VerticalAlignment = VerticalAlignmentType.Centrato }); //tablePDF.Columns.Add(new ColumnPDF("stimatoTotale", 80, HorizontalAlignmentType.Destra, false, false, 7, ColumnType.Testo, "stimatoTotale", "Valore stimato
totale (€)") { FontBold = false, HeaderFontBold = true, HeaderFontSize = 7, DeltaYContent = 1, HeaderFontColor = ColorPDF.Nero, VerticalAlignment = VerticalAlignmentType.Centrato }); //tablePDF.Columns.Add(new ColumnPDF("comune", 140, HorizontalAlignmentType.Sinistra, false, false, 7, ColumnType.Testo, "comune", "Comune/Tipologia") { FontBold = false, HeaderFontBold = true, HeaderFontSize = 7, DeltaYContent = 1, HeaderFontColor = ColorPDF.Nero, VerticalAlignment = VerticalAlignmentType.Alto }); //tablePDF.Columns.Add(new ColumnPDF("posizione", 170, HorizontalAlignmentType.Sinistra, false, false, 7, ColumnType.Testo, "posizione", "Posizione urbana/Micro-zona") { FontBold = false, HeaderFontBold = true, HeaderFontSize = 7, DeltaYContent = 1, HeaderFontColor = ColorPDF.Nero, VerticalAlignment = VerticalAlignmentType.Alto }); //tablePDF.Columns.Add(new ColumnPDF("numeroImmobili", 50, HorizontalAlignmentType.Centrato, false, false, 7, ColumnType.Testo, "numeroImmobili", "Numero
immobili") { FontBold = false, HeaderFontBold = true, HeaderFontSize = 7, DeltaYContent = 1, HeaderFontColor = ColorPDF.Nero, VerticalAlignment = VerticalAlignmentType.Alto }); tablePDF.Columns.Add(new ColumnPDF("comune", 130, HorizontalAlignmentType.Sinistra, false, false, 7, ColumnType.Testo, "comune", "Comune/Tipologia") { FontBold = false, HeaderFontBold = true, HeaderFontSize = 7, DeltaYContent = 1, HeaderFontColor = ColorPDF.Nero, VerticalAlignment = VerticalAlignmentType.Alto }); tablePDF.Columns.Add(new ColumnPDF("posizione", 190, HorizontalAlignmentType.Sinistra, false, false, 7, ColumnType.Testo, "posizione", "Posizione urbana/Micro-zona") { FontBold = false, HeaderFontBold = true, HeaderFontSize = 7, DeltaYContent = 1, HeaderFontColor = ColorPDF.Nero, VerticalAlignment = VerticalAlignmentType.Alto }); tablePDF.Columns.Add(new ColumnPDF("numeroImmobili", 40, HorizontalAlignmentType.Centrato, false, false, 7, ColumnType.Testo, "numeroImmobili", "Numero
immobili") { FontBold = false, HeaderFontBold = true, HeaderFontSize = 7, DeltaYContent = 1, HeaderFontColor = ColorPDF.Nero, VerticalAlignment = VerticalAlignmentType.Alto}); tablePDF.Columns.Add(new ColumnPDF("rischioV", 60, HorizontalAlignmentType.Centrato, false, false, 7, ColumnType.Objectpdf, "rischioValore", "Rischio
valore") { FontBold = false, HeaderFontBold = true, HeaderFontSize = 7, HeaderFontColor = ColorPDF.Nero, VerticalAlignment = VerticalAlignmentType.Alto }); tablePDF.Columns.Add(new ColumnPDF("rischioL", 60, HorizontalAlignmentType.Destra, false, false, 7, ColumnType.Objectpdf, "rischioLiquidita", "Rischio
liquidabilità") { FontBold = false, HeaderFontBold = true, HeaderFontSize = 7, HeaderFontColor = ColorPDF.Nero, VerticalAlignment = VerticalAlignmentType.Alto }); tablePDF.Columns.Add(new ColumnPDF("trendV", 60, HorizontalAlignmentType.Destra, false, false, 7, ColumnType.Objectpdf, "trendValore", "Trend
valore*") { FontBold = false, HeaderFontBold = true, HeaderFontSize = 7, HeaderFontColor = ColorPDF.Nero, VerticalAlignment = VerticalAlignmentType.Alto }); tablePDF.Columns.Add(new ColumnPDF("ProQuota", 80, HorizontalAlignmentType.Destra, false, false, 7, ColumnType.Testo, "ProQuota", "Valore stimato
pro quota (€)") { FontBold = false, HeaderFontBold = true, HeaderFontSize = 7, DeltaYContent = 1, HeaderFontColor = ColorPDF.Nero, VerticalAlignment = VerticalAlignmentType.Alto }); tablePDF.Columns.Add(new ColumnPDF("stimatoTotale", 80, HorizontalAlignmentType.Destra, false, false, 7, ColumnType.Testo, "stimatoTotale", "Valore stimato
totale (€)") { FontBold = false, HeaderFontBold = true, HeaderFontSize = 7, DeltaYContent = 1, HeaderFontColor = ColorPDF.Nero, VerticalAlignment = VerticalAlignmentType.Alto}); tablePDF.FooterColumns.Add(new ColumnPDF("comuneFooter", 320, HorizontalAlignmentType.Sinistra, false, true, 7, ColumnType.Testo) { HeaderFontBold = true, HeaderFontSize = 7, DeltaYContent = 0, FontColor = new ColorPDF(92, 89, 81), VerticalAlignment = VerticalAlignmentType.Centrato }); tablePDF.FooterColumns.Add(new ColumnPDF("numeroImmobiliFooter", 40, HorizontalAlignmentType.Centrato, false, true, 7, ColumnType.Testo) { HeaderFontBold = true, HeaderFontSize = 7, DeltaYContent = 0, FontColor = new ColorPDF(92, 89, 81), VerticalAlignment = VerticalAlignmentType.Centrato }); tablePDF.FooterColumns.Add(new ColumnPDF("rischioValoreFooter", 60, HorizontalAlignmentType.Centrato, false, false, 7, ColumnType.Immagine, "rischioValoreFooter", "") { HeaderFontBold = true, HeaderFontSize = 7, DeltaYContent = 1, ScaleColumnTypeImage = 0.30f, FontColor = new ColorPDF(92, 89, 81), VerticalAlignment = VerticalAlignmentType.Centrato }); tablePDF.FooterColumns.Add(new ColumnPDF("rischioLiquiditaFooter", 49, HorizontalAlignmentType.Destra, false, false, 7, ColumnType.Immagine, "rischioLiquiditaFooter", "") { HeaderFontBold = true, HeaderFontSize = 7, DeltaYContent = 1, ScaleColumnTypeImage = 0.30f, FontColor = new ColorPDF(92, 89, 81), VerticalAlignment = VerticalAlignmentType.Centrato }); tablePDF.FooterColumns.Add(new ColumnPDF("trend", 71, HorizontalAlignmentType.Destra, false, false, 7, ColumnType.Testo) { HeaderFontBold = true, HeaderFontSize = 7, DeltaYContent = 0, FontColor = new ColorPDF(92, 89, 81), VerticalAlignment = VerticalAlignmentType.Centrato }); tablePDF.FooterColumns.Add(new ColumnPDF("ProQuotaFooter", 80, HorizontalAlignmentType.Destra, false, true, 7, ColumnType.Testo) { HeaderFontBold = true, HeaderFontSize = 7, DeltaYContent = 0, FontColor = new ColorPDF(92, 89, 81), VerticalAlignment = VerticalAlignmentType.Centrato }); tablePDF.FooterColumns.Add(new ColumnPDF("stimatoTotaleFooter", 80, HorizontalAlignmentType.Destra, false, true, 7, ColumnType.Testo) { HeaderFontBold = true, HeaderFontSize = 7, DeltaYContent = 0, FontColor = new ColorPDF(92, 89, 81), VerticalAlignment = VerticalAlignmentType.Centrato }); tablePDF.FooterCells[2, 0].Value = dataset.Tables[contatore + "footer"].Rows[0]["rischioValore"].ToString(); tablePDF.FooterCells[3, 0].Value = dataset.Tables[contatore + "footer"].Rows[0]["rischioLiquidita"].ToString(); int i = 0; foreach (DataRow r in table.Rows) { if (table.Rows[i]["comune"].ToString().Contains("")) { tablePDF.Cells[0, i].FontColor = ColorPDF.Nero; tablePDF.RowsIndexesThatCantEndPage.Add(i); tablePDF.RowHeight = 15; } // Modifica ES in data 20170904 // if (!table.Rows[i]["trendValore"].ToString().Contains("n.d.") && !table.Rows[i]["trendValore"].ToString().Equals("")) if (!table.Rows[i]["trendValore"].ToString().Contains("n.d.") && !table.Rows[i]["trendValore"].ToString().Equals("") && !table.Rows[i]["trendValore"].ToString().Contains("n.c.")) { ImagePDF imageSymbol = new ImagePDF(0, 1, table.Rows[i]["trendValore"].ToString()) { DeltaX = table.Rows[i]["trendValore"].ToString().Contains("horizontal") ? -10 : -9, Scale = table.Rows[i]["trendValore"].ToString().Contains("horizontal") ? 0.35f : 0.50f }; var tempPositioneText = new FormattedTextAreaPDF(table.Rows[i]["posizione"].ToString(), 0, 170) { FontSize = 7 }; var positioneHeight = tempPositioneText.GetHeight(EnvironmentFacade.ReportEnvironment.FontFamily, false); var tempImage = new ceTe.DynamicPDF.PageElements.Image(imageSymbol.Path, 0, 0, imageSymbol.Scale); var currentRowHeight = rowHeight > positioneHeight ? rowHeight : positioneHeight; //var deltaYOffset = ((currentRowHeight - tempImage.Height) / 2) - (positioneHeight / 3); imageSymbol.DeltaY = 1; tablePDF.Cells[5, i].ValueObjectList.Add(imageSymbol); } else if (!table.Rows[i]["comune"].ToString().Contains("")) { var tempPositioneText = new FormattedTextAreaPDF { // Modifica ES in data 20170904 // Text = "n.d.", Text = table.Rows[i]["posizione"].ToString().Trim() == "-" ? "n.c." : "n.d.", FontBold = false, FontColor = new ColorPDF(92, 89, 81), DeltaX = sumColumns(tablePDF, 5) + 20, FontSize = 7, }; var calcolapos = new FormattedTextAreaPDF(table.Rows[i]["posizione"].ToString(), 0, 170) { FontSize = 7 }; var positioneHeight = calcolapos.GetHeight(EnvironmentFacade.ReportEnvironment.FontFamily, false); var currentRowHeight = rowHeight > positioneHeight ? rowHeight : positioneHeight; //var deltaYOffset = (currentRowHeight / 2) - (positioneHeight / 6) - 4; var deltaYOffset = (currentRowHeight / 2) - (positioneHeight / 6); //if (tempPositioneText.Text == "n.c." || tempPositioneText.Text == "n.d.") //tempPositioneText.DeltaY = deltaYOffset - Convert.ToSingle(5.7); //else tempPositioneText.DeltaY = deltaYOffset - Convert.ToSingle(7.5); tablePDF.Cells[5, i].ValueObjectList.Add(tempPositioneText); } //additionalSpace = table.Rows[i]["posizione"].ToString().Length >= 35 ? 4 : 0; // Modifica ES in data 20170904 //if (!table.Rows[i]["rischioValore"].ToString().Contains("n.d.") && !table.Rows[i]["rischioValore"].ToString().Equals("")) if (!table.Rows[i]["rischioValore"].ToString().Contains("n.d.") && !table.Rows[i]["rischioValore"].ToString().Equals("") && !table.Rows[i]["trendValore"].ToString().Contains("n.c.")) { ImagePDF imageSymbolRischioValore = new ImagePDF(0, 1, table.Rows[i]["rischioValore"].ToString()) { // DeltaY = additionalSpace, DeltaX = -2, Scale = 0.30f }; var tempPositioneText = new FormattedTextAreaPDF(table.Rows[i]["posizione"].ToString(), 0, 170) { FontSize = 7 }; var positioneHeight = tempPositioneText.GetHeight(EnvironmentFacade.ReportEnvironment.FontFamily, false); var tempImage = new ceTe.DynamicPDF.PageElements.Image(imageSymbolRischioValore.Path, 0, 0, imageSymbolRischioValore.Scale); var currentRowHeight = rowHeight > positioneHeight ? rowHeight : positioneHeight; //var deltaYOffset = ((currentRowHeight - tempImage.Height) / 2) - (positioneHeight / 3); imageSymbolRischioValore.DeltaY = 1; tablePDF.Cells[3, i].ValueObjectList.Add(imageSymbolRischioValore); } else if (!table.Rows[i]["comune"].ToString().Contains("")) { var tempPositioneText = new FormattedTextAreaPDF { // Modifica ES in data 20170904 // Text = "n.d.", Text = table.Rows[i]["posizione"].ToString().Trim() == "-" ? "n.c." : "n.d.", FontBold = false, FontColor = new ColorPDF(92, 89, 81), DeltaX = sumColumns(tablePDF, 3) + 60, FontSize = 7, }; var calcolapos = new FormattedTextAreaPDF(table.Rows[i]["posizione"].ToString(), 0, 170) { FontSize = 7 }; var positioneHeight = calcolapos.GetHeight(EnvironmentFacade.ReportEnvironment.FontFamily, false); var currentRowHeight = rowHeight > positioneHeight ? rowHeight : positioneHeight; //var deltaYOffset = (currentRowHeight / 2) - (positioneHeight / 6) - 4; var deltaYOffset = (currentRowHeight / 2) - (positioneHeight / 6); //if (tempPositioneText.Text == "n.c." || tempPositioneText.Text == "n.d.") // tempPositioneText.DeltaY = deltaYOffset - Convert.ToSingle(5.7); //else tempPositioneText.DeltaY = deltaYOffset - Convert.ToSingle(7.5); tablePDF.Cells[3, i].ValueObjectList.Add(tempPositioneText); } // Modifica ES in data 20170904 //if (!table.Rows[i]["rischioLiquidita"].ToString().Contains("n.d.") && !table.Rows[i]["rischioLiquidita"].ToString().Equals("")) if (!table.Rows[i]["rischioLiquidita"].ToString().Contains("n.d.") && !table.Rows[i]["rischioLiquidita"].ToString().Equals("") && !table.Rows[i]["trendValore"].ToString().Contains("n.c.")) { ImagePDF imageSymbolRischioLiquidita = new ImagePDF(0, 1, table.Rows[i]["rischioLiquidita"].ToString()) { //DeltaY = additionalSpace, DeltaX = -9.5F, //10 Scale = 0.30f }; var tempPositioneText = new FormattedTextAreaPDF(table.Rows[i]["posizione"].ToString(), 0, 170) { FontSize = 7 }; var positioneHeight = tempPositioneText.GetHeight(EnvironmentFacade.ReportEnvironment.FontFamily, false); var tempImage = new ceTe.DynamicPDF.PageElements.Image(imageSymbolRischioLiquidita.Path, 0, 0, imageSymbolRischioLiquidita.Scale); var currentRowHeight = rowHeight > positioneHeight ? rowHeight : positioneHeight; //var deltaYOffset = ((currentRowHeight - tempImage.Height) / 2) - (positioneHeight / 3); imageSymbolRischioLiquidita.DeltaY = 1; tablePDF.Cells[4, i].ValueObjectList.Add(imageSymbolRischioLiquidita); } else if (!table.Rows[i]["comune"].ToString().Contains("")) { var tempPositioneText = new FormattedTextAreaPDF { // Modifica ES in data 20170904 // Text = "n.d.", Text = table.Rows[i]["posizione"].ToString().Trim() == "-" ? "n.c." : "n.d.", FontBold = false, FontColor = new ColorPDF(92, 89, 81), DeltaX = sumColumns(tablePDF, 4) + 80, FontSize = 7, }; var calcolapos = new FormattedTextAreaPDF(table.Rows[i]["posizione"].ToString(), 0, 170) { FontSize = 7 }; var positioneHeight = calcolapos.GetHeight(EnvironmentFacade.ReportEnvironment.FontFamily, false); var currentRowHeight = rowHeight > positioneHeight ? rowHeight : positioneHeight; //var deltaYOffset = (currentRowHeight / 2) - (positioneHeight / 6) - 4; var deltaYOffset = (currentRowHeight / 2) - (positioneHeight / 6); //if (tempPositioneText.Text == "n.c." || tempPositioneText.Text == "n.d.") //tempPositioneText.DeltaY = deltaYOffset - Convert.ToSingle(5.7); //else tempPositioneText.DeltaY = deltaYOffset - Convert.ToSingle(7.5); tablePDF.Cells[4, i].ValueObjectList.Add(tempPositioneText); } i++; } AddElement(tablePDF); AddElement(new SpacePDF(20)); // patryk ------------------------- var tables = dataset.Tables.Cast().Where(x => x.Rows.Count > 0).ToList(); var lastTable = tables.Last(); if (tables.Count > 4) { lastTable = tables[4]; } if (table != lastTable) { ActionPDF action = new ActionPDF(); action.YPositionAction = (yPos) => { List objectsList = new List(); //if (yPos > 300) if (yPos > 260) { objectsList.Add(new PagePDF(PagePDF.PagePDFType.Generic)); } return objectsList; }; //AddElement(action); } // ------------------------------- cont++; } contatore++; } } protected float sumColumns(TablePDF table, int columns) { float _var = 0; for (int i = 0; i < Math.Min(columns, table.Columns.Count); i++) _var += table.Columns[i].Width; return _var; } protected void addLegend(List repeatedList) { int xLegenda = 35; int legendWidth = 260; int legendHeight = 15; float yLegenda = EnvironmentFacade.RendererFacade.YLowerLimit - 40; AddElement(new SpacePDF(5)); var ftaNomeLabel = new FormattedTextAreaPDF { Text = "Livello di rischio", FontColor = ColorPDF.Nero, X = xLegenda + 10, FontSize = 7, Y = yLegenda - 10, FontBold = true }; // Original //repeatedList.Add(new RectanglePDF(legendHeight, legendWidth, new ColorPDF(217, 217, 217)) { X = xLegenda, AutoIncrementYWritable = false, Y = yLegenda }); // Sfondo Bianco repeatedList.Add(new RectanglePDF(legendHeight, legendWidth, new ColorPDF(255, 255, 255)) { X = xLegenda, AutoIncrementYWritable = false, Y = yLegenda, BorderColor = ColorPDF.Immobiliare_Grigio_TitoloPiccolo, BorderWidth = 0.2f }); repeatedList.Add(new ImagePDF(xLegenda, 0.30F, "basso.png") { DeltaY = 4F, AutoIncrementYWritable = false, DeltaX = 4F, Y = yLegenda }); repeatedList.Add(ftaNomeLabel); xLegenda += 15; ftaNomeLabel = new FormattedTextAreaPDF { Text = "Basso", FontColor = ColorPDF.Nero, DeltaX = 1F, DeltaY = 4F, AutoIncrementYWritable = false, X = xLegenda, FontSize = 7, Y = yLegenda }; xLegenda += (ftaNomeLabel.Text.Length * 5) + (10 - ftaNomeLabel.Text.Length); repeatedList.Add(ftaNomeLabel); repeatedList.Add(new ImagePDF(xLegenda, 0.30F, "medio_basso.png") { DeltaY = 4F, AutoIncrementYWritable = false, DeltaX = 4F, Y = yLegenda }); xLegenda += 15; ftaNomeLabel = new FormattedTextAreaPDF { Text = "Medio basso", FontColor = ColorPDF.Nero, DeltaX = 1F, DeltaY = 4F, AutoIncrementYWritable = false, X = xLegenda, FontSize = 7, Y = yLegenda }; xLegenda += (ftaNomeLabel.Text.Length * 5) + (10 - ftaNomeLabel.Text.Length); repeatedList.Add(ftaNomeLabel); repeatedList.Add(new ImagePDF(xLegenda, 0.30F, "medio.png") { DeltaY = 4F, AutoIncrementYWritable = false, DeltaX = 4F, Y = yLegenda }); xLegenda += 15; ftaNomeLabel = new FormattedTextAreaPDF { Text = "Medio", FontColor = ColorPDF.Nero, DeltaX = 1F, DeltaY = 4F, AutoIncrementYWritable = false, X = xLegenda, FontSize = 7, Y = yLegenda }; xLegenda += (ftaNomeLabel.Text.Length * 5) + (10 - ftaNomeLabel.Text.Length); repeatedList.Add(ftaNomeLabel); repeatedList.Add(new ImagePDF(xLegenda, 0.30F, "medio_alto.png") { DeltaY = 4F, AutoIncrementYWritable = false, DeltaX = 4F, Y = yLegenda }); xLegenda += 15; ftaNomeLabel = new FormattedTextAreaPDF { Text = "Medio alto", FontColor = ColorPDF.Nero, DeltaX = 1F, DeltaY = 4F, AutoIncrementYWritable = false, X = xLegenda, FontSize = 7, Y = yLegenda }; xLegenda += +(ftaNomeLabel.Text.Length * 5) + (10 - ftaNomeLabel.Text.Length); repeatedList.Add(ftaNomeLabel); repeatedList.Add(new ImagePDF(xLegenda, 0.30F, "alto.png") { DeltaY = 4F, AutoIncrementYWritable = false, DeltaX = 4F, Y = yLegenda }); xLegenda += 15; ftaNomeLabel = new FormattedTextAreaPDF { Text = "Alto", FontColor = ColorPDF.Nero, DeltaX = 1F, DeltaY = 4F, AutoIncrementYWritable = false, X = xLegenda, FontSize = 7, Y = yLegenda }; repeatedList.Add(ftaNomeLabel); #region legenda freccia xLegenda += 50; legendWidth = 160; legendHeight = 15; // Original //repeatedList.Add(new RectanglePDF(legendHeight, legendWidth, new ColorPDF(217, 217, 217)) { X = xLegenda, AutoIncrementYWritable = false, Y = yLegenda }); // Sfondo Bianco repeatedList.Add(new RectanglePDF(legendHeight, legendWidth, new ColorPDF(255, 255, 255)) { X = xLegenda, AutoIncrementYWritable = false, Y = yLegenda, BorderColor = ColorPDF.Immobiliare_Grigio_TitoloPiccolo, BorderWidth = 0.2f }); repeatedList.Add(new ImagePDF(xLegenda, 0.50F, "upArrow.png") { DeltaY = 4F, AutoIncrementYWritable = false, DeltaX = 4F, Y = yLegenda }); ftaNomeLabel = new FormattedTextAreaPDF { Text = "Trend valore", FontColor = ColorPDF.Nero, X = xLegenda + 10, FontSize = 7, Y = yLegenda - 10, FontBold = true }; repeatedList.Add(ftaNomeLabel); xLegenda += 20; ftaNomeLabel = new FormattedTextAreaPDF { Text = "In crescita", FontColor = ColorPDF.Nero, DeltaX = 1F, DeltaY = 4F, AutoIncrementYWritable = false, X = xLegenda, FontSize = 7, Y = yLegenda }; xLegenda += 40;// + (ftaNomeLabel.Text.Length * 5) + (10 - ftaNomeLabel.Text.Length); repeatedList.Add(ftaNomeLabel); repeatedList.Add(new ImagePDF(xLegenda, 0.35F, "horizontalArrow.png") { DeltaY = 5.2F, AutoIncrementYWritable = false, DeltaX = 4F, Y = yLegenda }); xLegenda += 20; ftaNomeLabel = new FormattedTextAreaPDF { Text = "Stabile", FontColor = ColorPDF.Nero, DeltaX = 1F, DeltaY = 4F, AutoIncrementYWritable = false, X = xLegenda, FontSize = 7, Y = yLegenda }; xLegenda += 25;// + (ftaNomeLabel.Text.Length * 5) + (10 - ftaNomeLabel.Text.Length); repeatedList.Add(ftaNomeLabel); repeatedList.Add(new ImagePDF(xLegenda, 0.50F, "downArrow.png") { DeltaY = 4F, AutoIncrementYWritable = false, DeltaX = 4F, Y = yLegenda }); xLegenda += 20; ftaNomeLabel = new FormattedTextAreaPDF { Text = "In calo", FontColor = ColorPDF.Nero, DeltaX = 1F, DeltaY = 4F, AutoIncrementYWritable = false, X = xLegenda, FontSize = 7, Y = yLegenda }; repeatedList.Add(ftaNomeLabel); #endregion } /// /// 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.Int64, ParameterName = "ChiaveClientePB", Value = EnvironmentFacade.ReportEnvironment.Cliente.Chiave } }; var dsOriginal = DataAccess.ExecuteDataSetStoredProcedure(DBProvider.SqlServerConsulenzaUnica, "REP_ImmobiliareMonitoraggio_S_AnalisiRischioDettaglio", parametri); if (dsOriginal.Tables[0].Rows.Count == 0) return null; DataSet data = new DataSet(); data.Tables.Add(dsOriginal.Tables[0].Copy()); (data.Tables[0]).TableName = "diversificazione"; // Classe Diversificazione dsOriginal.Tables.Remove(dsOriginal.Tables[0]); data.Tables.Add(new DataTable("1")); // U data.Tables["1"].Columns.Add("comune", typeof(string)); data.Tables["1"].Columns.Add("posizione", typeof(string)); data.Tables["1"].Columns.Add("numeroImmobili", typeof(string)); data.Tables["1"].Columns.Add("rischioValore", typeof(string)); data.Tables["1"].Columns.Add("rischioLiquidita", typeof(string)); data.Tables["1"].Columns.Add("trendValore", typeof(string)); data.Tables["1"].Columns.Add("proQuota", typeof(string)); data.Tables["1"].Columns.Add("stimatoTotale", typeof(string)); data.Tables.Add(new DataTable("2")); // S data.Tables["2"].Columns.Add("comune", typeof(string)); data.Tables["2"].Columns.Add("posizione", typeof(string)); data.Tables["2"].Columns.Add("numeroImmobili", typeof(string)); data.Tables["2"].Columns.Add("rischioValore", typeof(string)); data.Tables["2"].Columns.Add("rischioLiquidita", typeof(string)); data.Tables["2"].Columns.Add("trendValore", typeof(string)); data.Tables["2"].Columns.Add("proQuota", typeof(string)); data.Tables["2"].Columns.Add("stimatoTotale", typeof(string)); data.Tables.Add(new DataTable("3")); // I data.Tables["3"].Columns.Add("comune", typeof(string)); data.Tables["3"].Columns.Add("posizione", typeof(string)); data.Tables["3"].Columns.Add("numeroImmobili", typeof(string)); data.Tables["3"].Columns.Add("rischioValore", typeof(string)); data.Tables["3"].Columns.Add("rischioLiquidita", typeof(string)); data.Tables["3"].Columns.Add("trendValore", typeof(string)); data.Tables["3"].Columns.Add("proQuota", typeof(string)); data.Tables["3"].Columns.Add("stimatoTotale", typeof(string)); data.Tables.Add(new DataTable("4")); // NS data.Tables["4"].Columns.Add("comune", typeof(string)); data.Tables["4"].Columns.Add("posizione", typeof(string)); data.Tables["4"].Columns.Add("numeroImmobili", typeof(string)); data.Tables["4"].Columns.Add("rischioValore", typeof(string)); data.Tables["4"].Columns.Add("rischioLiquidita", typeof(string)); data.Tables["4"].Columns.Add("trendValore", typeof(string)); data.Tables["4"].Columns.Add("proQuota", typeof(string)); data.Tables["4"].Columns.Add("stimatoTotale", typeof(string)); data.Tables.Add(new DataTable("1footer")); // U data.Tables["1footer"].Columns.Add("comune", typeof(string)); data.Tables["1footer"].Columns.Add("numeroImmobili", typeof(string)); data.Tables["1footer"].Columns.Add("rischioValore", typeof(string)); data.Tables["1footer"].Columns.Add("rischioLiquidita", typeof(string)); data.Tables["1footer"].Columns.Add("trendValore", typeof(string)); data.Tables["1footer"].Columns.Add("proQuota", typeof(string)); data.Tables["1footer"].Columns.Add("stimatoTotale", typeof(string)); data.Tables.Add(new DataTable("2footer")); // S data.Tables["2footer"].Columns.Add("comune", typeof(string)); data.Tables["2footer"].Columns.Add("numeroImmobili", typeof(string)); data.Tables["2footer"].Columns.Add("rischioValore", typeof(string)); data.Tables["2footer"].Columns.Add("rischioLiquidita", typeof(string)); data.Tables["2footer"].Columns.Add("trendValore", typeof(string)); data.Tables["2footer"].Columns.Add("proQuota", typeof(string)); data.Tables["2footer"].Columns.Add("stimatoTotale", typeof(string)); data.Tables.Add(new DataTable("3footer")); // I data.Tables["3footer"].Columns.Add("comune", typeof(string)); data.Tables["3footer"].Columns.Add("numeroImmobili", typeof(string)); data.Tables["3footer"].Columns.Add("rischioValore", typeof(string)); data.Tables["3footer"].Columns.Add("rischioLiquidita", typeof(string)); data.Tables["3footer"].Columns.Add("trendValore", typeof(string)); data.Tables["3footer"].Columns.Add("proQuota", typeof(string)); data.Tables["3footer"].Columns.Add("stimatoTotale", typeof(string)); data.Tables.Add(new DataTable("4footer")); // NS data.Tables["4footer"].Columns.Add("comune", typeof(string)); data.Tables["4footer"].Columns.Add("numeroImmobili", typeof(string)); data.Tables["4footer"].Columns.Add("rischioValore", typeof(string)); data.Tables["4footer"].Columns.Add("rischioLiquidita", typeof(string)); data.Tables["4footer"].Columns.Add("trendValore", typeof(string)); data.Tables["4footer"].Columns.Add("proQuota", typeof(string)); data.Tables["4footer"].Columns.Add("stimatoTotale", typeof(string)); List ordinamento = new List(); ordinamento.Add(1); ordinamento.Add(2); ordinamento.Add(3); ordinamento.Add(4); foreach (int value in ordinamento) { if (dsOriginal.Tables[0].AsEnumerable().Where(x => x.Field("chiaveUsoTipologia") == value).Count() > 0 && dsOriginal.Tables[1].AsEnumerable().Where(x => x.Field("chiaveUsoTipologia") == value).Count() > 0) { DataTable copyDataTableBold = dsOriginal.Tables[0].AsEnumerable().Where(x => x.Field("chiaveUsoTipologia") == value).CopyToDataTable(); var newSort = (from row in copyDataTableBold.AsEnumerable() group row by new { comuneTipologia = row.Field("comuneTipologia"), numImmobiliComune = row.Field("numImmobiliComune"), valProQuotaComune = row.Field("valProQuotacomune"), valTotaleComune = row.Field("valTotaleComune"), //finalitaTipologia = row.Field("finalitaTipologia"), //valTotale = row.Field("valTotale"), } into grp select new { //descrizione = copyDataTable.AsEnumerable().Where(f => f.Field("comune") == grp.Key.comune).Select(s => s.Field("descrizione")).FirstOrDefault(), comuneTipologia = grp.Key.comuneTipologia, numImmobiliComune = grp.Key.numImmobiliComune, valProQuotaComune = grp.Key.valProQuotaComune, valTotaleComune = grp.Key.valTotaleComune, //valTotale = grp.Key.valTotale, //finalitaTipologia = grp.Key.finalitaTipologia }).Distinct().ToList(); //.OrderByDescending(oo=> oo.valTotale).OrderBy(oo => oo.finalitaTipologia).ToList(); // Ciclo per la Tipologia non Terreni foreach(var item in newSort) { int contaRighe = dsOriginal.Tables[1].AsEnumerable().Where(x => x.Field("chiaveUsoTipologia").Equals(value) && x.Field("comuneTipologia").Equals(item.comuneTipologia) && !x.Field("finalitaTipologia").Equals("Terreni")).Count(); if (contaRighe > 0) { data.Tables[value].Rows.Add("" + item.comuneTipologia + "", "", "" + item.numImmobiliComune + "", "", "", "", "" + item.valProQuotaComune + "", "" + item.valTotaleComune + ""); DataTable copyDataTable = dsOriginal.Tables[1].AsEnumerable().Where(x => x.Field("chiaveUsoTipologia").Equals(value) && x.Field("comuneTipologia").Equals(item.comuneTipologia) && !x.Field("finalitaTipologia").Equals("Terreni")).CopyToDataTable(); for (int k = 0; k < copyDataTable.Rows.Count; k++) { string sEstero = "N"; if (copyDataTable.Rows[k]["posizioneMicroZona"].ToString() == "") sEstero = "n.d."; else sEstero = copyDataTable.Rows[k]["posizioneMicroZona"].ToString(); data.Tables[value].Rows.Add( (copyDataTable.Rows[k]["finalitaTipologia"] == null ? "n.c." : copyDataTable.Rows[k]["finalitaTipologia"]), sEstero, (copyDataTable.Rows[k]["numImmobili"] == null ? "n.c." : copyDataTable.Rows[k]["numImmobili"]), copyDataTable.Rows[k]["classeRischioValore"].ToString().ToLower() + ".png", copyDataTable.Rows[k]["classeRischioLiquidabilita"].ToString().ToLower() + ".png", translateStringInSymbol(copyDataTable.Rows[k]["trend"].ToString()), Helper.FormatCurrency(Convert.ToDecimal(copyDataTable.Rows[k]["valProQuota"] == null ? 0 : copyDataTable.Rows[k]["valProQuota"]).ToString()), Helper.FormatCurrency(Convert.ToDecimal(copyDataTable.Rows[k]["valTotale"] == null ? 0 : copyDataTable.Rows[k]["valTotale"]).ToString())); } } } // Ciclo per la tipologia Terreni if (dsOriginal.Tables[1].AsEnumerable().Where(x=> x.Field("finalitaTipologia").Equals("Terreni")).Count() > 0) { var _dt = dsOriginal.Tables[1].AsEnumerable().Where(x => x.Field("chiaveUsoTipologia").Equals(value) && x.Field("finalitaTipologia").Equals("Terreni")); foreach (var itemTerr in _dt.AsEnumerable()) { int contaRigheTerreni = dsOriginal.Tables[1].AsEnumerable().Where(x => x.Field("chiaveUsoTipologia").Equals(value) && x.Field("comuneTipologia").Equals(itemTerr.Field("comuneTipologia")) && x.Field("finalitaTipologia").Equals("Terreni")).Count(); if (contaRigheTerreni > 0) { data.Tables[value].Rows.Add("" + itemTerr["comuneTipologia"] + "", "", "" + string.Empty + " ", "", "", "", "" + string.Empty + "", "" + string.Empty + ""); DataTable copyDataTable = dsOriginal.Tables[1].AsEnumerable().Where(x => x.Field("chiaveUsoTipologia").Equals(value) && x.Field("comuneTipologia").Equals(itemTerr.Field("comuneTipologia")) && x.Field("finalitaTipologia").Equals("Terreni")).CopyToDataTable(); for (int k = 0; k < copyDataTable.Rows.Count; k++) { string sEstero = "N"; if (copyDataTable.Rows[k]["posizioneMicroZona"].ToString() == "") sEstero = "n.d."; else sEstero = copyDataTable.Rows[k]["posizioneMicroZona"].ToString(); data.Tables[value].Rows.Add( (copyDataTable.Rows[k]["finalitaTipologia"] == null ? "n.c." : copyDataTable.Rows[k]["finalitaTipologia"]), sEstero, (copyDataTable.Rows[k]["numImmobili"] == null ? "n.c." : copyDataTable.Rows[k]["numImmobili"]), copyDataTable.Rows[k]["classeRischioValore"].ToString().ToLower() + ".png", copyDataTable.Rows[k]["classeRischioLiquidabilita"].ToString().ToLower() + ".png", translateStringInSymbol(copyDataTable.Rows[k]["trend"].ToString()), Helper.FormatCurrency(Convert.ToDecimal(copyDataTable.Rows[k]["valProQuota"] == null ? 0 : copyDataTable.Rows[k]["valProQuota"]).ToString()), Helper.FormatCurrency(Convert.ToDecimal(copyDataTable.Rows[k]["valTotale"] == null ? 0 : copyDataTable.Rows[k]["valTotale"]).ToString())); } } } } //foreach (var itemTerreni in newSort) //{ // int contaRigheTerreni = dsOriginal.Tables[1].AsEnumerable().Where(x => // x.Field("chiaveUsoTipologia").Equals(value) && x.Field("comuneTipologia").Equals(itemTerreni.comuneTipologia) // && x.Field("finalitaTipologia").Equals("Terreni")).Count(); // if (contaRigheTerreni > 0) // { // data.Tables[value].Rows.Add("" + itemTerreni.comuneTipologia + "", "", // "" + itemTerreni.numImmobiliComune + "", "", "", "", // "" + itemTerreni.valProQuotaComune + "", // "" + itemTerreni.valTotaleComune + ""); // DataTable copyDataTable = dsOriginal.Tables[1].AsEnumerable().Where(x => // x.Field("chiaveUsoTipologia").Equals(value) && x.Field("comuneTipologia").Equals(itemTerreni.comuneTipologia) // && x.Field("finalitaTipologia").Equals("Terreni")).CopyToDataTable(); // for (int k = 0; k < copyDataTable.Rows.Count; k++) // { // string sEstero = "N"; // if (copyDataTable.Rows[k]["posizioneMicroZona"].ToString() == "") // sEstero = "n.d."; // else // sEstero = copyDataTable.Rows[k]["posizioneMicroZona"].ToString(); // data.Tables[value].Rows.Add( // (copyDataTable.Rows[k]["finalitaTipologia"] == null ? "n.c." : copyDataTable.Rows[k]["finalitaTipologia"]), // sEstero, // (copyDataTable.Rows[k]["numImmobili"] == null ? "n.c." : copyDataTable.Rows[k]["numImmobili"]), // copyDataTable.Rows[k]["classeRischioValore"].ToString().ToLower() + ".png", // copyDataTable.Rows[k]["classeRischioLiquidabilita"].ToString().ToLower() + ".png", // translateStringInSymbol(copyDataTable.Rows[k]["trend"].ToString()), // Helper.FormatCurrency(Convert.ToDecimal(copyDataTable.Rows[k]["valProQuota"] == null ? 0 : copyDataTable.Rows[k]["valProQuota"]).ToString()), // Helper.FormatCurrency(Convert.ToDecimal(copyDataTable.Rows[k]["valTotale"] == null ? 0 : copyDataTable.Rows[k]["valTotale"]).ToString())); // } // } //} DataTable copyDataTableTotale = dsOriginal.Tables[2].AsEnumerable().Where(x => x.Field("chiaveUsoTipologia") == value).CopyToDataTable(); data.Tables[value + "footer"].Rows.Add( "Totale", copyDataTableTotale.Rows[0]["numImmobili"], copyDataTableTotale.Rows[0]["classeRischioValore"].ToString().ToLower() + ".png", copyDataTableTotale.Rows[0]["classeRischioLiquidabilita"].ToString().ToLower() + ".png", "", Helper.FormatCurrency(Convert.ToDecimal(copyDataTableTotale.Rows[0]["valProQuota"]).ToString()), Helper.FormatCurrency(Convert.ToDecimal(copyDataTableTotale.Rows[0]["valTotale"]).ToString())); } } #region Old versione //foreach (int value in ordinamento) //{ // if (dsOriginal.Tables[0].AsEnumerable().Where(x => x.Field("chiaveUsoTipologia") == value).Count() > 0 && // dsOriginal.Tables[1].AsEnumerable().Where(x => x.Field("chiaveUsoTipologia") == value).Count() > 0) // { // DataTable copyDataTableBold = dsOriginal.Tables[0].AsEnumerable().Where(x => x.Field("chiaveUsoTipologia") == value).CopyToDataTable(); // for (int i = 0; i < copyDataTableBold.Rows.Count; i++) // { // data.Tables[value].Rows.Add("" + copyDataTableBold.Rows[i]["comuneTipologia"] + "", "", // "" + copyDataTableBold.Rows[i]["numImmobiliComune"] + "", "", "", "", // "" + copyDataTableBold.Rows[i]["valProQuotaComune"] + "", // "" + copyDataTableBold.Rows[i]["valTotaleComune"] + ""); // DataTable copyDataTable = dsOriginal.Tables[1].AsEnumerable().Where(x => // x.Field("chiaveUsoTipologia").Equals(value) && x.Field("comuneTipologia").Equals(copyDataTableBold.Rows[i]["comuneTipologia"])).CopyToDataTable(); // for (int k = 0; k < copyDataTable.Rows.Count; k++) // { // string sEstero = "N"; // if (copyDataTable.Rows[k]["posizioneMicroZona"].ToString() == "") // sEstero = "n.d."; // else // sEstero = copyDataTable.Rows[k]["posizioneMicroZona"].ToString(); // data.Tables[value].Rows.Add( // copyDataTable.Rows[k]["finalitaTipologia"], // sEstero, // copyDataTable.Rows[k]["numImmobili"], // copyDataTable.Rows[k]["classeRischioValore"].ToString().ToLower() + ".png", // copyDataTable.Rows[k]["classeRischioLiquidabilita"].ToString().ToLower() + ".png", // translateStringInSymbol(copyDataTable.Rows[k]["trend"].ToString()), // Helper.FormatCurrency(Convert.ToDecimal(copyDataTable.Rows[k]["valProQuota"]).ToString()), // Helper.FormatCurrency(Convert.ToDecimal(copyDataTable.Rows[k]["valTotale"]).ToString())); // } // } // DataTable copyDataTableTotale = dsOriginal.Tables[2].AsEnumerable().Where(x => x.Field("chiaveUsoTipologia") == value).CopyToDataTable(); // data.Tables[value + "footer"].Rows.Add( // "Totale", // copyDataTableTotale.Rows[0]["numImmobili"], // copyDataTableTotale.Rows[0]["classeRischioValore"].ToString().ToLower() + ".png", // copyDataTableTotale.Rows[0]["classeRischioLiquidabilita"].ToString().ToLower() + ".png", // "", // Helper.FormatCurrency(Convert.ToDecimal(copyDataTableTotale.Rows[0]["valProQuota"]).ToString()), // Helper.FormatCurrency(Convert.ToDecimal(copyDataTableTotale.Rows[0]["valTotale"]).ToString())); // } //} #endregion return data; } protected string getTesto1() { //return "Di seguito si rappresentano i diversi livelli di rischio del patrimonio immobiliare."; return "Di seguito si rappresentano i diversi livelli di rischio del patrimonio immobiliare. I terreni sono esclusi dalle elaborazioni di rischio e
diversificazione."; } public static string translateStringInSymbol(string trend) { string result = ""; switch (trend) { case "=": result = "horizontalArrow.png"; break; case "-": result = "downArrow.png"; break; case "+": result = "upArrow.png"; break; default: result = trend; break; } return result; } public static string getTitle(string number) { string result = ""; switch (number) { case "1": result = "Immobili d'uso abitativo"; break; case "2": result = "Immobili strumentali"; break; case "3": result = "Immobili d'investimento"; break; case "4": result = "Immobili con finalità non specificata"; break; } return result; } } }