public static WorkflowCorrelationTableRecord Run(
            [ActivityTrigger] WorkflowCorrelation workflowCorrelation,
            TraceWriter log)
        {
            log.Info($"Persisting Correlation");

            CloudStorageAccount storageAccount = CloudStorageAccount.Parse(Environment.GetEnvironmentVariable("Blob:StorageConnection"));
            CloudTableClient    tableClient    = storageAccount.CreateCloudTableClient();
            CloudTable          table          = tableClient.GetTableReference("WorkflowCorrelations");

            TableOperation operation = TableOperation.Retrieve <WorkflowCorrelationTableEntity>("ApprovalWorkflow", workflowCorrelation.EntityId);
            TableResult    result    = table.ExecuteAsync(operation).Result;

            string entityId = workflowCorrelation.EntityId;

            if (result.Result != null)
            {
                // When the EntityId already exists, append the timestamp
                entityId = $"{workflowCorrelation.EntityId}_{DateTime.Now.ToString("yyyyMMddTHHmmssfff")}";
            }

            return(new WorkflowCorrelationTableRecord {
                PartitionKey = "ApprovalWorkflow", RowKey = entityId, InstanceId = workflowCorrelation.WorkflowInstanceId
            });
        }
Beispiel #2
0
 public void Correlate()
 {
     if (this.Correlation.WorkflowId == Guid.Empty)
     {
         string serialized = string.Empty;
         serialized = File.ReadAllText(_storePath("Correlation"));
         WorkflowCorrelation correlation = WorkflowSerialization.DeSerialize <WorkflowCorrelation>(serialized);
         this.Correlation.WorkflowId = correlation.WorkflowId;
     }
 }