/// <summary>
 /// Create connection at the specified RevoDeployR URL
 /// </summary>
 /// <param name="deployRURL">URL address of RevoDeployR server</param>
 /// <param name="concurrentCallLimit">(optional) the maximum number of conccurent calls, beyond which they are queued (default = 3)</param>
 /// <returns>RClient object</returns>
 /// <remarks></remarks>
 public static RClient createClient(String deployRURL, int concurrentCallLimit)
 {
     RClient returnValue = new RClient(deployRURL, concurrentCallLimit);
     System.Net.ServicePointManager.DefaultConnectionLimit = concurrentCallLimit + 10;
     System.Net.ServicePointManager.Expect100Continue = false;
     return returnValue;
 }
예제 #2
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);
        }
예제 #3
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);
        }
        public static String downloadFiles(RProjectDetails details, List<String> files, RClient client, String uri)
        {
            String returnValue = "";
            StringBuilder filenames = new StringBuilder();

            if (!(files == null))
            {
                if (files.Count > 0)
                {
                    foreach (var s in files)
                    {
                        filenames.Append(HttpUtility.UrlEncode(s) + ",");
                    }
                    filenames.Remove(filenames.Length - 1, 1);
                }
            }

            if (filenames.Length > 0)
            {
                returnValue = client.URL + uri + "/" + details.id + "/" + HttpUtility.UrlEncode(filenames.ToString()) + ";jsessionid=" + client.Cookie.Value;
            }
            else
            {
                returnValue = client.URL + uri + "/" + details.id + ";jsessionid=" + client.Cookie.Value;
            }

            return returnValue;
        }
        public static 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;
        }
        public static 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);
        }
        public static 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;
        }
예제 #8
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);
        }
        public static 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;
        }
 internal RProjectResult(JSONResponse jresponse, RClient client)
 {
     m_client = client;
     if (!(jresponse == null))
     {
         parseProjectResult(jresponse, ref m_resultDetails);
     }
 }
 internal RProjectPackage(JSONResponse jresponse, RClient client)
 {
     m_client = client;
     if (!(jresponse == null))
     {
         parseProjectPackage(jresponse, ref m_packageDetails);
     }
 }
예제 #12
0
 internal RUser(JSONResponse jresponse, RClient client)
 {
     m_client = client;
     if (!(jresponse == null))
     {
         parseUser(jresponse, ref m_userDetails);
     }
 }
 internal RRepositoryFile(JSONResponse jresponse, RClient client)
 {
     m_client = client;
     if (!(jresponse == null))
     {
         parseRepositoryFile(jresponse, ref m_fileDetails);
     }
 }
 internal RRepositoryScript(JSONResponse jresponse, RClient client)
 {
     m_client = client;
     if (!(jresponse == null))
     {
         parseRepositoryScript(jresponse, ref m_scriptDetails);
     }
 }
 internal RScriptExecution(JSONResponse jresponse, RClient client)
 {
     m_client = client;
     if (!(jresponse == null))
     {
         parseScriptExecution(jresponse, ref m_executionDetails, ref m_projectDetails);
     }
 }
예제 #16
0
 internal RScriptExecution(JSONResponse jresponse, RClient client)
 {
     m_client = client;
     if (!(jresponse == null))
     {
         parseScriptExecution(jresponse, ref m_executionDetails, ref m_projectDetails);
     }
 }
 internal RProjectResult(JSONResponse jresponse, RClient client)
 {
     m_client = client;
     if (!(jresponse == null))
     {
         parseProjectResult(jresponse, ref m_resultDetails);
     }
 }
 internal RRepositoryDirectory(JSONResponse jresponse, RClient client)
 {
     m_client = client;
     if (!(jresponse == null))
     {
         parseRepositoryDirectory(jresponse, ref m_directoryDetails);
     }
 }
 internal RRepositoryFile(JSONResponse jresponse, RClient client)
 {
     m_client = client;
     if (!(jresponse == null))
     {
         parseRepositoryFile(jresponse, ref m_fileDetails);
     }
 }
 internal RRepositoryScript(JSONResponse jresponse, RClient client)
 {
     m_client = client;
     if (!(jresponse == null))
     {
         parseRepositoryScript(jresponse, ref m_scriptDetails);
     }
 }
 internal RRepositoryDirectory(JSONResponse jresponse, RClient client)
 {
     m_client = client;
     if (!(jresponse == null))
     {
         parseRepositoryDirectory(jresponse, ref m_directoryDetails);
     }
 }
 internal RProjectPackage(JSONResponse jresponse, RClient client)
 {
     m_client = client;
     if (!(jresponse == null))
     {
         parseProjectPackage(jresponse, ref m_packageDetails);
     }
 }
