コード例 #1
0
        static public RProject createProject(String name, String descr, ProjectCreationOptions options, RClient client, String uri)
        {
            StringBuilder data = new StringBuilder();

            //create the input String
            data.Append(Constants.FORMAT_JSON);
            data.Append("&projectname=" + HttpUtility.UrlEncode(name));
            data.Append("&projectdescr=" + HttpUtility.UrlEncode(descr));

            if (!(options == null))
            {
                data.Append("&blackbox=" + options.blackbox.ToString());

                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));
                }

                data.Append("&cluster=" + HttpUtility.UrlEncode(options.gridCluster));
            }

            //call the server
            JSONResponse jresponse = HTTPUtilities.callRESTPost(uri, data.ToString(), ref client);

            RProject returnValue = new RProject(jresponse, client);

            return(returnValue);
        }
コード例 #2
0
        public static void Execute()
        {
            Console.WriteLine("AuthProjectPoolCreate - start");

            //
            // 1. Connect to the DeployR Server
            //
            RClient rClient = Utility.Connect();

            //
            // 2. Authenticate the user
            //
            RUser rUser = Utility.Authenticate(rClient);

            //
            // 3. Create a pool of temporary projects (R sessions).
            //
            // Population options as needed.
            //
            int requestedPoolSize = 4;
            ProjectCreationOptions options = new ProjectCreationOptions();
            List<RProject> pool = rUser.createProjectPool(requestedPoolSize, options);

            Console.WriteLine("AuthProjectPoolCreate: created pool of " +
                    pool.Count + " temporary R sessions, pool=" + pool);

            //
            //  5. Cleanup
            //
            foreach(RProject rProject in pool)
            {
                rProject.close();
            }

            Utility.Cleanup(rUser, rClient);

            Console.WriteLine("AuthProjectPoolCreate - end");
        }
コード例 #3
0
        public static ProjectCreationOptions translate(PoolCreationOptions poolOptions)
        {
            ProjectCreationOptions options = null;

            if (poolOptions != null)
            {

                options = new ProjectCreationOptions();

                /*
                 * PoolCreationOptions to ProjectCreationOptions.
                 */

                options.rinputs = poolOptions.rinputs;

                if (poolOptions.preloadWorkspace != null)
                {

                    options.preloadWorkspace = new ProjectPreloadOptions();
                    options.preloadWorkspace.filename =  poolOptions.preloadWorkspace.filename;
                    options.preloadWorkspace.directory =  poolOptions.preloadWorkspace.directory;
                    options.preloadWorkspace.author =  poolOptions.preloadWorkspace.author;
                    options.preloadWorkspace.version = poolOptions.preloadWorkspace.version;
                }

                if (poolOptions.preloadDirectory != null)
                {

                    options.preloadDirectory = new ProjectPreloadOptions();
                    options.preloadDirectory.filename = poolOptions.preloadDirectory.filename;
                    options.preloadDirectory.directory = poolOptions.preloadDirectory.directory;
                    options.preloadDirectory.author = poolOptions.preloadDirectory.author;
                    options.preloadDirectory.version = poolOptions.preloadDirectory.version;
                }

                options.preloadByDirectory = poolOptions.preloadByDirectory;
            }

            return options;
        }
コード例 #4
0
        /// <summary>
        /// Create a named persistent project with options
        /// </summary>
        /// <param name="name">Name of project</param>
        /// <param name="descr">Description of project</param>
        /// <param name="options">ProjectCreationOptions that specifies what options the projects should be created with</param>
        /// <returns>RProject object</returns>
        /// <remarks></remarks>
        public RProject createProject(String name, String descr, ProjectCreationOptions options)
        {
            RProject returnValue = RUserProjectImpl.createProject(name, descr, options, m_client, Constants.RPROJECTCREATE);

            return(returnValue);
        }
