public async override Task <ActionResult> RunAsync(ActionProperties properties) { ActionResult results = new ActionResult() { Result = Intelledox.QAWizard.Design.ActionResultType.Success }; try { foreach (var doc in properties.Documents) { string fileName = properties.JobGuid.ToString() + " - " + doc.DisplayName + doc.Extension; using (var docStream = await properties.GetDocumentStreamAsync(doc)) // Write or send the document to a file, external service, etc using (FileStream file = new FileStream(Path.Combine("C:\\temp\\", fileName), FileMode.Create, FileAccess.Write)) { await docStream.CopyToAsync(file); } } } catch (Exception ex) { properties.AddMessage(ex.Message, "Document Action Error"); results.Result = Intelledox.QAWizard.Design.ActionResultType.Fail; } return(results); }
private async Task <string> GetDocumentTextAsync(ActionProperties properties, Document document) { Stream stream = await properties.GetDocumentStreamAsync(document); Stream documentStream = stream; stream = null; string result; try { using (StreamReader reader = new StreamReader(documentStream)) { result = reader.ReadToEnd(); } } finally { if (documentStream != null) { ((IDisposable)documentStream).Dispose(); } } return(result); }