/// <summary>
        /// Update repository file
        /// </summary>
        /// <param name="restricted">indicates if file is restricted</param>
        /// <param name="sharedUser">indicates if file is shared</param>
        /// <param name="published">indicates if file is published</param>
        /// <param name="descr">description of the file</param>
        /// <param name="inputs">description of inputs to the script</param>
        /// <param name="outputs">description of outputs from the script</param>
        /// <returns>RRepositoryFile object</returns>
        /// <remarks></remarks>
        public RRepositoryFile update(String restricted, Boolean sharedUser, Boolean published, String descr, String inputs, String outputs)
        {
            RRepositoryFile returnValue = default(RRepositoryFile);
            StringBuilder   data        = new StringBuilder();

            //set the url
            String uri = Constants.RREPOSITORYFILEUPDATE;

            //create the input String
            data.Append(Constants.FORMAT_JSON);
            data.Append("&filename=" + HttpUtility.UrlEncode(m_fileDetails.filename));
            data.Append("&directory=" + HttpUtility.UrlEncode(m_fileDetails.directory));
            data.Append("&shared=" + sharedUser.ToString());
            data.Append("&published=" + published.ToString());
            data.Append("&restricted=" + HttpUtility.UrlEncode(restricted));
            data.Append("&descr=" + HttpUtility.UrlEncode(descr));
            data.Append("&inputs=" + HttpUtility.UrlEncode(inputs));
            data.Append("&outputs=" + HttpUtility.UrlEncode(outputs));
            //call the server
            JSONResponse jresponse = HTTPUtilities.callRESTPost(uri, data.ToString(), ref m_client);

            if (!(jresponse.JSONMarkup["repository"] == null))
            {
                JObject jrepo = jresponse.JSONMarkup["repository"].Value <JObject>();
                if (!(jrepo["file"] == null))
                {
                    JObject jfile = jrepo["file"].Value <JObject>();
                    returnValue = new RRepositoryFile(new JSONResponse(jfile, true, "", 0), m_client);
                }
            }

            return(returnValue);
        }
        static public List <RProject> listProjects(Boolean sortByLastModified, Boolean showPublicProjects, RClient client, String uri)
        {
            StringBuilder data = new StringBuilder();

            //create the input String
            data.Append(Constants.FORMAT_JSON);
            data.Append("&publicprojectsalso=" + showPublicProjects.ToString());
            data.Append("&publicprojectsonly=false");
            data.Append("&isordered=" + sortByLastModified.ToString());

            //call the server
            JSONResponse jresponse = HTTPUtilities.callRESTGet(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);
        }
        static public List <RData> getObject(RProjectDetails details, List <String> objectNames, Boolean encodeDataFramePrimitiveAsVector, RClient client, String uri)
        {
            StringBuilder data = new StringBuilder();

            //create the input String
            data.Append(Constants.FORMAT_JSON);
            data.Append("&project=" + HttpUtility.UrlEncode(details.id));
            if (!(objectNames == null))
            {
                if (objectNames.Count > 0)
                {
                    data.Append("&name=");
                    foreach (var s in objectNames)
                    {
                        data.Append(HttpUtility.UrlEncode(s) + ",");
                    }
                    data.Remove(data.Length - 1, 1);
                }
            }
            data.Append("&encodeDataFramePrimitiveAsVector=" + encodeDataFramePrimitiveAsVector.ToString());

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

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

            returnValue = JSONUtilities.parseRObjects(jresponse.JSONMarkup);

            return(returnValue);
        }
