public static string ProcessPDF([ActivityTrigger] DistributorFile distributorFile, ILogger log) { log.LogInformation($"Processing PDF file {distributorFile.FilePath}"); JSONMessage jsonMessage = new JSONMessage() { OriginalFilePath = distributorFile.FilePath, FileName = Path.GetFileName(distributorFile.FilePath), FileLength = distributorFile.FileContents.Length }; return(JsonConvert.SerializeObject(jsonMessage)); }
public static async Task <string> RunOrchestrator( [OrchestrationTrigger] IDurableOrchestrationContext context, ILogger log) { DistributorFile distributorFile = context.GetInput <DistributorFile>(); log.LogInformation($"Running orchestration on file {distributorFile.FilePath}"); string json = string.Empty; if (Path.GetExtension(distributorFile.FilePath) == ".csv") { json = await context.CallActivityAsync <string>("FileProcessor_ProcessCSV", distributorFile); //DurableHttpResponse durableHttpResponse = await context.CallHttpAsync(HttpMethod.Post, new Uri("http://localhost:7072/api/FileProcessor_ProcessCSV"), JsonConvert.SerializeObject(distributorFile)); //if (durableHttpResponse.StatusCode == System.Net.HttpStatusCode.OK) //{ // json = durableHttpResponse.Content; //} } else if (Path.GetExtension(distributorFile.FilePath) == ".pdf") { json = await context.CallActivityAsync <string>("FileProcessor_ProcessPDF", distributorFile); //DurableHttpResponse durableHttpResponse = await context.CallHttpAsync(HttpMethod.Post, new Uri("http://localhost:7072/api/FileProcessor_ProcessPDF"), JsonConvert.SerializeObject(distributorFile)); //if (durableHttpResponse.StatusCode == System.Net.HttpStatusCode.OK) //{ // json = durableHttpResponse.Content; //} } if (!string.IsNullOrEmpty(json)) { // Write JSON to Service Bus Message message = new Message(Encoding.UTF8.GetBytes(json)); message.UserProperties["FileType"] = Path.GetExtension(distributorFile.FilePath); try { await _topicClient.SendAsync(message); } catch (ServiceBusException ex) { // If we reach this code, the retry policy was unable to handle the exception // Log the exception and re-throw log.LogError(ex.Message); throw; } } return(json); }
public static async Task BlobStart([BlobTrigger("sftpupload/{name}", Connection = "BlobStorageConnString")] Stream myBlob, string name, [DurableClient] IDurableOrchestrationClient starter, ILogger log) { string blobContents = string.Empty; using (StreamReader reader = new StreamReader(myBlob)) { blobContents = reader.ReadToEnd(); } DistributorFile distributorFile = new DistributorFile() { FilePath = name, FileContents = blobContents }; string instanceId = await starter.StartNewAsync <DistributorFile>("FileOrchestrator", distributorFile); }