211 lines
6.6 KiB
C#
211 lines
6.6 KiB
C#
using SteamWare;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
using C2P_Data;
|
|
|
|
namespace C2P.WebUserControls
|
|
{
|
|
public partial class mod_marginReport : SteamWare.UserControl
|
|
{
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!Page.IsPostBack)
|
|
{
|
|
setModVisibility("");
|
|
//memLayer.ML.setSessionVal("runningQLR", false);
|
|
}
|
|
mod_fileUploader1.eh_uploadDone += mod_fileUploader1_eh_uploadDone;
|
|
// verifico se sto eseguendo task lungo di caricamento...
|
|
if (runningQLR)
|
|
{
|
|
queueLenght();
|
|
setModVisibility("DataProc");
|
|
processQLR();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// verifica se sia in corso un run di import QLR
|
|
/// </summary>
|
|
protected bool runningQLR
|
|
{
|
|
get
|
|
{
|
|
return memLayer.ML.BoolSessionObj("runningQLR");
|
|
}
|
|
set
|
|
{
|
|
memLayer.ML.setSessionVal("runningQLR", value);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// file caricato
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
void mod_fileUploader1_eh_uploadDone(object sender, EventArgs e)
|
|
{
|
|
// caricato file su server, PROVA ad eseguire import tabella
|
|
int numRecIn = 0;
|
|
int numRecConv = 0;
|
|
try
|
|
{
|
|
numRecIn = DtProxy.man.taOH.import("OrdersHistRaw")[0].RecordsIn;
|
|
}
|
|
catch
|
|
{ }
|
|
try
|
|
{
|
|
numRecConv = DtProxy.man.taOH.convert("OrdersHistRaw")[0].RecordsIn;
|
|
}
|
|
catch
|
|
{ }
|
|
try
|
|
{
|
|
DtProxy.man.taOH.merge("OrdersHistRaw");
|
|
}
|
|
catch
|
|
{ }
|
|
lblUploadDone.Text = string.Format("{0} records IN, {1} records acquired", numRecIn, numRecConv);
|
|
logger.lg.scriviLog(lblUploadDone.Text, tipoLog.INFO);
|
|
btnGoStep2.Visible = true;
|
|
}
|
|
/// <summary>
|
|
/// premuto uno dei buttons dell'header
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void lbt_Click(object sender, EventArgs e)
|
|
{
|
|
LinkButton lBtn = ((LinkButton)sender);
|
|
setModVisibility(lBtn.CommandArgument);
|
|
}
|
|
/// <summary>
|
|
/// sistemazione della visibilità dei moduli di dettaglio/editing
|
|
/// </summary>
|
|
private void setModVisibility(string req)
|
|
{
|
|
//divHelp.Visible = false;
|
|
divDataIn.Visible = false;
|
|
divDataProc.Visible = false;
|
|
divAnalisys.Visible = false;
|
|
switch (req)
|
|
{
|
|
case "DataIn":
|
|
divDataIn.Visible = true;
|
|
break;
|
|
case "DataProc":
|
|
divDataProc.Visible = true;
|
|
btnDoAcquire.Enabled = (queueLenght() > 0);
|
|
break;
|
|
case "Analisys":
|
|
divAnalisys.Visible = true;
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
mod_MaRepNewData1.doUpdate();
|
|
mod_MaRepActData1.doUpdate();
|
|
queueLenght();
|
|
}
|
|
/// <summary>
|
|
/// lunghezza coda da acquisire + update visualizzazione
|
|
/// </summary>
|
|
private int queueLenght()
|
|
{
|
|
int qLen = 0;
|
|
try
|
|
{
|
|
qLen = DtProxy.man.taOH.countRemaining()[0].RecordsIn;
|
|
}
|
|
catch
|
|
{ }
|
|
lblAcqOut.Text = string.Format("{0} records", qLen);
|
|
return qLen;
|
|
}
|
|
/// <summary>
|
|
/// passa a step 2
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnGoStep2_Click(object sender, EventArgs e)
|
|
{
|
|
setModVisibility("DataProc");
|
|
}
|
|
/// <summary>
|
|
/// passa a step 3
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnGoStep3_Click(object sender, EventArgs e)
|
|
{
|
|
setModVisibility("Analisys");
|
|
}
|
|
/// <summary>
|
|
/// esegue acquisizione dati
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnDoAcquire_Click(object sender, EventArgs e)
|
|
{
|
|
processQLR();
|
|
}
|
|
/// <summary>
|
|
/// processa generazione QLR
|
|
/// </summary>
|
|
private void processQLR()
|
|
{
|
|
logger.lg.scriviLog(string.Format("Inizio Processing dati QLR x RepMar: {0} rec", queueLenght()), tipoLog.INFO);
|
|
DateTime tick = DateTime.Now;
|
|
// chiamo processing di merge ordini e generazione schede...
|
|
try
|
|
{
|
|
generateNewQLR();
|
|
logger.lg.scriviLog(string.Format("FINE Processing dati QLR x RepMar: {0} rec", queueLenght()), tipoLog.INFO);
|
|
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
logger.lg.scriviLog(string.Format("Errore in acquisizione ordini storici: {0}", exc), tipoLog.EXCEPTION);
|
|
setModVisibility("DataProc");
|
|
}
|
|
if (queueLenght() > 0)
|
|
{
|
|
// salvo che voglio continuare caricamento dati...
|
|
runningQLR = true;
|
|
Response.Redirect("~/MarginReport");
|
|
}
|
|
else
|
|
{
|
|
setModVisibility("Analisys");
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// esegue script x generazione di tutti i record QLR a batch di rec2procQLR alla volta
|
|
/// </summary>
|
|
protected void generateNewQLR()
|
|
{
|
|
// inizializzo
|
|
int rec2procQLR = 100;
|
|
try
|
|
{
|
|
rec2procQLR = memLayer.ML.confReadInt("rec2procQLR");
|
|
}
|
|
catch
|
|
{ }
|
|
// processing...
|
|
if (queueLenght() > 0)
|
|
{
|
|
DtProxy.man.taOH.generateNewQLR("R", string.Format("Imported by {0} on {1:dd/MM/yy HH:mm}", user_std.UtSn.userNameAD, DateTime.Now), rec2procQLR);
|
|
}
|
|
else
|
|
{
|
|
// salvo che ho finito con caricamento dati...
|
|
runningQLR = false;
|
|
}
|
|
}
|
|
}
|
|
} |