224 lines
5.9 KiB
C#
224 lines
5.9 KiB
C#
using SteamWare;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
|
|
namespace MP_SITE
|
|
{
|
|
public class BaseExportPage : System.Web.UI.Page
|
|
{
|
|
#region Public Properties
|
|
|
|
/// <summary>
|
|
/// inizio periodo da mostrare
|
|
/// </summary>
|
|
public DateTime dtFrom
|
|
{
|
|
get
|
|
{
|
|
DateTime dtRif = DateTime.Now.AddDays(-30);
|
|
try
|
|
{
|
|
string rawDate = memLayer.ML.StringSessionObj("_inizio)");
|
|
if (!string.IsNullOrEmpty(rawDate))
|
|
{
|
|
DateTime.TryParse(rawDate, out dtRif);
|
|
}
|
|
}
|
|
catch
|
|
{ }
|
|
return dtRif;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// fine periodo da mostrare
|
|
/// </summary>
|
|
public DateTime dtTo
|
|
{
|
|
get
|
|
{
|
|
DateTime dtRif = DateTime.Now;
|
|
try
|
|
{
|
|
string rawDate = memLayer.ML.StringSessionObj("_fine)");
|
|
if (!string.IsNullOrEmpty(rawDate))
|
|
{
|
|
DateTime.TryParse(rawDate, out dtRif);
|
|
}
|
|
}
|
|
catch
|
|
{ }
|
|
return dtRif;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// idx della macchina da mostrare
|
|
/// </summary>
|
|
public string idxMacchina
|
|
{
|
|
get
|
|
{
|
|
string idxMacchina = "0";
|
|
try
|
|
{
|
|
idxMacchina = memLayer.ML.StringSessionObj("IdxMacchina");
|
|
}
|
|
catch
|
|
{
|
|
}
|
|
return idxMacchina;
|
|
}
|
|
set
|
|
{
|
|
memLayer.ML.setSessionVal("IdxMacchina", value);
|
|
}
|
|
}
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Public Methods
|
|
|
|
/// <summary>
|
|
/// Recupera commessa al momento indicato
|
|
/// </summary>
|
|
/// <param name="_dtRif"></param>
|
|
/// <returns></returns>
|
|
public string commessaCorr(object _dtRif)
|
|
{
|
|
DateTime dtRif = DateTime.Now;
|
|
DateTime.TryParse($"{_dtRif}", out dtRif);
|
|
return _resoconti.commessaAttiva(idxMacchina, dtFrom, dtTo, dtRif);
|
|
}
|
|
|
|
/// <summary>
|
|
/// restituisce stringa formattata in HH:mm
|
|
/// </summary>
|
|
/// <param name="durataMinuti"></param>
|
|
/// <returns></returns>
|
|
public string durataEvento(object durataMinuti)
|
|
{
|
|
string answ = "";
|
|
if (durataMinuti != null)
|
|
{
|
|
answ = durataMinuti.ToString();
|
|
}
|
|
return answ;
|
|
}
|
|
|
|
public string macchinaDaIdx(object idx)
|
|
{
|
|
string answ = "";
|
|
if (idx != null)
|
|
{
|
|
answ = _resoconti.macchinaDaIdx(idx.ToString());
|
|
}
|
|
return answ;
|
|
}
|
|
|
|
public string operatoreDaMatr(object matricola)
|
|
{
|
|
int matr = 0;
|
|
string answ = "N.A.";
|
|
try
|
|
{
|
|
matr = Convert.ToInt32(matricola);
|
|
}
|
|
catch
|
|
{ }
|
|
// cerco in LUT...
|
|
if (OprLUT.ContainsKey(matr))
|
|
{
|
|
answ = OprLUT[matr];
|
|
}
|
|
else
|
|
{
|
|
answ = _resoconti.oprDaMatr(matr);
|
|
OprLUT.Add(matr, answ);
|
|
}
|
|
return answ;
|
|
}
|
|
|
|
public string statoDaIdx(object idx)
|
|
{
|
|
return _resoconti.statoDaIdx(Convert.ToInt32(idx));
|
|
}
|
|
|
|
public string tipoDaIdx(object idx)
|
|
{
|
|
return _resoconti.tipoDaIdx(Convert.ToInt32(idx));
|
|
}
|
|
|
|
public override void VerifyRenderingInServerForm(Control control)
|
|
{
|
|
// Confirms that an HtmlForm control is rendered for the specified ASP.NET server
|
|
// control at run time.
|
|
}
|
|
|
|
#endregion Public Methods
|
|
|
|
#region Internal Methods
|
|
|
|
internal virtual void aggiornamento()
|
|
{
|
|
}
|
|
|
|
internal void doExport()
|
|
{
|
|
StringWriter stringWrite;
|
|
HtmlTextWriter htmlWrite;
|
|
startResponse(out stringWrite, out htmlWrite);
|
|
renderControl(htmlWrite);
|
|
endResponse(stringWrite);
|
|
}
|
|
|
|
internal void endResponse(StringWriter stringWrite)
|
|
{
|
|
Response.Write(stringWrite.ToString());
|
|
Response.End();
|
|
}
|
|
|
|
internal virtual void renderControl(HtmlTextWriter htmlWrite)
|
|
{
|
|
}
|
|
|
|
internal void startResponse(out StringWriter stringWrite, out HtmlTextWriter htmlWrite)
|
|
{
|
|
Response.Clear();
|
|
Response.AddHeader("content-disposition", "attachment; filename=DatiConfermati.xls");
|
|
Response.Charset = "";
|
|
// If you want the option to open the Excel file without saving than comment out the
|
|
// line below
|
|
Response.Cache.SetCacheability(HttpCacheability.NoCache);
|
|
Response.ContentType = "application/vnd.xls";
|
|
stringWrite = new StringWriter();
|
|
htmlWrite = new HtmlTextWriter(stringWrite);
|
|
}
|
|
|
|
#endregion Internal Methods
|
|
|
|
#region Protected Fields
|
|
|
|
protected resoconti _resoconti;
|
|
protected Dictionary<int, string> OprLUT = new Dictionary<int, string>();
|
|
|
|
#endregion Protected Fields
|
|
|
|
#region Protected Methods
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
_resoconti = new resoconti();
|
|
if (!Page.IsPostBack)
|
|
{
|
|
aggiornamento();
|
|
doExport();
|
|
}
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
}
|
|
} |