289 lines
12 KiB
C#
289 lines
12 KiB
C#
using System;
|
||
using System.Data;
|
||
using System.Configuration;
|
||
using System.Web;
|
||
using System.Web.Security;
|
||
using System.Web.UI;
|
||
using System.Web.UI.WebControls;
|
||
using System.Web.UI.WebControls.WebParts;
|
||
using System.Web.UI.HtmlControls;
|
||
using System.Collections;
|
||
using ceTe.DynamicPDF;
|
||
using ceTe.DynamicPDF.Text;
|
||
using PDFGenerator.Presentation.Section.Tables;
|
||
using PDFGenerator.BusinessLayer.DataSection;
|
||
using PDFGenerator.BusinessLayer;
|
||
using System.Threading;
|
||
using System.Globalization;
|
||
using ContrattoSei.Utilities;
|
||
|
||
namespace PDFGenerator.Presentation.Section {
|
||
public class S23 : ISezione {
|
||
|
||
|
||
public S23() {
|
||
//
|
||
// TODO: Add constructor logic here
|
||
//
|
||
}
|
||
|
||
#region ISezione Members
|
||
|
||
public void writeSezione(DataThread dataThread) {
|
||
string sCulture = UtilityManager.getAppSetting("CultureToUse");
|
||
|
||
//System.Globalization.CultureInfo.CreateSpecificCulture(sCulture);
|
||
Thread.CurrentThread.CurrentCulture = new CultureInfo(sCulture);
|
||
|
||
Thread.CurrentThread.CurrentUICulture = new CultureInfo(sCulture);
|
||
Thread.CurrentThread.CurrentCulture.NumberFormat.NumberDecimalSeparator = ",";
|
||
DocumentPDF document = dataThread.DocumentPDF;
|
||
DataSetS23 set = (DataSetS23)dataThread.Data.DatiSezione;
|
||
DatiTabella datitab = new DatiTabella();
|
||
datitab.table = set.Tables["DettaglioRischio"];
|
||
|
||
if (document.checkMargin(datitab.GetRowDim() * (datitab.getNumRow() + 1))) document.addPage();
|
||
|
||
if (dataThread.TipoReport.ToUpper() == "DIAGNOSI")
|
||
document.setSezTitoloDiagnosi(dataThread.SezioneReport.Titolo);
|
||
else
|
||
document.setSezTitolo(dataThread.SezioneReport.Titolo);
|
||
|
||
DataSet ds = dataThread.Data.DatiSezione;
|
||
|
||
|
||
|
||
|
||
|
||
//this.setSlider(datitab, document, 272);
|
||
|
||
DataView view = new DataView(datitab.table);
|
||
view.RowFilter = "";
|
||
datitab.setHeaderFont(6);
|
||
if (atLeastOneInstituteCoverageCheck(datitab))
|
||
{
|
||
this.setMarkerFlag(datitab, document);
|
||
datitab.table = view.ToTable(false, setTableForTable());
|
||
datitab.setCell(130, ceTe.DynamicPDF.TextAlign.Left, Globals.OpenTypeFontVerdanaB, false, 7);
|
||
datitab.setCell(85, ceTe.DynamicPDF.TextAlign.Left, Globals.OpenTypeFontVerdana, false, 7);
|
||
datitab.setCell(90, ceTe.DynamicPDF.TextAlign.Left, Globals.OpenTypeFontVerdana, false, 7);
|
||
datitab.setCell(70, ceTe.DynamicPDF.TextAlign.Left, Globals.OpenTypeFontVerdana, false, 7);
|
||
datitab.setCell(85, ceTe.DynamicPDF.TextAlign.Left, Globals.OpenTypeFontVerdana, false, 7);
|
||
datitab.setCell(45, ceTe.DynamicPDF.TextAlign.Center, Globals.OpenTypeFontVerdana, false, 7);
|
||
|
||
|
||
}
|
||
else
|
||
{
|
||
datitab.table = view.ToTable(false, setTableForTableSP());
|
||
datitab.setCell(142, ceTe.DynamicPDF.TextAlign.Left, Globals.OpenTypeFontVerdanaB, false, 7);
|
||
datitab.setCell(97, ceTe.DynamicPDF.TextAlign.Left, Globals.OpenTypeFontVerdana, false, 7);
|
||
datitab.setCell(122, ceTe.DynamicPDF.TextAlign.Left, Globals.OpenTypeFontVerdana, false, 7);
|
||
datitab.setCell(67, ceTe.DynamicPDF.TextAlign.Left, Globals.OpenTypeFontVerdana, false, 7);
|
||
datitab.setCell(97, ceTe.DynamicPDF.TextAlign.Left, Globals.OpenTypeFontVerdana, false, 7);
|
||
|
||
}
|
||
//eventuali operazioni sul dataset
|
||
//calcola se entra nella pagina altrimenti aggiunge una nuova pagina.
|
||
|
||
datitab.setY(document.getLastPos());
|
||
datitab.setX(document.getMargineLeft());
|
||
datitab.setIsLinee(1);
|
||
datitab.setCellSpace(0);
|
||
datitab.setHeader();
|
||
|
||
ceTe.DynamicPDF.Merger.ImportedPage page = document.getCurrentPage();
|
||
|
||
Tabella tab = new Tabella();
|
||
if (dataThread.TipoReport.ToUpper() == "DIAGNOSI") tab.HeaderFont = 8;
|
||
//setta posizione tabella
|
||
document.InsertTable(tab.getTabella(datitab));
|
||
|
||
//aggiorno il puntatore alla posizione da cui si pu<70> scrivere
|
||
document.setLastPos(datitab.GetRowDim() * (datitab.getNumRow() + 1));
|
||
|
||
}
|
||
|
||
|
||
#endregion
|
||
|
||
public void writeSezioneSenzaProfilo(DataThread dataThread) {
|
||
|
||
DocumentPDF document = dataThread.DocumentPDF;
|
||
DataSetS23 set = (DataSetS23)dataThread.Data.DatiSezione;
|
||
DatiTabella datitab = new DatiTabella();
|
||
datitab.table = set.Tables["DettaglioRischio"];
|
||
|
||
if (document.checkMargin(datitab.GetRowDim() * datitab.getNumRow())) document.addPage();
|
||
|
||
if (dataThread.TipoReport.ToUpper() == "DIAGNOSI")
|
||
document.setSezTitoloDiagnosi(dataThread.SezioneReport.Titolo);
|
||
else
|
||
document.setSezTitolo(dataThread.SezioneReport.Titolo);
|
||
//this.setSlider(datitab, document, 350);
|
||
|
||
DataView view = new DataView(datitab.table);
|
||
view.RowFilter = "";
|
||
datitab.table = view.ToTable(false, setTableForTableSP());
|
||
|
||
|
||
|
||
// Marian
|
||
datitab.setHeaderFont(6);
|
||
datitab.setCell(142, ceTe.DynamicPDF.TextAlign.Left, Globals.OpenTypeFontVerdanaB, false, 7);
|
||
datitab.setCell(97, ceTe.DynamicPDF.TextAlign.Left, Globals.OpenTypeFontVerdana, false,7);
|
||
datitab.setCell(122, ceTe.DynamicPDF.TextAlign.Left, Globals.OpenTypeFontVerdana, false,7);
|
||
datitab.setCell(67, ceTe.DynamicPDF.TextAlign.Left, Globals.OpenTypeFontVerdana, false,7);
|
||
datitab.setCell(97, ceTe.DynamicPDF.TextAlign.Left, Globals.OpenTypeFontVerdana, false,7);
|
||
|
||
//////////
|
||
//eventuali operazioni sul dataset
|
||
//calcola se entra nella pagina altrimenti aggiunge una nuova pagina.
|
||
|
||
datitab.setY(document.getLastPos());
|
||
datitab.setX(document.getMargineLeft());
|
||
datitab.setIsLinee(1);
|
||
datitab.setCellSpace(0);
|
||
datitab.setHeader();
|
||
|
||
ceTe.DynamicPDF.Merger.ImportedPage page = document.getCurrentPage();
|
||
|
||
page.Elements.Add(new ceTe.DynamicPDF.PageElements.Rectangle(document.getMargineLeft(), document.getLastPos() - 11, 518, datitab.GetRowDim(), 0, new RgbColor(232, 236, 237)));
|
||
//page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label("Rispetto profilo", 430, document.getLastPos() - 6, 120, 10, Globals.OpenTypeFontVerdanaB, 9, ceTe.DynamicPDF.TextAlign.Right, ceTe.DynamicPDF.CmykColor.Red));
|
||
|
||
Tabella tab = new Tabella();
|
||
if (dataThread.TipoReport.ToUpper() == "DIAGNOSI") tab.HeaderFont = 8;
|
||
//setta posizione tabella
|
||
document.InsertTable(tab.getTabella(datitab));
|
||
|
||
//aggiorno il puntatore alla posizione da cui si pu<70> scrivere
|
||
document.setLastPos(datitab.GetRowDim() * datitab.getNumRow());
|
||
|
||
}
|
||
|
||
/// <summary>
|
||
/// Set the Indicator to OK or No according to the adequacy of the VAR and the Risk Credit.
|
||
/// </summary>
|
||
/// <param name="datitab"></param>
|
||
/// <param name="document"></param>
|
||
private void setMarkerFlag(DatiTabella datitab, DocumentPDF document) {
|
||
float y = document.getLastPos() + 16;
|
||
ceTe.DynamicPDF.Merger.ImportedPage page = document.getCurrentPage();
|
||
|
||
string flagPathOK = UtilityManager.getAppSetting("FlagOK");
|
||
string flagPathNO = UtilityManager.getAppSetting("FlagNO");
|
||
System.Reflection.Assembly thisExe;
|
||
thisExe = System.Reflection.Assembly.GetExecutingAssembly();
|
||
System.IO.Stream fileOK = thisExe.GetManifestResourceStream(flagPathOK);
|
||
System.IO.Stream fileNO = thisExe.GetManifestResourceStream(flagPathNO);
|
||
|
||
foreach (DataRow myRow in datitab.table.Rows) {
|
||
if (myRow["Rispetto"] != null && (int)myRow["Rispetto"] == 1)
|
||
//page.Elements.Add(new ceTe.DynamicPDF.PageElements.Image(fileOK, 507, y, 0.18F));
|
||
page.Elements.Add(new ceTe.DynamicPDF.PageElements.Image(fileOK, 515, y, 0.1F));
|
||
if (myRow["Rispetto"] != null && (int)myRow["Rispetto"] == 0)
|
||
//page.Elements.Add(new ceTe.DynamicPDF.PageElements.Image(fileNO, 507, y, 0.18F));
|
||
page.Elements.Add(new ceTe.DynamicPDF.PageElements.Image(fileNO, 515, y, 0.1F));
|
||
|
||
y += datitab.GetRowDim();
|
||
}
|
||
|
||
}
|
||
|
||
private void setSlider(DatiTabella datitab, DocumentPDF document, int x) {
|
||
float y = document.getLastPos() + 16;
|
||
ceTe.DynamicPDF.Merger.ImportedPage page = document.getCurrentPage();
|
||
|
||
string markerPath = UtilityManager.getAppSetting("Marker");
|
||
string sliderPath = UtilityManager.getAppSetting("Slider");
|
||
System.Reflection.Assembly thisExe;
|
||
thisExe = System.Reflection.Assembly.GetExecutingAssembly();
|
||
System.IO.Stream fileMarker = thisExe.GetManifestResourceStream(markerPath);
|
||
System.IO.Stream fileSlider = thisExe.GetManifestResourceStream(sliderPath);
|
||
|
||
foreach (DataRow myRow in datitab.table.Rows) {
|
||
page.Elements.Add(new ceTe.DynamicPDF.PageElements.Image(fileSlider, x + 3, y, 0.25F));
|
||
|
||
if (myRow["Var"].ToString().ToUpper() != "N.C.")
|
||
{
|
||
#region Marcatore (barra nera)
|
||
|
||
decimal VaR = Convert.ToDecimal(myRow["Var"].ToString());
|
||
float xMarker = getX(VaR);
|
||
|
||
page.Elements.Add(new ceTe.DynamicPDF.PageElements.Image(fileMarker, xMarker, y, 0.25F));
|
||
|
||
#endregion
|
||
}
|
||
y += datitab.GetRowDim();
|
||
}
|
||
|
||
}
|
||
|
||
/// <summary>
|
||
/// Ritorna la x su cui posizionare il marcatore ( barra nera )
|
||
/// Valido per i profili di rischio da 1,5 a 23
|
||
/// </summary>
|
||
/// <param name="var"></param>
|
||
/// <returns></returns>
|
||
private float getX(decimal var) {
|
||
decimal varMassimo = 23;
|
||
|
||
if (var > 23)
|
||
var = varMassimo;
|
||
|
||
decimal xPartenza = 272;
|
||
decimal xFine = 380;
|
||
|
||
decimal intervallo = xFine - xPartenza;
|
||
decimal rapporto = intervallo / varMassimo;
|
||
|
||
return Convert.ToSingle(xPartenza + (rapporto * var));
|
||
|
||
}
|
||
|
||
private string[] setTableForTable() {
|
||
//eventuali operazioni sul dataset
|
||
string[] Columns = new String[6];
|
||
Columns[0] = "Intermediario";
|
||
Columns[1] = "CreditRisk";
|
||
Columns[2] = "CreditRiskMax";
|
||
Columns[3] = "Var";
|
||
Columns[4] = "VarMax";
|
||
//Columns[2] = "Copertura";
|
||
Columns[5] = "Rispetto";
|
||
return Columns;
|
||
}
|
||
|
||
private string[] setTableForTableSP() {
|
||
//eventuali operazioni sul dataset
|
||
string[] Columns = new String[5];
|
||
Columns[0] = "Intermediario";
|
||
Columns[1] = "CreditRisk";
|
||
Columns[2] = "CreditRiskMax";
|
||
Columns[3] = "Var";
|
||
Columns[4] = "VarMax";
|
||
//Columns[2] = "Copertura";
|
||
return Columns;
|
||
}
|
||
|
||
private bool atLeastOneInstituteCoverageCheck(DatiTabella datitab)
|
||
{
|
||
bool instituteCoverage = true;
|
||
foreach (DataRow myRow in datitab.table.Rows)
|
||
{
|
||
if (myRow["Rispetto"] != null && (int)myRow["Rispetto"] != -1)
|
||
{
|
||
instituteCoverage = true;
|
||
return instituteCoverage;
|
||
}
|
||
else
|
||
instituteCoverage = false;
|
||
}
|
||
return instituteCoverage;
|
||
|
||
}
|
||
|
||
}
|
||
}
|