Beispiel #1
0
        public HandleResult HandleEvent(
            Guid processInstanceId,
            Guid tokenId,
            object eventData
            )
        {
            var instance = InstancesStore.GetById(processInstanceId);

            if (instance == null)
            {
                throw new InvalidOperationException("Instance not found.");
            }

            var model = ModelsStore.GetById(Guid.Parse(instance.ProcessModelId));

            if (model == null)
            {
                throw new InvalidOperationException("Instance process model not found.");
            }

            var context = new ExecutionContext(this, model, instance, instance.Token.FindById(tokenId), null);

            var tokens = instance.HandleEvent(context, eventData);

            InstancesStore.Store(instance);

            return(new HandleResult(
                       Guid.Parse(model.Id),
                       Guid.Parse(instance.Id),
                       tokens.Select(token => token.Id).ToList()));
        }
Beispiel #2
0
        public void Attach(ProcessInstance instance)
        {
            if (instance == null)
            {
                throw new ArgumentNullException(nameof(instance));
            }

            if (ModelsStore.GetById(Guid.Parse(instance.ProcessModelId)) == null)
            {
                throw new ArgumentException("Trying to attach an instance with an unrecognized model.", nameof(instance));
            }


            InstancesStore.Store(instance);
        }