ReportManager.NET/Consulenza.Web/PropostaUnica.aspx.cs

556 lines
26 KiB
C#

using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.IO;
using System.Net;
using System.Threading;
using Consulenza.Web.ConsulenzaUnicaWS;
using System.Linq;
using Newtonsoft.Json;
namespace Consulenza.Web
{
public partial class PropostaUnica : System.Web.UI.Page
{
private Dictionary<int, string> _elencoSezioni = new Dictionary<int, string>();
public Dictionary<int, string> ElencoSezioni
{
get { return _elencoSezioni; }
set { _elencoSezioni = value; }
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
//caricaElencoSezioni();
}
}
protected void Button1_Click(object sender, EventArgs e)
{
var reportManager = new ReportManager();
// reportManager.Timeout = 60000 * 10; //10 minuti
var chiaveClientePb = tx_chiave.Text != "" ? int.Parse(tx_chiave.Text) : 0;
#region Template costruito
//1,2,4,5,6,7,8,11,15,16,17,18 schede attive 22-01-2016
var template = new Template
{
CodicePb = "",
IdModello = 3, //rete F, 6 rete S
IsDefault = "N",
Options = new[]
{
new Option { Key = "Opzione1", Value = "{'anonimo':'N'}" },
//new Option { Key = "Opzione2", Value = "{'proposta':'1234567'}" }
},
Schede = new[]
{
//new SchedaTemplate {
// Id = 1001,
// Options = new Option[0]
// },
// new SchedaTemplate {
// Id =2001,
// Options = new Option[0]
// },
// new SchedaTemplate {
// Id = 11001,
// Options = new Option[0]
// },
// new SchedaTemplate {
// Id = 12001,
// Options = new Option[0]
// },
//new SchedaTemplate {
// Id = 25001,
// Options = new Option[0]
//},
//new SchedaTemplate {
// Id = 26001,
// Options = new Option[0]
//},
//new SchedaTemplate {
// Id = 27001,
// Options = new Option[0]
//},
//new SchedaTemplate {
// Id = 28001,
// Options = new Option[0]
//},
//new SchedaTemplate {
// Id = 29001,
// Options = new Option[0]
//},
//new SchedaTemplate {
// Id = 54001,
// Options = new Option[0]
//},
// new SchedaTemplate {
// Id = 55001,
// Options = new Option[0]
//},
// new SchedaTemplate {
// Id = 56001,
// Options = new Option[0]
//},
// new SchedaTemplate {
// Id = 57001,
// Options = new Option[0]
//},
// new SchedaTemplate {
// Id = 58001,
// Options = new Option[0]
//},
// new SchedaTemplate {
// Id = 59001,
// Options = new Option[0]
//},
//new SchedaTemplate {
// Id = 60001,
// Options = new Option[0]
//},
// new SchedaTemplate {
// Id = 61001,
// Options = new Option[0]
//},
new SchedaTemplate {
Id = 62001,
Options = new Option[0]
},
//new SchedaTemplate {
// Id = 63001,
// Options = new Option[0]
//},
// new SchedaTemplate {
// Id = 64001,
// Options = new Option[0]
// },
// new SchedaTemplate {
// Id = 65001,
// Options = new Option[0]
//},
//new SchedaTemplate {
// Id = 74001,
// Options = new Option[0]
//},
//new SchedaTemplate {
// Id = 75001,
// Options = new Option[0]
//},
}
};
#endregion
#region Template preso da DB
//template = new Template { IdModello = -1, Nome = "lindaprop2" };
//template = new Template { IdModello = -1, Nome = "Car_Prop" };
#endregion
//template = new Template { IdModello = -1, Nome = "cambioStepUp" };
/** Da utilizzare con l'ambiente di collaudo **/
template = new Template { IdModello = -1, Nome = "TestTemplate(P2)" };
//Chiamata a Report PO SS
//var imagePdf = reportManager.CreaReportPO("015312", "DMECST71D10H501E", "", "F", 29617932);//, template, new ConsulenzaUnicaWS.Parametro[0]);
//var imagePdf = reportManager.CreaReport("006803", "BTRHNJ58R30C377Z", "", "F", 1435521, template, new ConsulenzaUnicaWS.Parametro[0]);
//var imagePdf = reportManager.CreaReport("006803", "CZMZNB56M64A449Y", "", "F", 31110068, template, new ConsulenzaUnicaWS.Parametro[0]);
//var imagePdf = reportManager.CreaReport("015312", "DMECST71D10H501E", "", "F", 32848310, template, new ConsulenzaUnicaWS.Parametro[0]);
/** Da utilizzare con l'ambiente di collaudo **/
var imagePdf = reportManager.CreaReport("012461", "SPRFLV48A19Z602U", "", "F", 32850599, template, new ConsulenzaUnicaWS.Parametro[0]);
//Chiamata a Report OnLine
// var imagePdf = reportManager.CreaReport("015312", "DMECST71D10H501E", "", "F", 31090516, template, new ConsulenzaUnicaWS.Parametro[0]);
// var imagePdf = reportManager.CreaReport("012887", "ZMLFDN52S26L436Q", "", "F", 29846196, template, new ConsulenzaUnicaWS.Parametro[0]);
if (imagePdf == null) return;
Session["pdf"] = imagePdf;
Response.Redirect("Report.aspx", false);
//ripristinre dopo test PO
// var imagePdf = reportManager.CreaReport("002317", "ZZLDRN51E10B025O", "", "F", 29746810, template, new ConsulenzaUnicaWS.Parametro[0]);
// ADEGUATA
//var imagePdf = reportManager.CreaReport("012225", "QGLLND58R42E897H", "", "F", 9367260, template, new ConsulenzaUnicaWS.Parametro[0]);
// NON ADEGUATA
// var imagePdf = reportManager.CreaReport("012225", "QGLLND58R42E897H", "", "F", 9367261, template, new ConsulenzaUnicaWS.Parametro[0]);
//var imagePdf = reportManager.CreaReport("014407", "SGNMRC53E15D612T", "", "F", 9367297, template, new ConsulenzaUnicaWS.Parametro[0]);
// PdC - Eccessiva adeguatezza
//var imagePdf = reportManager.CreaReport("016002", "VLLNRC47S07A266P", "", "F", 9377334, template, new ConsulenzaUnicaWS.Parametro[0]);
// PdC - Ptf migliorativo
//var imagePdf = reportManager.CreaReport("016002", "ZRDLCU72M04G642D", "", "F", 9377303, template, new ConsulenzaUnicaWS.Parametro[0]);
// proposta3951-1
//var imagePdf = reportManager.CreaReport("015705", "BLDGNN46H12L599T", "", "F", 9377296, template, new ConsulenzaUnicaWS.Parametro[0]);
//var imagePdf = reportManager.CreaReport("002317", "ZZLDRN51E10B025O", "", "F", 9367298, template, new ConsulenzaUnicaWS.Parametro[0]);
//var imagePdf = reportManager.CreaReport("015238", "VAEMRA53M46I373R", "", "F", 9377328, template, new ConsulenzaUnicaWS.Parametro[0]);
//var imagePdf = reportManager.CreaReport("012057", "07573820581", "6160", "F", 9377302, template, new ConsulenzaUnicaWS.Parametro[0]);
// PdC - Prova
//var imagePdf = reportManager.CreaReport("014407", "SGNMRC53E15D612T", "", "F", 9367276, template, new ConsulenzaUnicaWS.Parametro[0]);
//var imagePdf = reportManager.CreaReport("015705", "BLDGNN46H12L599T", "", "F", 9367272, template, new ConsulenzaUnicaWS.Parametro[0]);
//var imagePdf = reportManager.CreaReport("006803", "BLDRRT35S23A632O", "", "F", 9367239, template, new ConsulenzaUnicaWS.Parametro[0]);
// PROVA 4490
//var imagePdf = reportManager.CreaReport("015238", "BCHPTR74C31L736K", "", "F", 9367271, template, new ConsulenzaUnicaWS.Parametro[0]);
// Fondo Pensione Alessio
//var imagePdf = reportManager.CreaReport("012278", "BNCFNC69B60F205V", "", "F", 9387472, template, new ConsulenzaUnicaWS.Parametro[0]);
// Proposta nuova con negativi
//var imagePdf = reportManager.CreaReport("012057", "DNDMCL54A11L551Z", "", "F", 9377340, template, new ConsulenzaUnicaWS.Parametro[0]);
//var imagePdf = reportManager.CreaReport("002317", "ZZLDRN51E10B025O", "", "F", 9377375, template, new ConsulenzaUnicaWS.Parametro[0]);
#region produzione
// FRITTITTA PRODUZIONE
//var imagePdf = reportManager.CreaReport("014783", "FRTCSM51E07G273F", "", "F", 20020243, template, new ConsulenzaUnicaWS.Parametro[0]);
//PdC - Prova
//var imagePdf = reportManager.CreaReport("000955", "BNCMNL72S15F205Z", "", "S", 20020504, template, new ConsulenzaUnicaWS.Parametro[0]);
//var imagePdf = reportManager.CreaReport("000275", "BNCMTR46C46B648J", "", "F", 29545517, template, new ConsulenzaUnicaWS.Parametro[0]);
//var imagePdf = reportManager.CreaReport("006803", "BCHRRT54L12G999R", "", "F", 19022368, template, new ConsulenzaUnicaWS.Parametro[0]);
//var imagePdf = reportManager.CreaReport("006803", "BCHRRT54L12G999R", "", "F", 19022368, template, new ConsulenzaUnicaWS.Parametro[0]);
//var imagePdf = reportManager.CreaReport("007115", "MRTGPP40H23A794N", "", "F", 20020506, template, new ConsulenzaUnicaWS.Parametro[0]);
// BECHERI
//var imagePdf = reportManager.CreaReport("006803", "BLDRRT35S23A632O", "", "F", 20020363, template, new ConsulenzaUnicaWS.Parametro[0]);
//var imagePdf = reportManager.CreaReport("011523", "CSNPRI61L59F839M", "", "F", 20020266, template, new ConsulenzaUnicaWS.Parametro[0]);
// DIGNANI
//var imagePdf = reportManager.CreaReport("015069", "DGNRSL53P53H501U", "", "F", 20020288, template, new ConsulenzaUnicaWS.Parametro[0]);
//var imagePdf = reportManager.CreaReport("015388", "PSNMDN40E01B140T", "", "F", 20020321, template, new ConsulenzaUnicaWS.Parametro[0]);
//var imagePdf = reportManager.CreaReport("008500", "NCLMLC46B23I826I", "", "F", 20020453, template, new ConsulenzaUnicaWS.Parametro[0]);
//var imagePdf = reportManager.CreaReport("016253", "SBBMRA44P52G463J", "", "F", 20010070, template, new ConsulenzaUnicaWS.Parametro[0]);
//var imagePdf = reportManager.CreaReport("006803", "BLDRRT35S23A632O", "", "F", 20010100, template, new ConsulenzaUnicaWS.Parametro[0]);
//var imagePdf = reportManager.CreaReport("007115", "MRTGPP40H23A794N", "", "F", 20020215, template, new ConsulenzaUnicaWS.Parametro[0]);
//var imagePdf = reportManager.CreaReport("014821", "94009110068", "", "F", 20010094, template, new ConsulenzaUnicaWS.Parametro[0]);
// AVE MARA
//var imagePdf = reportManager.CreaReport("015238", "VAEMRA53M46I373R", "", "F", 20020558, template, new ConsulenzaUnicaWS.Parametro[0]);
//var imagePdf = reportManager.CreaReport("011523", "LGLGNI53E20F257E", "", "F", 20020530, template, new ConsulenzaUnicaWS.Parametro[0]);
//var imagePdf = reportManager.CreaReport("012278", "BNCFNC69B60F205V", "", "F", 19000164, template, new ConsulenzaUnicaWS.Parametro[0]);
//ar imagePdf = reportManager.CreaReport("012278", "GRTCLD65S27F205Z", "", "F", 19000174, template, new ConsulenzaUnicaWS.Parametro[0]);
//var imagePdf = reportManager.CreaReport("011523", "MNTPLA54C71F257V", "", "F", 19000160, template, new ConsulenzaUnicaWS.Parametro[0]);
//var imagePdf = reportManager.CreaReport("011523", "MNTPLA54C71F257V", "", "F", 19000181, template, new ConsulenzaUnicaWS.Parametro[0]);
//var imagePdf = reportManager.CreaReport("011523", "BRTRNN62H60G999X", "", "F", 19000073, template, new ConsulenzaUnicaWS.Parametro[0]);
//var imagePdf = reportManager.CreaReport("011523", "BRTRNN62H60G999X", "", "F", 19000075, template, new ConsulenzaUnicaWS.Parametro[0]);
//var imagePdf = reportManager.CreaReport("012225", "DLLGNE36A05C195Z", "", "F", 19000132, template, new ConsulenzaUnicaWS.Parametro[0]);
//var imagePdf = reportManager.CreaReport("012278", "BRTCRC34D62D783D", "", "F", 20020599, template, new ConsulenzaUnicaWS.Parametro[0]);
//var imagePdf = reportManager.CreaReport("014821", "94009110068", "", "F", 20010077, template, new ConsulenzaUnicaWS.Parametro[0]);
//var imagePdf = reportManager.CreaReport("012278", "GFFMTR43A59E694W", "", "F", 20020587, template, new ConsulenzaUnicaWS.Parametro[0]);
#endregion
if (imagePdf == null) return;
Session["pdf"] = imagePdf;
Response.Redirect("Report.aspx", false);
}
private void caricaCheckboxList(Dictionary<int, string> elenco)
{
//chklstSezioni.DataSource = elenco;
//chklstSezioni.DataValueField = "Key";
//chklstSezioni.DataTextField = "Value";
//chklstSezioni.DataBind();
//chkAll.Visible = true;
}
//protected void ddl_report_SelectedIndexChanged(object sender, EventArgs e)
//{
// int[] elencosezioni =null;
// List<int> lista = new List<int>();
// Dictionary<int, string> listatemp = new Dictionary<int, string>();
// switch (ddl_report.SelectedItem.Text)
// {
// case "Diagnosi":
// for (int i = 44; i < 91; i++) lista.Add(i);
// elencosezioni = new int[] { 105, 107, 111, 112, 113, 114, 115 };
// lista.AddRange(elencosezioni.ToList());
// break;
// case "Monitoraggio":
// for (int i =1 ; i < 47; i++) lista.Add(i);
// lista.Remove(11);
// elencosezioni = new int[] { 57,58,59,60,61,63,65,66,67,68,69,70,71,72 };
// lista.AddRange(elencosezioni.ToList());
// break;
// case "Proposta":
// elencosezioni = new int[] { 1, 2, 3, 4, 10, 11, 12,13, 14, 15, 16, 47,48,49, 50, 51,52,53,54,55, 56,62,64, 73 };
// lista.AddRange(elencosezioni.ToList());
// break;
// case "Nucleo":
// elencosezioni = new int[] { 1, 2, 3};
// lista.AddRange(elencosezioni.ToList());
// for (int i = 5; i < 47; i++) lista.Add(i);
// lista.Remove(10);
// lista.Remove(11);
// lista.Remove(12);
// lista.Remove(13);
// lista.Remove(14);
// lista.Remove(32);
// lista.Remove(39);
// lista.Remove(41);
// elencosezioni = new int[] { 68,69,70,71,72,74,75,76,77,78 };
// lista.AddRange(elencosezioni.ToList());
// break;
// }
// ElencoSezioni = (Dictionary<int,string>)Session["elenco"];
// listatemp = ElencoSezioni.Where(p => lista.Contains(p.Key)).ToDictionary(p => p.Key, p => p.Value);
// caricaCheckboxList(listatemp);
//}
private void caricaElencoSezioni()
{
try
{
var dt = DataAccess.ExecuteDataTableSqlStatement(
DBProvider.SqlServerConsulenzaEvoluta
, "SELECT ID, Descrizione FROM ReportModeler2..Sezioni WHERE id>=44 and id<=121", null);
foreach (DataRow r in dt.Rows)
_elencoSezioni.Add(int.Parse(r["ID"].ToString()), r["Descrizione"].ToString());
Session["elenco"] = _elencoSezioni;
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
#region follia
//_elencoSezioni.Add(1, "Copertina");
//_elencoSezioni.Add(2, "Glossario");
//_elencoSezioni.Add(3, "Avvertenze");
//_elencoSezioni.Add(4, "Sintesi Cliente");
//_elencoSezioni.Add(5, "Patrimonio finanziario: rappresentazione per intermediario");
//_elencoSezioni.Add(6, "Patrimonio finanziario: rappresentazione per macro asset class");
//_elencoSezioni.Add(7, "Patrimonio finanziario: rappresentazione per asset class");
//_elencoSezioni.Add(8, "Patrimonio finanziario: macro categoria di prodotto");
//_elencoSezioni.Add(9, "Patrimonio finanziario: categoria di prodotto");
//_elencoSezioni.Add(10, "Patrimonio Banca Fideuram: piramide dei bisogni");
//_elencoSezioni.Add(11, "Pianificazione: piramide dei bisogni");
//_elencoSezioni.Add(12, "Pianificazione: dettaglio prodotti");
//_elencoSezioni.Add(13, "Progetto 'nome progetto': dettaglio portafoglio modello");
//_elencoSezioni.Add(14, "Riserva: dettaglio portafoglio modello");
//_elencoSezioni.Add(15, "Patrimonio Banca Fideuram: dettaglio contratti");
//_elencoSezioni.Add(16, "Patrimonio Banca Fideuram: dettaglio prodotti");
//_elencoSezioni.Add(17, "Patrimonio Banca Fideuram: rappresentazione per macro asset class");
//_elencoSezioni.Add(18, "Patrimonio Banca Fideuram: rappresentazione per asset class");
//_elencoSezioni.Add(19, "Patrimonio Banca Fideuram: rappresentazione per valute");
//_elencoSezioni.Add(20, "Patrimonio Banca Fideuram: macro categoria prodotto");
//_elencoSezioni.Add(21, "Patrimonio Banca Fideuram: categoria prodotto");
//_elencoSezioni.Add(22, "Patrimonio Banca Fideuram: rappresentazione per rating");
//_elencoSezioni.Add(23, "Patrimonio Banca Fideuram: rappresentazione per emittenti");
//_elencoSezioni.Add(24, "Patrimonio Banca Fideuram: rappresentazione per scadenze");
//_elencoSezioni.Add(25, "Patrimonio Banca Fideuram: rappresentazione per tassi");
//_elencoSezioni.Add(26, "Patrimonio altri Istituti: distribuzione per intermediario");
//_elencoSezioni.Add(27, "Patrimonio altri Istituti: dettaglio prodotti");
//_elencoSezioni.Add(28, "Patrimonio altri Istituti: rappresentazione per macro asset class");
//_elencoSezioni.Add(29, "Patrimonio altri Istituti: rappresentazione per asset class");
//_elencoSezioni.Add(30, "Patrimonio altri Istituti: macro categoria prodotto");
//_elencoSezioni.Add(31, "Copertina");
//_elencoSezioni.Add(32, "Copertina");
//_elencoSezioni.Add(33, "Copertina");
//_elencoSezioni.Add(34, "Copertina");
//_elencoSezioni.Add(35, "Copertina");
//_elencoSezioni.Add(36, "Copertina");
//_elencoSezioni.Add(37, "Copertina");
//_elencoSezioni.Add(38, "Copertina");
//_elencoSezioni.Add(39, "Copertina");
//_elencoSezioni.Add(40, "Copertina");
//_elencoSezioni.Add(41, "Copertina");
//_elencoSezioni.Add(42, "Copertina");
//_elencoSezioni.Add(43, "Copertina");
//_elencoSezioni.Add(44, "Copertina");
//_elencoSezioni.Add(45, "Copertina");
//_elencoSezioni.Add(46, "Copertina");
//_elencoSezioni.Add(47, "Copertina");
//_elencoSezioni.Add(48, "Copertina");
//_elencoSezioni.Add(49, "Copertina");
//_elencoSezioni.Add(50, "Copertina");
//_elencoSezioni.Add(51, "Copertina");
//_elencoSezioni.Add(52, "Copertina");
//_elencoSezioni.Add(53, "Copertina");
//_elencoSezioni.Add(54, "Copertina");
//_elencoSezioni.Add(55, "Copertina");
//_elencoSezioni.Add(56, "Copertina");
//_elencoSezioni.Add(57, "Copertina");
//_elencoSezioni.Add(58, "Copertina");
//_elencoSezioni.Add(59, "Copertina");
//_elencoSezioni.Add(60, "Copertina");
//_elencoSezioni.Add(61, "Copertina");
//_elencoSezioni.Add(62, "Copertina");
//_elencoSezioni.Add(63, "Copertina");
//_elencoSezioni.Add(64, "Copertina");
//_elencoSezioni.Add(65, "Copertina");
//_elencoSezioni.Add(66, "Copertina");
//_elencoSezioni.Add(67, "Copertina");
//_elencoSezioni.Add(68, "Copertina");
//_elencoSezioni.Add(69, "Copertina");
//_elencoSezioni.Add(70, "Copertina");
//_elencoSezioni.Add(71, "Copertina");
//_elencoSezioni.Add(72, "Copertina");
//_elencoSezioni.Add(73, "Copertina");
//_elencoSezioni.Add(74, "Copertina");
//_elencoSezioni.Add(75, "Copertina");
//_elencoSezioni.Add(76, "Copertina");
//_elencoSezioni.Add(77, "Copertina");
//_elencoSezioni.Add(78, "Copertina");
#endregion
}
protected void Button2_Click(object sender, EventArgs e)
{
var dt = DataAccess.ExecuteDataTableSqlStatement(DBProvider.SqlServerConsulenzaUnica, "select * from vInfoCliente WHERE chiaveclientePb=" + tx_chiave.Text, null);
var agente = dt.Rows[0]["agente"].ToString();
var rete = dt.Rows[0]["rete"].ToString();
var mandato = dt.Rows[0]["codman"].ToString();
var codfiscale = dt.Rows[0]["codfis"].ToString();
var prefisso = rete.Equals("F") ? "R" : "P";
var cliente = string.Format("{0} {1}", dt.Rows[0]["nomecliente"].ToString(), dt.Rows[0]["cognomecliente"].ToString());
var privatebancker = string.Format("{0} {1}", dt.Rows[0]["nomepb"].ToString(), dt.Rows[0]["cognomepb"].ToString());
var url = ConfigurationManager.AppSettings["UrlAPI"];
var stringUrl1 = string.Format("{0}/api/login/main", url);
var stringUrl2 = string.Format("{0}/api/login/home", url);
var stringUrl3 = string.Format("{0}/api/cliente/load/customer", url);
using (var client = new CookieWebClient())
{
client.Headers.Clear();
client.Headers.Add(HttpRequestHeader.ContentType, "application/json");
var dataString1 = "{\"mainUserId\":\"" + prefisso + agente + "\"}";
client.UploadString(new Uri(stringUrl1), "POST", dataString1);
client.Headers.Clear();
client.Headers.Add(HttpRequestHeader.ContentType, "application/json");
var dataString2 = "{\"impersonificatedAgentCode\":\"" + agente + "\"}";
client.UploadString(new Uri(stringUrl2), "POST", dataString2);
client.Headers.Clear();
client.Headers.Add(HttpRequestHeader.ContentType, "application/json");
var dataString3 = "{\"codiceFiscale\":\"" + codfiscale + "\",\"codiceMandato\":\"\",\"codiceAgente\": \"" + agente + "\",\"codiceRete\": \"" + rete + "\"}";
client.UploadString(new Uri(stringUrl3), "POST", dataString3);
}
lblAgente.Text = "Agente: " + agente;
lblCodiceFiscale.Text = "CodiceFiscale: " + codfiscale;
lblRete.Text = "Rete: " + rete;
lblMandato.Text = "Mandato: " + mandato;
lblCliente.Text = "Cliente: " + cliente;
lblPb.Text = "Private Bancker: " + privatebancker;
}
public class CookieWebClient : WebClient
{
public CookieContainer CookieContainer { get; private set; }
/// <summary>
/// This will instanciate an internal CookieContainer.
/// </summary>
public CookieWebClient()
{
this.CookieContainer = new CookieContainer();
}
/// <summary>
/// Use this if you want to control the CookieContainer outside this class.
/// </summary>
public CookieWebClient(CookieContainer cookieContainer)
{
this.CookieContainer = cookieContainer;
}
protected override WebRequest GetWebRequest(Uri address)
{
var request = base.GetWebRequest(address) as HttpWebRequest;
if (request == null) return base.GetWebRequest(address);
request.CookieContainer = CookieContainer;
return request;
}
}
}
}