<%@ LANGUAGE="JSCRIPT" %>
<% if(!User.CanUpload && !User.IsAdministrator) { Response.Write("

No permission to upload

"); } else { if(Request.ServerVariables("request_method").toLowerCase() != "post") { %>
">

1. Select Local RTML File


2. Submit RTML Request to Scheduler

Submit RTML    Enable immediately
<% } else { // // POST: Import the RTML. The If nesting is because the stuff at the // endhas to run to make the iframe work inside the TiddlyWiki. // if(Request.Form("FileName")) { // No file uploaded... var DB = Scheduler.Database; var RT = new ActiveXObject("DC3.RTML23.Importer"); RT.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 RT.ImportString(rtmlBuf); Response.Write("

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

\r\n"); // 6. Loop through RT.Projects and patch the Contact.Name with [ACP xxxx] and // output some useful info. RT.Projects and RT.Plans come from the importer // and are the Database objects for the affected Projects and Plans. // var submit = ((Request.Form("autoSubmit") == undefined) ? false : true); var eR = new Enumerator(RT.Projects); // Projects affected by this RTML upload for (; !eR.atEnd(); eR.moveNext()) { var R = eR.item(); Response.Write("Project: " + R.Name + ":
\r\n"); R.ContactName = User.Name; if (User.Username != 'localweb') // Unless this is localhost/in observatory { R.ContactName += " [ACP " + User.Username + "]"; // Force it to the uploader's if (User.WantsCompress) R.ContactName += "#"; // Add compression signal for AcquireScheduler } if (submit) R.Disabled = false; // If autoSubmit, enable parent project R.Update(); var eP = new Enumerator(RT.Plans); // Plans created by this RTML for (; !eP.atEnd(); eP.moveNext()) { var totTgt = 0; var totImg = 0; var totTime = 0; 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()) { var 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; } totImg *= O.SetCount; totTime *= O.SetCount; totTgt += 1; } Response.Write("  Plan " + P.Name + " (" + totTgt + " targets, " + 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 Plans with the " + "Schedule Browser when you want it to become eligible to run.

\r\n"); Response.Write("Upload another."); } catch(ex) { Response.Write("

RTML failed: " + (ex.message ? ex.message : ex) + "

"); } finally { RT = null; } } else { Response.Write("
No file. Try again."); } } } %>