Ejemplo n.º 1
0
 public void InitializeProcess(ProcessInstance processInstance)
 {
     using (var scope = PredefinedTransactionScopes.ReadCommittedSupressedScope)
     {
         using (var context = CreateContext())
         {
             var oldProcess = context.WorkflowProcessInstances.SingleOrDefault(wpi => wpi.Id == processInstance.ProcessId);
             if (oldProcess != null)
             {
                 throw new ProcessAlredyExistsException();
             }
             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
             };
             context.WorkflowProcessInstances.InsertOnSubmit(newProcess);
             context.SubmitChanges();
         }
         scope.Complete();
     }
 }
Ejemplo n.º 2
0
 public bool IsProcessExists(Guid processId)
 {
     using (OracleConnection connection = new OracleConnection(ConnectionString))
     {
         return(WorkflowProcessInstance.SelectByKey(connection, processId) != null);
     }
 }
 public void DeleteProcess(Guid processId)
 {
     using (NpgsqlConnection connection = new NpgsqlConnection(ConnectionString))
     {
         WorkflowProcessInstance.Delete(connection, processId);
         WorkflowProcessInstanceStatus.Delete(connection, processId);
         WorkflowProcessInstancePersistence.DeleteByProcessId(connection, processId);
         WorkflowProcessTransitionHistory.DeleteByProcessId(connection, processId);
         WorkflowProcessTimer.DeleteByProcessId(connection, processId);
     }
 }
Ejemplo n.º 4
0
 private WorkflowProcessInstance GetProcessInstance(Guid processId)
 {
     using (OracleConnection connection = new OracleConnection(ConnectionString))
     {
         var processInstance = WorkflowProcessInstance.SelectByKey(connection, processId);
         if (processInstance == null)
         {
             throw new ProcessNotFoundException();
         }
         return(processInstance);
     }
 }
Ejemplo n.º 5
0
        public void DeleteProcess(Guid processId)
        {
            using (SqlConnection connection = new SqlConnection(ConnectionString))
            {
                connection.Open();

                using (var transaction = connection.BeginTransaction())
                {
                    WorkflowProcessInstance.Delete(connection, processId, transaction);
                    WorkflowProcessInstanceStatus.Delete(connection, processId, transaction);
                    WorkflowProcessInstancePersistence.DeleteByProcessId(connection, processId, transaction);
                    WorkflowProcessTransitionHistory.DeleteByProcessId(connection, processId, transaction);
                    WorkflowProcessTimer.DeleteByProcessId(connection, processId, null, transaction);
                    transaction.Commit();
                }
            }
        }
Ejemplo n.º 6
0
        private WorkflowProcessInstance GetProcessInstance(Guid processId)
        {
            WorkflowProcessInstance result;

            using (PredefinedTransactionScopes.ReadCommittedSupressedScope)
            {
                using (WorkflowPersistenceModelDataContext workflowPersistenceModelDataContext = base.CreateContext())
                {
                    WorkflowProcessInstance workflowProcessInstance = workflowPersistenceModelDataContext.WorkflowProcessInstances.SingleOrDefault((WorkflowProcessInstance wpi) => wpi.Id == processId);
                    if (workflowProcessInstance == null)
                    {
                        throw new ProcessNotFoundException();
                    }
                    result = workflowProcessInstance;
                }
            }
            return(result);
        }
        public void BindProcessToNewScheme(ProcessInstance processInstance, bool resetIsDeterminingParametersChanged)
        {
            using (NpgsqlConnection connection = new NpgsqlConnection(ConnectionString))
            {
                var oldProcess = WorkflowProcessInstance.SelectByKey(connection, processInstance.ProcessId);
                if (oldProcess == null)
                {
                    throw new ProcessNotFoundException();
                }

                oldProcess.SchemeId = processInstance.SchemeId;
                if (resetIsDeterminingParametersChanged)
                {
                    oldProcess.IsDeterminingParametersChanged = false;
                }
                oldProcess.Update(connection);
            }
        }
 public void InitializeProcess(ProcessInstance processInstance)
 {
     using (NpgsqlConnection connection = new NpgsqlConnection(ConnectionString))
     {
         var oldProcess = WorkflowProcessInstance.SelectByKey(connection, processInstance.ProcessId);
         if (oldProcess != null)
         {
             throw new ProcessAlredyExistsException();
         }
         var newProcess = new WorkflowProcessInstance
         {
             Id           = processInstance.ProcessId,
             SchemeId     = processInstance.SchemeId,
             ActivityName = processInstance.ProcessScheme.InitialActivity.Name,
             StateName    = processInstance.ProcessScheme.InitialActivity.State
         };
         newProcess.Insert(connection);
     }
 }
 public void InitializeProcess(ProcessInstance processInstance)
 {
     using (var session = Store.OpenSession())
     {
         var oldProcess = session.Load <WorkflowProcessInstance>(processInstance.ProcessId);
         if (oldProcess != null)
         {
             throw new ProcessAlredyExistsException();
         }
         var newProcess = new WorkflowProcessInstance {
             Id           = processInstance.ProcessId,
             SchemeId     = processInstance.SchemeId,
             ActivityName = processInstance.ProcessScheme.InitialActivity.Name,
             StateName    = processInstance.ProcessScheme.InitialActivity.State
         };
         session.Store(newProcess);
         session.SaveChanges();
     }
 }
