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;
namespace Consulenza.ReportWriter.Manager.Section.Immobiliare.Monitoraggio
{
///
/// Distribuzione geografica Fabbricati (id 35)
///
public class S3 : Entity.Section
{
public S3(EnvironmentFacade environmentFacade, int idSection)
: base(environmentFacade, idSection)
{
try
{
Draw();
}
catch (Exception ex)
{
SectionLogger.Write("S3", 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()
{
var width = 345;
FormattedTextAreaPDF testoSx = null;
FormattedTextAreaPDF testoDx = null;
var _text = GetTextSet();
List indiciPagina = _text.Tables[0].AsEnumerable()
.Select(z => z.Field("idREP_IMM_MON_Pagina")).Distinct().ToList();
int i = -1;
foreach (var indice in indiciPagina)
{
string paragrafoSx;
string paragrafoDx;
i++;
AddElement(new PagePDF(PagePDF.PagePDFType.Generic));
var data = _text.Tables[0].AsEnumerable().Where(x => x.Field("idREP_IMM_MON_Pagina") == indice).ToList();
foreach (var row in data)
{
paragrafoSx = paragrafoDx = "";
if (!row.Field("posizione").Equals("R"))
paragrafoSx += "" + row.Field("titolo") + "
";
else
paragrafoDx += "" + row.Field("titolo") + "
";
for (int j = 1; j <= 15; j++)
if (!row.Field("posizione").Equals("R"))
paragrafoSx += row.Field("testo" + j) != null ?
"" + row.Field("testo" + j) + "
" : "";
else
paragrafoDx += row.Field("testo" + j) != null ?
"" + row.Field("testo" + j) + "
" : "";
// 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;
}
if (indice == 3)
{
testoSx = new FormattedTextAreaPDF(paragrafoSx.Replace("
", ""), 35, width) { AutoIncrementYWritable = false, FontColor = ColorPDF.Immobiliare_Grigio_TestoStandard, FontSize = 9.26F, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Justify };
testoDx = new FormattedTextAreaPDF(paragrafoDx.Replace("
", "
"), 405, width) { AutoIncrementYWritable = false, FontColor = ColorPDF.Immobiliare_Grigio_TestoStandard, FontSize = 9.26F, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Justify };
////AddElement(new ResetterYPDF(55+(i*5)));
////if (indice == 3)
//// AddElement(new ResetterYPDF(45 + (i * 5)));
////else
//// AddElement(new ResetterYPDF(40 + (i * 5)));
////AddElement(testoSx);
////addFiller(row, 3);
////if (paragrafoDx != "") {
//// //AddElement(new ResetterYPDF((paragrafoDx.ToLower().Contains("") ? 55 : 50)+(i * 5)));
//// if (indice == 3)
//// AddElement(new ResetterYPDF((paragrafoDx.ToLower().Contains("") ? 94 : 40) + (i * 5)));
//// else
//// AddElement(new ResetterYPDF((paragrafoDx.ToLower().Contains("") ? 94 : 35) + (i * 5)));
//// if (indice == 4)
//// AddElement(new SpacePDF(21));
//// AddElement(testoDx);
//// addFiller(row, 4);
////}
//AddElement(new ResetterYPDF(45 + (i * 5)));
//AddElement(testoSx);
//addFiller(row, 3);
//if (paragrafoDx != "")
//{
// //AddElement(new ResetterYPDF((paragrafoDx.ToLower().Contains("") ? 55 : 50)+(i * 5)));
// AddElement(new ResetterYPDF((paragrafoDx.ToLower().Contains("") ? 94 : 40) + (i * 5)));
// if (indice == 4)
// AddElement(new SpacePDF(21));
// AddElement(testoDx);
// addFiller(row, 4);
//}
//AddElement(new ResetterYPDF(45 + (i * 5)));
//AddElement(new SpacePDF(38)); /// Originale
AddElement(new SpacePDF(28));
AddElement(testoSx);
/************************* Modifiche per parti statiche Semestrale 17/2021 - Pino **********************/
if (paragrafoSx == string.Empty)
{
AddElement(new SpacePDF(-31)); //103
//AddElement(new ResetterYPDF(176));
}
/************************************************************************************************/
AddElement(testoDx);
}
else
{
testoSx = new FormattedTextAreaPDF(paragrafoSx.Replace("
", ""), 35, width) { AutoIncrementYWritable = false, FontColor = ColorPDF.Immobiliare_Grigio_TestoStandard, FontSize = 9.26F, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Justify };
testoDx = new FormattedTextAreaPDF(paragrafoDx.Replace("
", "
"), 405, width) { AutoIncrementYWritable = false, FontColor = ColorPDF.Immobiliare_Grigio_TestoStandard, FontSize = 9.26F, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Justify };
//testoDx = new FormattedTextAreaPDF(paragrafoDx.Replace("
", ""), 405, width) { AutoIncrementYWritable = false, FontColor = ColorPDF.Immobiliare_Grigio_TestoStandard, FontSize = 9.26F, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Justify };
AddElement(new ResetterYPDF(45 + (i * 5)));
AddElement(testoSx);
addFiller(row, 3);
if (paragrafoDx != "")
{
//AddElement(new ResetterYPDF((paragrafoDx.ToLower().Contains("") ? 55 : 50)+(i * 5)));
AddElement(new ResetterYPDF((paragrafoDx.ToLower().Contains("") ? 94 : 40) + (i * 5)));
/************************** Modifiche per parti statiche Semestrale 10/2020 - Pino *************************************/
if (indice == 4)
AddElement(new SpacePDF(-1)); //18
/****************************************************************************************************************/
AddElement(testoDx);
addFiller(row, 4);
}
}
}
if (getNota(_text.Tables[0].AsEnumerable().Where(x => x.Field("idREP_IMM_MON_Pagina") == indice).ToList()[0]).Length > 0)
{
string testoNota = getNota(_text.Tables[0].AsEnumerable().Where(x => x.Field("idREP_IMM_MON_Pagina") == indice).ToList()[0]);
IEnumerable rows = _text.Tables[0].AsEnumerable()
.Where(x => x.Field("notaGraf1") != null);
int count = testoNota.Replace("
", "\t").Count(x => x == '\t');
//var nota = new FormattedTextAreaPDF(testoNota, 60, width*2) { AutoIncrementYWritable = false, Y = EnvironmentFacade.RendererFacade.YLowerLimit - 18 - (5 * count), FontSize = 6, FontColor = ColorPDF.Nero, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Justify };
var nota = new FormattedTextAreaPDF(testoNota, 60, width * 2) { AutoIncrementYWritable = false, Y = EnvironmentFacade.RendererFacade.YLowerLimit - 13 - (5 * count), FontSize = 6, FontColor = ColorPDF.Nero, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Justify };
AddElement(nota);
}
}
}
protected void addFiller(DataRow row, int position)
{
int x = 0;
int y = 0;
switch (position) {
case 3:
x = 35;
y = 130;
break;
case 4:
x = 600;
y = 150;
break;
}
if (row.Field("bytesImage") != null && row.Field("isIcon") != null && row.Field("isIcon") == position) {
var casetta = new ImagePDF(x, 0.25F, "CASA.jpeg")
{ AutoIncrementYWritable = false, Y = EnvironmentFacade.RendererFacade.YLowerLimit - y };
AddElement(casetta);
}
}
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()
{
return null;
}
///
/// Recupera i testi
///
///
protected DataSet GetTextSet()
{
#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_Testi_Paragrafi", parametri);
}
}
}