Beispiel #1
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();
            }
        }
        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 (NpgsqlConnection connection = new NpgsqlConnection(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);
                            }
                        }
                    }
                }
            }
        }
Beispiel #3
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 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();
            }
        }
Beispiel #4
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);
            }
        }