Пример #1
0
        public override int GetHashCode()
        {
            unchecked
            {
                var hashCode = 1561563491;

                hashCode = (hashCode * 157) + Id.GetHashCode();
                hashCode = (hashCode * 157) + WorkflowID.GetHashCode();
                hashCode = (hashCode * 157) + ExecutionID.GetHashCode();
                hashCode = (hashCode * 157) + ExecutionOrigin.GetHashCode();
                hashCode = (hashCode * 157) + IsSubExecution.GetHashCode();
                hashCode = (hashCode * 157) + IsRemoteWorkflow.GetHashCode();
                hashCode = (hashCode * 157) + WorkflowName.GetHashCode();
                hashCode = (hashCode * 157) + AuditType.GetHashCode();
                hashCode = (hashCode * 157) + PreviousActivity.GetHashCode();
                hashCode = (hashCode * 157) + PreviousActivityType.GetHashCode();
                hashCode = (hashCode * 157) + PreviousActivityId.GetHashCode();
                hashCode = (hashCode * 157) + NextActivity.GetHashCode();
                hashCode = (hashCode * 157) + NextActivityType.GetHashCode();
                hashCode = (hashCode * 157) + NextActivityId.GetHashCode();
                hashCode = (hashCode * 157) + ServerID.GetHashCode();
                hashCode = (hashCode * 157) + ParentID.GetHashCode();
                hashCode = (hashCode * 157) + ExecutingUser.GetHashCode();
                hashCode = (hashCode * 157) + ExecutionOriginDescription.GetHashCode();
                hashCode = (hashCode * 157) + ExecutionToken.GetHashCode();
                hashCode = (hashCode * 157) + AdditionalDetail.GetHashCode();
                hashCode = (hashCode * 157) + Environment.GetHashCode();
                hashCode = (hashCode * 157) + AuditDate.GetHashCode();

                return(hashCode);
            }
        }
Пример #2
0
        public override IEnumerator ReceivePayload(VisualPayload payload)
        {
            var filename = TraceFilename.GetFirstValue(payload.Data);

            var trace = Trace.LoadFromFile(filename);

            var newExecution = new Execution
            {
                CbAuthor      = CbAuthor.GetFirstValue(payload.Data),
                CbId          = 0,
                ExecutionId   = (uint)ExecutionID.GetFirstValue(payload.Data),
                PovType       = PovType.GetFirstValue(payload.Data),
                RequestId     = (uint)RequestId.GetFirstValue(payload.Data),
                ServiceId     = new ServiceIdentifier(),
                RequestNature = RequestNature.GetFirstValue(payload.Data),
                Success       = Success.GetFirstValue(payload.Data),
                Traces        = new List <Trace> {
                    trace
                }
            };

            var executionMutable = ExecutionAdapter.ExecutionToMutable(
                newExecution,
                IncludeMemory.GetFirstValue(payload.Data),
                PovType.GetFirstValue(payload.Data));

            ExecutionTarget.SetValue(executionMutable, payload.Data);

            var iterator = Router.TransmitAll(payload);

            while (iterator.MoveNext())
            {
                yield return(null);
            }
        }
Пример #3
0
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("Exec");
            sb.Append(ExecutionID.ToString("{0:000000}"));
            sb.Append(" ");
            sb.Append(this.SQL.Replace("\n", " _ "));
            if (null != this.Parameters && this.Parameters.Length > 0)
            {
                sb.Append(", Parameters : ");
                foreach (object obj in this.Parameters)
                {
                    if (null == obj || obj is DBNull)
                    {
                        sb.Append("[NULL]");
                    }
                    else
                    {
                        sb.Append("'");
                        sb.Append("'");
                        sb.Append(obj.ToString());
                    }
                    sb.Append(",");
                }

                sb.Length -= 1;
            }
            sb.Append("Duration : ");
            sb.Append(this.Ended - this.Started);

            return(sb.ToString());
        }