Exemplo n.º 4
0
        static public void copyDirectory(String source, String destination, List <RRepositoryFile> files, RClient client, String uri)
        {
            StringBuilder data      = new StringBuilder();
            StringBuilder filenames = new StringBuilder();

            //create the input String
            data.Append(Constants.FORMAT_JSON);
            data.Append("&directory=" + HttpUtility.UrlEncode(source));
            data.Append("&destination=" + HttpUtility.UrlEncode(destination));

            if (!(files == null))
            {
                foreach (var file in files)
                {
                    if (filenames.Length != 0)
                    {
                        filenames.Append(",");
                        filenames.Append(file.about().filename);
                    }
                    else
                    {
                        filenames.Append(file.about().filename);
                    }
                }
            }
            data.Append("&filename=" + HttpUtility.UrlEncode(filenames.ToString()));

            //call the server
            JSONResponse jresponse = HTTPUtilities.callRESTPost(uri, data.ToString(), ref client);
        }
        /// <summary>
        /// Grant repository file to another user
        /// </summary>
        /// <param name="newauthor">name of the user to grant authorship</param>
        /// <param name="revokeauthor">name of the user to revoke authorship</param>
        /// <returns>RRepositoryFile object</returns>
        /// <remarks></remarks>
        public RRepositoryFile grant(String newauthor, String revokeauthor)
        {
            RRepositoryFile returnValue = default(RRepositoryFile);
            StringBuilder   data        = new StringBuilder();

            //set the url
            String uri = Constants.RREPOSITORYFILEGRANT;

            //create the input String
            data.Append(Constants.FORMAT_JSON);
            data.Append("&filename=" + HttpUtility.UrlEncode(m_fileDetails.filename));
            data.Append("&directory=" + HttpUtility.UrlEncode(m_fileDetails.directory));
            data.Append("&newauthor=" + HttpUtility.UrlEncode(newauthor));
            data.Append("&revokeauthor=" + HttpUtility.UrlEncode(revokeauthor));

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

            if (!(jresponse.JSONMarkup["repository"] == null))
            {
                JObject jrepo = jresponse.JSONMarkup["repository"].Value <JObject>();
                if (!(jrepo["file"] == null))
                {
                    JObject jfile = jrepo["file"].Value <JObject>();
                    returnValue = new RRepositoryFile(new JSONResponse(jfile, true, "", 0), m_client);
                }
            }

            return(returnValue);
        }
Exemplo n.º 6
0
        static public RProjectFile uploadFile(RProjectDetails details, String file, DirectoryUploadOptions options, RClient client, String uri)
        {
            RProjectFile  returnValue = default(RProjectFile);
            StringBuilder data        = new StringBuilder();
            Dictionary <String, String> parameters = new Dictionary <String, String>();

            parameters.Add("format", "json");
            parameters.Add("project", HttpUtility.UrlEncode(details.id));

            //create the input String
            if (!(options == null))
            {
                parameters.Add("filename", HttpUtility.UrlEncode(options.filename));
                parameters.Add("descr", HttpUtility.UrlEncode(options.descr));
                parameters.Add("overwrite", options.overwrite.ToString());
            }
            else
            {
                parameters.Add("filename", HttpUtility.UrlEncode(Path.GetFileName(file)));
            }
            //call the server
            JSONResponse jresponse = HTTPUtilities.callRESTFileUploadPost(uri, parameters, file, ref client);

            if (!(jresponse.JSONMarkup["directory"] == null))
            {
                JObject jdir = jresponse.JSONMarkup["directory"].Value <JObject>();
                if (!(jdir["file"] == null))
                {
                    JObject jfile = jdir["file"].Value <JObject>();
                    returnValue = new RProjectFile(new JSONResponse(jfile, true, "", 0), client, details.id);
                }
            }

            return(returnValue);
        }
        /// <summary>
        /// Rename repository-managed user directory.
        /// </summary>
        /// <param name="destination">New name of the directory</param>
        /// <returns>RRepositoryDirectory object</returns>
        /// <remarks></remarks>
        public RRepositoryDirectory rename(String destination)
        {
            RRepositoryDirectory returnValue = default(RRepositoryDirectory);
            StringBuilder        data        = new StringBuilder();

            //set the url
            String uri = Constants.RREPOSITORYDIRECTORYRENAME;

            //create the input String
            data.Append(Constants.FORMAT_JSON);
            data.Append("&directory=" + HttpUtility.UrlEncode(m_directoryDetails.name));
            data.Append("&destination=" + HttpUtility.UrlEncode(destination.Trim()));

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

            if (!(jresponse.JSONMarkup["repository"] == null))
            {
                JObject jrepo = jresponse.JSONMarkup["repository"].Value <JObject>();
                if (!(jrepo["directory"] == null))
                {
                    JObject jdir = jrepo["directory"].Value <JObject>();
                    returnValue = new RRepositoryDirectory(new JSONResponse(jdir, true, "", 0), m_client);
                }
            }

            return(returnValue);
        }
        static public RRepositoryFile storeObject(RProjectDetails details, String name, Boolean sharedUser, Boolean published, String restricted, String descr, Boolean versioning, RClient client, String uri)
        {
            RRepositoryFile returnValue = default(RRepositoryFile);
            StringBuilder   data        = new StringBuilder();

            //create the input String
            data.Append(Constants.FORMAT_JSON);
            data.Append("&project=" + HttpUtility.UrlEncode(details.id));
            data.Append("&name=" + HttpUtility.UrlEncode(name));
            data.Append("&descr=" + HttpUtility.UrlEncode(descr));
            data.Append("&version=" + versioning.ToString());
            data.Append("&shared=" + sharedUser.ToString());
            data.Append("&published=" + published.ToString());
            data.Append("&restricted=" + HttpUtility.UrlEncode(restricted));

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

            if (!(jresponse.JSONMarkup["repository"] == null))
            {
                JObject jrepo = jresponse.JSONMarkup["repository"].Value <JObject>();
                if (!(jrepo["file"] == null))
                {
                    JObject jfile = jrepo["file"].Value <JObject>();
                    returnValue = new RRepositoryFile(new JSONResponse(jfile, true, "", 0), client);
                }
            }

            return(returnValue);
        }
