Esempio n. 1
0
        /// <summary>Creates new user in orchestrator. Returns information about new created user</summary>
        /// <param name="connection">UiPath orchestrator connection info</param>
        /// <param name="parameters">Name(optional), Surname(optinal), Username(required). Optional can be empty string "" </param>
        /// <param name="roles">Roles that will be assigned to user</param>
        public static bool CreateUser(UiPathOrchestratorConnection connection, string[] parameters, string[] roles)
        {
            string rolesToJson = "";

            foreach (string role in roles)
            {
                rolesToJson = rolesToJson + "\"" + role + "\",";
            }
            rolesToJson = rolesToJson.TrimEnd(Convert.ToChar(","));
            IRestResponse response = OrchAPI.POSTrequest(connection, "Users", "{\"Name\":\"" + parameters[0] + "\",\"Surname\":\"" + parameters[1] + "\",\"UserName\":\"" + parameters[2] + "\",\"TenancyName\":\"" + connection.Tenant + "\",\"RolesList\":[" + rolesToJson + "]}");

            return(OrchAPI.GetStatus(response));
        }
Esempio n. 2
0
        /// <summary>Starts job with input parameters</summary>
        /// <param name="connection">UiPath orchestrator connection info</param>
        /// <param name="JobInfo">Package release key, Robot ID</param>
        /// <param name="inputParameters">Input parameters in format {input key}-{value}. Input key is case sensitive</param>
        public static string StartJob(UiPathOrchestratorConnection connection, string[] jobInfo, string[] inputParameters)
        {
            string parameters = "";

            foreach (string par in inputParameters)
            {
                string[] splitter = par.Split('-');
                parameters = parameters + "\\\"" + splitter[0] + "\\\":\\\"" + splitter[1] + "\\\",";
            }
            parameters = parameters.TrimEnd(',');
            IRestResponse response = OrchAPI.POSTrequest(connection, "Jobs/UiPath.Server.Configuration.OData.StartJobs", "{\"startInfo\":{\"ReleaseKey\":\"" + jobInfo[0] + "\",\"RobotIds\":[" + jobInfo[1] + "],\"JobsCount\":0,\"Strategy\":\"Specific\",\"InputArguments\":\"{" + parameters + "}\"}}");

            return(OrchAPI.ParseJson(response, "value"));
        }
Esempio n. 3
0
        /// <summary>Returns status of the robot</summary>
        /// <param name="connection">UiPath orchestrator connection info</param>
        /// <param name="robotName">Name of the robot</param>
        public static string GetRobotStatus(UiPathOrchestratorConnection connection, string robotName)
        {
            IRestResponse response = OrchAPI.GETrequest(connection, "Sessions?$expand=Robot");
            JObject       jsonObj  = JObject.Parse(response.Content);
            JArray        jsonArr  = JArray.Parse(jsonObj.SelectToken("value").ToString());

            foreach (var item in jsonArr)
            {
                if (item.SelectToken("Robot").SelectToken("Name").ToString().ToLower() == robotName.ToLower())
                {
                    return(item.SelectToken("State").ToString());
                }
            }
            return("Robot not found");
        }
Esempio n. 4
0
        /// <summary>Deletes queue in orchestrator. Returns bool if  delete was successful</summary>
        /// <param name="connection">UiPath orchestrator connection info</param>
        /// <param name="ID">ID of the queue</param>
        public static bool DeleteQueue(UiPathOrchestratorConnection connection, string ID)
        {
            IRestResponse response = OrchAPI.DELETErequest(connection, "QueueDefinitions", ID);

            return(OrchAPI.GetStatus(response));
        }
Esempio n. 5
0
        /// <summary>Creates new queue in orchestrator. Returns bool if created successfuly</summary>
        /// <param name="connection">UiPath orchestrator connection info</param>
        /// <param name="parameters">Name, Description, Number of retries, Automatic retry("true"/"false"), Unique reference("true"/"false")</param>
        public static bool CreateQueue(UiPathOrchestratorConnection connection, string[] parameters)
        {
            IRestResponse response = OrchAPI.POSTrequest(connection, "QueueDefinitions", "{\r\n  \"Name\": \"" + parameters[0] + "\",\r\n  \"Description\": \"" + parameters[1] + "\",\r\n  \"MaxNumberOfRetries\": " + parameters[2] + ",\r\n  \"AcceptAutomaticallyRetry\": " + parameters[3] + ",\r\n  \"EnforceUniqueReference\": " + parameters[4] + "\r\n}");

            return(OrchAPI.GetStatus(response));
        }
Esempio n. 6
0
        /// <summary>Returns information about all QUeues in the orchestrator</summary>
        /// <param name="connection">UiPath orchestrator connection info</param>
        public static string GetQueues(UiPathOrchestratorConnection connection)
        {
            IRestResponse response = OrchAPI.GETrequest(connection, "QueueDefinitions");

            return(OrchAPI.ParseJson(response, "value"));
        }
Esempio n. 7
0
        /// <summary>Returns information about all roles in the orchestrator</summary>
        /// <param name="connection">UiPath orchestrator connection info</param>
        public static string GetRoles(UiPathOrchestratorConnection connection)
        {
            IRestResponse response = OrchAPI.GETrequest(connection, "Roles?$expand=Permissions");

            return(OrchAPI.ParseJson(response, "value"));
        }
Esempio n. 8
0
        /// <summary>Activates or deactivates user in orchestrator. Returns bool if it was successful</summary>
        /// <param name="connection">UiPath orchestrator connection info</param>
        /// <param name="ID">ID of the user</param>
        /// <param name="activate">True/False as string</param>
        public static bool deActivateUser(UiPathOrchestratorConnection connection, string ID, string activate)
        {
            IRestResponse response = OrchAPI.POSTrequest(connection, "Users(" + ID + ")/UiPath.Server.Configuration.OData.SetActive", "{\"active\":" + activate + "}");

            return(OrchAPI.GetStatus(response));
        }
Esempio n. 9
0
        /// <summary>Stops or kills job. Returns bool if it was successful</summary>
        /// <param name="connection">UiPath orchestrator connection info</param>
        /// <param name="ID">ID of the process</param>
        /// <param name="strategy">Input "Softstop" to stop process, "Kill" to kill it</param>
        public static bool CancelJob(UiPathOrchestratorConnection connection, string ID, string strategy)
        {
            IRestResponse response = OrchAPI.POSTrequest(connection, "Jobs(" + ID + ")/UiPath.Server.Configuration.OData.StopJob", "{\"strategy\": \"" + strategy + "\"}");

            return(OrchAPI.GetStatus(response));
        }
Esempio n. 10
0
        /// <summary>Returns information about status of the job</summary>
        /// <param name="connection">UiPath orchestrator connection info</param>
        /// <param name="ID">ID of the job</param>
        public static string GetJobStatus(UiPathOrchestratorConnection connection, string ID)
        {
            IRestResponse response = OrchAPI.GETrequest(connection, "Jobs(" + ID + ")");

            return(OrchAPI.ParseJson(response, "State"));
        }