Esempio n. 1
0
        private IEnumerable <ParameterDefinitionWithValue> GetPersistedProcessParameters(Guid processId, ProcessDefinition processDefinition)
        {
            var persistenceParameters = processDefinition.PersistenceParameters.ToList();
            var parameters            = new List <ParameterDefinitionWithValue>(persistenceParameters.Count());

            List <WorkflowProcessInstancePersistence> persistedParameters;

            using (SqlConnection connection = new SqlConnection(ConnectionString))
            {
                persistedParameters = WorkflowProcessInstancePersistence.SelectByProcessId(connection, processId).ToList();
            }

            foreach (var persistedParameter in persistedParameters)
            {
                var parameterDefinition = persistenceParameters.FirstOrDefault(p => p.Name == persistedParameter.ParameterName);
                if (parameterDefinition == null)
                {
                    parameterDefinition = ParameterDefinition.Create(persistedParameter.ParameterName, "System.String", ParameterPurpose.Persistence.ToString(), null);
                }

                parameters.Add(ParameterDefinition.Create(parameterDefinition, _runtime.DeserializeParameter(persistedParameter.Value, parameterDefinition.Type)));
            }

            return(parameters);
        }
Esempio n. 2
0
        public void SavePersistenceParameters(ProcessInstance processInstance)
        {
            var parametersToPersistList =
                processInstance.ProcessParameters.Where(ptp => ptp.Purpose == ParameterPurpose.Persistence)
                .Select(ptp => new { Parameter = ptp, SerializedValue = _runtime.SerializeParameter(ptp.Value, ptp.Type) })
                .ToList();
            var persistenceParameters = processInstance.ProcessScheme.PersistenceParameters.ToList();

            using (var scope = PredefinedTransactionScopes.ReadUncommittedSupressedScope)
            {
                using (var context = CreateContext())
                {
                    var persistedParameters =
                        context.WorkflowProcessInstancePersistences.Where(
                            wpip =>
                            wpip.ProcessId == processInstance.ProcessId &&
                            persistenceParameters.Select(pp => pp.Name).Contains(wpip.ParameterName)).ToList();

                    foreach (var parameterDefinitionWithValue in parametersToPersistList)
                    {
                        WorkflowProcessInstancePersistence persistence =
                            persistedParameters.SingleOrDefault(
                                pp => pp.ParameterName == parameterDefinitionWithValue.Parameter.Name);
                        {
                            if (persistence == null)
                            {
                                if (parameterDefinitionWithValue.SerializedValue != null)
                                {
                                    persistence = new WorkflowProcessInstancePersistence()
                                    {
                                        Id            = Guid.NewGuid(),
                                        ParameterName = parameterDefinitionWithValue.Parameter.Name,
                                        ProcessId     = processInstance.ProcessId,
                                        Value         = parameterDefinitionWithValue.SerializedValue
                                    };
                                    context.WorkflowProcessInstancePersistences.InsertOnSubmit(persistence);
                                }
                            }
                            else
                            {
                                if (parameterDefinitionWithValue.SerializedValue != null)
                                {
                                    persistence.Value = parameterDefinitionWithValue.SerializedValue;
                                }
                                else
                                {
                                    context.WorkflowProcessInstancePersistences.DeleteOnSubmit(persistence);
                                }
                            }
                        }
                    }

                    context.SubmitChanges();
                }

                scope.Complete();
            }
        }
