public async Task AggregateAnalysisAsync([ActivityTrigger] FileAnalysisResult analysisResult, ILogger log) { if (analysisResult != null) { await _dataService.AddAsync(analysisResult); } else { log.LogError($"Analysis result is empty, cannot insert record."); } }
public async Task <FileAnalysisResult> AnalyzeFileContentAsync(InputFileData inputFileData) { if (inputFileData.FileContentType == FileContentType.PDF) { var sasToken = _storageService.GenerateSasToken(); inputFileData.FilePath = $"{inputFileData.FilePath}?{sasToken}"; var textFromTheInputDocument = await _ocrScannerService.ScanDocumentAndGetResultsAsync(inputFileData.FilePath); var sentimentAnalysisResponse = await _textAnalyticsClient.AnalyzeSentimentAsync(textFromTheInputDocument); if (sentimentAnalysisResponse != null) { var sentimentAnalysisResult = sentimentAnalysisResponse.Value; var fileAnalysisResult = new FileAnalysisResult(); fileAnalysisResult.SentimentValues.Add(sentimentAnalysisResult.Sentiment.ToString()); return(fileAnalysisResult); } } throw new ArgumentException("Input file shuld be either TXT or PDF file."); }
/** * 확장자 분리시킴 */ public static FileAnalysisResult analysisfileInfo(String path) { FileAnalysisResult result = new FileAnalysisResult(); result.Path = path; try { FileEntity fileEntity = new FileEntity(); fileEntity.주소 = result.Path; fileEntity.확장자 = Path.GetExtension(path); fileEntity.일명 = Path.GetFileName(path); fileEntity.순수파일명 = Path.GetFileNameWithoutExtension(path); result.Data = fileEntity; } catch (Exception e) { result.Error = e.Message; } return(result); }
public FileVIewModel(FileAnalysisResult result) { }
public async Task <FileAnalysisResult> AnalyzeFileContentAsync(InputFileData inputFileData) { FileAnalysisResult fileAnalysisResult = new FileAnalysisResult(); var sasToken = _storageService.GenerateSasToken(); var videoUrl = $"{inputFileData.FilePath}?{sasToken}"; AddApiKeyHeader(); var accountAccessToken = await GetVideoIndexerAccountAccessTokenAsync(); var content = new MultipartFormDataContent(); var queryParams = CreateQueryString( new Dictionary <string, string>() { { "accessToken", accountAccessToken }, { "name", $"new-video-{Guid.NewGuid()}" }, { "privacy", "private" }, { "partition", "partition" }, { "videoUrl", videoUrl }, }); var uploadRequestResult = await _httpClient.PostAsync($"{_videoIndexerServiceConfiguration.Endpoint}/{_videoIndexerServiceConfiguration.Location}/Accounts/{_videoIndexerServiceConfiguration.AccountId}/Videos?{queryParams}", content); var uploadResult = await uploadRequestResult.Content.ReadAsStringAsync(); var videoId = JsonConvert.DeserializeObject <dynamic>(uploadResult)["id"]; var videoTokenRequestResult = await _httpClient.GetAsync($"{_videoIndexerServiceConfiguration.Endpoint}/auth/" + $"{_videoIndexerServiceConfiguration.Location}/Accounts/" + $"{_videoIndexerServiceConfiguration.AccountId}/Videos/{videoId}/AccessToken?allowEdit=true"); var videoAccessToken = await videoTokenRequestResult.Content.ReadAsStringAsync(); videoAccessToken = videoAccessToken.Replace("\"", ""); RemoveApiKeyHeader(); queryParams = CreateQueryString( new Dictionary <string, string>() { { "accessToken", videoAccessToken }, { "language", "English" } }); AudioVideoAnalysisResult audioVideoAnalysisResult = null; while (true) { await Task.Delay(10000); var videoGetIndexRequestResult = await _httpClient.GetAsync($"{_videoIndexerServiceConfiguration.Endpoint}/{_videoIndexerServiceConfiguration.Location}/Accounts/" + $"{_videoIndexerServiceConfiguration.AccountId}/Videos/{videoId}/Index?{queryParams}"); var videoGetIndexResult = await videoGetIndexRequestResult.Content.ReadAsStringAsync(); var processingState = JsonConvert.DeserializeObject <dynamic>(videoGetIndexResult)["state"]; if (processingState != "Uploaded" && processingState != "Processing") { audioVideoAnalysisResult = JsonConvert.DeserializeObject <AudioVideoAnalysisResult>(videoGetIndexResult); break; } } if (audioVideoAnalysisResult != null) { if (audioVideoAnalysisResult.summarizedInsights != null) { foreach (var sentimentValue in audioVideoAnalysisResult.summarizedInsights.sentiments) { fileAnalysisResult.SentimentValues.Add(sentimentValue.sentimentKey); } } } return(fileAnalysisResult); }
private void btn_open_file_Click(object sender, RoutedEventArgs e) { FileAnalysisResult selectedObject = ((sender as System.Windows.Controls.Button).DataContext as FileAnalysisResult); Process.Start(selectedObject.Path); }