414 lines
15 KiB
Plaintext
414 lines
15 KiB
Plaintext
using System;
|
|
using System.Collections.Generic;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
using System.Data;
|
|
using ConsulenzaEvoluta;
|
|
using ClassLibraryWS.bancafideuram.nac.anagrafica;
|
|
|
|
public partial class query : System.Web.UI.Page
|
|
{
|
|
private DataTable GetDataOracle()
|
|
{
|
|
DataSectionParameter dsr = new DataSectionParameter();
|
|
dsr.CodiceCliente = this.txtCF.Text.Trim();
|
|
dsr.CodicePB = this.txtPB.Text.Trim();
|
|
dsr.CodiceRete = this.txtRETE.Text.Trim();
|
|
|
|
try
|
|
{
|
|
return SectionManager.GetDataSection(txtFileSQL.Text.ToUpper(), dsr);
|
|
}
|
|
catch (DataBaseException ex)
|
|
{
|
|
throw new DataBaseException(ex, ex.ConnectionStringWithoutCredentials, ex.CommandText);
|
|
}
|
|
}
|
|
|
|
private DataTable GetDataSqlServer()
|
|
{
|
|
DataSectionParameter dsr = new DataSectionParameter();
|
|
dsr.CodiceCliente = this.txtCF.Text.Trim();
|
|
dsr.CodicePB = this.txtPB.Text.Trim();
|
|
dsr.CodiceRete = this.txtRETE.Text.Trim();
|
|
|
|
try
|
|
{
|
|
Cliente cliente = Cliente.getCliente(dsr.CodiceRete + dsr.CodicePB, dsr.CodiceCliente);
|
|
return BusinessManager.GetDataTableFromStoredProcedure_ConsulenzaEvoluta(txtStoredSQL.Text, cliente.ChiaveClientePB);
|
|
}
|
|
catch (DataBaseException ex)
|
|
{
|
|
throw new DataBaseException(ex, ex.ConnectionStringWithoutCredentials, ex.CommandText);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Esegue le query su Oracle (SEIReport)
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Esegui_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
lblNoDatiOracle.Visible = false;
|
|
|
|
DateTime inizioElaborazioneQuery = DateTime.Now;
|
|
|
|
DataTable dt = GetDataOracle();
|
|
|
|
DateTime fineElaborazioneQuery = DateTime.Now;
|
|
|
|
#region Tempo impiegato alla elaborazione
|
|
|
|
TimeSpan tempoImpiegato = fineElaborazioneQuery.Subtract(inizioElaborazioneQuery);
|
|
|
|
#endregion
|
|
|
|
this.tempoElaborazioneOracle.Text = dt.Rows.Count + " righe in (m:s:ms) = " + tempoImpiegato.Minutes + " : " + tempoImpiegato.Seconds + " : " + tempoImpiegato.Milliseconds;
|
|
|
|
if (dt.Rows.Count > 0)
|
|
{
|
|
grigliaOracle.DataSource = dt;
|
|
grigliaOracle.DataBind();
|
|
}
|
|
else
|
|
{
|
|
grigliaOracle.DataSource = null;
|
|
grigliaOracle.DataBind();
|
|
lblNoDatiOracle.Visible = true;
|
|
}
|
|
}
|
|
catch (DataBaseException ex)
|
|
{
|
|
Response.Write(ex.Eccezione.Message);
|
|
Response.End();
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Response.Write(ex.Message);
|
|
Response.End();
|
|
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Esegue le query su SqlServer (ConsulenzaEvoluta)
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void EseguiSql_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
lblNoDatiSqlServer.Visible = false;
|
|
|
|
DateTime inizioElaborazioneQuery = DateTime.Now;
|
|
|
|
DataTable dt = GetDataSqlServer();
|
|
|
|
DateTime fineElaborazioneQuery = DateTime.Now;
|
|
|
|
#region Tempo impiegato alla elaborazione
|
|
|
|
TimeSpan tempoImpiegato = fineElaborazioneQuery.Subtract(inizioElaborazioneQuery);
|
|
|
|
#endregion
|
|
|
|
this.tempoElaborazioneSqlServer.Text = dt.Rows.Count + " righe in (m:s:ms) = " + tempoImpiegato.Minutes + " : " + tempoImpiegato.Seconds + " : " + tempoImpiegato.Milliseconds;
|
|
|
|
if (dt.Rows.Count > 0)
|
|
{
|
|
grigliaSqlServer.DataSource = dt;
|
|
grigliaSqlServer.DataBind();
|
|
}
|
|
else
|
|
{
|
|
grigliaSqlServer.DataSource = null;
|
|
grigliaSqlServer.DataBind();
|
|
lblNoDatiSqlServer.Visible = true;
|
|
}
|
|
}
|
|
catch (DataBaseException ex)
|
|
{
|
|
Response.Write(ex.Eccezione.Message);
|
|
Response.End();
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Response.Write(ex.Message);
|
|
Response.End();
|
|
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Compara i dati da oracle con quelli da sqlserver
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Compara_Click(object sender, EventArgs e)
|
|
{
|
|
DataTable dt;
|
|
dt = getDifferentRecords(GetDataOracle(), GetDataSqlServer());
|
|
|
|
if (dt.Rows.Count == 0)
|
|
lblRisultatoComparazione.Text = "Uguali";
|
|
else
|
|
lblRisultatoComparazione.Text = "Diversi";
|
|
}
|
|
|
|
protected void NoSession_Click(object sender, EventArgs e)
|
|
{
|
|
int numeroChiaviTotale = Session.Keys.Count - 1;
|
|
int i = numeroChiaviTotale;
|
|
|
|
while (i > 0)
|
|
{
|
|
if (Session.Keys[i].ToString().ToLower().Contains(txtCF.Text.Trim().ToLower()))
|
|
Session.Remove(Session.Keys[i].ToString());
|
|
i--;
|
|
|
|
}
|
|
}
|
|
|
|
protected void griglia_Sorting(object sender, GridViewSortEventArgs e)
|
|
{
|
|
DataTable dataTable = GetDataOracle();
|
|
|
|
if (dataTable != null)
|
|
{
|
|
DataView dataView = new DataView(dataTable);
|
|
dataView.Sort = e.SortExpression + " " + ConvertSortDirectionToSql(e.SortDirection);
|
|
|
|
grigliaOracle.DataSource = dataView;
|
|
grigliaOracle.DataBind();
|
|
}
|
|
|
|
}
|
|
|
|
private string ConvertSortDirectionToSql(SortDirection sortDirection)
|
|
{
|
|
string newSortDirection = String.Empty;
|
|
|
|
switch (sortDirection)
|
|
{
|
|
case SortDirection.Ascending:
|
|
newSortDirection = "ASC";
|
|
break;
|
|
|
|
case SortDirection.Descending:
|
|
newSortDirection = "DESC";
|
|
break;
|
|
}
|
|
|
|
return newSortDirection;
|
|
}
|
|
|
|
protected void LanciaProceduraCaricamentoDati_Click(object sender, EventArgs e)
|
|
{
|
|
List<Parametro> listParameters = new List<Parametro>();
|
|
|
|
Parametro parametro;
|
|
parametro = new Parametro();
|
|
parametro.ParameterName = "v_codfis";
|
|
parametro.Value = this.txtCF.Text.Trim();
|
|
parametro.DbType = DbType.AnsiStringFixedLength;
|
|
listParameters.Add(parametro);
|
|
|
|
parametro = new Parametro();
|
|
parametro.ParameterName = "v_rete";
|
|
parametro.Value = this.txtRETE.Text.Trim();
|
|
parametro.DbType = DbType.AnsiStringFixedLength;
|
|
listParameters.Add(parametro);
|
|
|
|
try
|
|
{
|
|
DataAccess.ExecuteNonQueryStoredProcedure(DBProvider.Oracle, "avvio_report", listParameters);
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
|
|
|
|
}
|
|
|
|
#region Compare two DataTables and return a DataTable with DifferentRecords
|
|
|
|
public DataTable getDifferentRecords(DataTable FirstDataTable, DataTable SecondDataTable)
|
|
{
|
|
|
|
FirstDataTable.TableName = "TabellaOracle";
|
|
SecondDataTable.TableName = "TabellaSqlServer";
|
|
|
|
//Create Empty Table
|
|
DataTable ResultDataTable = new DataTable("ResultDataTable");
|
|
|
|
//use a Dataset to make use of a DataRelation object
|
|
using (DataSet ds = new DataSet())
|
|
{
|
|
//Add tables
|
|
ds.Tables.AddRange(new DataTable[] { FirstDataTable.Copy(), SecondDataTable.Copy() });
|
|
|
|
//Get Columns for DataRelation
|
|
DataColumn[] firstColumns = new DataColumn[ds.Tables[0].Columns.Count];
|
|
for (int i = 0; i < firstColumns.Length; i++)
|
|
{
|
|
firstColumns[i] = ds.Tables[0].Columns[i];
|
|
}
|
|
|
|
DataColumn[] secondColumns = new DataColumn[ds.Tables[1].Columns.Count];
|
|
for (int i = 0; i < secondColumns.Length; i++)
|
|
{
|
|
secondColumns[i] = ds.Tables[1].Columns[i];
|
|
}
|
|
|
|
////Create DataRelation
|
|
//DataRelation r1 = new DataRelation(string.Empty, firstColumns, secondColumns, false);
|
|
//ds.Relations.Add(r1);
|
|
|
|
//DataRelation r2 = new DataRelation(string.Empty, secondColumns, firstColumns, false);
|
|
//ds.Relations.Add(r2);
|
|
|
|
//Create columns for return table
|
|
for (int i = 0; i < FirstDataTable.Columns.Count; i++)
|
|
{
|
|
ResultDataTable.Columns.Add(FirstDataTable.Columns[i].ColumnName, typeof(string)); //FirstDataTable.Columns[i].DataType);
|
|
}
|
|
|
|
//If FirstDataTable Row not in SecondDataTable, Add to ResultDataTable.
|
|
ResultDataTable.BeginLoadData();
|
|
foreach (DataRow parentrow in ds.Tables[0].Rows)
|
|
{
|
|
//DataRow[] childrows = parentrow.GetChildRows(r1);
|
|
//if (childrows == null || childrows.Length == 0)
|
|
ResultDataTable.LoadDataRow(parentrow.ItemArray, true);
|
|
}
|
|
|
|
//If SecondDataTable Row not in FirstDataTable, Add to ResultDataTable.
|
|
foreach (DataRow parentrow in ds.Tables[1].Rows)
|
|
{
|
|
//DataRow[] childrows = parentrow.GetChildRows(r2);
|
|
//if (childrows == null || childrows.Length == 0)
|
|
ResultDataTable.LoadDataRow(parentrow.ItemArray, true);
|
|
}
|
|
ResultDataTable.EndLoadData();
|
|
}
|
|
|
|
return ResultDataTable;
|
|
}
|
|
#endregion
|
|
|
|
|
|
protected void btnMigrazioneDettaglioASUL_Click(object sender, EventArgs e)
|
|
{
|
|
esitoMigrazioneFettaglioASUL.Text = string.Empty;
|
|
|
|
try
|
|
{
|
|
DataTable tabellaInputOracle = DataAccess.ExecuteDataTableSqlStatement(DBProvider.Oracle, "select distinct a.adbkid as cf, v.rete_pb as rete, v.codice_pb as agente from v_all_cf_e_pb v, proposta a, clonepos clo, catitemref t where v.codicefiscale = a.adbkid and v.rete_pb = a.instid and a.type$_statop_1e6ec='Validata' and clo.propostaid=a.c_propostaid_117d4 and clo.f_oid$_posit_a78ff=t.oid$ and t.tipoprodotto='ASUL' order by a.adbkid", null);
|
|
|
|
foreach (DataRow rowInputOracle in tabellaInputOracle.Rows)
|
|
{
|
|
HttpContext.Current.Session.RemoveAll();
|
|
|
|
#region Recupero il cliente
|
|
|
|
string rete = rowInputOracle["rete"].ToString();
|
|
string cf = rowInputOracle["cf"].ToString();
|
|
string agente = rowInputOracle["agente"].ToString();
|
|
string token = string.Empty;
|
|
|
|
Cliente cliente = Cliente.getCliente(rete + agente, cf);
|
|
|
|
#endregion
|
|
|
|
#region Recupero token da AnagraficaWS.GetVersion
|
|
|
|
if (string.IsNullOrEmpty(token))
|
|
{
|
|
string codPortal = WebConfigParameter.getParameter("CODICEPORTALEPERVERSIONESIMPB");
|
|
|
|
InfoClient infoCliente = new InfoClient();
|
|
infoCliente.codiceApplicazione = WebConfigParameter.getParameter("CODICEAPPLICAZIONE").ToString();
|
|
infoCliente.codiceRete = rete;
|
|
infoCliente.versioneDatabaseSIMPB = 0;
|
|
|
|
AnagraficaWS wsana = new AnagraficaWS();
|
|
PBRes risposta = wsana.GetVersion(infoCliente, codPortal);
|
|
token = risposta.info.versioneDatabaseSIMPB.ToString();
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region InfoClient e ChiaveCliente di GlobalPosition e Anagrafica
|
|
|
|
// Global Position
|
|
ClassLibraryWS.bancafideuram.nac.globalposition.InfoClient _infoCliente_GlobalPosition = new ClassLibraryWS.bancafideuram.nac.globalposition.InfoClient();
|
|
_infoCliente_GlobalPosition.codiceApplicazione = WebConfigParameter.getParameter("CODICEAPPLICAZIONE").ToString();
|
|
_infoCliente_GlobalPosition.codiceRete = rete;
|
|
_infoCliente_GlobalPosition.versioneDatabaseSIMPB = int.Parse(token);
|
|
|
|
|
|
ClassLibraryWS.bancafideuram.nac.globalposition.ChiaveCliente _chiaveCliente_GlobalPosition = new ClassLibraryWS.bancafideuram.nac.globalposition.ChiaveCliente();
|
|
_chiaveCliente_GlobalPosition.codiceAgente = agente;
|
|
_chiaveCliente_GlobalPosition.codicefiscale = cf;
|
|
_chiaveCliente_GlobalPosition.codiceRete = rete;
|
|
_chiaveCliente_GlobalPosition.potenzialeClienteNAC = true;
|
|
|
|
|
|
// Anagrafica
|
|
ClassLibraryWS.bancafideuram.nac.anagrafica.InfoClient _infoCliente_Anagrafica = new ClassLibraryWS.bancafideuram.nac.anagrafica.InfoClient();
|
|
_infoCliente_Anagrafica.codiceApplicazione = WebConfigParameter.getParameter("CODICEAPPLICAZIONE").ToString();
|
|
_infoCliente_Anagrafica.codiceRete = rete;
|
|
_infoCliente_Anagrafica.versioneDatabaseSIMPB = int.Parse(token);
|
|
|
|
ClassLibraryWS.bancafideuram.nac.anagrafica.ChiaveCliente _chiaveCliente_Anagrafica = new ClassLibraryWS.bancafideuram.nac.anagrafica.ChiaveCliente();
|
|
_chiaveCliente_Anagrafica.codiceAgente = agente;
|
|
_chiaveCliente_Anagrafica.codicefiscale = cf;
|
|
_chiaveCliente_Anagrafica.codiceRete = rete;
|
|
_chiaveCliente_Anagrafica.potenzialeClienteNAC = true;
|
|
|
|
#endregion
|
|
|
|
#region Caricamento tabella Dettaglio_Asul
|
|
|
|
// Recupero i dati dalla Prometeia.GetContrattoSintesiPerClienteCaricamentoAsul
|
|
DataTable dtDettaglioAsul = new DataTable();
|
|
DataTable dtContrattoSintesiPerCliente = Prometeia.GetContrattoSintesiPerClienteCaricamentoAsul(_chiaveCliente_GlobalPosition, _infoCliente_GlobalPosition, cliente.ChiaveClientePB);
|
|
DataRow[] rowsProdottiAsul = dtContrattoSintesiPerCliente.Select("tipoProdotto='ASUL'");
|
|
|
|
// Richiamo il dettaglio asul per ogni asul trovato nel portafoglio del cliente.
|
|
foreach (DataRow itemProdottoAsul in rowsProdottiAsul)
|
|
{
|
|
dtDettaglioAsul.Merge(Prometeia.GetContrattoUnitLinkedSaldo(_chiaveCliente_GlobalPosition, itemProdottoAsul["CODICECONTRATTO"].ToString(), _infoCliente_GlobalPosition, cliente.ChiaveClientePB));
|
|
}
|
|
|
|
// Insert sulla DETTAGLIO_ASUL di ConsulenzaEvoluta
|
|
if (dtDettaglioAsul.Rows.Count > 0)
|
|
BusinessManager.InsertData_Into_DettaglioAsul(cliente.ChiaveClientePB, dtDettaglioAsul);
|
|
|
|
#endregion
|
|
|
|
}
|
|
|
|
esitoMigrazioneFettaglioASUL.Text = "migrazione COMPLETATA";
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
esitoMigrazioneFettaglioASUL.Text = "migrazione NON COMPLETATA -- " + ex.Message;
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|