Esempio n. 3
0
        public void SavePersistenceParameters(ProcessInstance processInstance)
        {
            var parametersToPersistList =
                processInstance.ProcessParameters.Where(ptp => ptp.Purpose == ParameterPurpose.Persistence)
                .Select(ptp =>
            {
                if (ptp.Type == typeof(UnknownParameterType))
                {
                    return new { Parameter = ptp, SerializedValue = (string)ptp.Value }
                }
                ;
                return(new { Parameter = ptp, SerializedValue = ParametersSerializer.Serialize(ptp.Value, ptp.Type) });
            })
                .ToList();

            using (SqlConnection connection = new SqlConnection(ConnectionString))
            {
                var persistedParameters = WorkflowProcessInstancePersistence.SelectByProcessId(connection, processInstance.ProcessId).ToList();

                foreach (var parameterDefinitionWithValue in parametersToPersistList)
                {
                    var persistence =
                        persistedParameters.SingleOrDefault(
                            pp => pp.ParameterName == parameterDefinitionWithValue.Parameter.Name);
                    {
                        if (persistence == null)
                        {
                            if (parameterDefinitionWithValue.SerializedValue != null)
                            {
                                persistence = new WorkflowProcessInstancePersistence()
                                {
                                    Id            = Guid.NewGuid(),
                                    ProcessId     = processInstance.ProcessId,
                                    ParameterName = parameterDefinitionWithValue.Parameter.Name,
                                    Value         = parameterDefinitionWithValue.SerializedValue
                                };
                                persistence.Insert(connection);
                            }
                        }
                        else
                        {
                            if (parameterDefinitionWithValue.SerializedValue != null)
                            {
                                persistence.Value = parameterDefinitionWithValue.SerializedValue;
                                persistence.Update(connection);
                            }
                            else
                            {
                                WorkflowProcessInstancePersistence.Delete(connection, persistence.Id);
                            }
                        }
                    }
                }
            }
        }
 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);
     }
 }
        public void SavePersistenceParameters(ProcessInstance processInstance)
        {
            var parametersToPersistList =
                processInstance.ProcessParameters.Where(ptp => ptp.Purpose == ParameterPurpose.Persistence).Select(ptp => new { Parameter = ptp, SerializedValue = _runtime.SerializeParameter(ptp.Value, ptp.Type) })
                .ToList();
            var persistenceParameters = processInstance.ProcessScheme.PersistenceParameters.ToList();

            using (var session = Store.OpenSession())
            {
                var process = session.Load <WorkflowProcessInstance>(processInstance.ProcessId);
                if (process != null && process.Persistence != null)
                {
                    var persistedParameters = process.Persistence.Where(
                        WorkflowProcessInstancep => persistenceParameters.Select(pp => pp.Name).Contains(WorkflowProcessInstancep.ParameterName)).ToList();

                    foreach (var parameterDefinitionWithValue in parametersToPersistList)
                    {
                        var persistence =
                            persistedParameters.SingleOrDefault(
                                pp => pp.ParameterName == parameterDefinitionWithValue.Parameter.Name);
                        {
                            if (persistence == null)
                            {
                                if (parameterDefinitionWithValue.SerializedValue != null)
                                {
                                    persistence = new WorkflowProcessInstancePersistence()
                                    {
                                        ParameterName = parameterDefinitionWithValue.Parameter.Name,
                                        Value         = parameterDefinitionWithValue.SerializedValue
                                    };
                                    process.Persistence.Add(persistence);
                                }
                            }
                            else
                            {
                                if (parameterDefinitionWithValue.SerializedValue != null)
                                {
                                    persistence.Value = parameterDefinitionWithValue.SerializedValue;
                                }
                                else
                                {
                                    process.Persistence.Remove(persistence);
                                }
                            }
                        }
                    }
                }
                session.SaveChanges();
            }
        }