Пример #4
0
        public override int GetHashCode()
        {
            var hashCode = -2125768153;

            hashCode = hashCode * -1521134295 + Event.GetHashCode();
            hashCode = hashCode * -1521134295 + ExecutionID.GetHashCode();
            return(hashCode);
        }
Пример #5
0
        public StepData GetNextToCompensate(
            ExecutionID executionID)
        {
            StepData executionData = this.LastOrDefault(s =>
                                                        s.ExecutionID == executionID &&
                                                        s.CompensationData == null);

            return(executionData);
        }
Пример #6
0
        public StepData GetLatestByStepName(
            ExecutionID executionID,
            string stepName)
        {
            StepData executionData = this.LastOrDefault(s =>
                                                        s.ExecutionID == executionID &&
                                                        s.StepName == stepName);

            return(executionData);
        }
Пример #7
0
        public StepData GetLatestCompensationByStepName(
            ExecutionID executionID,
            string stepName)
        {
            StepData executionData = this.LastOrDefault(s =>
                                                        s.ExecutionID == executionID &&
                                                        (s.CompensationData == null || s.CompensationData.EndTime == null) &&
                                                        s.StepName == stepName);

            return(executionData);
        }
Пример #8
0
        public StepData GetLastWithStepName(
            ExecutionID executionID,
            string stepName)
        {
            StepData executionData = this.LastOrDefault();

            if (executionData != null &&
                executionData.ExecutionID == executionID &&
                executionData.StepName == stepName)
            {
                return(executionData);
            }

            return(null);
        }
 public SagaExecutionState()
 {
     History     = new SagaHistory();
     ExecutionID = ExecutionID.Empty();
 }
Пример #10
0
 public SagaExecutionState()
 {
     History      = new SagaHistory();
     ExecutionID  = ExecutionID.Empty();
     CanBeResumed = true;
 }
        private async Task <ISaga> ExecuteSaga(
            ISagaEvent @event, ISagaModel model,
            ISaga saga,
            Guid sagaID,
            IDictionary <string, object> executionValues,
            bool resume)
        {
            bool sagaStarted = false;

            try
            {
                serviceProvider.
                GetRequiredService <ObservableRegistrator>().
                Initialize();

                await messageBus.
                Publish(new ExecutionStartMessage(SagaID.From(sagaID), model));

                sagaStarted = true;

                if (saga == null)
                {
                    saga = await sagaPersistance.Get(sagaID);
                }

                if (saga == null)
                {
                    throw new SagaInstanceNotFoundException();
                }

                if (saga.ExecutionState.IsDeleted)
                {
                    throw new CountNotExecuteDeletedSagaException(sagaID);
                }

                if (!resume)
                {
                    if (saga.IsIdle())
                    {
                        saga.ExecutionState.CurrentError = null;
                        saga.ExecutionState.ExecutionID  = ExecutionID.New();
                        if (model.HistoryPolicy == ESagaHistoryPolicy.StoreOnlyCurrentStep)
                        {
                            saga.ExecutionState.History.Clear();
                        }

                        saga.ExecutionValues.
                        Set(executionValues);

                        saga.ExecutionState.
                        CurrentEvent = @event ?? new EmptyEvent();
                    }
                    else
                    {
                        throw new SagaNeedToBeResumedException(saga.Data.ID);
                    }

                    logger.
                    LogInformation($"Executing saga: {saga.Data.ID}");
                }
                else
                {
                    logger.
                    LogInformation($"Resuming saga: {saga.Data.ID}");
                }

                ExecuteActionCommandHandler handler = serviceProvider.
                                                      GetRequiredService <ExecuteActionCommandHandler>();

                return(await handler.Handle(new ExecuteActionCommand
                {
                    Async = AsyncExecution.False(),
                    Saga = saga,
                    Model = model
                }));
            }
            catch (Exception ex)
            {
                if (sagaStarted)
                {
                    await messageBus.Publish(
                        new ExecutionEndMessage(SagaID.From(sagaID)));
                }

                if (ex is SagaStepException sagaStepException && sagaStepException?.OriginalException != null)
                {
                    throw sagaStepException.OriginalException;
                }

                throw;
            }
        }