private IEnumerable <ParameterDefinitionWithValue> GetPersistedProcessParameters(Guid processId, ProcessDefinition processDefinition) { var persistenceParameters = processDefinition.PersistenceParameters.ToList(); var parameters = new List <ParameterDefinitionWithValue>(persistenceParameters.Count()); List <WorkflowProcessInstancePersistence> persistedParameters; using (MySqlConnection connection = new MySqlConnection(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); }
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 (MySqlConnection connection = new MySqlConnection(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 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 (MySqlConnection connection = new MySqlConnection(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); } } } } } }
private IEnumerable <ParameterDefinitionWithValue> GetPersistedProcessParameters(Guid processId, ProcessDefinition processDefinition) { var persistenceParameters = processDefinition.PersistenceParameters.ToList(); var parameters = new List <ParameterDefinitionWithValue>(persistenceParameters.Count()); List <WorkflowProcessInstancePersistence> persistedParameters; using (MySqlConnection connection = new MySqlConnection(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); }