7d289a3b64
pulizia codice...
232 lines
7.4 KiB
C#
232 lines
7.4 KiB
C#
using SteamWare;
|
|
using System;
|
|
using System.Web.UI;
|
|
|
|
public partial class adminDB : System.Web.UI.Page
|
|
{
|
|
/// <summary>
|
|
/// versioni db in prod/richiesti
|
|
/// </summary>
|
|
protected int appDB_act, appDB_req, vocDB_act, vocDB_req, anaDB_act, anaDB_req;
|
|
/// <summary>
|
|
/// caricamento pagina
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
// calcolo versioni db
|
|
calcolaVersioniDb();
|
|
// aggiorno labels
|
|
lblResult.Text = "";
|
|
lblDbAppVers.Text = string.Format("Versione DB Installata: <b>{0}</b> / Richiesta: <b>{1}</b>", appDB_act, appDB_req);
|
|
lblDbVocVers.Text = string.Format("Versione DB Installata: <b>{0}</b> / Richiesta: <b>{1}</b>", vocDB_act, vocDB_req);
|
|
lblDbAnaVers.Text = string.Format("Versione DB Installata: <b>{0}</b> / Richiesta: <b>{1}</b>", anaDB_act, anaDB_req);
|
|
// setto abilitazione dei buttons...
|
|
setButtonState();
|
|
// compilo step x update area di test...
|
|
if (!Page.IsPostBack)
|
|
{
|
|
txtStepFrom.Text = "0";
|
|
txtStepTo.Text = appDB_req.ToString();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// calcola le versioni dei db in uso e richiesti
|
|
/// </summary>
|
|
private void calcolaVersioniDb()
|
|
{
|
|
appDB_act = TA_app.obj.appDB_act;
|
|
appDB_req = TA_app.obj.appDB_req;
|
|
vocDB_act = TA_app.obj.vocDB_act;
|
|
vocDB_req = TA_app.obj.vocDB_req;
|
|
anaDB_act = TA_app.obj.anaDB_act;
|
|
anaDB_req = TA_app.obj.anaDB_req;
|
|
}
|
|
/// <summary>
|
|
/// setta abilitazione dei buttons
|
|
/// </summary>
|
|
private void setButtonState()
|
|
{
|
|
// check abilitazione creazione db
|
|
if (appDB_act < 0)
|
|
{
|
|
btnCreaDbProd.Enabled = true;
|
|
}
|
|
else
|
|
{
|
|
btnCreaDbProd.Enabled = false;
|
|
}
|
|
if (vocDB_act < 0)
|
|
{
|
|
btnCreaVocab.Enabled = true;
|
|
}
|
|
else
|
|
{
|
|
btnCreaVocab.Enabled = false;
|
|
}
|
|
if (anaDB_act < 0)
|
|
{
|
|
btnCreaAnag.Enabled = true;
|
|
}
|
|
else
|
|
{
|
|
btnCreaAnag.Enabled = false;
|
|
}
|
|
// check update db
|
|
if (appDB_req > appDB_act)
|
|
{
|
|
btnUpdDbProd.Enabled = true;
|
|
}
|
|
else
|
|
{
|
|
btnUpdDbProd.Enabled = false;
|
|
}
|
|
if (vocDB_req > vocDB_act)
|
|
{
|
|
btnUpdVocab.Enabled = true;
|
|
}
|
|
else
|
|
{
|
|
btnUpdVocab.Enabled = false;
|
|
}
|
|
if (anaDB_req > anaDB_act)
|
|
{
|
|
btnUpdAnag.Enabled = true;
|
|
}
|
|
else
|
|
{
|
|
btnUpdAnag.Enabled = false;
|
|
}
|
|
}
|
|
|
|
#region buttons Applicazione
|
|
|
|
/// <summary>
|
|
/// crea da zero db applicazione
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnCreaDbProd_Click(object sender, EventArgs e)
|
|
{
|
|
lblResult.Text = "Funzione disattivata";
|
|
#if false
|
|
dbUpdateManager dum = new dbUpdateManager(memLayer.ML.confReadString("AppConnectionString"), "sql", "{0}_{1:0000}.sql");
|
|
dum.updateDbToRev("GIM", 0, 0, 600);
|
|
lblResult.Text = "Creato DB di produzione!";
|
|
#endif
|
|
}
|
|
/// <summary>
|
|
/// update del db in produzione
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnUpdDbProd_Click(object sender, EventArgs e)
|
|
{
|
|
// faccio update SOLO se la versione corrente del db è precedente a quella richiesta...
|
|
if (appDB_act < appDB_req)
|
|
{
|
|
dbUpdateManager dum = new dbUpdateManager(memLayer.ML.confReadString("AppConnectionString"), "sql", "{0}_{1:0000}.sql");
|
|
dum.updateDbToRev("GIM", appDB_act + 1, appDB_req, 600);
|
|
lblResult.Text = "Aggiornato DB di produzione!";
|
|
}
|
|
else
|
|
{
|
|
lblResult.Text = "DB di produzione è up-to-date!";
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// rigenerazione db in test
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnResetDbTest_Click(object sender, EventArgs e)
|
|
{
|
|
dbUpdateManager dum = new dbUpdateManager(memLayer.ML.confReadString("TestAppConnectionString"), "sql", "{0}_{1:0000}.sql");
|
|
dum.updateDbToRev("GIM", 0, appDB_req, 600);
|
|
lblResult.Text = "Rigenerato il DB di test!";
|
|
}
|
|
/// <summary>
|
|
/// esegue gli step di update richeisti sul db di test
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnDoReqUpdDbTest_Click(object sender, EventArgs e)
|
|
{
|
|
int from = 0;
|
|
int to = appDB_req;
|
|
if (Convert.ToInt32(txtStepFrom.Text) > from) from = Convert.ToInt32(txtStepFrom.Text);
|
|
if (Convert.ToInt32(txtStepTo.Text) < to) to = Convert.ToInt32(txtStepTo.Text);
|
|
dbUpdateManager dum = new dbUpdateManager(memLayer.ML.confReadString("TestAppConnectionString"), "sql", "{0}_{1:0000}.sql");
|
|
dum.updateDbToRev("GIM", from, to, 600);
|
|
lblResult.Text = "Eseguiti gli step per il DB di test!";
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region buttons Vocabolario ed Anagrafica
|
|
|
|
/// <summary>
|
|
/// creo il db del vocabolario
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnCreaVocab_Click(object sender, EventArgs e)
|
|
{
|
|
lblResult.Text = "...non implementato...";
|
|
#if false
|
|
// !!!FARE!!!
|
|
dbUpdateManager dum = new dbUpdateManager(memLayer.ML.confReadString("VocabolarioConnectionString"), "sql", "{0}_{1:0000}.sql");
|
|
dum.updateDbToRev("VOC", 0, 0, 600);
|
|
lblResult.Text = "Creato DB Vocabolario!";
|
|
#endif
|
|
}
|
|
/// <summary>
|
|
/// aggiorna il db del vocabolario
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnUpdVocab_Click(object sender, EventArgs e)
|
|
{
|
|
lblResult.Text = "...non implementato...";
|
|
#if false
|
|
// !!!FARE!!!
|
|
dbUpdateManager dum = new dbUpdateManager(memLayer.ML.confReadString("VocabolarioConnectionString"), "sql", "{0}_{1:0000}.sql");
|
|
dum.updateDbToRev("VOC", 1, memLayer.ML.confReadInt("dbVocabVers"), 600);
|
|
lblResult.Text = "Aggiornato DB Vocabolario!";
|
|
#endif
|
|
}
|
|
/// <summary>
|
|
/// crea il db di anagrafica
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnCreaAnag_Click(object sender, EventArgs e)
|
|
{
|
|
lblResult.Text = "...non implementato...";
|
|
#if false
|
|
// !!!FARE!!!
|
|
dbUpdateManager dum = new dbUpdateManager(memLayer.ML.confReadString("UtenteCdcConnectionString"), "sql", "{0}_{1:0000}.sql");
|
|
dum.updateDbToRev("ANA", 0, 0, 600);
|
|
lblResult.Text = "Creato DB Anagrafica!";
|
|
#endif
|
|
}
|
|
/// <summary>
|
|
/// update dell'anagrafica
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnUpdAnag_Click(object sender, EventArgs e)
|
|
{
|
|
lblResult.Text = "...non implementato...";
|
|
#if false
|
|
// !!!FARE!!!
|
|
dbUpdateManager dum = new dbUpdateManager(memLayer.ML.confReadString("UtenteCdcConnectionString"), "sql", "{0}_{1:0000}.sql");
|
|
dum.updateDbToRev("ANA", 1, memLayer.ML.confReadInt("dbAuthVers"), 600);
|
|
lblResult.Text = "Aggiornato DB Anagrafica!";
|
|
#endif
|
|
}
|
|
|
|
#endregion
|
|
}
|