Пример #1
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);
        }
Пример #2
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);
        }
        static public RProjectFile saveObject(RProjectDetails details, String name, String descr, Boolean versioning, 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("&name=" + HttpUtility.UrlEncode(name));
            data.Append("&descr=" + HttpUtility.UrlEncode(descr));
            data.Append("&version=" + versioning.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);
        }
Пример #4
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);
        }
Пример #5
0
        /// <summary>
        /// Update project file details
        /// </summary>
        /// <param name="name">name of project file</param>
        /// <param name="descr">description of project file</param>
        /// <param name="overwrite">flag indicating if file should be overwritten</param>
        /// <returns>RRepositoryFile object</returns>
        /// <remarks></remarks>
        public RProjectFile update(String name, String descr, Boolean overwrite)
        {
            StringBuilder data = new StringBuilder();

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

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

            RProjectFile returnValue = new RProjectFile(jresponse, m_client, m_project);

            return(returnValue);
        }
        /// <summary>
        /// Update project file details
        /// </summary>
        /// <param name="name">name of project file</param>
        /// <param name="descr">description of project file</param>
        /// <param name="overwrite">flag indicating if file should be overwritten</param>
        /// <returns>RRepositoryFile object</returns>
        /// <remarks></remarks>
        public RProjectFile update(String name, String descr, Boolean overwrite)
        {
            StringBuilder data = new StringBuilder();

            //set the url
            String uri = Constants.RPROJECTDIRECTORYUPDATE;
            //create the input String
            data.Append(Constants.FORMAT_JSON);
            data.Append("&project=" + m_project);
            data.Append("&name=" + HttpUtility.UrlEncode(m_fileDetails.filename));
            data.Append("&rename=" + HttpUtility.UrlEncode(name));
            data.Append("&descr=" + HttpUtility.UrlEncode(descr));
            //call the server
            JSONResponse jresponse = HTTPUtilities.callRESTPost(uri, data.ToString(), ref m_client);

            RProjectFile returnValue = new RProjectFile(jresponse, m_client, m_project);

            return returnValue;
        }
        public static RProjectFile saveObject(RProjectDetails details, String name, String descr, Boolean versioning, 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("&name=" + HttpUtility.UrlEncode(name));
            data.Append("&descr=" + HttpUtility.UrlEncode(descr));
            data.Append("&version=" + versioning.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;
        }
Пример #8
0
        /// <summary>
        /// save an object from the workspace to a project file
        /// </summary>
        /// <param name="name">name of the object to save</param>
        /// <param name="descr">description of the object to save</param>
        /// <param name="versioning">indicate if versioning of the file should be enabled</param>
        /// <returns>RProjectFile object</returns>
        /// <remarks></remarks>
        public RProjectFile saveObject(String name, String descr, Boolean versioning)
        {
            RProjectFile returnValue = RProjectWorkspaceImpl.saveObject(m_projectDetails, name, descr, versioning, m_client, Constants.RPROJECTWORKSPACESAVE);

            return(returnValue);
        }
Пример #9
0
        /// <summary>
        /// Write a file to project directory
        /// </summary>
        /// <param name="text">text to write to a file in the project directory</param>
        /// <param name="options">DirectoryUploadOptions object specifying behavior of the transfer</param>
        /// <returns>RProjectFile object created</returns>
        /// <remarks></remarks>
        public RProjectFile writeFile(String text, DirectoryUploadOptions options)
        {
            RProjectFile returnValue = RProjectDirectoryImpl.writeFile(m_projectDetails, text, options, m_client, Constants.RPROJECTDIRECTORYWRITE);

            return(returnValue);
        }
Пример #10
0
        /// <summary>
        /// Upload a file to project directory
        /// </summary>
        /// <param name="file">complete path to the file to upload</param>
        /// <param name="options">DirectoryUploadOptions object specifying behavior of the transfer</param>
        /// <returns>RProjectFile object created</returns>
        /// <remarks></remarks>
        public RProjectFile uploadFile(String file, DirectoryUploadOptions options)
        {
            RProjectFile returnValue = RProjectDirectoryImpl.uploadFile(m_projectDetails, file, options, m_client, Constants.RPROJECTDIRECTORYUPLOAD);

            return(returnValue);
        }
Пример #11
0
        /// <summary>
        /// Transfer file to project directory
        /// </summary>
        /// <param name="url">url of file to transfer</param>
        /// <param name="options">DirectoryUploadOptions object specifying behavior of the transfer</param>
        /// <returns>RProjectFile object created</returns>
        /// <remarks></remarks>
        public RProjectFile transferFile(String url, DirectoryUploadOptions options)
        {
            RProjectFile returnValue = RProjectDirectoryImpl.transferFile(m_projectDetails, url, options, m_client, Constants.RPROJECTDIRECTORYTRANSFER);

            return(returnValue);
        }
Пример #12
0
        /// <summary>
        /// Load file from user repository into project directory
        /// </summary>
        /// <param name="file">RRepositoryFile object to load</param>
        /// <returns>RProjectFile object created</returns>
        /// <remarks></remarks>
        public RProjectFile loadFile(RRepositoryFile file)
        {
            RProjectFile returnValue = RProjectDirectoryImpl.loadFile(m_projectDetails, file, m_client, Constants.RPROJECTDIRECTORYLOAD);

            return(returnValue);
        }
        public static 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;
        }
        public static 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;
        }