private async Task CreateWorkItem(IDurableOrchestrationContext context, PullRequestStateContext pullRequestStateContext, CommandHookContext commandHookContext) { CreatedReviewComment parentReviewComment = GetParentReviewCommentAsync(pullRequestStateContext, commandHookContext); var issue = await GetIssueAsync(context, pullRequestStateContext, parentReviewComment); // Create WorkItem that match WorkItem Provider var workItem = await context.CallActivityAsync <WorkItem>( nameof(CommandOrchestrator) + "_" + BotConfiguration.WorkItemProvider + "_CreateWorkItem", new CreateWorkItemContext() { Issue = issue, CreatedReviewComment = parentReviewComment, PullRequestId = pullRequestStateContext.PullRequestId }); // Create Comment that match Repository Provider await context.CallActivityAsync( nameof(CommandOrchestrator) + "_" + BotConfiguration.RepositoryProvider + "_CreateWorkItemReplyComment", new CreateWorkItemReplyCommentContext() { WorkItem = workItem, InReplyTo = parentReviewComment.CommentId, PullRequestId = pullRequestStateContext.PullRequestId }); // Update the PullRequestStateContext pullRequestStateContext.Add(new CreatedWorkItem() { CommentId = parentReviewComment.CommentId, }); }
private async Task TransitIssueAsync(IDurableOrchestrationContext context, PullRequestStateContext pullRequestStateContext, CommandHookContext commandHookContext) { // GetIssue that match Scan Provider CreatedReviewComment parentReviewComment = GetParentReviewCommentAsync(pullRequestStateContext, commandHookContext); var issue = await GetIssueAsync(context, pullRequestStateContext, parentReviewComment); // Update the Issue state if (issue.Status == "OPEN" || issue.Status == "REOPEN") { await context.CallActivityAsync(nameof(CommandOrchestrator) + "_" + parentReviewComment.ScanProvider + "_TransitIssue", new TransitIssueContext() { CreatedReviewComment = parentReviewComment, Transition = CommandRouter.GetTransition(commandHookContext.Command), Issue = issue }); // Create Comment that match Repository Provider await context.CallActivityAsync( nameof(CommandOrchestrator) + "_" + BotConfiguration.RepositoryProvider + "_CreateIssueTransitionReplyComment", new CreateIssueTransitionReplyCommentContext() { PullRequestId = commandHookContext.PullRequestId, InReplyTo = commandHookContext.ReplyToId, Command = commandHookContext.Command, Issue = issue }); } else // Issue is already resolved or confirmed { await context.CallActivityAsync(nameof(CommandOrchestrator) + "_" + BotConfiguration.RepositoryProvider + "_CreateSimpleReplyComment", new CreateSimpleReplyCommentContext() { Body = "The issue is already resolved or confirmed.", InReplyTo = commandHookContext.ReplyToId, PullRequestId = commandHookContext.PullRequestId }); } }
private CreatedReviewComment GetParentReviewCommentAsync(PullRequestStateContext pullRequestStateContext, CommandHookContext commandHookContext) { return(pullRequestStateContext.CreatedReviewComment.FirstOrDefault(p => p.CommentId.ToString() == commandHookContext.ReplyToId)); }