Ejemplo n.º 10
0
        public void InitializeProcess(ProcessInstance processInstance)
        {
            var dbcoll     = Store.GetCollection <WorkflowProcessInstance>(MongoDBConstants.WorkflowProcessInstanceCollectionName);
            var oldProcess = dbcoll.FindOneById(processInstance.ProcessId);

            if (oldProcess != null)
            {
                throw new ProcessAlredyExistsException();
            }
            var newProcess = new WorkflowProcessInstance
            {
                Id           = processInstance.ProcessId,
                SchemeId     = processInstance.SchemeId,
                ActivityName = processInstance.ProcessScheme.InitialActivity.Name,
                StateName    = processInstance.ProcessScheme.InitialActivity.State
            };

            dbcoll.Insert(newProcess);
        }
Ejemplo n.º 11
0
        public SchemeDefinition <XElement> GetProcessSchemeByProcessId(Guid processId)
        {
            using (OracleConnection connection = new OracleConnection(ConnectionString))
            {
                var processInstance = WorkflowProcessInstance.SelectByKey(connection, processId);
                if (processInstance == null)
                {
                    throw new ProcessNotFoundException();
                }

                if (!processInstance.SchemeId.HasValue)
                {
                    throw new SchemeNotFoundException();
                }

                var schemeDefinition = GetProcessSchemeBySchemeId(processInstance.SchemeId.Value);
                schemeDefinition.IsDeterminingParametersChanged = processInstance.IsDeterminingParametersChanged;
                return(schemeDefinition);
            }
        }
Ejemplo n.º 12
0
 public void BindProcessToNewScheme(ProcessInstance processInstance, bool resetIsDeterminingParametersChanged)
 {
     using (TransactionScope readCommittedSupressedScope = PredefinedTransactionScopes.ReadCommittedSupressedScope)
     {
         using (WorkflowPersistenceModelDataContext workflowPersistenceModelDataContext = base.CreateContext())
         {
             WorkflowProcessInstance workflowProcessInstance = workflowPersistenceModelDataContext.WorkflowProcessInstances.SingleOrDefault((WorkflowProcessInstance wpi) => wpi.Id == processInstance.ProcessId);
             if (workflowProcessInstance == null)
             {
                 throw new ProcessNotFoundException();
             }
             workflowProcessInstance.SchemeId = new Guid?(processInstance.SchemeId);
             if (resetIsDeterminingParametersChanged)
             {
                 workflowProcessInstance.IsDeterminingParametersChanged = false;
             }
             workflowPersistenceModelDataContext.SubmitChanges();
         }
         readCommittedSupressedScope.Complete();
     }
 }
