Ejemplo n.º 1
0
        public SchemeDefinition <XElement> GetProcessSchemeWithParameters(string schemeCode, string definingParameters,
                                                                          Guid?rootSchemeId, bool ignoreObsolete)
        {
            IEnumerable <WorkflowProcessScheme> processSchemes = new List <WorkflowProcessScheme>();
            var hash = HashHelper.GenerateStringHash(definingParameters);

            using (OracleConnection connection = new OracleConnection(ConnectionString))
            {
                processSchemes =
                    WorkflowProcessScheme.Select(connection, schemeCode, hash, ignoreObsolete ? false : (bool?)null,
                                                 rootSchemeId);
            }

            if (!processSchemes.Any())
            {
                throw new SchemeNotFoundException();
            }

            if (processSchemes.Count() == 1)
            {
                var scheme = processSchemes.First();
                return(ConvertToSchemeDefinition(scheme));
            }

            foreach (var processScheme in processSchemes.Where(processScheme => processScheme.DefiningParameters == definingParameters))
            {
                return(ConvertToSchemeDefinition(processScheme));
            }

            throw new SchemeNotFoundException();
        }
Ejemplo n.º 2
0
 public void SetSchemeIsObsolete(string schemeCode)
 {
     using (OracleConnection connection = new OracleConnection(ConnectionString))
     {
         WorkflowProcessScheme.SetObsolete(connection, schemeCode);
         WorkflowProcessScheme.Commit(connection);
     }
 }
Ejemplo n.º 3
0
 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,
                                            JsonConvert.DeserializeObject <List <string> >(workflowProcessScheme.AllowedActivities ?? "null"),
                                            workflowProcessScheme.StartingTransition,
                                            workflowProcessScheme.DefiningParameters));
 }
Ejemplo n.º 4
0
        public void SetSchemeIsObsolete(string schemeCode, IDictionary <string, object> parameters)
        {
            var definingParameters     = DefiningParametersSerializer.Serialize(parameters);
            var definingParametersHash = HashHelper.GenerateStringHash(definingParameters);

            using (OracleConnection connection = new OracleConnection(ConnectionString))
            {
                WorkflowProcessScheme.SetObsolete(connection, schemeCode, definingParametersHash);
                WorkflowProcessScheme.Commit(connection);
            }
        }
Ejemplo n.º 5
0
        public SchemeDefinition <XElement> GetProcessSchemeBySchemeId(Guid schemeId)
        {
            using (OracleConnection connection = new OracleConnection(ConnectionString))
            {
                WorkflowProcessScheme processScheme = WorkflowProcessScheme.SelectByKey(connection, schemeId);

                if (processScheme == null || string.IsNullOrEmpty(processScheme.Scheme))
                {
                    throw new SchemeNotFoundException();
                }

                return(ConvertToSchemeDefinition(processScheme));
            }
        }
Ejemplo n.º 6
0
        public void SaveScheme(SchemeDefinition <XElement> scheme)
        {
            var definingParameters     = scheme.DefiningParameters;
            var definingParametersHash = HashHelper.GenerateStringHash(definingParameters);

            using (OracleConnection connection = new OracleConnection(ConnectionString))
            {
                var oldSchemes = WorkflowProcessScheme.Select(connection, scheme.SchemeCode, definingParametersHash,
                                                              scheme.IsObsolete, scheme.RootSchemeId);

                if (oldSchemes.Any())
                {
                    foreach (var oldScheme in oldSchemes)
                    {
                        if (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  = JsonConvert.SerializeObject(scheme.AllowedActivities),
                    StartingTransition = scheme.StartingTransition,
                    IsObsolete         = scheme.IsObsolete
                };

                newProcessScheme.Insert(connection);
                WorkflowProcessScheme.Commit(connection);
            }
        }