Ejemplo n.º 1
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);
        }
        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);
        }
        static public RProject importProject(String file, String descr, 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("name", HttpUtility.UrlEncode(Path.GetFileName(file)));
            parameters.Add("descr", HttpUtility.UrlEncode(descr));
            //call the server
            JSONResponse jresponse = HTTPUtilities.callRESTFileUploadPost(uri, parameters, file, ref client);

            RProject returnValue = new RProject(jresponse, client);

            return(returnValue);
        }
Ejemplo n.º 4
0
        static public void uploadDirectory(String file, RepoUploadOptions options, RClient client, String uri)
        {
            StringBuilder data = new StringBuilder();
            Dictionary <String, String> parameters = new Dictionary <String, String>();

            //create the input String
            if (!(options == null))
            {
                parameters.Add("format", "json");
                parameters.Add("directory", HttpUtility.UrlEncode(options.directory));
                parameters.Add("descr", HttpUtility.UrlEncode(options.descr));
                parameters.Add("shared", options.sharedUser.ToString());
                parameters.Add("published", options.published.ToString());
                parameters.Add("restricted", HttpUtility.UrlEncode(options.restricted));
                parameters.Add("newversion", options.newversion.ToString());
                parameters.Add("newversionmsg", HttpUtility.UrlEncode(options.newversionmsg));
            }
            //call the server
            JSONResponse jresponse = HTTPUtilities.callRESTFileUploadPost(uri, parameters, file, ref client);
        }
Ejemplo n.º 5
0
        static public RRepositoryFile uploadFile(String file, RepoUploadOptions options, RClient client, String uri)
        {
            RRepositoryFile             returnValue = default(RRepositoryFile);
            StringBuilder               data        = new StringBuilder();
            Dictionary <String, String> parameters  = new Dictionary <String, String>();

            //create the input String
            if (!(options == null))
            {
                parameters.Add("format", "json");
                parameters.Add("filename", HttpUtility.UrlEncode(options.filename));
                parameters.Add("directory", HttpUtility.UrlEncode(options.directory));
                parameters.Add("descr", HttpUtility.UrlEncode(options.descr));
                parameters.Add("shared", options.sharedUser.ToString());
                parameters.Add("published", options.published.ToString());
                parameters.Add("restricted", HttpUtility.UrlEncode(options.restricted));
                parameters.Add("inputs", HttpUtility.UrlEncode(options.inputs));
                parameters.Add("outputs", HttpUtility.UrlEncode(options.outputs));
                parameters.Add("newversion", options.newversion.ToString());
                parameters.Add("newversionmsg", HttpUtility.UrlEncode(options.newversionmsg));
            }
            else
            {
                parameters.Add("filename", HttpUtility.UrlEncode(Path.GetFileName(file)));
            }
            //call the server
            JSONResponse jresponse = HTTPUtilities.callRESTFileUploadPost(uri, parameters, file, 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);
                }
            }

            return(returnValue);
        }
        /// <summary>
        /// Upload files in a zip archive to repository-managed user directory
        /// </summary>
        /// <param name="file">Full path to the zip file to be uploaded</param>
        /// <param name="options">RepoUploadOptions object to apply to the upload</param>
        /// <remarks></remarks>
        public void uploadDirectory(String file, RepoUploadOptions options)
        {
            StringBuilder data = new StringBuilder();
            Dictionary <String, String> parameters = new Dictionary <String, String>();

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

            //create the input String
            if (!(options == null))
            {
                parameters.Add("format", "json");
                parameters.Add("directory", HttpUtility.UrlEncode(m_directoryDetails.name));
                parameters.Add("descr", HttpUtility.UrlEncode(options.descr));
                parameters.Add("newversion", options.newversion.ToString());
                parameters.Add("shared", options.sharedUser.ToString());
                parameters.Add("published", options.published.ToString());
                parameters.Add("restricted", HttpUtility.UrlEncode(options.restricted));
            }
            //call the server
            JSONResponse jresponse = HTTPUtilities.callRESTFileUploadPost(uri, parameters, file, ref m_client);
        }