Esempio n. 6
0
        public void SavePersistenceParameters(ProcessInstance processInstance)
        {
            var parametersToPersistList =
                processInstance.ProcessParameters.Where(ptp => ptp.Purpose == ParameterPurpose.Persistence).Select(ptp => new { Parameter = ptp, SerializedValue = _runtime.SerializeParameter(ptp.Value, ptp.Type) })
                .ToList();
            var persistenceParameters = processInstance.ProcessScheme.PersistenceParameters.ToList();

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

            if (process != null && process.Persistence != null)
            {
                var persistedParameters = process.Persistence.Where(
                    WorkflowProcessInstancep => persistenceParameters.Select(pp => pp.Name).Contains(WorkflowProcessInstancep.ParameterName)).ToList();

                foreach (var parameterDefinitionWithValue in parametersToPersistList)
                {
                    var persistence =
                        persistedParameters.SingleOrDefault(
                            pp => pp.ParameterName == parameterDefinitionWithValue.Parameter.Name);
                    {
                        if (persistence == null)
                        {
                            if (parameterDefinitionWithValue.SerializedValue != null)
                            {
                                persistence = new WorkflowProcessInstancePersistence()
                                {
                                    ParameterName = parameterDefinitionWithValue.Parameter.Name,
                                    Value         = parameterDefinitionWithValue.SerializedValue
                                };
                                process.Persistence.Add(persistence);
                            }
                        }
                        else
                        {
                            if (parameterDefinitionWithValue.SerializedValue != null)
                            {
                                persistence.Value = parameterDefinitionWithValue.SerializedValue;
                            }
                            else
                            {
                                process.Persistence.Remove(persistence);
                            }
                        }
                    }
                }

                dbcoll.Save(process);
            }
        }
        public void SavePersistenceParameters(ProcessInstance processInstance)
        {
            var parametersToPersistList =
                processInstance.ProcessParameters.Where(ptp => ptp.Purpose == ParameterPurpose.Persistence).Select(ptp => new { Parameter = ptp, SerializedValue = _runtime.SerializeParameter(ptp.Value, ptp.Type) })
                .ToList();
            var persistenceParameters = processInstance.ProcessScheme.PersistenceParameters.ToList();

            using (OracleConnection connection = new OracleConnection(ConnectionString))
            {
                var persistedParameters = WorkflowProcessInstancePersistence.SelectByProcessId(connection, processInstance.ProcessId).Where(
                    WorkflowProcessInstancep => persistenceParameters.Select(pp => pp.Name).Contains(WorkflowProcessInstancep.ParameterName)).ToList();

                foreach (var parameterDefinitionWithValue in parametersToPersistList)
                {
                    var persistence =
                        persistedParameters.SingleOrDefault(
                            pp => pp.ParameterName == parameterDefinitionWithValue.Parameter.Name);
                    {
                        if (persistence == null)
                        {
                            if (parameterDefinitionWithValue.SerializedValue != null)
                            {
                                persistence = new WorkflowProcessInstancePersistence()
                                {
                                    Id            = Guid.NewGuid(),
                                    ProcessId     = processInstance.ProcessId,
                                    ParameterName = parameterDefinitionWithValue.Parameter.Name,
                                    Value         = parameterDefinitionWithValue.SerializedValue
                                };
                                persistence.Insert(connection);
                            }
                        }
                        else
                        {
                            if (parameterDefinitionWithValue.SerializedValue != null)
                            {
                                persistence.Value = parameterDefinitionWithValue.SerializedValue;
                                persistence.Update(connection);
                            }
                            else
                            {
                                WorkflowProcessInstancePersistence.Delete(connection, persistence.Id);
                            }
                        }
                    }
                }
                WorkflowProcessInstancePersistence.Commit(connection);
            }
        }
Esempio n. 8
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();
                }
            }
        }