Ejemplo n.º 13
0
        /// <summary>
        /// 获取审批流程实例中系统定义的缺省参数及参数值(DefaultDefinitions中定义)
        /// </summary>
        /// <param name="processId"></param>
        /// <param name="processDefinition"></param>
        /// <returns></returns>
        private IEnumerable <ParameterDefinitionWithValue> GetSystemProcessParameters(Guid processId, ProcessDefinition processDefinition)
        {
            WorkflowProcessInstance    processInstance = this.GetProcessInstance(processId);
            List <ParameterDefinition> source          = (
                from p in processDefinition.Parameters
                where p.Purpose == ParameterPurpose.System
                select p).ToList <ParameterDefinition>();

            var list = new List <ParameterDefinitionWithValue>(source.Count <ParameterDefinition>());

            list.Add(ParameterDefinition.Create(source.Single((ParameterDefinition sp) => sp.Name == DefaultDefinitions.ParameterProcessId.Name), processId));
            list.Add(ParameterDefinition.Create(source.Single((ParameterDefinition sp) => sp.Name == DefaultDefinitions.ParameterPreviousState.Name), (object)processInstance.PreviousState));

            list.Add(ParameterDefinition.Create(source.Single((ParameterDefinition sp) => sp.Name == DefaultDefinitions.ParameterCurrentState.Name), (object)processInstance.StateName));
            list.Add(ParameterDefinition.Create(source.Single((ParameterDefinition sp) => sp.Name == DefaultDefinitions.ParameterPreviousStateForDirect.Name), (object)processInstance.PreviousStateForDirect));
            list.Add(ParameterDefinition.Create(source.Single((ParameterDefinition sp) => sp.Name == DefaultDefinitions.ParameterPreviousStateForReverse.Name), (object)processInstance.PreviousStateForReverse));
            list.Add(ParameterDefinition.Create(source.Single((ParameterDefinition sp) => sp.Name == DefaultDefinitions.ParameterPreviousActivity.Name), (object)processInstance.PreviousActivity));
            list.Add(ParameterDefinition.Create(source.Single((ParameterDefinition sp) => sp.Name == DefaultDefinitions.ParameterCurrentActivity.Name), (object)processInstance.ActivityName));
            list.Add(ParameterDefinition.Create(source.Single((ParameterDefinition sp) => sp.Name == DefaultDefinitions.ParameterPreviousActivityForDirect.Name), (object)processInstance.PreviousActivityForDirect));
            list.Add(ParameterDefinition.Create(source.Single((ParameterDefinition sp) => sp.Name == DefaultDefinitions.ParameterPreviousActivityForReverse.Name), (object)processInstance.PreviousActivityForReverse));
            return(list);
        }
        public SchemeDefinition <XElement> GetProcessSchemeByProcessId(Guid processId)
        {
            WorkflowProcessInstance processInstance = new WorkflowProcessInstance();

            using (var session = Store.OpenSession())
            {
                processInstance = session.Load <WorkflowProcessInstance>(processId);
            }

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

            if (!processInstance.SchemeId.HasValue)
            {
                throw new SchemeNotFoundException();
            }
            var schemeDefinition = GetProcessSchemeBySchemeId(processInstance.SchemeId.Value);

            schemeDefinition.IsDeterminingParametersChanged = processInstance.IsDeterminingParametersChanged;
            return(schemeDefinition);
        }
Ejemplo n.º 15
0
        public SchemeDefinition <XElement> GetProcessSchemeByProcessId(Guid processId)
        {
            WorkflowProcessInstance processInstance = new WorkflowProcessInstance();
            var dbcoll = Store.GetCollection <WorkflowProcessInstance>(MongoDBConstants.WorkflowProcessInstanceCollectionName);

            {
                processInstance = dbcoll.FindOneById(processId);
            }

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

            if (!processInstance.SchemeId.HasValue)
            {
                throw new SchemeNotFoundException();
            }
            var schemeDefinition = GetProcessSchemeBySchemeId(processInstance.SchemeId.Value);

            schemeDefinition.IsDeterminingParametersChanged = processInstance.IsDeterminingParametersChanged;
            return(schemeDefinition);
        }
Ejemplo n.º 16
0
 public void InitializeProcess(ProcessInstance processInstance)
 {
     using (TransactionScope readCommittedSupressedScope = PredefinedTransactionScopes.ReadCommittedSupressedScope)
     {
         using (WorkflowPersistenceModelDataContext workflowPersistenceModelDataContext = base.CreateContext())
         {
             var workflowProcessInstance = workflowPersistenceModelDataContext.WorkflowProcessInstances.SingleOrDefault((WorkflowProcessInstance wpi) => wpi.Id == processInstance.ProcessId);
             if (workflowProcessInstance != null)
             {
                 throw new ProcessAlredyExistsException();
             }
             var entity = new WorkflowProcessInstance
             {
                 Id           = processInstance.ProcessId,
                 SchemeId     = new Guid?(processInstance.SchemeId),
                 ActivityName = processInstance.ProcessScheme.InitialActivity.Name,
                 StateName    = processInstance.ProcessScheme.InitialActivity.State
             };
             workflowPersistenceModelDataContext.WorkflowProcessInstances.InsertOnSubmit(entity);
             workflowPersistenceModelDataContext.SubmitChanges();
         }
         readCommittedSupressedScope.Complete();
     }
 }
 partial void InsertWorkflowProcessInstance(WorkflowProcessInstance instance);