Exemplo n.º 9
0
        static public List <RProjectFile> listFiles(RProjectDetails details, RClient client, String uri)
        {
            StringBuilder data = new StringBuilder();

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

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

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

            if (!(jresponse.JSONMarkup["directory"] == null))
            {
                JObject jdir = jresponse.JSONMarkup["directory"].Value <JObject>();
                if (!(jdir["files"] == null))
                {
                    JArray jvalues = jdir["files"].Value <JArray>();
                    foreach (var j in jvalues)
                    {
                        if (j.Type != JTokenType.Null)
                        {
                            returnValue.Add(new RProjectFile(new JSONResponse(j.Value <JObject>(), true, "", 0), client, details.id));
                        }
                    }
                }
            }

            return(returnValue);
        }
        /// <summary>
        /// Download zip archive of files found in repository-managed user directory. If the files parameter is null, all files in the directory are downloaded
        /// </summary>
        /// <param name="files">List of Repository file to delete</param>
        /// <returns>Byte arrary containing contents of downloaded zip file</returns>
        /// <remarks></remarks>
        public byte[] download(List <RRepositoryFile> files)
        {
            StringBuilder data      = new StringBuilder();
            StringBuilder filenames = new StringBuilder();

            //set the url
            String uri = Constants.RREPOSITORYDIRECTORYDOWNLOAD;

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

            if (!(files == null))
            {
                foreach (var file in files)
                {
                    if (filenames.Length != 0)
                    {
                        filenames.Append(",");
                        filenames.Append(file.about().filename);
                    }
                    else
                    {
                        filenames.Append(file.about().filename);
                    }
                }
            }
            data.Append("&filename=" + HttpUtility.UrlEncode(filenames.ToString()));

            //call the server
            byte[] returnValue = HTTPUtilities.callRESTBytesGet(uri, data.ToString(), ref m_client);

            return(returnValue);
        }
Exemplo n.º 11
0
        static public List <RJob> listJobs(RClient client, String uri)
        {
            StringBuilder data = new StringBuilder();

            //create the input String
            data.Append(Constants.FORMAT_JSON);
            //call the server
            JSONResponse jresponse = HTTPUtilities.callRESTGet(uri, data.ToString(), ref client);

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

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


            return(returnValue);
        }
        /// <summary>
        /// Lists the results associated with this Execution
        /// </summary>
        /// <returns>List of RProjectResult objects</returns>
        /// <remarks></remarks>
        public List <RProjectResult> listResults()
        {
            StringBuilder data = new StringBuilder();

            //set the url
            String uri = Constants.RPROJECTEXECUTERESULTLIST;

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

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

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

            if (!(jresponse.JSONMarkup["execution"] == null))
            {
                JObject jexec = jresponse.JSONMarkup["execution"].Value <JObject>();
                if (!(jexec["results"] == null))
                {
                    JArray jvalues = jexec["results"].Value <JArray>();
                    foreach (var j in jvalues)
                    {
                        if (j.Type != JTokenType.Null)
                        {
                            returnValue.Add(new RProjectResult(new JSONResponse(j.Value <JObject>(), true, "", 0), m_client));
                        }
                    }
                }
            }

            return(returnValue);
        }
