2025-04-15 12:10:19 +02:00

130 lines
4.8 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 ContrattoSei.Utilities;
namespace PDFGenerator.Presentation.Section {
public class S36 : ISezione {
private string _header = "";
public string Header
{
get { return _header; }
set { _header = value; }
}
public S36() {
//
// TODO: Add constructor logic here
//
}
#region ISezione Members
public void writeSezione(DataThread dataThread) {
DocumentPDF document = dataThread.DocumentPDF;
DatiTabella datitab = new DatiTabella();
//datitab.CreateNewDataRow3();
DataSetS36 set = (DataSetS36)dataThread.Data.DatiSezione;
datitab.table = set.Tables["ProfiloRischio"];
datitab.setIsLinee(2);
datitab.setCell(170, ceTe.DynamicPDF.TextAlign.Left, Globals.OpenTypeFontVerdanaB, true);
datitab.setCell(343, ceTe.DynamicPDF.TextAlign.Left, Globals.OpenTypeFontVerdana, false);
//eventuali operazioni sul dataset
//calcola se entra nella pagina altrimenti aggiunge una nuova pagina. In questa sezione il # di righe è fissato, più 30 per l'header
if (document.checkMargin(datitab.GetRowDim() * datitab.getNumRow() + 30)) document.addPage();
document.setSezTitolo(dataThread.SezioneReport.Titolo);
document.setChapterHeader(UtilityBusinessLayer.ReplaceVariables(dataThread.SezioneReport.TestoIntroduttivo, dataThread));
datitab.setY(document.getLastPos());
datitab.setX(document.getMargineLeft());
Tabella tab = new Tabella();
//setta posizione tabella
ceTe.DynamicPDF.Merger.ImportedPage page = document.getCurrentPage();
string relativePath = UtilityManager.getAppSetting("Slider");
System.Reflection.Assembly thisExe;
thisExe = System.Reflection.Assembly.GetExecutingAssembly();
//COSA C'é NELL?ASSEMBLY? DECOMMENTA SE VUOI UNA RISPOSTA
//string[] resources = thisExe.GetManifestResourceNames();
//string list = "";
//// Build the string of resources.
//foreach (string resource in resources)
// list += resource + "\r\n";
System.IO.Stream fileSlider = thisExe.GetManifestResourceStream(relativePath);
page.Elements.Add(new ceTe.DynamicPDF.PageElements.Image(fileSlider, 57 + 150 + 65, document.getLastPos() + datitab.GetRowDim() * 0.7F, 0.25F));
relativePath = UtilityManager.getAppSetting("Marker");
System.IO.Stream fileMarker = thisExe.GetManifestResourceStream(relativePath);
float VaRMassimo = Convert.ToSingle(datitab.table.Rows[1]["Valore"]);
float xMarker = getX(VaRMassimo.ToString());
page.Elements.Add(new ceTe.DynamicPDF.PageElements.Image(fileMarker, xMarker, document.getLastPos() + datitab.GetRowDim() * 0.7F, 0.25F));
FormatNum conv = new FormatNum();
//IMPORTANT
//V When doing S95 Remove from here and make the right value into the DSS95
datitab.table.Rows[1]["Valore"] = conv.ConvertNum(Convert.ToDouble(datitab.table.Rows[1]["Valore"])) + "%";
document.InsertTable(tab.getTabella(datitab));
//aggiorno il puntatore alla posizione da cui si può scrivere
document.setLastPos(datitab.GetRowDim() * datitab.getNumRow());
}
#endregion
/// <summary>
/// Ritorna la x sulla quale andrà posizionato il marker (barra nera) in funzione del VaR massimo del profilo.
/// Il posizionamento della x in questa sezione è fisso e non graduale.
/// La funzione è valida per le fasce di profilo 1.5 , 3.5 , 7.5 , 12 , 23
/// </summary>
/// <param name="varmassimo">var massimo del profilo</param>
/// <returns></returns>
private float getX(string varmassimo) {
float xPartenza = 272;
switch (varmassimo) {
case "1,5":
return xPartenza + 7;
case "3,5":
return xPartenza + 21;
case "7,5":
return xPartenza + 42;
case "12":
return xPartenza + 70;
case "23":
return xPartenza + 107;
default:
return xPartenza;
}
}
}
}