Esempio n. 9
0
        public void SavePersistenceParameters(ProcessInstance processInstance)
        {
            var list = (
                from ptp in processInstance.ProcessParameters
                where ptp.Purpose == ParameterPurpose.Persistence
                select new
            {
                Parameter = ptp,
                SerializedValue = this.SerializeParameter(ptp.Value)
            }).ToList();
            List <ParameterDefinition> persistenceParameters = processInstance.ProcessScheme.PersistenceParameters.ToList <ParameterDefinition>();

            using (TransactionScope readUncommittedSupressedScope = PredefinedTransactionScopes.ReadUncommittedSupressedScope)
            {
                using (WorkflowPersistenceModelDataContext workflowPersistenceModelDataContext = base.CreateContext())
                {
                    List <WorkflowProcessInstancePersistence> source = (
                        from wpip in workflowPersistenceModelDataContext.WorkflowProcessInstancePersistences
                        where wpip.ProcessId == processInstance.ProcessId && (
                            from pp in persistenceParameters
                            select pp.Name).Contains(wpip.ParameterName)
                        select wpip).ToList <WorkflowProcessInstancePersistence>();
                    foreach (var parameterDefinitionWithValue in list)
                    {
                        WorkflowProcessInstancePersistence workflowProcessInstancePersistence = source.SingleOrDefault((WorkflowProcessInstancePersistence pp) => pp.ParameterName == parameterDefinitionWithValue.Parameter.Name);
                        if (workflowProcessInstancePersistence == null)
                        {
                            workflowProcessInstancePersistence = new WorkflowProcessInstancePersistence
                            {
                                Id            = Guid.NewGuid(),
                                ParameterName = parameterDefinitionWithValue.Parameter.Name,
                                ProcessId     = processInstance.ProcessId,
                                Value         = parameterDefinitionWithValue.SerializedValue
                            };
                            workflowPersistenceModelDataContext.WorkflowProcessInstancePersistences.InsertOnSubmit(workflowProcessInstancePersistence);
                        }
                        else
                        {
                            workflowProcessInstancePersistence.Value = parameterDefinitionWithValue.SerializedValue;
                        }
                    }
                    workflowPersistenceModelDataContext.SubmitChanges();
                }
                readUncommittedSupressedScope.Complete();
            }
        }
        private IEnumerable <ParameterDefinitionWithValue> GetPersistedProcessParameters(Guid processId, ProcessDefinition processDefinition)
        {
            var persistenceParameters = processDefinition.PersistenceParameters.ToList();
            var parameters            = new List <ParameterDefinitionWithValue>(persistenceParameters.Count());

            List <WorkflowProcessInstancePersistence> persistedParameters;

            using (OracleConnection connection = new OracleConnection(ConnectionString))
            {
                persistedParameters = WorkflowProcessInstancePersistence.SelectByProcessId(connection, processId)
                                      .Where(WorkflowProcessInstancep => persistenceParameters.Select(pp => pp.Name).Contains(WorkflowProcessInstancep.ParameterName)).ToList();
            }

            foreach (var persistedParameter in persistedParameters)
            {
                var parameterDefinition = persistenceParameters.Single(p => p.Name == persistedParameter.ParameterName);
                parameters.Add(ParameterDefinition.Create(parameterDefinition, _runtime.DeserializeParameter(persistedParameter.Value, parameterDefinition.Type)));
            }

            return(parameters);
        }
Esempio n. 11
0
 public void SavePersistenceParameters(ProcessInstance processInstance)
 {
     var list = (
         from ptp in processInstance.ProcessParameters
         where ptp.Purpose == ParameterPurpose.Persistence
         select new
         {
             Parameter = ptp,
             SerializedValue = this.SerializeParameter(ptp.Value)
         }).ToList();
     List<ParameterDefinition> persistenceParameters = processInstance.ProcessScheme.PersistenceParameters.ToList<ParameterDefinition>();
     using (TransactionScope readUncommittedSupressedScope = PredefinedTransactionScopes.ReadUncommittedSupressedScope)
     {
         using (WorkflowPersistenceModelDataContext workflowPersistenceModelDataContext = base.CreateContext())
         {
             List<WorkflowProcessInstancePersistence> source = (
                 from wpip in workflowPersistenceModelDataContext.WorkflowProcessInstancePersistences
                 where wpip.ProcessId == processInstance.ProcessId && (
                     from pp in persistenceParameters
                     select pp.Name).Contains(wpip.ParameterName)
                 select wpip).ToList<WorkflowProcessInstancePersistence>();
             foreach (var parameterDefinitionWithValue in list)
             {
                 WorkflowProcessInstancePersistence workflowProcessInstancePersistence = source.SingleOrDefault((WorkflowProcessInstancePersistence pp) => pp.ParameterName == parameterDefinitionWithValue.Parameter.Name);
                 if (workflowProcessInstancePersistence == null)
                 {
                     workflowProcessInstancePersistence = new WorkflowProcessInstancePersistence
                     {
                         Id = Guid.NewGuid(),
                         ParameterName = parameterDefinitionWithValue.Parameter.Name,
                         ProcessId = processInstance.ProcessId,
                         Value = parameterDefinitionWithValue.SerializedValue
                     };
                     workflowPersistenceModelDataContext.WorkflowProcessInstancePersistences.InsertOnSubmit(workflowProcessInstancePersistence);
                 }
                 else
                 {
                     workflowProcessInstancePersistence.Value = parameterDefinitionWithValue.SerializedValue;
                 }
             }
             workflowPersistenceModelDataContext.SubmitChanges();
         }
         readUncommittedSupressedScope.Complete();
     }
 }
 partial void DeleteWorkflowProcessInstancePersistence(WorkflowProcessInstancePersistence instance);
 partial void InsertWorkflowProcessInstancePersistence(WorkflowProcessInstancePersistence instance);