Exemplo n.º 13
0
        static public RProjectFile loadFile(RProjectDetails details, RRepositoryFile file, RClient client, String uri)
        {
            RProjectFile  returnValue = default(RProjectFile);
            StringBuilder data        = new StringBuilder();

            //create the input String
            data.Append(Constants.FORMAT_JSON);
            data.Append("&project=" + HttpUtility.UrlEncode(details.id));
            data.Append("&filename=" + HttpUtility.UrlEncode(file.about().filename));
            data.Append("&directory=" + HttpUtility.UrlEncode(file.about().directory));
            data.Append("&author=" + HttpUtility.UrlEncode(file.about().author));
            data.Append("&version=" + HttpUtility.UrlEncode(file.about().version));
            //call the server
            JSONResponse jresponse = HTTPUtilities.callRESTPost(uri, data.ToString(), ref client);

            if (!(jresponse.JSONMarkup["directory"] == null))
            {
                JObject jdir = jresponse.JSONMarkup["directory"].Value <JObject>();
                if (!(jdir["file"] == null))
                {
                    JObject jfile = jdir["file"].Value <JObject>();
                    returnValue = new RProjectFile(new JSONResponse(jfile, true, "", 0), client, details.id);
                }
            }

            return(returnValue);
        }
Exemplo n.º 14
0
        static public String ping(RProjectDetails details, RClient client, String uri)
        {
            StringBuilder data = new StringBuilder();

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

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

            RProjectDetails projectDetails = default(RProjectDetails);

            RProjectBaseImpl.parseProject(jresponse, ref projectDetails);
            String returnValue = "";

            if (!(projectDetails == null))
            {
                returnValue = System.Convert.ToString(projectDetails.islive);
            }
            else
            {
                returnValue = System.Convert.ToString(false);
            }

            return(returnValue);
        }
Exemplo n.º 15
0
        static public RProjectFile writeFile(RProjectDetails details, String text, DirectoryUploadOptions options, RClient client, String uri)
        {
            RProjectFile  returnValue = default(RProjectFile);
            StringBuilder data        = new StringBuilder();

            //create the input String
            data.Append(Constants.FORMAT_JSON);
            data.Append("&project=" + HttpUtility.UrlEncode(details.id));
            data.Append("&text=" + HttpUtility.UrlEncode(text));
            if (!(options == null))
            {
                data.Append("&filename=" + HttpUtility.UrlEncode(options.filename));
                data.Append("&descr=" + HttpUtility.UrlEncode(options.descr));
                data.Append("&overwrite=" + options.overwrite.ToString());
            }

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

            if (!(jresponse.JSONMarkup["directory"] == null))
            {
                JObject jdir = jresponse.JSONMarkup["directory"].Value <JObject>();
                if (!(jdir["file"] == null))
                {
                    JObject jfile = jdir["file"].Value <JObject>();
                    returnValue = new RProjectFile(new JSONResponse(jfile, true, "", 0), client, details.id);
                }
            }

            return(returnValue);
        }
Exemplo n.º 16
0
        static public RRepositoryFile fetchFile(String filename, String author, String directory, String version, RClient client, String uri)
        {
            RRepositoryFile returnValue = default(RRepositoryFile);
            StringBuilder   data        = new StringBuilder();

            //create the input String
            data.Append(Constants.FORMAT_JSON);
            data.Append("&filename=" + HttpUtility.UrlEncode(filename));
            data.Append("&directory=" + HttpUtility.UrlEncode(directory));
            data.Append("&author=" + HttpUtility.UrlEncode(author));
            data.Append("&version=" + HttpUtility.UrlEncode(version));

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

            if (!(jresponse.JSONMarkup["repository"] == null))
            {
                JObject jrepo = jresponse.JSONMarkup["repository"].Value <JObject>();
                if (!(jrepo["file"] == null))
                {
                    JObject jfile = jrepo["file"].Value <JObject>();
                    returnValue = new RRepositoryFile(new JSONResponse(jfile, true, "", 0), client);
                }
            }

            return(returnValue);
        }
        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);
        }
