private RScriptExecution executeScriptImp(String scriptName, String scriptDirectory, String scriptAuthor, String scriptVersion, String ExternalSource, AnonymousProjectExecutionOptions options) { StringBuilder data = new StringBuilder(); String uri = Constants.RREPOSITORYSCRIPTEXECUTE; //create the input String data.Append(Constants.FORMAT_JSON); if (ExternalSource == null) { data.Append("&filename=" + HttpUtility.UrlEncode(scriptName)); data.Append("&author=" + HttpUtility.UrlEncode(scriptAuthor)); data.Append("&directory=" + HttpUtility.UrlEncode(scriptDirectory)); data.Append("&version=" + HttpUtility.UrlEncode(scriptVersion)); } else { data.Append("&externalsource=" + HttpUtility.UrlEncode(ExternalSource)); } if (!(options == null)) { data.Append("&blackbox=" + options.blackbox.ToString()); data.Append("&recycle=" + options.recycle.ToString()); data.Append("&csvinputs=" + HttpUtility.UrlEncode(options.csvrinputs)); data.Append("&cluster=" + HttpUtility.UrlEncode(options.gridCluster)); if (!(options.rinputs == null)) { if (options.rinputs.Count > 0) { data.Append("&inputs="); String sJSON = JSONSerialize.createJSONfromRData(options.rinputs); data.Append(HttpUtility.UrlEncode(sJSON)); if (HTTPUtilities.DEBUGMODE == true) { Console.Write(sJSON); } } } if (!(options.preloadDirectory == null)) { data.Append("&preloadfilename=" + HttpUtility.UrlEncode(options.preloadDirectory.filename)); data.Append("&preloadfiledirectory=" + HttpUtility.UrlEncode(options.preloadDirectory.directory)); data.Append("&preloadfileauthor=" + HttpUtility.UrlEncode(options.preloadDirectory.author)); data.Append("&preloadfileversion=" + HttpUtility.UrlEncode(options.preloadDirectory.version)); } if (!(options.preloadWorkspace == null)) { data.Append("&preloadobjectname=" + HttpUtility.UrlEncode(options.preloadWorkspace.filename)); data.Append("&preloadobjectdirectory=" + HttpUtility.UrlEncode(options.preloadWorkspace.directory)); data.Append("&preloadobjectauthor=" + HttpUtility.UrlEncode(options.preloadWorkspace.author)); data.Append("&preloadobjectversion=" + HttpUtility.UrlEncode(options.preloadWorkspace.version)); } if (!(options.adoptionOptions == null)) { data.Append("&adoptworkspace=" + HttpUtility.UrlEncode(options.adoptionOptions.adoptWorkspace)); data.Append("&adoptdirectory=" + HttpUtility.UrlEncode(options.adoptionOptions.adoptDirectory)); data.Append("&adoptpackages=" + HttpUtility.UrlEncode(options.adoptionOptions.adoptPackages)); } if (!(options.storageOptions == null)) { data.Append("&storefile=" + HttpUtility.UrlEncode(options.storageOptions.files)); data.Append("&storedirectory=" + HttpUtility.UrlEncode(options.storageOptions.directory)); data.Append("&storeobject=" + HttpUtility.UrlEncode(options.storageOptions.objects)); data.Append("&storeworkspace=" + HttpUtility.UrlEncode(options.storageOptions.workspace)); data.Append("&storenewversion=" + options.storageOptions.newVersion.ToString()); data.Append("&storepublic=" + options.storageOptions.published.ToString()); } if (!(options.routputs == null)) { if (options.routputs.Count > 0) { data.Append("&robjects="); foreach (var s in options.routputs) { data.Append(HttpUtility.UrlEncode(s) + ","); } data.Remove(data.Length - 1, 1); } } data.Append("&echooff=" + options.echooff.ToString()); data.Append("&consoleoff=" + options.consoleoff.ToString()); data.Append("&tag=" + HttpUtility.UrlEncode(options.tag)); data.Append("&graphics=" + HttpUtility.UrlEncode(options.graphicsDevice)); data.Append("&graphicswidth=" + HttpUtility.UrlEncode(options.graphicsWidth.ToString())); data.Append("&graphicsheight=" + HttpUtility.UrlEncode(options.graphicsHeight.ToString())); data.Append("&nan=" + HttpUtility.UrlEncode(options.nan)); data.Append("&infinity=" + HttpUtility.UrlEncode(options.infinity)); data.Append("&encodeDataFramePrimitiveAsVector=" + options.encodeDataFramePrimitiveAsVector.ToString()); data.Append("&enableConsoleEvents=" + options.enableConsoleEvents.ToString()); data.Append("&preloadbydirectory=" + HttpUtility.UrlEncode(options.preloadByDirectory)); } //call the server RClient client = this; JSONResponse jresponse = HTTPUtilities.callRESTPost(uri, data.ToString(), ref client); RScriptExecution returnValue = new RScriptExecution(jresponse, this); return(returnValue); }
/// <summary> /// Execute a single script found on a URL/path or a chain of scripts found on a set of URLs/paths /// on an anonymous project. /// /// To execute a chain of repository-managed scripts on this call provide a comma-separated /// list of values on the externalSource parameter. /// Chained execution executes each of the scripts identified on the call in a sequential /// fashion on the R session, with execution occuring in the order specified on the parameter list. /// /// POWER_USER privileges are required for this call. /// </summary> /// <param name="externalSource">URL or DeployR file path</param> /// <param name="options">execute options associated with the external script</param> /// <returns>RScriptExecution object</returns> /// <remarks></remarks> public RScriptExecution executeExternal(String externalSource, AnonymousProjectExecutionOptions options) { RScriptExecution returnValue = executeScriptImp(null, null, null, null, externalSource, options); return(returnValue); }
/// <summary> /// Execute a single repository-managed script or a chain of repository-managed scripts /// on an anonymous project. /// /// To execute a chain of repository-managed scripts on this call provide a comma-separated /// list of values on the scriptName, scriptAuthor and optionally scriptVersion parameters. /// Chained execution executes each of the scripts identified on the call in a sequential /// fashion on the R session, with execution occuring in the order specified on the parameter list. /// /// </summary> /// <param name="scriptName">name of valid R Script</param> /// <param name="scriptDirectory">directory containing R Script.</param> /// <param name="scriptAuthor">author of the R Script</param> /// <param name="scriptVersion">version of the R Script to execute</param> /// <param name="options">execute options associated with the R Script</param> /// <returns>RScriptExecution object</returns> /// <remarks></remarks> public RScriptExecution executeScript(String scriptName, String scriptDirectory, String scriptAuthor, String scriptVersion, AnonymousProjectExecutionOptions options) { RScriptExecution returnValue = executeScriptImp(scriptName, scriptDirectory, scriptAuthor, scriptVersion, null, options); return(returnValue); }
/// <summary> /// Execute a single repository-managed script or a chain of repository-managed scripts /// on an anonymous project. /// /// To execute a chain of repository-managed scripts on this call provide a comma-separated /// list of values on the scriptName, scriptAuthor and optionally scriptVersion parameters. /// Chained execution executes each of the scripts identified on the call in a sequential /// fashion on the R session, with execution occuring in the order specified on the parameter list. /// /// </summary> /// <param name="scriptName">RRepositoryScript object identifying the script to execute</param> /// <param name="scriptDirectory">directory containing R Script.</param> /// <param name="scriptAuthor">author of the R Script</param> /// <param name="scriptVersion">version of the R Script to execute</param> /// <returns>RScriptExecution object</returns> /// <remarks></remarks> public RScriptExecution executeScript(String scriptName, String scriptDirectory, String scriptAuthor, String scriptVersion) { RScriptExecution returnValue = executeScriptImp(scriptName, scriptDirectory, scriptAuthor, scriptVersion, null, null); return(returnValue); }
private RScriptExecution executeScriptImp(String scriptName, String scriptDirectory, String scriptAuthor, String scriptVersion, String ExternalSource, AnonymousProjectExecutionOptions options) { StringBuilder data = new StringBuilder(); String uri = Constants.RREPOSITORYSCRIPTEXECUTE; //create the input String data.Append(Constants.FORMAT_JSON); if (ExternalSource == null) { data.Append("&filename=" + HttpUtility.UrlEncode(scriptName)); data.Append("&author=" + HttpUtility.UrlEncode(scriptAuthor)); data.Append("&directory=" + HttpUtility.UrlEncode(scriptDirectory)); data.Append("&version=" + HttpUtility.UrlEncode(scriptVersion)); } else { data.Append("&externalsource=" + HttpUtility.UrlEncode(ExternalSource)); } if (!(options == null)) { data.Append("&blackbox=" + options.blackbox.ToString()); data.Append("&recycle=" + options.recycle.ToString()); data.Append("&csvinputs=" + HttpUtility.UrlEncode(options.csvrinputs)); data.Append("&cluster=" + HttpUtility.UrlEncode(options.gridCluster)); if (!(options.rinputs == null)) { if (options.rinputs.Count > 0) { data.Append("&inputs="); String sJSON = JSONSerialize.createJSONfromRData(options.rinputs); data.Append(HttpUtility.UrlEncode(sJSON)); if (HTTPUtilities.DEBUGMODE == true) { Console.Write(sJSON); } } } if (!(options.preloadDirectory == null)) { data.Append("&preloadfilename=" + HttpUtility.UrlEncode(options.preloadDirectory.filename)); data.Append("&preloadfiledirectory=" + HttpUtility.UrlEncode(options.preloadDirectory.directory)); data.Append("&preloadfileauthor=" + HttpUtility.UrlEncode(options.preloadDirectory.author)); data.Append("&preloadfileversion=" + HttpUtility.UrlEncode(options.preloadDirectory.version)); } if (!(options.preloadWorkspace == null)) { data.Append("&preloadobjectname=" + HttpUtility.UrlEncode(options.preloadWorkspace.filename)); data.Append("&preloadobjectdirectory=" + HttpUtility.UrlEncode(options.preloadWorkspace.directory)); data.Append("&preloadobjectauthor=" + HttpUtility.UrlEncode(options.preloadWorkspace.author)); data.Append("&preloadobjectversion=" + HttpUtility.UrlEncode(options.preloadWorkspace.version)); } if (!(options.adoptionOptions == null)) { data.Append("&adoptworkspace=" + HttpUtility.UrlEncode(options.adoptionOptions.adoptWorkspace)); data.Append("&adoptdirectory=" + HttpUtility.UrlEncode(options.adoptionOptions.adoptDirectory)); data.Append("&adoptpackages=" + HttpUtility.UrlEncode(options.adoptionOptions.adoptPackages)); } if (!(options.storageOptions == null)) { data.Append("&storefile=" + HttpUtility.UrlEncode(options.storageOptions.files)); data.Append("&storedirectory=" + HttpUtility.UrlEncode(options.storageOptions.directory)); data.Append("&storeobject=" + HttpUtility.UrlEncode(options.storageOptions.objects)); data.Append("&storeworkspace=" + HttpUtility.UrlEncode(options.storageOptions.workspace)); data.Append("&storenewversion=" + options.storageOptions.newVersion.ToString()); data.Append("&storepublic=" + options.storageOptions.published.ToString()); } if (!(options.routputs == null)) { if (options.routputs.Count > 0) { data.Append("&robjects="); foreach (var s in options.routputs) { data.Append(HttpUtility.UrlEncode(s) + ","); } data.Remove(data.Length - 1, 1); } } data.Append("&echooff=" + options.echooff.ToString()); data.Append("&consoleoff=" + options.consoleoff.ToString()); data.Append("&tag=" + HttpUtility.UrlEncode(options.tag)); data.Append("&graphics=" + HttpUtility.UrlEncode(options.graphicsDevice)); data.Append("&graphicswidth=" + HttpUtility.UrlEncode(options.graphicsWidth.ToString())); data.Append("&graphicsheight=" + HttpUtility.UrlEncode(options.graphicsHeight.ToString())); data.Append("&nan=" + HttpUtility.UrlEncode(options.nan)); data.Append("&infinity=" + HttpUtility.UrlEncode(options.infinity)); data.Append("&encodeDataFramePrimitiveAsVector=" + options.encodeDataFramePrimitiveAsVector.ToString()); data.Append("&enableConsoleEvents=" + options.enableConsoleEvents.ToString()); data.Append("&preloadbydirectory=" + HttpUtility.UrlEncode(options.preloadByDirectory)); } //call the server RClient client = this; JSONResponse jresponse = HTTPUtilities.callRESTPost(uri, data.ToString(), ref client); RScriptExecution returnValue = new RScriptExecution(jresponse, this); return returnValue; }