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.Jobs;
using edu.jhu.Cas.Util;
using edu.jhu.Cas.Users;

namespace edu.jhu.Cas.Web {
	/// <summary>
	/// $Id: jobdetails.aspx.cs 126000 2011-07-27 22:21:35Z nli $
	/// $evision: 1.7 $
	/// $Date: 2011-07-27 18:21:35 -0400 (Wed, 27 Jul 2011) $
	/// </summary>
	public class jobdetails : System.Web.UI.Page {
		protected Job job ;
		protected long wsid;
		protected string lmessage ;
		protected edu.jhu.Cas.Jobs.CasJobs jobServ = new edu.jhu.Cas.Jobs.CasJobs();
        protected bool admin, noheaders = false;
		protected string position;
		protected DateTime nullDate = new DateTime(0);

		private void Page_Load(object sender, System.EventArgs e) {
			long id = Convert.ToInt64(Request.Params["id"]);
			WebUtils.CheckLoggedIn(Session,Response,Request);
			wsid = Convert.ToInt64(Session["USER"]);
            noheaders = Request.Params["noheaders"] != null && Request.Params["noheaders"].ToLower() == "true";
			try {
				Job[] jobs = jobServ.FindJob(wsid," jobid = "+id);
				if (jobs ==null || jobs.Length ==0 ) {
					lmessage = "Did not find job "+id;
				} 
				else {
					job = jobs[0];
					if(job.Status == QUERY_STATUS.READY){
						position = SqlFactory.scalar("select count(*) from jobs where status = "+QUERY_STATUS.READY+" and estimate = "+job.Estimate+" and target like '"+job.Target+"' and timesubmit <'"+job.TimeSubmit.ToString()+"'").ToString();

					}
					Session["JOB"]=job;
				}
			} 
			catch (Exception ex) {
				lmessage = ex.Message;
			}
            admin = (new CasUsers()).HasPrivilegeSafe(wsid, PRIVS.ADMIN);
		}
	
		protected string GetDate(DateTime dt){
			if(dt.CompareTo(nullDate) == 0) return "";
			return dt.ToString();
		}
		#region Web Form Designer generated code
		override protected void OnInit(EventArgs e) {
			//
			// CODEGEN: This call is required by the ASP.NET Web Form Designer.
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <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);
		}
		#endregion
	}
}
/**
 * $Log$
 * Revision 1.11  2007/04/18 01:39:52  nli
 * partial updates to mydbcontent
 *
 * Revision 1.10  2007/04/12 18:53:04  nli
 * #7207 closed
 *
 * Revision 1.9  2007/03/13 22:27:21  nli
 * anon access removed.
 * cleaned up for release
 *
 * Revision 1.8  2006/09/14 16:35:15  nli
 * minor cosmetic changes
 *
 * Revision 1.7  2006/09/12 18:42:59  nli
 * back
 *
 * Revision 1.6  2006/03/09 19:42:28  nli
 * fancy style sheet
 *
 * Revision 1.5  2004/10/08 15:13:37  nli
 * --queue position available in job details
 * --queues page shows all queues, and all waiting jobs
 * --it also shows waiting output jobs (separately)
 * --session timeout set to one hour
 * -- password encryption
 *
 * Revision 1.4  2004/09/22 16:32:13  nli
 * --another cjobscl update
 * --some faq checks
 * --some session over queries in mydbbrowser
 * --fixed bug where cookies were overriding resubmits
 *
 * Revision 1.3  2004/07/07 17:54:25  nli
 * fixed null dates showing up as not null
 *
 * Revision 1.2  2004/06/10 15:53:15  womullan
 *  Now may call mydb.fn()
 *
 * Revision 1.1.1.1  2004/04/27 16:38:28  cvsuser
 * import CasJobs to FERMI
 *
 * Revision 1.1.1.1  2004/02/18 16:38:24  nli
 * new version
 *
 * Revision 1.2  2004/02/13 16:28:19  nli
 * plot images sort
 *
 * Revision 1.1.1.1  2004/01/25 18:16:56  nli
 * first
 *
 * Revision 1.1.1.1  2004/01/20 20:59:55  nli
 * new
 *
 * Revision 1.2  2003/08/13 19:51:19  nli
 * cpl group pages in, no top part
 *
 * Revision 1.1  2003/07/01 23:18:19  womullan
 * cancel job and re submit
 *
 **/