Exemplo n.º 18
0
        static public RProject saveAs(RProjectDetails details, ProjectDropOptions 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("&name=" + HttpUtility.UrlEncode(details.name));
            data.Append("&descr=" + HttpUtility.UrlEncode(details.descr));
            data.Append("&longdescr=" + HttpUtility.UrlEncode(details.longdescr));
            data.Append("&projectcookie=" + HttpUtility.UrlEncode(details.cookie));
            data.Append("&shared=" + details.sharedUsers.ToString());

            if (!(options == null))
            {
                data.Append("&dropworkspace=" + options.dropWorkspace.ToString());
                data.Append("&dropdirectory=" + options.dropDirectory.ToString());
                data.Append("&drophistory=" + options.dropHistory.ToString());
            }

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

            RProject returnValue = default(RProject);

            returnValue = new RProject(jresponse, client);
            return(returnValue);
        }
        static public void releaseProjects(RClient client, String uri)
        {
            StringBuilder data = new StringBuilder();

            //create the input String
            data.Append(Constants.FORMAT_JSON);
            //call the server
            JSONResponse jresponse = HTTPUtilities.callRESTPost(uri, data.ToString(), ref client);
        }
        static public void autosaveProjects(Boolean save, RClient client, String uri)
        {
            StringBuilder data = new StringBuilder();

            //create the input String
            data.Append(Constants.FORMAT_JSON);
            data.Append("&enable=" + save.ToString().ToLower());
            //call the server
            JSONResponse jresponse = HTTPUtilities.callRESTPost(uri, data.ToString(), ref client);
        }
Exemplo n.º 21
0
        static public void interruptExecution(RProjectDetails details, RClient client, String uri)
        {
            StringBuilder data = new StringBuilder();

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

            //call the server
            JSONResponse jresponse = HTTPUtilities.callRESTPost(uri, data.ToString(), ref client);
        }
Exemplo n.º 22
0
        /// <summary>
        ///  Interrupts the current execution on the HTTP blackbox project associated
        /// with the current HTTP session.
        /// </summary>

        public void interruptScript()
        {
            StringBuilder data = new StringBuilder();

            String uri = Constants.RREPOSITORYSCRIPTINTERRUPT;

            data.Append(Constants.FORMAT_JSON);

            //call the server
            RClient      client    = this;
            JSONResponse jresponse = HTTPUtilities.callRESTGet(uri, data.ToString(), ref client);
        }
Exemplo n.º 23
0
        /// <summary>
        /// Logout from the RevoDeployR server.
        /// </summary>
        /// <param name="user">The RUser object representing the user to logout</param>
        /// <remarks></remarks>
        public void logout(RUser user)
        {
            StringBuilder data = new StringBuilder();

            String uri = Constants.RUSERLOGOUT;

            //create the input String
            data.Append(Constants.FORMAT_JSON);
            //call the server
            RClient      client    = this;
            JSONResponse jresponse = HTTPUtilities.callRESTPost(uri, data.ToString(), ref client);
        }
