예제 #1
0
 public void SetSchemeIsObsolete(string schemeCode)
 {
     using (MySqlConnection connection = new MySqlConnection(ConnectionString))
     {
         WorkflowProcessScheme.SetObsolete(connection, schemeCode);
     }
 }
예제 #2
0
        public void SaveScheme(string schemeCode, Guid schemeId, XElement scheme, IDictionary <string, object> parameters)
        {
            var definingParameters     = SerializeParameters(parameters);
            var definingParametersHash = HashHelper.GenerateStringHash(definingParameters);

            using (MySqlConnection connection = new MySqlConnection(ConnectionString))
            {
                var oldSchemes = WorkflowProcessScheme.Select(connection, schemeCode, definingParametersHash, true);
                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
                };

                newProcessScheme.Insert(connection);
            }
        }
예제 #3
0
        public SchemeDefinition <XElement> GetProcessSchemeWithParameters(string schemeCode, IDictionary <string, object> parameters, bool ignoreObsolete)
        {
            IEnumerable <WorkflowProcessScheme> processSchemes = new List <WorkflowProcessScheme>();
            var definingParameters = SerializeParameters(parameters);
            var hash = HashHelper.GenerateStringHash(definingParameters);

            using (MySqlConnection connection = new MySqlConnection(ConnectionString))
            {
                processSchemes =
                    WorkflowProcessScheme.Select(connection, schemeCode, hash, ignoreObsolete);
            }

            if (processSchemes.Count() < 1)
            {
                throw new SchemeNotFoundException();
            }

            if (processSchemes.Count() == 1)
            {
                var scheme = processSchemes.First();
                return(new SchemeDefinition <XElement>(scheme.Id, scheme.SchemeCode, XElement.Parse(scheme.Scheme), scheme.IsObsolete));
            }

            foreach (var processScheme in processSchemes.Where(processScheme => processScheme.DefiningParameters == definingParameters))
            {
                return(new SchemeDefinition <XElement>(processScheme.Id, processScheme.SchemeCode, XElement.Parse(processScheme.Scheme), processScheme.IsObsolete));
            }

            throw new SchemeNotFoundException();
        }
예제 #4
0
        public void SaveScheme(SchemeDefinition <XElement> scheme)
        {
            var definingParameters     = scheme.DefiningParameters;
            var definingParametersHash = HashHelper.GenerateStringHash(definingParameters);


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

                if (oldSchemes.Any())
                {
                    if (oldSchemes.Any(oldScheme => oldScheme.DefiningParameters == definingParameters))
                    {
                        throw new SchemeAlredyExistsException();
                    }
                }

                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
                };

                newProcessScheme.Insert(connection);
            }
        }
예제 #5
0
        public SchemeDefinition <XElement> GetProcessSchemeWithParameters(string schemeCode, string definingParameters,
                                                                          Guid?rootSchemeId, bool ignoreObsolete)
        {
            IEnumerable <WorkflowProcessScheme> processSchemes;
            var hash = HashHelper.GenerateStringHash(definingParameters);

            using (MySqlConnection connection = new MySqlConnection(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();
        }
예제 #6
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,
         JsonSerializer.DeserializeFromString<List<string>>(workflowProcessScheme.AllowedActivities), workflowProcessScheme.StartingTransition,
         workflowProcessScheme.DefiningParameters);
 }
예제 #7
0
        public void SetSchemeIsObsolete(string schemeCode, IDictionary <string, object> parameters)
        {
            var definingParameters     = SerializeParameters(parameters);
            var definingParametersHash = HashHelper.GenerateStringHash(definingParameters);

            using (MySqlConnection connection = new MySqlConnection(ConnectionString))
            {
                WorkflowProcessScheme.SetObsolete(connection, schemeCode, definingParametersHash);
            }
        }
예제 #8
0
        public SchemeDefinition<XElement> GetProcessSchemeBySchemeId(Guid schemeId)
        {
            using (MySqlConnection connection = new MySqlConnection(ConnectionString))
            {
                WorkflowProcessScheme processScheme = WorkflowProcessScheme.SelectByKey(connection, schemeId);

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

                return ConvertToSchemeDefinition(processScheme);
            }
        }
예제 #9
0
        public SchemeDefinition <XElement> GetProcessSchemeBySchemeId(Guid schemeId)
        {
            using (MySqlConnection connection = new MySqlConnection(ConnectionString))
            {
                WorkflowProcessScheme processScheme = WorkflowProcessScheme.SelectByKey(connection, schemeId);

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

                return(new SchemeDefinition <XElement>(schemeId, processScheme.SchemeCode, XElement.Parse(processScheme.Scheme), processScheme.IsObsolete));
            }
        }