public void BindProcessToNewScheme(ProcessInstance processInstance, bool resetIsDeterminingParametersChanged)
        {
            var cache =
                Store.GetOrCreateCache <Guid, WorkflowProcessInstance>(IgniteConstants.WorkflowProcessInstanceCacheName);

            WorkflowProcessInstance oldProcess = null;

            try
            {
                oldProcess = cache.Get(processInstance.ProcessId);
            }
            catch (KeyNotFoundException)
            {
            }

            if (oldProcess == null)
            {
                throw new ProcessNotFoundException(processInstance.ProcessId);
            }

            oldProcess.SchemeId = processInstance.SchemeId;
            if (resetIsDeterminingParametersChanged)
            {
                oldProcess.IsDeterminingParametersChanged = false;
            }
            cache.Put(oldProcess.Id, oldProcess);
        }
        public SchemeDefinition <XElement> GetProcessSchemeByProcessId(Guid processId)
        {
            WorkflowProcessInstance processInstance = null;
            var cache =
                Store.GetOrCreateCache <Guid, WorkflowProcessInstance>(IgniteConstants.WorkflowProcessInstanceCacheName);

            try
            {
                processInstance = cache.Get(processId);
            }
            catch (KeyNotFoundException)
            {
            }

            if (processInstance == null)
            {
                throw new ProcessNotFoundException(processId);
            }

            if (!processInstance.SchemeId.HasValue)
            {
                throw SchemeNotFoundException.Create(processId, SchemeLocation.WorkflowProcessInstance);
            }

            var schemeDefinition = GetProcessSchemeBySchemeId(processInstance.SchemeId.Value);

            schemeDefinition.IsDeterminingParametersChanged = processInstance.IsDeterminingParametersChanged;
            return(schemeDefinition);
        }
        private WorkflowProcessInstance GetProcessInstance(Guid processId)
        {
            var cache =
                Store.GetOrCreateCache <Guid, WorkflowProcessInstance>(IgniteConstants.WorkflowProcessInstanceCacheName);

            WorkflowProcessInstance processInstance = null;

            try
            {
                processInstance = cache.Get(processId);
            }
            catch (KeyNotFoundException)
            {
            }

            if (processInstance == null)
            {
                throw new ProcessNotFoundException(processId);
            }
            return(processInstance);
        }
        public void InitializeProcess(ProcessInstance processInstance)
        {
            var cache =
                Store.GetOrCreateCache <Guid, WorkflowProcessInstance>(IgniteConstants.WorkflowProcessInstanceCacheName);

            if (cache.ContainsKey(processInstance.ProcessId))
            {
                throw new ProcessAlreadyExistsException(processInstance.ProcessId);
            }

            var newProcess = new WorkflowProcessInstance
            {
                Id              = processInstance.ProcessId,
                SchemeId        = processInstance.SchemeId,
                ActivityName    = processInstance.ProcessScheme.InitialActivity.Name,
                StateName       = processInstance.ProcessScheme.InitialActivity.State,
                RootProcessId   = processInstance.RootProcessId,
                ParentProcessId = processInstance.ParentProcessId,
                Persistence     = new List <WorkflowProcessInstancePersistence>()
            };

            cache.Put(newProcess.Id, newProcess);
        }