257 lines
12 KiB
C#
257 lines
12 KiB
C#
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
|
||
{
|
||
/// <summary>
|
||
/// Patrimonio Immobiliare Stima delle imposte (id 41) Fabbricati
|
||
/// </summary>
|
||
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);
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// Scheda2. Patrimonio immobiliare –Sintesi (distribuzione del patrimonio complessivo del cliente diviso per tipologia e cointestatari)
|
||
/// </summary>
|
||
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<int> indiciPagina = _data.AsEnumerable()
|
||
.Select(z => z.Field<int>("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<int>("idREP_IMM_MON_Pagina") == indice).Count() > 0)
|
||
{
|
||
foreach (var row in _text.AsEnumerable().Where(x => x.Field<int>("idREP_IMM_MON_Pagina") == indice).ToList())
|
||
{
|
||
testo = "";
|
||
labelSx = "";
|
||
labelDx = "";
|
||
|
||
testo = "<B>" + row.Field<string>("titolo") + "</B><br><br>";
|
||
|
||
for (int i = 1; i <= 15; i++)
|
||
{
|
||
//if (i == 2)
|
||
//{
|
||
// List<string> _Zone = new List<string>() { "Zona 1:", "Zona 2:", "Zona 3:", "Zona 4:" };
|
||
// testo = SplitTestoPuntato(row.Field<string>("testo" + i).ToString(), _Zone);
|
||
//}
|
||
//else
|
||
// testo += row.Field<string>("testo" + i) != null ? "<p>" + row.Field<string>("testo" + i) + "</p><br>" : "";
|
||
|
||
|
||
|
||
#region Sezione testo puntato vecchia versione
|
||
// Gestione elenco puntato
|
||
if ((i == 2) || (i == 3) || (i == 4) || (i == 5))
|
||
{
|
||
//testo += row.Field<string>("testo" + i) != null ? "<p>" + row.Field<string>("testo" + i) + "</p>" : "";
|
||
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<string>("testo" + i) != null ? "<p> -" + row.Field<string>("testo" + i) + "</p>" : "";
|
||
testo += row.Field<string>("testo" + i) != null ? "<p>" + row.Field<string>("testo" + i) + "</p>" : "";
|
||
/*****************************************************************************************************************/
|
||
|
||
if (row.Field<string>("testo" + i).Contains("Zona 4:"))
|
||
testo += "<br>";
|
||
}
|
||
else
|
||
{
|
||
if (row.Field<string>("testo" + i) != null)
|
||
{
|
||
string str = row.Field<string>("testo" + i).ToString();
|
||
if (str.Contains("Zona 1:"))
|
||
{
|
||
/***************************** Modifica per parti statiche semestrale 10/2020 - Pino *****************************/
|
||
//testo += row.Field<string>("testo" + i) != null ? "<p> -" + row.Field<string>("testo" + i) + "</p>" : "";
|
||
testo += row.Field<string>("testo" + i) != null ? "<p>" + row.Field<string>("testo" + i) + "</p>" : "";
|
||
/*****************************************************************************************************************/
|
||
}
|
||
else
|
||
testo += row.Field<string>("testo" + i) != null ? "<p>" + row.Field<string>("testo" + i) + "</p><br>" : "";
|
||
|
||
}
|
||
else
|
||
testo += row.Field<string>("testo" + i) != null ? "<p>" + row.Field<string>("testo" + i) + "</p><br>" : "";
|
||
}
|
||
}
|
||
else
|
||
testo += row.Field<string>("testo" + i) != null ? "<p>" + row.Field<string>("testo" + i) + "</p><br>" : "";
|
||
#endregion
|
||
|
||
|
||
}
|
||
|
||
|
||
// SPLIT PARAGRAFO
|
||
if (testo.Contains("SPLITPARAGRAPH"))
|
||
{
|
||
var listaSplit = StringExtensions.SplitAtOccurence(testo, "SPLITPARAGRAPH", 1);
|
||
labelSx = listaSplit[0] + "</p>";
|
||
labelDx += "<br><p>";
|
||
listaSplit.RemoveRange(0, 1);
|
||
foreach (var stringa in listaSplit)
|
||
labelDx += stringa;
|
||
|
||
paragrafoSx += labelSx;
|
||
paragrafoDx += labelDx;
|
||
}
|
||
else
|
||
{
|
||
if (row.Field<string>("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<int>("idREP_IMM_MON_Pagina") == indice).Count() > 0
|
||
&& _data.AsEnumerable().Where(x => x.Field<int>("idREP_IMM_MON_Pagina") == indice && x.Field<string>("descrizioneImage") != null).Count() > 0)
|
||
{
|
||
foreach (var image in _data.AsEnumerable().Where(x => x.Field<int>("idREP_IMM_MON_Pagina") == indice).ToList())
|
||
{
|
||
string titoloStatico = image.Field<string>("descrizioneImage") +"<br>";
|
||
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<string>("bytesImage") + ".jpeg");
|
||
AddElement(new ResetterYPDF(50));
|
||
AddElement(titoloGrafico);
|
||
AddElement(cartina);
|
||
if (getNota(image).Length > 0)
|
||
{
|
||
string testoNota = getNota(image);
|
||
IEnumerable<DataRow> rows = _data.AsEnumerable()
|
||
.Where(x => x.Field<string>("nota1") != null);
|
||
int count = testoNota.Replace("<br>", "\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<string> 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(), "<u>", testoCercato, "</u>", 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<string>("nota" + i) != null)
|
||
nota += row.Field<string>("nota" + i) + "<br>";
|
||
return nota;
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// Recupera i dati necessari alla Section restituendo un DataTable.
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
protected override DataTable GetDataTable()
|
||
{
|
||
return null;
|
||
}
|
||
|
||
/// <summary>
|
||
/// Recupera i dati necessari alla Section restituendo un DataSet.
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
protected override DataSet GetDataSet()
|
||
{
|
||
#region Definizione dei parametri
|
||
|
||
var parametri = new List<Parametro>
|
||
{
|
||
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);
|
||
}
|
||
}
|
||
}
|