public void WriteImage() { WebSession = (Web.Session)Session["WebSession"]; Response.ClearContent(); Response.BufferOutput = false; string imageID = Request.QueryString["ImageID"]; if ((imageID != null) && (imageID != String.Empty)) { using (Stream stream = WebSession.ImageCache.Read(imageID)) { Response.AppendHeader(ContentLengthHeader, stream.Length.ToString()); StreamUtility.CopyStream(stream, Response.OutputStream); } } else { imageID = Request.QueryString["HandlerID"]; if ((imageID != null) && (imageID != String.Empty)) { LoadImageHandler handler = WebSession.ImageCache.GetImageHandler(imageID); if (handler != null) { handler(Context, imageID, Response.OutputStream); } } } }
private void AdvanceToApplication() { DataSession session = new DataSession(); session.Alias = _configuration.Aliases[_configuration.DefaultAliasName]; session.Active = true; session.SessionInfo.Environment = "WindowsClient"; Web.Session webSession = new Web.Session(session, true); Session["WebSession"] = webSession; string applicationID = (string)Session["ApplicationID"]; if ((applicationID != null) && (applicationID != String.Empty)) { webSession.SetApplication(applicationID); Response.Redirect((string)Session["DefaultPage"]); } else { Response.Redirect((string)Session["ApplicationsPage"]); } }
public Web.ChunkedResponse HttpPost(Web.Session sess, string page, params string[] postfields) { return(HttpGet(sess, page, postfields)); }
public Web.ChunkedResponse HttpGet(Web.Session sess, string page, params string[] queryget) { if (String.Compare(page, "/qn") == 0) { return(new SySal.Web.HTMLResponse(Trackers.Length.ToString())); } int g = -1; RWDJob rwdj = new RWDJob(); bool rwdj_zone_set = false; bool rwdj_strip_set = false; bool rwdj_outdir_set = false; bool rwdj_firstview_set = false; bool rwdj_lastview_set = false; bool rwdj_index_set = false; string jobid = null; foreach (string s in queryget) { if (s.StartsWith(a_gpu + "=")) { g = int.Parse(s.Substring(a_gpu.Length + 1)); if (g < 0 || g >= Trackers.Length) { return(new SySal.Web.HTMLResponse("ERROR: INVALID QUEUE SPECIFIED")); } } else if (s.StartsWith(a_rwdz + "=")) { rwdj.ZoneFile = SySal.Web.WebServer.URLDecode(s.Substring(a_rwdz.Length + 1)); rwdj_zone_set = true; } else if (s.StartsWith(a_rwds + "=")) { rwdj.StripId = uint.Parse(s.Substring(a_rwds.Length + 1)); rwdj_strip_set = true; } else if (s.StartsWith(a_rwdi + "=")) { rwdj.FragmentIndex = (int)uint.Parse(s.Substring(a_rwdi.Length + 1)); rwdj_index_set = true; } else if (s.StartsWith(a_rwdfv + "=")) { rwdj.FirstView = (int)uint.Parse(s.Substring(a_rwdfv.Length + 1)); rwdj_firstview_set = true; } else if (s.StartsWith(a_rwdlv + "=")) { rwdj.LastView = (int)uint.Parse(s.Substring(a_rwdlv.Length + 1)); rwdj_lastview_set = true; } else if (s.StartsWith(a_rwdd + "=")) { rwdj.OutputDir = SySal.Web.WebServer.URLDecode(s.Substring(a_rwdd.Length + 1)); rwdj_outdir_set = true; } else if (s.StartsWith(a_jobid + "=")) { jobid = s.Substring(a_jobid.Length + 1); } } if (g >= 0) { if (String.Compare(page, "/queryjob") == 0) { IEnumerable <Job> res = null; lock (Trackers[g].Jobs) res = Trackers[g].Jobs.Where(x => String.Compare(x.ID, jobid) == 0); if (res.Count() == 1) { return(new SySal.Web.HTMLResponse("WAITING")); } res = null; lock (Trackers[g].Completed) { Job jc = Trackers[g].Current; if (jc != null && String.Compare(jc.ID, jobid) == 0) { return(new SySal.Web.HTMLResponse("RUNNING")); } res = Trackers[g].Completed.Where(x => String.Compare(x.ID, jobid) == 0); } if (res.Count() == 1) { Job jj = res.First(); return(new SySal.Web.HTMLResponse((rwdj.ExitException.Length > 0) ? ("FAILED\r\n" + jj.ExitException) : "DONE")); } return(new SySal.Web.HTMLResponse("UNKNOWN")); } else if (String.Compare(page, "/killjob") == 0) { bool killed = false; IEnumerable <Job> res = null; lock (Trackers[g].Jobs) { res = Trackers[g].Jobs.Where(x => String.Compare(x.ID, jobid) == 0); if (res.Count() == 1) { Trackers[g].Jobs.Remove(res.First()); killed = true; } } return(new SySal.Web.HTMLResponse(killed ? "KILLED" : "CANNOT KILL")); } else if (String.Compare(page, "/addrwdj") == 0 && rwdj_zone_set && rwdj_strip_set && rwdj_outdir_set && (rwdj_firstview_set == rwdj_lastview_set && rwdj_index_set == rwdj_firstview_set)) { rwdj.Id = System.Guid.NewGuid(); lock (Trackers[g].Jobs) if (Trackers[g].Jobs.Count > 0 || Trackers[g].Current != null) { return(new SySal.Web.HTMLResponse("REFUSED-BUSY")); } else { Trackers[g].Jobs.Add(rwdj); } JobsWaiting.Set(); return(new SySal.Web.HTMLResponse("CREATED " + rwdj.ID)); } } System.IO.StringWriter swr = new System.IO.StringWriter(); swr.WriteLine("<html><head><title>GPUTrackingServer " + ProcessInstance + " at " + ComputerName + "</title>" + " <style type=\"text/css\"> " + "H1 " + "{ " + " color : Navy; font-family : Segoe UI, Trebuchet MS, Verdana, Helvetica, Arial; font-size : 24px; opacity: 1; line-height: 24px; " + "} " + "H6 " + "{ " + " color : Navy; font-family : Segoe UI, Trebuchet MS, Verdana, Helvetica, Arial; font-size : 12px; opacity: 1; line-height: 24px; " + "} " + "DIV " + "{ " + " color : Blue; font-family : Segoe UI, Trebuchet MS, Verdana, Helvetica, Arial; font-size : 12px; opacity: 1; line-height: 12px; " + "} " + "TD " + "{ " + " color : Navy; font-family : Segoe UI, Trebuchet MS, Verdana, Helvetica, Arial; font-size : 12px; opacity: 1; line-height: 12px; " + "} " + "TH " + "{ " + " color : Blue; font-family : Segoe UI, Trebuchet MS, Verdana, Helvetica, Arial; font-size : 12px; opacity: 1; line-height: 12px; " + "} " + " </style> " + "</head><body>"); swr.WriteLine("<h1>GPUTrackingServer " + ComputerName + " running <b>" + Trackers.Length + "</b> GPU(s)</h1><h6>Process Instance " + ProcessInstance + " </h6><hr />"); swr.WriteLine("<div><form action=\"addrwdj\" metod=\"get\"><table align=\"left\" border=\"0\" width=\"100%\">" + "<tr><th colspan=\"2\" align=\"left\">Add RWD job</th><td width=\"100%\"> </td></tr>" + "<tr><td>GPU</td><td><select name=\"" + a_gpu + "\" id=\"" + a_gpu + "\">" + GPUHTMLSelect + "</td></tr>" + "<tr><td>Zone path</td><td><input type=\"text\" name=\"" + a_rwdz + "\" id=\"" + a_rwdz + "\" size=\"100\" /></td></tr>" + "<tr><td>Strip</td><td><input type=\"text\" name=\"" + a_rwds + "\" id=\"" + a_rwds + "\" /></td><td>Index</td><td><input type=\"text\" name=\"" + a_rwdi + "\" id=\"" + a_rwdi + "\" /></td></tr>" + "<tr><td>First View</td><td><input type=\"text\" name=\"" + a_rwdfv + "\" id=\"" + a_rwdfv + "\" /></td><td>Last View</td><td><input type=\"text\" name=\"" + a_rwdlv + "\" id=\"" + a_rwdlv + "\" /></td></tr>" + "<tr><td>Output dir</td><td><input type=\"text\" name=\"" + a_rwdd + "\" id=\"" + a_rwdd + "\" size=\"100\" /></td></tr>" + "<tr><td colspan=\"2\"><input type=\"submit\" value=\"Submit job\" /></td></tr>" + "</table></form></div><br />"); for (g = 0; g < Trackers.Length; g++) { Job current = Trackers[g].Current; swr.WriteLine("<hr /><br /><div><table align=\"left\" border=\"1\" width=\"100%\"><tr><th>Queue " + g + " current " + ((current == null) ? "" : current.ID) + "</th></tr>"); string[] jstr = null; lock (Trackers[g].Jobs) { jstr = new string[Trackers[g].Jobs.Count]; int i = 0; foreach (Job jj in Trackers[g].Jobs) { jstr[i++] = jj.ID; } } foreach (string ss in jstr) { swr.WriteLine("<tr><td>" + ss + "</td></tr>"); } swr.WriteLine("</table></div><br />"); } swr.WriteLine("<hr /><br /><div><table align=\"left\"><tr><th colspan=\"2\">Profiling info</th></tr>"); lock (ProfilingInfo) { int total = 0; foreach (int t in ProfilingInfo.Values) { total += t; } if (total > 0) { foreach (string s in ProfilingInfo.Keys) { swr.WriteLine("<tr><td>" + s + "</td><td>" + (ProfilingInfo[s] * 100 / total).ToString() + "</td></tr>"); } } } swr.WriteLine("</table></div><br />"); swr.WriteLine("</body></html>\r\n\r\n"); return(new SySal.Web.HTMLResponse(swr.ToString())); }
private void Page_Load(object sender, System.EventArgs e) { _configuration = (AliasConfiguration)Session["AliasConfiguration"]; if (_configuration == null) { _configuration = AliasConfiguration.Load(AliasConfigurationFileName); Session["AliasConfiguration"] = _configuration; } // End any previous session Web.Session session = (Web.Session)Session["WebSession"]; if (session != null) { try { session.Dispose(); } finally { Session["WebSession"] = null; } } string aliasName = Request.QueryString["Alias"]; if (aliasName == null) { aliasName = String.Empty; } if (IsPostBack) { if (aliasName != String.Empty) { UserIDTextBox.Text = _configuration.Aliases[aliasName].SessionInfo.UserID; _configuration.DefaultAliasName = aliasName; } string deleteAlias = Request.QueryString["Delete"]; if ((deleteAlias != null) && (deleteAlias != String.Empty)) { _configuration.Aliases.Remove(deleteAlias); if (String.Compare(deleteAlias, _configuration.DefaultAliasName, true) == 0) { _configuration.DefaultAliasName = String.Empty; } _configuration.Save(AliasConfigurationFileName); } } else { if (_configuration.DefaultAliasName != String.Empty) { ServerAlias connection = _configuration.Aliases[_configuration.DefaultAliasName]; if (connection != null) { UserIDTextBox.Text = connection.SessionInfo.UserID; } } string applicationID = Request.QueryString["ApplicationID"]; if ((applicationID != null) && (applicationID != String.Empty)) { Session["ApplicationID"] = applicationID; } if (aliasName != String.Empty) { _configuration.DefaultAliasName = aliasName; AdvanceToApplication(); } } _editButton.Enabled = _configuration.Aliases.Count > 0; _deleteButton.Enabled = _editButton.Enabled; _deleteButton.Attributes.Add ( "onclick", HttpUtility.HtmlAttributeEncode ( String.Format ( @"if (confirm('{0}')) Submit('Connect.aspx?Delete={1}',event)", Strings.Get("ConfirmAliasDeleteMessage"), HttpUtility.UrlEncode(Configuration.DefaultAliasName).Replace("'", "\\'") ) ) ); UserIDTextBox.Attributes.Add("onkeydown", "TrapKeyDown(FLogin, event)"); PasswordTextBox.Attributes.Add("onkeydown", "TrapKeyDown(FLogin, event)"); }