예제 #23
0
 internal RJob(JSONResponse jresponse, RClient client)
 {
     m_client = client;
     if (!(jresponse == null))
     {
         parseJob(jresponse, ref m_jobDetails);
     }
 }
예제 #24
0
 internal RJob(JSONResponse jresponse, RClient client)
 {
     m_client = client;
     if (!(jresponse == null))
     {
         parseJob(jresponse, ref m_jobDetails);
     }
 }
 internal RProjectFile(JSONResponse jresponse, RClient client, String project)
 {
     m_client = client;
     m_project = project;
     if (!(jresponse == null))
     {
         parseProjectFile(jresponse, ref m_fileDetails);
     }
 }
        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);
        }
예제 #27
0
 internal RProjectFile(JSONResponse jresponse, RClient client, String project)
 {
     m_client  = client;
     m_project = project;
     if (!(jresponse == null))
     {
         parseProjectFile(jresponse, ref m_fileDetails);
     }
 }
        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);
        }
        public static 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);
        }
예제 #30
0
        /// <summary>
        /// Create connection at the specified RevoDeployR URL
        /// </summary>
        /// <param name="deployRURL">URL address of RevoDeployR server</param>
        /// <param name="concurrentCallLimit">(optional) the maximum number of conccurent calls, beyond which they are queued (default = 3)</param>
        /// <returns>RClient object</returns>
        /// <remarks></remarks>
        static public RClient createClient(String deployRURL, int concurrentCallLimit)
        {
            RClient returnValue = new RClient(deployRURL, concurrentCallLimit);

            System.Net.ServicePointManager.DefaultConnectionLimit = concurrentCallLimit + 10;
            System.Net.ServicePointManager.Expect100Continue      = false;
            System.Net.ServicePointManager.SetTcpKeepAlive(true, 10000, 10000);

            return(returnValue);
        }
예제 #31
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);
        }
        public static void delete(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);
        }
예제 #33
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);
        }
예제 #34
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);
        }
예제 #35
0
        public static void Cleanup(RUser rUser, RClient rClient)
        {
            //
            // Clenaup and logout when we are finished
            //
            if (rUser != null)
            {
                Console.WriteLine("User logged out: " + rUser.about().Username);

                rClient.logout(rUser);
            }
        }
        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);
        }
        public static String export(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);

            String returnValue = System.Convert.ToString(HttpUtility.UrlEncode(uri + "/" + details.id + ";jsessionid=" + client.Cookie.Value));
            return returnValue;
        }
 /// <summary>
 /// Constructor for specifying a Discrete Instance of RBrokerWorker
 /// </summary>
 /// <param name="task">DiscreteTask reference</param>
 /// <param name="executorTaskRef">Reserved for future use</param>
 /// <param name="isPriorityTask">Boolean indicating if this ia high priority task</param>
 /// <param name="rClient">RClient reference</param>
 /// <param name="resourceToken">integer referencing the token from the reosurce pool</param>
 /// <param name="rBroker">RBroker reference</param>
 /// <remarks></remarks>
 public DiscreteTaskWorker(DiscreteTask task,
                           long executorTaskRef,
                           Boolean isPriorityTask,
                           RClient rClient,
                           int resourceToken,
                           RBroker rBroker)
 {
     m_task = task;
     m_executorTaskRef = executorTaskRef;
     m_isPriorityTask = isPriorityTask;
     m_rClient = rClient;
     m_resourceToken = resourceToken;
     m_rBroker = (DiscreteTaskBroker) rBroker;
 }
예제 #39
0
        public static RUser Authenticate(RClient rClient)
        {
            //
            // Authenticate an end-user or client application.
            //
            // The RBasicAuthentication supports basic username/password authentication.
            // The RUser returned represents an authenticated end-user or application.
            //
            RAuthentication authToken = new RBasicAuthentication("testuser", "changeme");
            RUser rUser = rClient.login(authToken);

            Console.WriteLine("User Authenticated: user: " + rUser.about().Username);

            return rUser;
        }
        public static RProjectDetails about(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 returnValue = default(RProjectDetails);
            parseProject(jresponse, ref returnValue);
            return returnValue;
        }
