private async Task <Dictionary <long?, JobsStartJobsParameters> > BuildStartJobParameters(string inputArgs, string jobNameSearchTerm = "Monday", string folderNameSearchTerm = "External", string userNameSearchTerm = "DataManager") { //Get process key var release = await _uiPathWebApi110.Releases.GetWithHttpMessagesAsync(filter : $"contains(Name,'{jobNameSearchTerm}') and contains(Description, '{folderNameSearchTerm}')", customHeaders : _headers); var releaseKey = release?.Body?.Value?.FirstOrDefault()?.Key; // Get organization unit Id var folders = await _uiPathWebApi110.Folders.GetWithHttpMessagesAsync(filter : $"Displayname eq '{folderNameSearchTerm}'", customHeaders : _headers); var orgUnitId = folders?.Body?.Value?.FirstOrDefault()?.Id; // Get robot Id //var robots = await _uiPathWebApi110.Robots.GetWithHttpMessagesAsync(filter: $"contains(MachineName,'{userNameSearchTerm}')", customHeaders: _headers, xUIPATHOrganizationUnitId: orgUnitId); var robots = await _uiPathWebApi110.Robots.GetRobotsFromFolderWithHttpMessagesAsync(orgUnitId.ToString(), filter : $"contains(Username,'{userNameSearchTerm}')", customHeaders : _headers); var robot = robots?.Body?.Value?.FirstOrDefault()?.Id; // Start job JobsStartJobsParameters jobsStartJobsParameters = new JobsStartJobsParameters(new StartProcessDto(releaseKey, StartProcessDtoStrategy.Specific, robotIds: new[] { robot }, inputArguments: inputArgs)); return(new Dictionary <long?, JobsStartJobsParameters>() { { orgUnitId, jobsStartJobsParameters } }); }
/// <summary> /// Adds a new job and sets it in Pending state for each robot based on the /// input parameters and notifies the respective robots about the pending job. /// </summary> /// <remarks> /// Client Credentials Flow required permissions: Jobs or Jobs.Write. /// /// Required permissions: Jobs.Create. /// </remarks> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='body'> /// StartInfo - The information required to register the new jobs. /// </param> /// <param name='expand'> /// Indicates the related entities to be represented inline. The maximum depth /// is 2. /// </param> /// <param name='filter'> /// Restricts the set of items returned. The maximum number of expressions is /// 100. /// </param> /// <param name='select'> /// Limits the properties returned in the result. /// </param> /// <param name='orderby'> /// Specifies the order in which items are returned. The maximum number of /// expressions is 5. /// </param> /// <param name='count'> /// Indicates whether the total count of items within a collection are returned /// in the result. /// </param> /// <param name='xUIPATHOrganizationUnitId'> /// Folder/OrganizationUnit Id /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <ODataValueOfIEnumerableOfJobDto> StartJobsAsync(this IJobs operations, JobsStartJobsParameters body = default(JobsStartJobsParameters), string expand = default(string), string filter = default(string), string select = default(string), string orderby = default(string), bool?count = default(bool?), long?xUIPATHOrganizationUnitId = default(long?), CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.StartJobsWithHttpMessagesAsync(body, expand, filter, select, orderby, count, xUIPATHOrganizationUnitId, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Adds a new job and sets it in Pending state for each robot based on the /// input parameters and notifies the respective robots about the pending job. /// </summary> /// <remarks> /// Client Credentials Flow required permissions: Jobs or Jobs.Write. /// /// Required permissions: Jobs.Create. /// </remarks> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='body'> /// StartInfo - The information required to register the new jobs. /// </param> /// <param name='expand'> /// Indicates the related entities to be represented inline. The maximum depth /// is 2. /// </param> /// <param name='filter'> /// Restricts the set of items returned. The maximum number of expressions is /// 100. /// </param> /// <param name='select'> /// Limits the properties returned in the result. /// </param> /// <param name='orderby'> /// Specifies the order in which items are returned. The maximum number of /// expressions is 5. /// </param> /// <param name='count'> /// Indicates whether the total count of items within a collection are returned /// in the result. /// </param> /// <param name='xUIPATHOrganizationUnitId'> /// Folder/OrganizationUnit Id /// </param> public static ODataValueOfIEnumerableOfJobDto StartJobs(this IJobs operations, JobsStartJobsParameters body = default(JobsStartJobsParameters), string expand = default(string), string filter = default(string), string select = default(string), string orderby = default(string), bool?count = default(bool?), long?xUIPATHOrganizationUnitId = default(long?)) { return(operations.StartJobsAsync(body, expand, filter, select, orderby, count, xUIPATHOrganizationUnitId).GetAwaiter().GetResult()); }