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 Consulenza.ReportWriter.Business.Headers;
using System.Drawing;
using Dundas.Charting.WebControl;
namespace Consulenza.ReportWriter.Manager.Section.Immobiliare.Monitoraggio
{
///
/// Scheda 16
///
public class S16 : Entity.Section
{
public bool bEstero = false;
public S16(EnvironmentFacade environmentFacade, int idSection)
: base(environmentFacade, idSection)
{
try
{
Draw();
}
catch (Exception ex)
{
SectionLogger.Write("S16", 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()
{
AddElement(new SpacePDF(55));
// Modifica ES del 24.05.2018
// var sintesiImage = new ImagePDF(25, 0.67F, "sintesi.png");
var sintesiImage = new ImagePDF(25, 0.71F, "sintesi.jpg");
AddElement(sintesiImage);
AddElement(new PagePDF(PagePDF.PagePDFType.Generic));
var data = GetDataSet();
// INDICATORI DI DIVERSIFICAZIONE 11.05.2018
AddElement(new FormattedTextAreaPDF("Di seguito sono rappresentati il livello di rischio e la diversificazione del patrimonio immobiliare.", 30)
{
AutoIncrementYWritable = false,
Width = 800,
FontSize = 9.96f,
FontColor = new ColorPDF(91, 88, 79),
Y = 60
});
AddElement(new LinePDF()
{
AutoIncrementYWritable = false,
Width = 1.5f,
Y1 = 85,
Y2 = 85,
X1 = 35,
X2 = 750,
Color = new ColorPDF(153,149,133)
});
AddElement(new RectanglePDF()
{
AutoIncrementYWritable = false,
Width = 120,
Height = 15,
X = 35,
Y = 98,
Color = new ColorPDF(196, 196, 186)
});
AddElement(new FormattedTextAreaPDF("Rischio valore", 40)
{
AutoIncrementYWritable = false,
Y = 99,
FontBold = true,
FontSize = 9.96f,
FontColor = new ColorPDF(255, 255, 255),
TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Left
});
AddElement(new FormattedTextAreaPDF("Rappresentazione del rischio di deprezzamento dell’immobile in funzione dell’esposizione a possibili variazioni delle condizioni di domanda.", 163)
{
AutoIncrementYWritable = false,
Y = 95,
FontSize = 9.96f,
FontColor = new ColorPDF(92, 89, 81),
Width = 260,
TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Left,
});
AddElement(new RectanglePDF()
{
AutoIncrementYWritable = false,
Width = 120,
Height = 15,
X = 35,
Y = 151,
Color = new ColorPDF(196, 196, 186)
});
AddElement(new FormattedTextAreaPDF("Rischio liquidabilità", 40)
{
AutoIncrementYWritable = false,
Y = 152,
FontBold = true,
FontSize = 9.96f,
FontColor = new ColorPDF(255, 255, 255),
TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Left
});
AddElement(new FormattedTextAreaPDF("Rappresentazione del rischio legato alle difficoltà di smobilizzo dell’immobile in tempi brevi alle condizioni di mercato.", 163)
{
AutoIncrementYWritable = false,
Y = 148,
FontSize = 9.96f,
FontColor = new ColorPDF(92, 89, 81),
Width = 260,
TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Left,
});
AddElement(new LinePDF()
{
AutoIncrementYWritable = false,
Width = 1.5f,
Y1 = 195,
Y2 = 195,
X1 = 35,
X2 = 750,
Color = new ColorPDF(153, 149, 133)
});
var chartData = GetChartsData(data);
List legendItems = new List()
{
new LegendItem() {Color = Color.FromArgb(0,109,45), Text = "Basso"},
new LegendItem() {Color = Color.FromArgb(162,216,154), Text = "Medio basso"},
new LegendItem() {Color = Color.FromArgb(242,221,68), Text = "Medio"},
new LegendItem() {Color = Color.FromArgb(233,148,33), Text = "Medio alto"},
new LegendItem() {Color = Color.FromArgb(213,38,7), Text = "Alto"}
};
DrawLegend(428, 97, 265, 65, legendItems, chartData.ClasseRischioValore, chartData.ClasseRischioLiquidabilita);
//float widthSmallRectangle = 173;
float widthSmallRectangle = 172;
float xSmallRectangle = 103;
AddElement(new RectanglePDF()
{
AutoIncrementYWritable = false,
Width = 355,
Height = 255,
X = 32,
Y = 205,
Color = new ColorPDF(196, 196, 186)
});
// INDICATORI DI DIVERSIFICAZIONE 11.05.2018
AddElement(new FormattedTextAreaPDF("Diversificazione", 35)
{
AutoIncrementYWritable = false,
Y = 206,
FontBold = true,
FontSize = 9.96f,
FontColor = new ColorPDF(255, 255, 255),
TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Left
});
AddElement(new RectanglePDF()
{
AutoIncrementYWritable = false,
Width = 353,
Height = 239,
X = 33,
Y = 220,
Color = new ColorPDF(255, 255, 255)
});
AddElement(new FormattedTextAreaPDF("Indicatore complessivo che prende in considerazione la diversificazione per geografia, per tipologia immobiliare e per numerosità degli immobili.", 36)
{
AutoIncrementYWritable = false,
Y = 225,
FontSize = 8f,
FontColor = new ColorPDF(92, 89, 81),
Width = 325,
TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Left,
});
AddElement(new RectanglePDF()
{
AutoIncrementYWritable = false,
Width = widthSmallRectangle,
Height = 65,
X = 36,
Y = 250,
// Original
//Color = new ColorPDF(239, 240, 237)
// Sfondo Bianco su Rectangle
Color = new ColorPDF(255, 255, 255),
BorderColor = ColorPDF.Immobiliare_Grigio_TitoloPiccolo,
BorderWidth = 0.2f
});
// Original
//DrawPieChart((double)chartData.ValDiversificazioneGeografia, Color.FromArgb(196, 196, 186), Color.FromArgb(239, 240, 237), xSmallRectangle, 252, 60, 35);
// Sfondo Bianco su Graph
DrawPieChart((double)chartData.ValDiversificazioneGeografia, Color.FromArgb(196, 196, 186), Color.FromArgb(255, 255, 255), xSmallRectangle, 252, 60, 35);
AddElement(new FormattedTextAreaPDF("Diversificazione per geografia", 38)
{
AutoIncrementYWritable = false,
Y = 252,
FontBold = true,
FontSize = 8.00f,
Width = 72,
FontColor = new ColorPDF(79, 92, 100),
TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Left
});
AddElement(new FormattedTextAreaPDF(chartData.ClasseDiversificazioneGeografia, 163, 45)
{
AutoIncrementYWritable = false,
Y = 278,
FontBold = true,
FontSize = 6.96f,
FontColor = new ColorPDF(0, 0, 0),
TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Center
});
AddElement(new RectanglePDF()
{
AutoIncrementYWritable = false,
Width = widthSmallRectangle,
Height = 65,
X = 36,
Y = 320,
// Original
//Color = new ColorPDF(239, 240, 237)
// Sfondo Bianco su Rectangle
Color = new ColorPDF(255, 255, 255),
BorderColor = ColorPDF.Immobiliare_Grigio_TitoloPiccolo,
BorderWidth = 0.2f
});
// Original
//DrawPieChart((double)chartData.ValDiversificazioneTipologia, Color.FromArgb(196, 196, 186), Color.FromArgb(239, 240, 237), xSmallRectangle, 322, 60, 35);
// Sfondo Bianco su Graph
DrawPieChart((double)chartData.ValDiversificazioneTipologia, Color.FromArgb(196, 196, 186), Color.FromArgb(255, 255, 255), xSmallRectangle, 322, 60, 35);
AddElement(new FormattedTextAreaPDF("Diversificazione per tipologia", 38)
{
AutoIncrementYWritable = false,
Y = 321,
FontBold = true,
FontSize = 8.00f,
Width = 72,
FontColor = new ColorPDF(79, 92, 100),
TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Left
});
AddElement(new FormattedTextAreaPDF(chartData.ClasseDiversificazioneTipologia, 163, 45)
{
AutoIncrementYWritable = false,
Y = 348,
FontBold = true,
FontSize = 6.96f,
FontColor = new ColorPDF(0, 0, 0),
TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Center
});
AddElement(new RectanglePDF()
{
AutoIncrementYWritable = false,
Width = widthSmallRectangle,
Height = 65,
X = 36,
Y = 390,
// Original
//Color = new ColorPDF(239, 240, 237)
// Sfondo Bianco su Rectangle
Color = new ColorPDF(255, 255, 255),
BorderColor = ColorPDF.Immobiliare_Grigio_TitoloPiccolo,
BorderWidth = 0.2f
});
// Original
//DrawPieChart((double)chartData.ValDiversificazioneNumerosita, Color.FromArgb(196, 196, 186), Color.FromArgb(239, 240, 237), xSmallRectangle, 392, 60, 35);
// Sfondo Bianco su Graph
DrawPieChart((double)chartData.ValDiversificazioneNumerosita, Color.FromArgb(196, 196, 186), Color.FromArgb(255, 255, 255), xSmallRectangle, 392, 60, 35);
AddElement(new FormattedTextAreaPDF("Diversificazione per numerosità", 38)
{
AutoIncrementYWritable = false,
Y = 392,
FontBold = true,
FontSize = 8.00f,
Width = 72,
FontColor = new ColorPDF(79, 92, 100),
TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Left
});
AddElement(new FormattedTextAreaPDF(chartData.ClasseDiversificazioneNumerosita, 163, 45)
{
AutoIncrementYWritable = false,
Y = 417,
FontBold = true,
FontSize = 6.96f,
FontColor = new ColorPDF(0, 0, 0),
TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Center
});
AddElement(new RectanglePDF()
{
AutoIncrementYWritable = false,
Width = widthSmallRectangle-1,
Height = 205,
X = 212,
Y = 250,
// Original
//Color = new ColorPDF(239, 240, 237)
// Sfondo Bianco su Rectangle
Color = new ColorPDF(255, 255, 255),
BorderColor = ColorPDF.Immobiliare_Grigio_TitoloPiccolo,
BorderWidth = 0.2f
});
AddElement(new FormattedTextAreaPDF("Diversificazione
complessiva", 257)
{
AutoIncrementYWritable = false,
Y = 270,
FontBold = true,
FontSize = 9.04f,
Width = 85,
FontColor = new ColorPDF(79, 92, 100),
TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Center
});
// Original
//DrawPieChart((double)chartData.ValDiversificazioneComplessiva, Color.FromArgb(196, 196, 186), Color.FromArgb(239, 240, 237), 235, 300, 120, 30);
DrawPieChart((double)chartData.ValDiversificazioneComplessiva, Color.FromArgb(196, 196, 186), Color.FromArgb(255, 255, 255), 235, 300, 120, 30);
AddElement(new FormattedTextAreaPDF(chartData.ClasseDiversificazioneComplessiva, 212)
{
Width = widthSmallRectangle,
AutoIncrementYWritable = false,
Y = 427,
FontBold = true,
FontSize = 11f,
FontColor = new ColorPDF(0, 0, 0),
TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Center
});
AddElement(new RectanglePDF()
{
AutoIncrementYWritable = false,
Width = 355,
Height = 255,
X = 397,
Y = 205,
Color = new ColorPDF(196, 196, 186)
});
// INDICATORI DI DIVERSIFICAZIONE 11.05.2018
AddElement(new FormattedTextAreaPDF("Rischio complessivo e Diversificazione", 400)
{
AutoIncrementYWritable = false,
Y = 206,
FontBold = true,
FontSize = 9.96f,
FontColor = new ColorPDF(255, 255, 255),
TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Left
});
AddElement(new RectanglePDF()
{
AutoIncrementYWritable = false,
Width = 353,
Height = 239,
X = 398,
Y = 220,
Color = new ColorPDF(255, 255, 255)
});
DrawChart(chartData, 410, 230, 325, 165);
AddElement(new FormattedTextAreaPDF("Diversificazione", 410)
{
AutoIncrementYWritable = false,
Y = 360,
FontBold = false,
FontSize = 8f,
FontColor = new ColorPDF(0, 0, 0),
TextVerticalDirection = true
});
AddElement(new FormattedTextAreaPDF("Controvalore del portafoglio immobiliare €/mln", 510)
{
AutoIncrementYWritable = false,
Y = 400,
FontBold = false,
FontSize = 8f,
FontColor = new ColorPDF(0, 0, 0),
});
AddElement(new ImagePDF(447, 0.45f, "dotted_blue_line.png")
{
Y = 420
});
AddElement(new FormattedTextAreaPDF("Livello di massima diversificazione", 435)
{
AutoIncrementYWritable = false,
Y = 428,
Width = 60,
FontBold = false,
FontSize = 6f,
FontColor = new ColorPDF(0, 0, 0),
TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Center
});
AddElement(new ImagePDF(505, 0.45f, "colored_bar.png")
{
Y = 435
});
AddElement(new FormattedTextAreaPDF("Area di
ECCESSIVA CONCENTRAZIONE", 505)
{
AutoIncrementYWritable = false,
Y = 423,
Width = 75,
FontBold = false,
FontSize = 4.56f,
FontColor = new ColorPDF(0, 0, 0),
TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Center
});
AddElement(new FormattedTextAreaPDF("Area di
EQUILIBRIO", 575)
{
AutoIncrementYWritable = false,
Y = 423,
Width = 75,
FontBold = false,
FontSize = 4.56f,
FontColor = new ColorPDF(0, 0, 0),
TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Center
});
AddElement(new FormattedTextAreaPDF("Area di
OTTIMALE CONCENTRAZIONE", 643)
{
AutoIncrementYWritable = false,
Y = 423,
Width = 75,
FontBold = false,
FontSize = 4.56f,
FontColor = new ColorPDF(0, 0, 0),
TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Center
});
if (bEstero == true)
AddElement(new FormattedTextAreaPDF("NB: il grafico non tiene conto del controvalore degli immobili ubicati all'Estero.", 400)
{
AutoIncrementYWritable = false,
Y = 450,
Width = 200,
FontBold = false,
FontSize = 4.56f,
FontColor = new ColorPDF(0, 0, 0),
TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Center
});
}
private void DrawPieChartTipologia(ChartRecord chartData)
{
CustomChartPDF pieChart = new CustomChartPDF();
var baseChart = pieChart.ChartBase;
baseChart.ChartAreas.Add("Default");
baseChart.Width = new System.Web.UI.WebControls.Unit(200);
baseChart.Height = new System.Web.UI.WebControls.Unit(200);
baseChart.ChartAreas["Default"].Area3DStyle.Enable3D = false;
baseChart.PaletteCustomColors = new Color[] { Color.White, Color.Red, Color.White, Color.Green };
var serie = baseChart.Series.Add("SerieName");
serie.Type = Dundas.Charting.WebControl.SeriesChartType.Pie;
serie.Points.AddXY(1, 1);
serie.Points.AddXY(1, 69);
serie.Points.AddXY(1, 1);
serie.Points.AddXY(1, 29);
AddElement(pieChart);
}
private void DrawPieChart(double value, Color colorRest, Color backgroundColor, double posX, double posY, double size, int widthPercentage)
{
CustomChartPDF pieChart = new CustomChartPDF()
{
X = (float)posX,
Y = (float)posY
};
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.Doughnut;
serie["DoughnutRadius"] = "30";
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);
AddElement(pieChart);
}
private void DrawChart(ChartRecord chartData, int x, int y, double width, double height)
{
var dir = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase)
.Replace("bin", "Images");
var path = string.Format("{0}\\{1}", dir, "s16_chart_background-cropped2.png");
var customChart = new CustomChartPDF()
{
X = x,
Y = y
};
var baseChart = customChart.ChartBase;
baseChart.Width = new System.Web.UI.WebControls.Unit(width);
baseChart.Height = new System.Web.UI.WebControls.Unit(height);
baseChart.ChartAreas.Add("Default");
baseChart.ChartAreas["Default"].Area3DStyle.Enable3D = false;
baseChart.ChartAreas[0].AxisX.MajorGrid.Enabled = false;
baseChart.ChartAreas[0].AxisY.MajorGrid.Enabled = false;
baseChart.ChartAreas[0].AxisX.LabelsAutoFit = true;
baseChart.ChartAreas[0].AxisX.LabelsAutoFitStyle = LabelsAutoFitStyle.WordWrap;
baseChart.ChartAreas[0].AxisY.LabelStyle.Font = new Font("Verdana", 6);
baseChart.ChartAreas[0].AxisX.LabelStyle.Font = new Font("Verdana", 6);
baseChart.ChartAreas[0].AxisX.MajorTickMark.Enabled = true;
baseChart.ChartAreas[0].AxisX.MinorTickMark.Enabled = false;
baseChart.ChartAreas[0].BackImage = path;
baseChart.ChartAreas[0].BackImageMode = ChartImageWrapMode.Scaled;
baseChart.Legends[0].Enabled = false;
var singleAxisXLabelWidth = width / 7;
baseChart.ChartAreas[0].AxisX.LabelStyle.Enabled = true;
baseChart.ChartAreas[0].AxisX.Minimum = 0;
baseChart.ChartAreas[0].AxisX.Maximum = 6;
baseChart.ChartAreas[0].AxisX.Interval = 1;
baseChart.ChartAreas[0].AxisX.CustomLabels.Add(-0.5d, 0.5d, "0€");
for (int i = 1; i <= 5; i++)
{
//baseChart.ChartAreas[0].AxisX.CustomLabels.Add(i * singleAxisXLabelWidth - singleAxisXLabelWidth / 2, i * singleAxisXLabelWidth + singleAxisXLabelWidth / 2, i.ToString());
baseChart.ChartAreas[0].AxisX.CustomLabels.Add(i - 0.5d, i + 0.5d, i.ToString());
}
baseChart.ChartAreas[0].AxisX.CustomLabels.Add(5.5d, 6.5d, "≥6");
baseChart.ChartAreas[0].AxisY.LabelStyle.Enabled = true;
baseChart.ChartAreas[0].AxisY.Minimum = 0;
baseChart.ChartAreas[0].AxisY.Maximum = 5;
baseChart.ChartAreas[0].AxisY.Interval = 1;
//baseChart.ChartAreas[0].AxisY.CustomLabels.Add(-0.5d, 0.5d, "MINIMO");
//baseChart.ChartAreas[0].AxisY.CustomLabels.Add(0.5d, 1.5d, "MODERATO");
//baseChart.ChartAreas[0].AxisY.CustomLabels.Add(1.5d, 2.5d, "MEDIO");
//baseChart.ChartAreas[0].AxisY.CustomLabels.Add(2.5d, 3.5d, "ELEVATO");
//baseChart.ChartAreas[0].AxisY.CustomLabels.Add(3.5d, 4.5d, "MASSIMO");
baseChart.ChartAreas[0].AxisY.CustomLabels.Add(0d, 1d, "MINIMO");
baseChart.ChartAreas[0].AxisY.CustomLabels.Add(1d, 2d, "MODERATO");
baseChart.ChartAreas[0].AxisY.CustomLabels.Add(2d, 3d, "MEDIO");
baseChart.ChartAreas[0].AxisY.CustomLabels.Add(3d, 4d, "ELEVATO");
baseChart.ChartAreas[0].AxisY.CustomLabels.Add(4d, 5d, "MASSIMO");
var xx = chartData.CtvPortafoglioImmobiliare / 1000000 + 0.01m;
var yy = chartData.ValDiversificazioneComplessiva * 5;
if (xx > 6) xx = 6;
if (yy > 5) yy = 5;
if (yy < 0) yy = 0;
if (xx < 0) xx = 0;
var serie = baseChart.Series.Add("serie");
serie.Type = Dundas.Charting.WebControl.SeriesChartType.Area;
serie.Color = Color.Black;
serie.MarkerStyle = MarkerStyle.Diamond;
serie.MarkerSize = 25;
serie.Font = new Font("Verdana", 6);
serie.ShowInLegend = false;
serie.Points.AddXY(xx, yy);
//xx = 0.115m;
//yy = chartData.ValDiversificazioneComplessiva * 5;
//if (xx > 6) xx = 6;
//if (yy > 5) yy = 5;
//if (yy < 0) yy = 0;
//if (xx < 0) xx = 0;
//var serieHorizontalTriangle = baseChart.Series.Add("serieHorizontalTriangle");
//serieHorizontalTriangle.Type = Dundas.Charting.WebControl.SeriesChartType.Area;
//serieHorizontalTriangle.Color = Color.Black;
//serieHorizontalTriangle.MarkerImage = string.Format("{0}\\{1}", dir, "triangle_marker_horizontal.png");
//serieHorizontalTriangle.MarkerSize = 35;
//serieHorizontalTriangle.Font = new Font("Verdana", 6);
//serieHorizontalTriangle.ShowInLegend = false;
//serieHorizontalTriangle.Points.AddXY(xx, yy);
//xx = chartData.CtvPortafoglioImmobiliare / 1000000 + 0.01m;
//yy = 0.115m;
//if (xx > 6) xx = 6;
//if (yy > 5) yy = 5;
//if (yy < 0) yy = 0;
//if (xx < 0) xx = 0;
//var serieVerticalTriangle = baseChart.Series.Add("serieVerticalTriangle");
//serieVerticalTriangle.Type = Dundas.Charting.WebControl.SeriesChartType.Area;
//serieVerticalTriangle.Color = Color.Black;
//serieVerticalTriangle.MarkerImage = string.Format("{0}\\{1}", dir, "triangle_marker_vertical.png");
//serieVerticalTriangle.MarkerSize = 35;
//serieVerticalTriangle.Font = new Font("Verdana", 6);
//serieVerticalTriangle.ShowInLegend = false;
//serieVerticalTriangle.Points.AddXY(xx, yy);
AddElement(customChart);
}
///
/// Recupera i dati necessari alla Section restituendo un DataTable.
///
///
///
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);
}
protected override DataTable GetDataTable()
{
return null;
}
///
/// Recupera i dati necessari alla Section restituendo un DataSet.
///
///
protected override DataSet GetDataSet()
{
// COMMENTATA PER TEST BATCH IMMOBILIARE
var parametri = new List
{
new Parametro
{
Direction = ParameterDirection.Input,
DbType = DbType.Int64,
ParameterName = "ChiaveClientePB",
Value = EnvironmentFacade.ReportEnvironment.Cliente.Chiave
}
};
var dt = DataAccess.ExecuteDataSetStoredProcedure(DBProvider.SqlServerConsulenzaUnica, "REP_ImmobiliareMonitoraggio_S28_MapStratImmEstero", parametri);
if (dt.Tables[0].Rows.Count > 0)
bEstero = true;
//bEstero = false;
// FINE COMMENTO
parametri = new List
{
new Parametro
{
Direction = ParameterDirection.Input,
DbType = DbType.Int32,
ParameterName = "chiaveClientePB",
Value = EnvironmentFacade.ReportEnvironment.Cliente.Chiave
},
new Parametro
{
Direction = ParameterDirection.Input,
DbType = DbType.Int32,
ParameterName = "chiaveNucleo",
Value = (long) 0,
}
};
return DataAccess.ExecuteDataSetStoredProcedure(DBProvider.SqlServerConsulenzaUnica, "REP_ImmobiliareMonitoraggio_S_AnalisiRischioSintesi", parametri);
}
private ChartRecord GetChartsData(DataSet dataSet)
{
DataRow row = dataSet.Tables[0].Rows[0];
ChartRecord result = new ChartRecord();
result.ClasseDiversificazioneComplessiva = (row["classeDiversificazioneComplessiva"] != DBNull.Value ? (string)row["classeDiversificazioneComplessiva"] : "n.c.") ;
result.ClasseDiversificazioneGeografia = (row["classeDiversificazioneGeografia"] != DBNull.Value ? (string)row["classeDiversificazioneGeografia"] : "n.c.");
result.ClasseDiversificazioneNumerosita =(row["classeDiversificazioneNumerosita"] != DBNull.Value ? (string)row["classeDiversificazioneNumerosita"] : "n.c.");
result.ClasseDiversificazioneTipologia = (row["classeDiversificazioneTipologia"] != DBNull.Value ? (string)row["classeDiversificazioneTipologia"] : "n.c.");
result.ClasseRischioLiquidabilita = (row["classeRischioLiquidabilita"] != DBNull.Value ? (string)row["classeRischioLiquidabilita"] : "n.c.");
result.ClasseRischioValore =(row["classeRischioValore"] != DBNull.Value ? (string)row["classeRischioValore"] : "n.c.");
result.ValDiversificazioneComplessiva = (row["valDiversificazioneComplessiva"] != DBNull.Value ? (decimal)row["valDiversificazioneComplessiva"] : 0);
result.ValDiversificazioneGeografia = (row["valDiversificazioneGeografia"] != DBNull.Value ? (decimal)row["valDiversificazioneGeografia"] : 0);
result.ValDiversificazioneNumerosita = (row["valDiversificazioneNumerosita"] != DBNull.Value ? (decimal)row["valDiversificazioneNumerosita"] : 0);
result.ValDiversificazioneTipologia = (row["valDiversificazioneTipologia"] != DBNull.Value ? (decimal)row["valDiversificazioneTipologia"] : 0);
result.CtvPortafoglioImmobiliare = (row["ctvPortafoglioImmobiliare"] != DBNull.Value ? (decimal)row["ctvPortafoglioImmobiliare"] : 0);
/***** ORIGINALE - Pino ***************/
//DataRow row = dataSet.Tables[0].Rows[0];
//ChartRecord result = new ChartRecord();
//result.ClasseDiversificazioneComplessiva = (string)row["classeDiversificazioneComplessiva"];
//result.ClasseDiversificazioneGeografia = (string)row["classeDiversificazioneGeografia"];
//result.ClasseDiversificazioneNumerosita = (string)row["classeDiversificazioneNumerosita"];
//result.ClasseDiversificazioneTipologia = (string)row["classeDiversificazioneTipologia"];
//result.ClasseRischioLiquidabilita = (string)row["classeRischioLiquidabilita"];
//result.ClasseRischioValore = (string)row["classeRischioValore"];
//result.ValDiversificazioneComplessiva = (decimal)row["valDiversificazioneComplessiva"];
//result.ValDiversificazioneGeografia = (decimal)row["valDiversificazioneGeografia"];
//result.ValDiversificazioneNumerosita = (decimal)row["valDiversificazioneNumerosita"];
//result.ValDiversificazioneTipologia = (decimal)row["valDiversificazioneTipologia"];
//result.CtvPortafoglioImmobiliare = (decimal)row["ctvPortafoglioImmobiliare"];
/************************************/
return result;
}
private class ChartRecord
{
public string ClasseDiversificazioneComplessiva { get; set; }
public string ClasseDiversificazioneGeografia { get; set; }
public string ClasseDiversificazioneNumerosita { get; set; }
public string ClasseDiversificazioneTipologia { get; set; }
public string ClasseRischioLiquidabilita { get; set; }
public string ClasseRischioValore { get; set; }
public decimal ValDiversificazioneComplessiva { get; set; }
public decimal ValDiversificazioneGeografia { get; set; }
public decimal ValDiversificazioneNumerosita { get; set; }
public decimal ValDiversificazioneTipologia { get; set; }
public decimal CtvPortafoglioImmobiliare { get; set; }
}
private void DrawLegend(int x, int y, int width, int height, List legendItems, string firstValue, string secondValue)
{
int rowsCount = 2;
int distanceXPercentage = 5;
int distanceYPercentage = 33;
float xDistance = width * distanceXPercentage / 100 / (legendItems.Count - 1);
float yDistance = height * distanceYPercentage / 100 / (rowsCount - 1);
float itemWidth = width * (100 - distanceXPercentage) / 100 / (legendItems.Count - 1);
float itemHeight = height * (100 - distanceYPercentage) / 100 / rowsCount;
float positionX = x;
float positionY = y;
for (int i = 0; i < rowsCount; i++)
{
positionX = x;
for (int j = 0; j < legendItems.Count; j++)
{
var legendItem = legendItems[j];
var rectangle = new RectanglePDF()
{
X = positionX,
Y = positionY,
Height = itemHeight,
Width = itemWidth,
Color = new ColorPDF(legendItem.Color),
AutoIncrementYWritable = false,
BorderColor = new ColorPDF(196, 196, 186),
BorderWidth = 1.5f
};
var text = new FormattedTextAreaPDF()
{
X = positionX,
Y = positionY,
FixedHeight = itemHeight,
Width = itemWidth,
Text = legendItem.Text,
AutoIncrementYWritable = false,
TextVerticalAlign = ceTe.DynamicPDF.VAlign.Center,
TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Center,
FontBold = true,
FontColor = new ColorPDF(Color.White)
};
AddElement(rectangle);
AddElement(text);
if ((legendItem.Text.ToLower() == firstValue.ToLower().Replace("_", " ") && i == 0)||
(legendItem.Text.ToLower() == secondValue.ToLower().Replace("_", " ") && i == 1))
{
#region triangle
var imagePositionX = positionX;
var imagePositionY = positionY;
var image = new ImagePDF(positionX, 1, "triangle_marker_vertical.png")
{
Y = positionY + rectangle.Height,
X = positionX + (rectangle.Width / 2) - 5,
Width = 10,
Height = 10
};
AddElement(image);
#endregion
}
positionX += itemWidth;
if (j != legendItems.Count - 1)
{
positionX += xDistance;
}
}
positionY += itemHeight+10;
if (i != rowsCount - 1)
{
positionY += yDistance;
}
}
}
private class LegendItem
{
public Color Color { get; set; }
public string Text { get; set; }
}
}
}