예제 #41
0
        static public String export(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);

            String returnValue = System.Convert.ToString(HttpUtility.UrlEncode(uri + "/" + details.id + ";jsessionid=" + client.Cookie.Value));

            return(returnValue);
        }
예제 #42
0
        static public RProjectDetails about(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 returnValue = default(RProjectDetails);

            parseProject(jresponse, ref returnValue);
            return(returnValue);
        }
        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);
        }
예제 #44
0
        /// <summary>
        /// Authenticate with the RevoDeployR server
        /// </summary>
        /// <param name="authentication">A valid RAuthentication object</param>
        /// <param name="autosave">(optional) Flag indicating that autosave should be turned on/off for the user</param>
        /// <returns>RResponse object</returns>
        /// <remarks></remarks>
        public RUser login(RAuthentication authentication, Boolean autosave)
        {
            StringBuilder data = new StringBuilder();

            String uri = Constants.RUSERLOGIN;

            //create the input String
            data.Append(Constants.FORMAT_JSON + "&username="******"&password="******"&save=" + HttpUtility.UrlEncode(autosave.ToString()));
            //call the server
            RClient      client      = this;
            JSONResponse jresponse   = HTTPUtilities.callRESTPost(uri, data.ToString(), ref client);
            RUser        returnValue = new RUser(jresponse, this);

            return(returnValue);
        }
예제 #45
0
        static public String getConsole(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);


            String console = "";

            parseConsole(jresponse, ref console);
            return(console);
        }
        static public void loadObject(RProjectDetails details, RRepositoryFile file, 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 (!(file == null))
            {
                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);
        }
예제 #47
0
        private List <String> executeShellImp(String shellName, String shellDirectory, String shellAuthor, String shellVersion, String args)
        {
            StringBuilder data = new StringBuilder();

            String uri = Constants.RREPOSITORYSHELLEXECUTE;

            //create the input String
            data.Append(Constants.FORMAT_JSON);

            data.Append("&filename=" + HttpUtility.UrlEncode(shellName));
            data.Append("&author=" + HttpUtility.UrlEncode(shellAuthor));
            data.Append("&directory=" + HttpUtility.UrlEncode(shellDirectory));
            data.Append("&version=" + HttpUtility.UrlEncode(shellVersion));
            data.Append("&args=" + HttpUtility.UrlEncode(args));

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

            List <String> console = new List <String>();
            JArray        jvalues;

            if (!(jresponse.JSONMarkup["repository"] == null))
            {
                JObject jrepo = jresponse.JSONMarkup["repository"].Value <JObject>();
                if (!(jrepo["shell"] == null))
                {
                    JObject jshell = jrepo["shell"].Value <JObject>();;

                    if (!(jshell["console"] == null))
                    {
                        jvalues = jshell["console"].Value <JArray>();
                        foreach (var j in jvalues)
                        {
                            if (j.Type != JTokenType.Null)
                            {
                                console.Add(j.Value <string>());
                            }
                        }
                    }
                }
            }
            return(console);
        }
예제 #48
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);
        }