Ejemplo n.º 18
0
        public void UpdatePersistenceState(ProcessInstance processInstance, TransitionDefinition transition)
        {
            var paramIdentityId    = processInstance.GetParameter(DefaultDefinitions.ParameterIdentityId.Name);
            var paramImpIdentityId = processInstance.GetParameter(DefaultDefinitions.ParameterImpersonatedIdentityId.Name);

            var identityId    = paramIdentityId == null ? string.Empty : (string)paramIdentityId.Value;
            var impIdentityId = paramImpIdentityId == null ? identityId : (string)paramImpIdentityId.Value;

            var dbcoll = Store.GetCollection <WorkflowProcessInstance>(MongoDBConstants.WorkflowProcessInstanceCollectionName);
            WorkflowProcessInstance inst = dbcoll.FindOneById(processInstance.ProcessId);

            if (inst != null)
            {
                if (!string.IsNullOrEmpty(transition.To.State))
                {
                    inst.StateName = transition.To.State;
                }

                inst.ActivityName     = transition.To.Name;
                inst.PreviousActivity = transition.From.Name;

                if (!string.IsNullOrEmpty(transition.From.State))
                {
                    inst.PreviousState = transition.From.State;
                }

                if (transition.Classifier == TransitionClassifier.Direct)
                {
                    inst.PreviousActivityForDirect = transition.From.Name;

                    if (!string.IsNullOrEmpty(transition.From.State))
                    {
                        inst.PreviousStateForDirect = transition.From.State;
                    }
                }
                else if (transition.Classifier == TransitionClassifier.Reverse)
                {
                    inst.PreviousActivityForReverse = transition.From.Name;
                    if (!string.IsNullOrEmpty(transition.From.State))
                    {
                        inst.PreviousStateForReverse = transition.From.State;
                    }
                }

                dbcoll.Save(inst);
            }

            var history = new WorkflowProcessTransitionHistory()
            {
                ActorIdentityId    = impIdentityId,
                ExecutorIdentityId = identityId,
                Id                   = Guid.NewGuid(),
                IsFinalised          = false,
                ProcessId            = processInstance.ProcessId,
                FromActivityName     = transition.From.Name,
                FromStateName        = transition.From.State,
                ToActivityName       = transition.To.Name,
                ToStateName          = transition.To.State,
                TransitionClassifier =
                    transition.Classifier.ToString(),
                TransitionTime = _runtime.RuntimeDateTimeNow,
                TriggerName    = string.IsNullOrEmpty(processInstance.ExecutedTimer) ? processInstance.CurrentCommand : processInstance.ExecutedTimer
            };

            var dbcollTransition = Store.GetCollection <WorkflowProcessTransitionHistory>(MongoDBConstants.WorkflowProcessTransitionHistoryCollectionName);

            dbcollTransition.Insert(history);
        }
 partial void DeleteWorkflowProcessInstance(WorkflowProcessInstance instance);
