using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Text; using GPW_data; using SteamWare; namespace GPW_Admin { public partial class ExportTimbZucchetti : BasePage { protected DateTime inizio; protected DateTime fine; protected int idxDipendente; string codTimbra; /// /// caricamento pagina /// /// /// protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { aggiornamento(); doExport(); } } /// /// update controlli /// public void aggiornamento() { // carico dati inizio/fine periodo richiesti inizio = Convert.ToDateTime(memLayer.ML.objSessionObj("_inizio")); fine = Convert.ToDateTime(memLayer.ML.objSessionObj("_fine")); idxDipendente = memLayer.ML.IntSessionObj("idxDip_sel"); if (idxDipendente == -1) idxDipendente = 0; codTimbra = memLayer.ML.confReadString("codTimbra"); if (string.IsNullOrEmpty(codTimbra)) { codTimbra = "90"; // timbratrice 90: da web.config } } /// /// export html pagina /// private void doExport() { string attachment = "attachment; filename=Timbrature.txt"; Response.Clear(); Response.ClearHeaders(); Response.ClearContent(); Response.AddHeader("content-disposition", attachment); 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 = "text/csv"; Response.AddHeader("Pragma", "public"); // scrivo le righe dell'output! DS_export.TimbratureZucchettiDataTable tabTimb = DataProxy.DP.taExpZucc.GetData(inizio, fine, idxDipendente, codTimbra); foreach (DS_export.TimbratureZucchettiRow riga in tabTimb) { Response.Write(riga.campoExport); Response.Write(Environment.NewLine); } //System.IO.StringWriter stringWrite = new System.IO.StringWriter(); //System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite); //grView.RenderControl(htmlWrite); //Response.Write(stringWrite.ToString()); Response.End(); } } }