예제 #49
0
        static public RProjectDetails update(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));
            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());

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

            RProjectDetails returnValue = default(RProjectDetails);

            parseProject(jresponse, ref returnValue);
            return(returnValue);
        }
        public static List<RProjectPackage> attachPackage(RProjectDetails details, List<String> packageNames, String repo, 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("&repo=" + HttpUtility.UrlEncode(repo));
            if (!(packageNames == null))
            {
                if (packageNames.Count > 0)
                {
                    data.Append("&name=");
                    foreach (var s in packageNames)
                    {
                        data.Append(HttpUtility.UrlEncode(s) + ",");
                    }
                    data.Remove(data.Length - 1, 1);
                }
            }

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

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

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

            return returnValue;
        }
        public static void deleteObject(RProjectDetails details, List<String> objectNames, 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);
                }
            }

            //call the server
            JSONResponse jresponse = HTTPUtilities.callRESTPost(uri, data.ToString(), ref client);
        }
        public static void close(RProjectDetails details, ProjectCloseOptions 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));
            if (!(options == null))
            {
                if (!(options.dropOptions == null))
                {
                    data.Append("&dropworkspace=" + options.dropOptions.dropWorkspace.ToString());
                    data.Append("&dropdirectory=" + options.dropOptions.dropDirectory.ToString());
                    data.Append("&drophistory=" + options.dropOptions.dropHistory.ToString());
                }
                data.Append("&flushhistory=" + options.flushHistory.ToString());
                data.Append("&disableautosave=" + options.disableAutosave.ToString());
                data.Append("&projectcookie=" + options.cookie);
            }

            //call the server
            JSONResponse jresponse = HTTPUtilities.callRESTPost(uri, data.ToString(), ref client);
        }
        public static List<RRepositoryScript> listScripts(String filename, String directory, Boolean archived, Boolean sharedUsers, Boolean published, Boolean external, String categoryFilter, RClient client, String uri)
        {
            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("&archived=" + archived.ToString());
            data.Append("&shared=" + sharedUsers.ToString());
            data.Append("&published=" + published.ToString());
            data.Append("&external=" + external.ToString());
            data.Append("&categoryFilter=" + HttpUtility.UrlEncode(categoryFilter));

            JSONResponse jresponse = HTTPUtilities.callRESTGet(uri, data.ToString(), ref client);

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

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

            return returnValue;
        }
        static public void pushObject(RProjectDetails details, List <RData> inputs, 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 (!(inputs == null))
            {
                if (inputs.Count > 0)
                {
                    data.Append("&inputs=");
                    String sJSON = JSONSerialize.createJSONfromRData(inputs);
                    data.Append(HttpUtility.UrlEncode(sJSON));
                    if (HTTPUtilities.DEBUGMODE == true)
                    {
                        Console.Write(sJSON);
                    }
                }
            }

            //call the server
            JSONResponse jresponse = HTTPUtilities.callRESTPost(uri, data.ToString(), ref client);
        }
예제 #55
0
        static public RRepositoryDirectory createDirectory(String directory, RClient client, String uri)
        {
            RRepositoryDirectory returnValue = default(RRepositoryDirectory);

            StringBuilder data = new StringBuilder();

            //create the input String
            data.Append(Constants.FORMAT_JSON);
            data.Append("&directory=" + HttpUtility.UrlEncode(directory.Trim()));
            //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["directory"] == null))
                {
                    JObject jdir = jrepo["directory"].Value <JObject>();
                    returnValue = new RRepositoryDirectory(new JSONResponse(jdir, true, "", 0), client);
                }
            }

            return(returnValue);
        }
        public static RRepositoryDirectory createDirectory(String directory, RClient client, String uri)
        {
            RRepositoryDirectory returnValue = default(RRepositoryDirectory);

            StringBuilder data = new StringBuilder();

            //create the input String
            data.Append(Constants.FORMAT_JSON);
            data.Append("&directory=" + HttpUtility.UrlEncode(directory.Trim()));
            //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["directory"] == null))
                {
                    JObject jdir = jrepo["directory"].Value<JObject>();
                    returnValue = new RRepositoryDirectory(new JSONResponse(jdir, true, "", 0), client);
                }
            }

            return returnValue;
        }
        public static RJob callJob(String name, String descr, String code, String scriptName, String scriptDirectory, String scriptAuthor, String scriptVersion, String ExternalSource, JobExecutionOptions options, RClient client, String uri)
        {
            StringBuilder data = new StringBuilder();

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

            if (ExternalSource == null)
            {
                data.Append("&rscriptname=" + HttpUtility.UrlEncode(scriptName));
                data.Append("&rscriptdirectory=" + HttpUtility.UrlEncode(scriptDirectory));
                data.Append("&rscriptauthor=" + HttpUtility.UrlEncode(scriptAuthor));
                data.Append("&rscriptversion=" + HttpUtility.UrlEncode(scriptVersion));
            }
            else
            {
                data.Append("&externalsource=" + HttpUtility.UrlEncode(ExternalSource));
            }

            if (!(options == null))
            {

                data.Append("&csvinputs=" + HttpUtility.UrlEncode(options.csvrinputs));

                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=" + options.graphicsWidth.ToString());
                data.Append("&graphicsheight=" + 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));

                if (!(options.schedulingOptions == null))
                {
                    data.Append("&schedstart=" + options.schedulingOptions.startTime.ToString());
                    data.Append("&schedrepeat=" + options.schedulingOptions.repeatCount.ToString());
                    data.Append("&schedinterval=" + options.schedulingOptions.repeatInterval.ToString());
                }

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

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

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

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

            RProjectDetails returnValue = default(RProjectDetails);
            parseProject(jresponse, ref returnValue);
            return returnValue;
        }