InstanceEntityBase TableEntityToHistoryEvent(AzureTableCompositeTableEntity entity)
        {
            AzureTableOrchestrationHistoryEventEntity workItemEntity     = null;
            AzureTableOrchestrationStateEntity        historyStateEntity = null;

            if ((workItemEntity = entity as AzureTableOrchestrationHistoryEventEntity) != null)
            {
                return(new OrchestrationWorkItemInstanceEntity
                {
                    InstanceId = workItemEntity.InstanceId,
                    ExecutionId = workItemEntity.ExecutionId,
                    SequenceNumber = workItemEntity.SequenceNumber,
                    EventTimestamp = workItemEntity.TaskTimeStamp,
                    HistoryEvent = workItemEntity.HistoryEvent
                });
            }
            else if ((historyStateEntity = entity as AzureTableOrchestrationStateEntity) != null)
            {
                return(new OrchestrationStateInstanceEntity {
                    State = historyStateEntity.State
                });
            }
            else
            {
                throw new InvalidOperationException($"Invalid entity event type: {entity.GetType()}");
            }
        }
Exemplo n.º 2
0
        internal override IEnumerable <ITableEntity> BuildDenormalizedEntities()
        {
            var entity1 = new AzureTableOrchestrationStateEntity(State);

            entity1.PartitionKey = AzureTableConstants.InstanceStatePrefix;
            entity1.RowKey       = AzureTableConstants.InstanceStateExactRowPrefix +
                                   AzureTableConstants.JoinDelimiter + State.OrchestrationInstance.InstanceId +
                                   AzureTableConstants.JoinDelimiter + State.OrchestrationInstance.ExecutionId;

            return(new [] { entity1 });
            // TODO : additional indexes for efficient querying in the future
        }
        /// <summary>
        /// Gets the orchestration state for a given instance and execution id
        /// </summary>
        /// <param name="instanceId">The instance id to return state for</param>
        /// <param name="executionId">The execution id to return state for</param>
        /// <returns>The matching orchestation state or null if not found</returns>
        public async Task <OrchestrationStateInstanceEntity> GetOrchestrationStateAsync(string instanceId, string executionId)
        {
            AzureTableOrchestrationStateEntity result =
                (await this.tableClient.QueryOrchestrationStatesAsync(
                     new OrchestrationStateQuery().AddInstanceFilter(instanceId, executionId)).ConfigureAwait(false)).FirstOrDefault();


            if (result == null)
            {
                // Query from JumpStart table
                result = (await this.tableClient.QueryJumpStartOrchestrationsAsync(
                              new OrchestrationStateQuery()
                              .AddInstanceFilter(instanceId, executionId))
                          .ConfigureAwait(false))
                         .FirstOrDefault();
            }

            return((result != null) ? TableStateToStateEvent(result.State) : null);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Gets the orchestration state for a given instance and execution id
        /// </summary>
        /// <param name="instanceId">The instance id to return state for</param>
        /// <param name="executionId">The execution id to return state for</param>
        /// <returns>The matching orchestration state or null if not found</returns>
        public async Task <OrchestrationStateInstanceEntity> GetOrchestrationStateAsync(string instanceId, string executionId)
        {
            AzureTableOrchestrationStateEntity result =
                (await this.tableClient.QueryOrchestrationStatesAsync(
                     new OrchestrationStateQuery().AddInstanceFilter(instanceId, executionId)).ConfigureAwait(false)).FirstOrDefault();

            // ReSharper disable once ConvertIfStatementToNullCoalescingExpression
            if (result == null)
            {
                // Query from JumpStart table
                result = (await this.tableClient.QueryJumpStartOrchestrationsAsync(
                              new OrchestrationStateQuery()
                              .AddInstanceFilter(instanceId, executionId))
                          .ConfigureAwait(false))
                         .FirstOrDefault();
            }

            return(result != null?TableStateToStateEvent(result.State) : null);
        }