Ejemplo n.º 20
0
        public void UpdatePersistenceState(ProcessInstance processInstance, TransitionDefinition transition)
        {
            var paramIdentityId    = processInstance.GetParameter(DefaultDefinitions.ParameterIdentityId.Name);
            var paramImpIdentityId = processInstance.GetParameter(DefaultDefinitions.ParameterImpersonatedIdentityId.Name);

            var identityId    = paramIdentityId == null ? string.Empty : (string)paramIdentityId.Value;
            var impIdentityId = paramImpIdentityId == null ? identityId : (string)paramImpIdentityId.Value;

            using (OracleConnection connection = new OracleConnection(ConnectionString))
            {
                WorkflowProcessInstance inst = WorkflowProcessInstance.SelectByKey(connection, processInstance.ProcessId);

                if (inst != null)
                {
                    if (!string.IsNullOrEmpty(transition.To.State))
                    {
                        inst.StateName = transition.To.State;
                    }

                    inst.ActivityName     = transition.To.Name;
                    inst.PreviousActivity = transition.From.Name;

                    if (!string.IsNullOrEmpty(transition.From.State))
                    {
                        inst.PreviousState = transition.From.State;
                    }

                    if (transition.Classifier == TransitionClassifier.Direct)
                    {
                        inst.PreviousActivityForDirect = transition.From.Name;

                        if (!string.IsNullOrEmpty(transition.From.State))
                        {
                            inst.PreviousStateForDirect = transition.From.State;
                        }
                    }
                    else if (transition.Classifier == TransitionClassifier.Reverse)
                    {
                        inst.PreviousActivityForReverse = transition.From.Name;
                        if (!string.IsNullOrEmpty(transition.From.State))
                        {
                            inst.PreviousStateForReverse = transition.From.State;
                        }
                    }

                    inst.Update(connection);
                }

                var history = new WorkflowProcessTransitionHistory()
                {
                    ActorIdentityId    = impIdentityId,
                    ExecutorIdentityId = identityId,
                    Id                   = Guid.NewGuid(),
                    IsFinalised          = false,
                    ProcessId            = processInstance.ProcessId,
                    FromActivityName     = transition.From.Name,
                    FromStateName        = transition.From.State,
                    ToActivityName       = transition.To.Name,
                    ToStateName          = transition.To.State,
                    TransitionClassifier =
                        transition.Classifier.ToString(),
                    TransitionTime = _runtime.RuntimeDateTimeNow,
                    TriggerName    = string.IsNullOrEmpty(processInstance.ExecutedTimer) ? processInstance.CurrentCommand : processInstance.ExecutedTimer
                };
                history.Insert(connection);
                WorkflowProcessTransitionHistory.Commit(connection);
            }
        }
        public void UpdatePersistenceState(ProcessInstance processInstance, TransitionDefinition transition)
        {
            var paramIdentityId    = processInstance.GetParameter(DefaultDefinitions.ParameterIdentityId.Name);
            var paramImpIdentityId = processInstance.GetParameter(DefaultDefinitions.ParameterImpersonatedIdentityId.Name);

            string identityId    = paramIdentityId == null ? string.Empty : (string)paramIdentityId.Value;
            string impIdentityId = paramImpIdentityId == null ? identityId : (string)paramImpIdentityId.Value;

            using (var session = Store.OpenSession())
            {
                WorkflowProcessInstance inst = session.Load <WorkflowProcessInstance>(processInstance.ProcessId);
                if (inst != null)
                {
                    if (!string.IsNullOrEmpty(transition.To.State))
                    {
                        inst.StateName = transition.To.State;
                    }

                    inst.ActivityName     = transition.To.Name;
                    inst.PreviousActivity = transition.From.Name;

                    if (!string.IsNullOrEmpty(transition.From.State))
                    {
                        inst.PreviousState = transition.From.State;
                    }

                    if (transition.Classifier == TransitionClassifier.Direct)
                    {
                        inst.PreviousActivityForDirect = transition.From.Name;

                        if (!string.IsNullOrEmpty(transition.From.State))
                        {
                            inst.PreviousStateForDirect = transition.From.State;
                        }
                    }
                    else if (transition.Classifier == TransitionClassifier.Reverse)
                    {
                        inst.PreviousActivityForReverse = transition.From.Name;
                        if (!string.IsNullOrEmpty(transition.From.State))
                        {
                            inst.PreviousStateForReverse = transition.From.State;
                        }
                    }
                }

                var history = new WorkflowProcessTransitionHistory()
                {
                    ActorIdentityId    = impIdentityId,
                    ExecutorIdentityId = identityId,
                    Id                   = Guid.NewGuid(),
                    IsFinalised          = false,
                    ProcessId            = processInstance.ProcessId,
                    FromActivityName     = transition.From.Name,
                    FromStateName        = transition.From.State,
                    ToActivityName       = transition.To.Name,
                    ToStateName          = transition.To.State,
                    TransitionClassifier =
                        transition.Classifier.ToString(),
                    TransitionTime = _runtime.RuntimeDateTimeNow,
                    TriggerName    = string.IsNullOrEmpty(processInstance.ExecutedTimer) ? processInstance.CurrentCommand : processInstance.ExecutedTimer
                };

                session.Store(history);
                session.SaveChanges();
            }
        }