コード例 #5
0
        /// <summary>
        /// Create a pool of temporary projects
        /// </summary>
        /// <param name="poolSize">Number of temporary projects to create</param>
        /// <param name="options">ProjectCreationOptions that specifies what options the projects should be created with</param>
        /// <returns>List of RProject objects</returns>
        /// <remarks></remarks>

        public List <RProject> createProjectPool(int poolSize, ProjectCreationOptions options)
        {
            List <RProject> returnValue = RUserProjectImpl.createProjectPool(poolSize, options, m_client, Constants.RPROJECTPOOL);

            return(returnValue);
        }
コード例 #6
0
        /// <summary>
        /// Create a temporary project with options
        /// </summary>
        /// <param name="options">ProjectCreationOptions that specifies what options the projects should be created with</param>
        /// <returns>RProject object</returns>
        /// <remarks></remarks>
        public RProject createProject(ProjectCreationOptions options)
        {
            RProject returnValue = RUserProjectImpl.createProject("", "", options, m_client, Constants.RPROJECTCREATE);

            return(returnValue);
        }
コード例 #7
0
        public static RProject createProject(String name, String descr, ProjectCreationOptions options, RClient client, String uri)
        {
            StringBuilder data = new StringBuilder();

            //create the input String
            data.Append(Constants.FORMAT_JSON);
            data.Append("&projectname=" + HttpUtility.UrlEncode(name));
            data.Append("&projectdescr=" + HttpUtility.UrlEncode(descr));

            if (!(options == null))
            {

                data.Append("&blackbox=" + options.blackbox.ToString());

                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));
                }

                data.Append("&cluster=" + HttpUtility.UrlEncode(options.gridCluster));
            }

            //call the server
            JSONResponse jresponse = HTTPUtilities.callRESTPost(uri, data.ToString(), ref client);

            RProject returnValue = new RProject(jresponse, client);

            return returnValue;
        }
コード例 #8
0
        public static List<RProject> createProjectPool(int poolSize, ProjectCreationOptions options, RClient client, String uri)
        {
            StringBuilder data = new StringBuilder();

            //create the input String
            data.Append(Constants.FORMAT_JSON);
            data.Append("&poolsize=" + poolSize.ToString());

            if (!(options == null))
            {

                data.Append("&blackbox=" + options.blackbox.ToString());

                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));
                }

                data.Append("&cluster=" + HttpUtility.UrlEncode(options.gridCluster));
            }

            //call the server
            JSONResponse jresponse = HTTPUtilities.callRESTPost(uri, data.ToString(), ref client);

            List<RProject> returnValue = new List<RProject>();

            //Parse the response
            if (!(jresponse.JSONMarkup["projects"] == null))
            {
                JArray jvalues = jresponse.JSONMarkup["projects"].Value<JArray>();
                foreach (var j in jvalues)
                {
                    if (j.Type != JTokenType.Null)
                    {
                        returnValue.Add(new RProject(new JSONResponse(j.Value<JObject>(), true, "", 0), client));
                    }
                }
            }

            return returnValue;
        }
コード例 #9
0
        static public List <RProject> createProjectPool(int poolSize, ProjectCreationOptions options, RClient client, String uri)
        {
            StringBuilder data = new StringBuilder();

            //create the input String
            data.Append(Constants.FORMAT_JSON);
            data.Append("&poolsize=" + poolSize.ToString());

            if (!(options == null))
            {
                data.Append("&blackbox=" + options.blackbox.ToString());

                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));
                }

                data.Append("&cluster=" + HttpUtility.UrlEncode(options.gridCluster));
            }

            //call the server
            JSONResponse jresponse = HTTPUtilities.callRESTPost(uri, data.ToString(), ref client);

            List <RProject> returnValue = new List <RProject>();

            //Parse the response
            if (!(jresponse.JSONMarkup["projects"] == null))
            {
                JArray jvalues = jresponse.JSONMarkup["projects"].Value <JArray>();
                foreach (var j in jvalues)
                {
                    if (j.Type != JTokenType.Null)
                    {
                        returnValue.Add(new RProject(new JSONResponse(j.Value <JObject>(), true, "", 0), client));
                    }
                }
            }

            return(returnValue);
        }