using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using edu.jhu.Cas.Util;
using edu.jhu.Cas.Jobs;
namespace edu.jhu.Cas.Web {
	/// <summary>
	/// Summary description for Output.
	/// </summary>
	public class OutputPage : System.Web.UI.Page {
		private void Page_Load(object sender, System.EventArgs e){}
		protected DataSet ds,pendingDs,failedDs;
		protected string lmessage;
		protected long wsid;
		protected bool loggedin;
		protected DataGrid grid,pendingGrid,failedGrid;
		protected System.Web.UI.HtmlControls.HtmlForm Output;
		override protected void OnInit(EventArgs e) {
			InitializeComponent();
			base.OnInit(e);
			WebUtils.CheckLoggedIn(Session,Response,Request,true);
			lmessage = Request.Params["lmessage"];
			loggedin = Session["USER"] != null;  
			if (loggedin) 
				wsid = (long)Session["USER"];
			ds = (new CasJobs()).GetOutputDownloads(wsid);
			pendingDs = (new CasJobs()).GetPendingOutput(wsid);
			failedDs = (new CasJobs()).GetFailedOutput(wsid);
			
			grid.DataSource = ds.Tables[0];
			grid.DataBind();
			failedGrid.DataSource = failedDs.Tables[0];
			failedGrid.DataBind();
			pendingGrid.DataSource = pendingDs.Tables[0];
			pendingGrid.DataBind();
		}
		public void Download(Object sender, DataGridCommandEventArgs e) {
			Response.Write(e.CommandName);
			Response.Write(e.CommandSource);
			Response.Write(e.Item);
		}
		
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent() {    
			this.Load += new System.EventHandler(this.Page_Load);
		}
	}
}