/// <summary> /// Checks for all conversational analytics requests that were marked as running if they have completed and sets a new state accordingly. /// </summary> /// <param name="audioFileInfos">Enumerable for audioFiles.</param> /// <returns>True if all requests completed, else false.</returns> public async Task <bool> ConversationalRequestsCompleted(IEnumerable <AudioFileInfo> audioFileInfos) { if (!IsConversationalPiiEnabled() || !audioFileInfos.Where(audioFileInfo => audioFileInfo.TextAnalyticsRequests.ConversationRequests != null).Any()) { return(true); } var conversationRequests = audioFileInfos.SelectMany(audioFileInfo => audioFileInfo.TextAnalyticsRequests.ConversationRequests).Where(text => text.Status == TextAnalyticsRequestStatus.Running); var runningJobsCount = 0; foreach (var textAnalyticsJob in conversationRequests) { var response = await ConversationAnalysisClient.GetAnalyzeConversationJobStatusAsync(Guid.Parse(textAnalyticsJob.Id)).ConfigureAwait(false); if (response.IsError) { continue; } var analysisResult = JsonConvert.DeserializeObject <AnalyzeConversationsResult>(response.Content.ToString()); if (analysisResult.Tasks.InProgress != 0) { // some jobs are still running. runningJobsCount++; } } return(runningJobsCount == 0); }