<%@ LANGUAGE="JSCRIPT" %> <% // // Supports web-based RTML submission. // // 16-Feb-08 rbd Initial edit // 14-Mar-08 rbd Flesh out, make reply nicer, free objects, etc. // 09-Jun-09 rbd 3.0 HF1 - Fix redirecting/refreshing on success. // 13-Aug-10 rbd 3.3 GEM:423 ACP user integration, display upload info, // GEM:441 Force Request.UserName to be ACP user's // friendly name. // 20-Jan-11 rbd GEM:571 - Set our parent iframe's height. // 22-Jan-11 rbd GEM:571 - Make IE fudge manifest constant, change to 18. // 18-Feb-11 rbd GEM:602 - Add "Auto resubmit" popup. For AAVSO. Weird, but... // function endResponse() { Response.Write("

The browser will be refreshed in a few seconds...
\r\n"); Response.Write("... or click here to refresh now.

\r\n"); Response.Write("\r\n"); } function dispTime(t) { if(t >= 3600) { t /= 3600; return t.toFixed(2) + "h"; } else { t /= 60; return t.toFixed(1) + "min"; } } Response.ExpiresAbsolute = new Date("Jan 1, 2000").getVarDate(); // Expire even with clocdk offsets Response.AddHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0"); %> Submit RTML Request <% if(Request.ServerVariables("REQUEST_METHOD").toLowerCase() == "post") { %> <% } else { %> <% } %> <% if(Request.ServerVariables("REQUEST_METHOD").toLowerCase() == "get") { // === GET === %>

Submit an observing request (RTML)

Upload RTML to add observing requests to the schedule database. Note that you are logged into ACP as <%= User.Name %> (<%= User.Username %>). The Plan(s) created by this RTML will belong to Scheduler Observer <%= User.Name %>. Images and logs will go into your ACP web images and logs areas.

1. Select the RTML file:
RTML File:
2. Upload the RTML
<% } else { // === POST === if(!User.CanUpload) { Response.Write("

No permission to upload.

\r\n"); endResponse(); Response.End(); } if(Request.ServerVariables("REQUEST_METHOD").toLowerCase() != "post") { Response.Write("

This URL allows only uploaded content.

\r\n"); endResponse(); Response.End(); } // // Suck up the file contents, feed to importer // if(Request.Form("FileName")) // Did upload the file { var db = new ActiveXObject("DC3.Scheduler.Database"); db.Connect(); var rtml = new ActiveXObject("DC3.RTML23.Importer"); rtml.DB = db; try { // 1. Get the RTML into a buffer for modification var fso = new ActiveXObject("Scripting.FileSystemObject"); var rtmlFile = fso.OpenTextFile(Request.Form("FilePath")); var rtmlBuf = rtmlFile.ReadAll(); rtmlFile.Close(); // 2. Delete the tempfile provided by the webserver fso.DeleteFile(Request.Form("FilePath")); // 3. Using XPath, modify all Request.UserName elements to have // the ACP logged in user's friendly name. var xmlDoc = new ActiveXObject("Msxml2.DOMDocument"); xmlDoc.preserveWhiteSpace = true; xmlDoc.loadXML(rtmlBuf); var nodes = xmlDoc.selectNodes("/RTML/Request/UserName"); var eN = new Enumerator(nodes); for (; !eN.atEnd(); eN.moveNext()) { var N = eN.item(); N.text = User.Name; } // 4. Put back the encoding part of the xml introducer. Why is this needed??? rtmlBuf = xmlDoc.xml; rtmlBuf = rtmlBuf.replace("", ""); // 5. Import the fixed-up RTML to the Schedule Database rtml.ImportString(rtmlBuf); Response.Write("

RTML uploaded successfully for " + User.Name + " (" + User.Username + ").

\r\n"); // 6. Loop through rtml.Projects and patch the Contact.Name with [ACP xxxx] and // output some useful info. rtml.Projects and rtml.Plans come from the importer // and are the Database objects for the affected Projects and Plans. // var submit = (Request.Form("autoSubmit") == "true") var eR = new Enumerator(rtml.Projects); // Projects affected by this RTML upload Response.Write("

Plans added by RTML:
\r\n"); for (; !eR.atEnd(); eR.moveNext()) { var R = eR.item(); Response.Write(" Project: " + R.Name + "
\r\n"); R.ContactName = User.Name + " [ACP " + User.Username + "]"; // Force it to the uploader's if (submit) R.Disabled = false; // If autoSubmit, enable parent project R.Update(); var totImg = 0; var totTime = 0; var eP = new Enumerator(rtml.Plans); // Plans created by this RTML for (; !eP.atEnd(); eP.moveNext()) { var P = eP.item(); if (P.Project.Name != R.Name) continue; var eO = new Enumerator(P.Observations); // Plan belongs to this project if (submit) // If autoSubmit do it now. P.Resubmit(); for(;!eO.atEnd(); eO.moveNext()) { O = eO.item(); var eI = new Enumerator(O.Images); for(;!eI.atEnd(); eI.moveNext()) { I = eI.item(); totImg += I.RepeatCount; totTime += I.ExposureInterval * I.RepeatCount; } } Response.Write("  " + P.Name + " (" + totImg + " images, " + dispTime(totTime) + " image time)
\r\n"); } } if (submit) Response.Write("

\r\n

The newly added Plans are already eligible to run.

\r\n"); else Response.Write("

\r\n

Enable the project when you want it to become eligible to run!

\r\n"); } catch(ex) { Response.Write("RTML failed: " + (ex.message ? ex.message : ex)); } finally { if(db != null) db.Disconnect(); db = null; rtml = null; } } else { Response.Write("

No file in upload request.

\r\n"); } endResponse(); Response.End(); } %>