Ejemplo n.º 22
0
        public void UpdatePersistenceState(ProcessInstance processInstance, TransitionDefinition transition)
        {
            var paramIdentityId    = processInstance.GetParameter(DefaultDefinitions.ParameterIdentityId.Name);
            var paramImpIdentityId = processInstance.GetParameter(DefaultDefinitions.ParameterImpersonatedIdentityId.Name);

            string identityId = paramIdentityId == null || paramIdentityId.Value == null
                ? string.Empty
                : paramIdentityId.Value.ToString();
            string impIdentityId = paramImpIdentityId == null || paramImpIdentityId.Value == null
                ? identityId
                : paramImpIdentityId.Value.ToString();

            using (var context = CreateContext())
            {
                WorkflowProcessInstance inst = context.WorkflowProcessInstances.FirstOrDefault(c => c.Id == processInstance.ProcessId);
                if (inst != null)
                {
                    if (!string.IsNullOrEmpty(transition.To.State))
                    {
                        inst.StateName = transition.To.State;
                    }

                    inst.ActivityName     = transition.To.Name;
                    inst.PreviousActivity = transition.From.Name;

                    if (!string.IsNullOrEmpty(transition.From.State))
                    {
                        inst.PreviousState = transition.From.State;
                    }

                    if (transition.Classifier == TransitionClassifier.Direct)
                    {
                        inst.PreviousActivityForDirect = transition.From.Name;

                        if (!string.IsNullOrEmpty(transition.From.State))
                        {
                            inst.PreviousStateForDirect = transition.From.State;
                        }
                    }
                    else if (transition.Classifier == TransitionClassifier.Reverse)
                    {
                        inst.PreviousActivityForReverse = transition.From.Name;
                        if (!string.IsNullOrEmpty(transition.From.State))
                        {
                            inst.PreviousStateForReverse = transition.From.State;
                        }
                    }

                    inst.ParentProcessId = processInstance.ParentProcessId;
                    inst.RootProcessId   = processInstance.RootProcessId;
                }

                var history = new WorkflowProcessTransitionHistory()
                {
                    ActorIdentityId    = impIdentityId,
                    ExecutorIdentityId = identityId,
                    Id          = Guid.NewGuid(),
                    IsFinalised = false,
                    //TODO Зачем на м финализед тут????
                    ProcessId            = processInstance.ProcessId,
                    FromActivityName     = transition.From.Name,
                    FromStateName        = transition.From.State,
                    ToActivityName       = transition.To.Name,
                    ToStateName          = transition.To.State,
                    TransitionClassifier =
                        transition.Classifier.ToString(),
                    TransitionTime = _runtime.RuntimeDateTimeNow,
                    TriggerName    = string.IsNullOrEmpty(processInstance.ExecutedTimer) ? processInstance.CurrentCommand : processInstance.ExecutedTimer
                };


                context.WorkflowProcessTransitionHistories.InsertOnSubmit(history);

                context.SubmitChanges();
            }
        }
Ejemplo n.º 23
0
 public void InitializeProcess(ProcessInstance processInstance)
 {
     using (TransactionScope readCommittedSupressedScope = PredefinedTransactionScopes.ReadCommittedSupressedScope)
     {
         using (WorkflowPersistenceModelDataContext workflowPersistenceModelDataContext = base.CreateContext())
         {
             var workflowProcessInstance = workflowPersistenceModelDataContext.WorkflowProcessInstances.SingleOrDefault((WorkflowProcessInstance wpi) => wpi.Id == processInstance.ProcessId);
             if (workflowProcessInstance != null)
             {
                 throw new ProcessAlredyExistsException();
             }
             var entity = new WorkflowProcessInstance
             {
                 Id = processInstance.ProcessId,
                 SchemeId = new Guid?(processInstance.SchemeId),
                 ActivityName = processInstance.ProcessScheme.InitialActivity.Name,
                 StateName = processInstance.ProcessScheme.InitialActivity.State
             };
             workflowPersistenceModelDataContext.WorkflowProcessInstances.InsertOnSubmit(entity);
             workflowPersistenceModelDataContext.SubmitChanges();
         }
         readCommittedSupressedScope.Complete();
     }
 }
 partial void UpdateWorkflowProcessInstance(WorkflowProcessInstance instance);