Exemplo n.º 24
0
        static public List <RRepositoryDirectory> listDirectories(Boolean userfiles, Boolean archived, Boolean sharedUsers, Boolean published, Boolean external, String directory, String category, RClient client, String uri)
        {
            StringBuilder data = new StringBuilder();

            //create the input String
            data.Append(Constants.FORMAT_JSON);
            data.Append("&userfiles=" + userfiles.ToString());
            data.Append("&archived=" + archived.ToString());
            data.Append("&shared=" + sharedUsers.ToString());
            data.Append("&published=" + published.ToString());
            data.Append("&external=" + external.ToString());
            data.Append("&directory=" + HttpUtility.UrlEncode(directory.Trim()));
            data.Append("&categoryFilter=" + HttpUtility.UrlEncode(category.Trim()));

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

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

            if (!(jresponse.JSONMarkup["repository"] == null))
            {
                JObject jrepo = jresponse.JSONMarkup["repository"].Value <JObject>();
                if (!(jrepo["directories"] == null))
                {
                    JObject jdirs = jrepo["directories"].Value <JObject>();
                    if (!(jdirs["user"] == null))
                    {
                        JArray jvalues = jdirs["user"].Value <JArray>();
                        foreach (var j in jvalues)
                        {
                            if (j.Type != JTokenType.Null)
                            {
                                returnValue.Add(new RRepositoryDirectory(new JSONResponse(j.Value <JObject>(), true, "", 0), client));
                            }
                        }
                    }
                    if (!(jdirs["system"] == null))
                    {
                        JArray jvalues = jdirs["system"].Value <JArray>();
                        foreach (var j in jvalues)
                        {
                            if (j.Type != JTokenType.Null)
                            {
                                returnValue.Add(new RRepositoryDirectory(new JSONResponse(j.Value <JObject>(), true, "", 0), client));
                            }
                        }
                    }
                }
            }

            return(returnValue);
        }
Exemplo n.º 25
0
        /// <summary>
        /// Deletes the job
        /// </summary>
        /// <remarks></remarks>
        public void delete()
        {
            StringBuilder data = new StringBuilder();

            //set the url
            String uri = Constants.RJOBDELETE;

            //create the input String
            data.Append(Constants.FORMAT_JSON);
            data.Append("&job=" + HttpUtility.UrlEncode(m_jobDetails.id));
            //call the server
            JSONResponse jresponse = HTTPUtilities.callRESTPost(uri, data.ToString(), ref m_client);
        }
        /// <summary>
        /// Delete repository-managed user directory.
        /// </summary>
        /// <remarks></remarks>
        public void delete()
        {
            StringBuilder data = new StringBuilder();

            //set the url
            String uri = Constants.RREPOSITORYDIRECTORYDELETE;

            //create the input String
            data.Append(Constants.FORMAT_JSON);
            data.Append("&directory=" + HttpUtility.UrlEncode(m_directoryDetails.name));
            //call the server
            JSONResponse jresponse = HTTPUtilities.callRESTPost(uri, data.ToString(), ref m_client);
        }
        static public void transferObject(RProjectDetails details, String name, String url, 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("&name=" + HttpUtility.UrlEncode(name));
            data.Append("&url=" + HttpUtility.UrlEncode(url));

            //call the server
            JSONResponse jresponse = HTTPUtilities.callRESTPost(uri, data.ToString(), ref client);
        }
        static public void uploadObject(RProjectDetails details, String name, String filename, RClient client, String uri)
        {
            StringBuilder data = new StringBuilder();
            Dictionary <String, String> parameters = new Dictionary <String, String>();

            //create the input String
            parameters.Add("format", "json");
            parameters.Add("project", HttpUtility.UrlEncode(details.id));
            parameters.Add("name", HttpUtility.UrlEncode(name));

            //call the server
            JSONResponse jresponse = HTTPUtilities.callRESTFileUploadPost(uri, parameters, filename, ref client);
        }
        /// <summary>
        /// Flushes this Execution
        /// </summary>
        /// <remarks></remarks>
        public void flush()
        {
            StringBuilder data = new StringBuilder();

            //set the url
            String uri = Constants.RPROJECTEXECUTEFLUSH;

            //create the input String
            data.Append(Constants.FORMAT_JSON);
            data.Append("&execution=" + HttpUtility.UrlEncode(m_executionDetails.id));
            data.Append("&project=" + HttpUtility.UrlEncode(m_projectDetails.id));
            //call the server
            JSONResponse jresponse = HTTPUtilities.callRESTPost(uri, data.ToString(), ref m_client);
        }
        static public RProject getProject(String name, RClient client, String uri)
        {
            StringBuilder data = new StringBuilder();

            //create the input String
            data.Append(Constants.FORMAT_JSON);
            data.Append("&project=" + HttpUtility.UrlEncode(name));
            //call the server
            JSONResponse jresponse = HTTPUtilities.callRESTPost(uri, data.ToString(), ref client);

            RProject returnValue = new RProject(jresponse, client);

            return(returnValue);
        }