bool CompareStateEntity(OrchestrationStateEntity expected, OrchestrationStateEntity actual)
 {
     return
         (expected.State.OrchestrationInstance.InstanceId.Equals(actual.State.OrchestrationInstance.InstanceId) &&
          expected.State.OrchestrationInstance.ExecutionId.Equals(actual.State.OrchestrationInstance.ExecutionId) &&
          expected.State.Name.Equals(actual.State.Name) &&
          expected.State.CreatedTime.Equals(actual.State.CreatedTime) &&
          expected.State.LastUpdatedTime.Equals(actual.State.LastUpdatedTime) &&
          ((expected.State.CompletedTime == null && actual.State.CompletedTime == null) ||
           expected.State.CompletedTime.Equals(actual.State.CompletedTime)) &&
          expected.State.Status.Equals(actual.State.Status) &&
          expected.State.Input.Equals(actual.State.Input) &&
          ((string.IsNullOrEmpty(expected.State.Output) && string.IsNullOrEmpty(actual.State.Output)) ||
           expected.State.Output.Equals(actual.State.Output)));
 }
Ejemplo n.º 2
0
        /// <summary>
        ///     Get a list of orchestration states from the instance storage table for the
        ///     specified execution (generation) of the specified instance.
        ///     Throws if an Azure Storage account was not specified in the constructor.
        /// </summary>
        /// <param name="instanceId">Instance id</param>
        /// <param name="executionId">Exectuion id</param>
        /// <returns>The OrchestrationState of the specified instanceId or null if not found</returns>
        public async Task <OrchestrationState> GetOrchestrationStateAsync(string instanceId, string executionId)
        {
            if (string.IsNullOrEmpty(instanceId))
            {
                throw new ArgumentException("instanceId");
            }

            if (string.IsNullOrEmpty(executionId))
            {
                throw new ArgumentException("executionId");
            }

            ThrowIfInstanceStoreNotConfigured();
            OrchestrationStateEntity stateEntity = (await tableClient.QueryOrchestrationStatesAsync(
                                                        new OrchestrationStateQuery()
                                                        .AddInstanceFilter(instanceId, executionId)).ConfigureAwait(false))
                                                   .FirstOrDefault();

            return(stateEntity != null ? stateEntity.State : null);
        }
Ejemplo n.º 3
0
        string GetNormalizedStateEntityTrace(int index, string message, OrchestrationStateEntity stateEntity)
        {
            string serializedHistoryEvent = Utils.EscapeJson(JsonConvert.SerializeObject(stateEntity.State));
            int    historyEventLength     = serializedHistoryEvent.Length;

            if (historyEventLength > MaxDisplayStringLengthForAzureTableColumn)
            {
                serializedHistoryEvent =
                    serializedHistoryEvent.Substring(0, MaxDisplayStringLengthForAzureTableColumn) +
                    " ....(truncated)..]";
            }

            return
                (GetFormattedLog(
                     string.Format(message + " - #{0} - Instance Id: {1}, Execution Id: {2}, State Length: {3}\n{4}",
                                   index,
                                   stateEntity.State != null && stateEntity.State.OrchestrationInstance != null
                            ? stateEntity.State.OrchestrationInstance.InstanceId
                            : string.Empty,
                                   stateEntity.State != null && stateEntity.State.OrchestrationInstance != null
                            ? stateEntity.State.OrchestrationInstance.ExecutionId
                            : string.Empty,
                                   historyEventLength, serializedHistoryEvent)));
        }