public static RProjectExecution executeCode(RProjectDetails details, String code, ProjectExecutionOptions options, RClient client, String uri)
        {
            StringBuilder data = new StringBuilder();

            //create the input String
            data.Append(Constants.FORMAT_JSON);
            data.Append("&project=" + HttpUtility.UrlEncode(details.id));
            data.Append("&code=" + HttpUtility.UrlEncode(code));

            if (!(options == null))
            {

                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
            JSONResponse jresponse = HTTPUtilities.callRESTPost(uri, data.ToString(), ref client);

            RProjectExecution returnValue = new RProjectExecution(jresponse, client);

            return returnValue;
        }
Пример #2
0
        static public RProjectExecution executeCode(RProjectDetails details, String code, ProjectExecutionOptions options, RClient client, String uri)
        {
            StringBuilder data = new StringBuilder();

            //create the input String
            data.Append(Constants.FORMAT_JSON);
            data.Append("&project=" + HttpUtility.UrlEncode(details.id));
            data.Append("&code=" + HttpUtility.UrlEncode(code));

            if (!(options == null))
            {
                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
            JSONResponse jresponse = HTTPUtilities.callRESTPost(uri, data.ToString(), ref client);

            RProjectExecution returnValue = new RProjectExecution(jresponse, client);

            return(returnValue);
        }
Пример #3
0
        /// <summary>
        /// Execute a single repository-managed script or a chain of repository-managed scripts
        /// on the current 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.
        ///
        /// Deprecated. As of release 7.1, use executeScript method that supports scriptDirectory parameter. This deprecated call assumes each script is found in the root directory.
        ///
        /// </summary>
        /// <param name="scriptName">name of valid 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">Options for this execution</param>
        /// <returns>RProjectExecution object</returns>
        /// <remarks></remarks>
        public RProjectExecution executeScript(String scriptName, String scriptAuthor, String scriptVersion, ProjectExecutionOptions options)
        {
            RProjectExecution returnValue = RProjectExecuteImpl.executeScript(m_projectDetails, scriptName, "root", scriptAuthor, scriptVersion, null, options, m_client, Constants.RPROJECTEXECUTESCRIPT);

            return(returnValue);
        }
Пример #4
0
        /// <summary>
        /// Execute a single script found on a URL/path or a chain of scripts found on a set of URLs/paths
        /// on the current 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">RScript represented as a URL or DeployR file path</param>
        /// <param name="options">Options for this execution</param>
        /// <returns>RProjectExecution object</returns>
        /// <remarks></remarks>
        public RProjectExecution executeExternal(String externalSource, ProjectExecutionOptions options)
        {
            RProjectExecution returnValue = RProjectExecuteImpl.executeScript(m_projectDetails, null, null, null, null, externalSource, options, m_client, Constants.RPROJECTEXECUTESCRIPT);

            return(returnValue);
        }
Пример #5
0
        /// <summary>
        /// Execute R code on a project
        /// </summary>
        /// <param name="code">R code to be executed</param>
        /// <param name="options">Options for this execution</param>
        /// <returns>RProjectExecution object</returns>
        /// <remarks></remarks>
        public RProjectExecution executeCode(String code, ProjectExecutionOptions options)
        {
            RProjectExecution returnValue = RProjectExecuteImpl.executeCode(m_projectDetails, code, options, m_client, Constants.RPROJECTEXECUTECODE);

            return(returnValue);
        }