public void SaveScheme(SchemeDefinition <XElement> scheme) { var definingParameters = scheme.DefiningParameters; var definingParametersHash = HashHelper.GenerateStringHash(definingParameters); var dbcoll = Store.GetCollection <WorkflowProcessScheme>(MongoDBConstants.WorkflowProcessSchemeCollectionName); var oldSchemes = dbcoll.Find( wps => wps.DefiningParametersHash == definingParametersHash && wps.SchemeCode == scheme.SchemeCode && wps.IsObsolete == scheme.IsObsolete).ToList(); if (oldSchemes.Any()) { if (oldSchemes.Any(oldScheme => oldScheme.DefiningParameters == definingParameters)) { throw SchemeAlredyExistsException.Create(scheme.SchemeCode, SchemeLocation.WorkflowProcessScheme, scheme.DefiningParameters); } } var newProcessScheme = new WorkflowProcessScheme { Id = scheme.Id, DefiningParameters = definingParameters, DefiningParametersHash = definingParametersHash, Scheme = scheme.Scheme.ToString(), SchemeCode = scheme.SchemeCode, RootSchemeCode = scheme.RootSchemeCode, RootSchemeId = scheme.RootSchemeId, AllowedActivities = scheme.AllowedActivities, StartingTransition = scheme.StartingTransition, IsObsolete = scheme.IsObsolete }; dbcoll.InsertOne(newProcessScheme); }
public void SaveScheme(string schemeCode, Guid schemeId, XElement scheme, IDictionary <string, object> parameters) { var definingParameters = SerializeParameters(parameters); var definingParametersHash = HashHelper.GenerateStringHash(definingParameters); var dbcoll = Store.GetCollection <WorkflowProcessScheme>(MongoDBConstants.WorkflowProcessSchemeCollectionName); var oldSchemes = dbcoll.Find(Query <WorkflowProcessScheme> .Where( wps => wps.DefiningParametersHash == definingParametersHash && wps.SchemeCode == schemeCode && !wps.IsObsolete)).ToList(); if (oldSchemes.Count() > 0) { foreach (var oldScheme in oldSchemes) { if (oldScheme.DefiningParameters == definingParameters) { throw new SchemeAlredyExistsException(); } } } var newProcessScheme = new WorkflowProcessScheme { Id = schemeId, DefiningParameters = definingParameters, DefiningParametersHash = definingParametersHash, Scheme = scheme.ToString(), SchemeCode = schemeCode }; dbcoll.Insert(newProcessScheme); }
private SchemeDefinition <XElement> ConvertToSchemeDefinition(WorkflowProcessScheme workflowProcessScheme) { return(new SchemeDefinition <XElement>(workflowProcessScheme.Id, workflowProcessScheme.RootSchemeId, workflowProcessScheme.SchemeCode, workflowProcessScheme.RootSchemeCode, XElement.Parse(workflowProcessScheme.Scheme), workflowProcessScheme.IsObsolete, false, workflowProcessScheme.AllowedActivities, workflowProcessScheme.StartingTransition, workflowProcessScheme.DefiningParameters)); }
public SchemeDefinition <XElement> GetProcessSchemeBySchemeId(Guid schemeId) { WorkflowProcessScheme processScheme = new WorkflowProcessScheme(); var dbcoll = Store.GetCollection <WorkflowProcessScheme>(MongoDBConstants.WorkflowProcessSchemeCollectionName); { processScheme = dbcoll.FindOneById(schemeId); } if (processScheme == null || string.IsNullOrEmpty(processScheme.Scheme)) { throw new SchemeNotFoundException(); } return(new SchemeDefinition <XElement>(schemeId, processScheme.SchemeCode, XElement.Parse(processScheme.Scheme), processScheme.IsObsolete)); }