Exemplo n.º 1
0
 private SchemeDefinition <XElement> ConvertToSchemeDefinition(WorkflowProcessScheme workflowProcessScheme)
 {
     return(new SchemeDefinition <XElement>(workflowProcessScheme.Id,
                                            !string.IsNullOrEmpty(workflowProcessScheme.RootSchemeId)
             ? (Guid?)Guid.Parse(workflowProcessScheme.RootSchemeId)
             : null,
                                            workflowProcessScheme.SchemeCode, workflowProcessScheme.RootSchemeCode,
                                            XElement.Parse(workflowProcessScheme.Scheme), workflowProcessScheme.IsObsolete, false,
                                            JsonConvert.DeserializeObject <List <string> >(workflowProcessScheme.AllowedActivities ?? "null"),
                                            workflowProcessScheme.StartingTransition,
                                            workflowProcessScheme.DefiningParameters));
 }
Exemplo n.º 2
0
        public void SaveScheme(SchemeDefinition <XElement> scheme)
        {
            var definingParameters     = scheme.DefiningParameters;
            var definingParametersHash = HashHelper.GenerateStringHash(definingParameters);

            var cache =
                Store.GetOrCreateCache <Guid, WorkflowProcessScheme>(IgniteConstants.WorkflowProcessSchemeCacheName);
            var schemeCode = scheme.SchemeCode;
            var isObsolete = scheme.IsObsolete;
            var oldSchemes =
                cache.AsCacheQueryable().Where(
                    wps =>
                    wps.Value.DefiningParametersHash == definingParametersHash &&
                    wps.Value.SchemeCode == schemeCode && wps.Value.IsObsolete == isObsolete).ToList();

            if (oldSchemes.Any())
            {
                if (oldSchemes.Any(oldScheme => oldScheme.Value.DefiningParameters == definingParameters))
                {
                    throw SchemeAlredyExistsException.Create(schemeCode, SchemeLocation.WorkflowProcessScheme, definingParameters);
                }
            }

            var newProcessScheme = new WorkflowProcessScheme
            {
                Id = scheme.Id,
                DefiningParameters     = definingParameters,
                DefiningParametersHash = definingParametersHash,
                Scheme             = scheme.Scheme.ToString(),
                SchemeCode         = schemeCode,
                RootSchemeCode     = scheme.RootSchemeCode,
                RootSchemeId       = scheme.RootSchemeId.HasValue ? scheme.RootSchemeId.Value.ToString("N") : null,
                AllowedActivities  = JsonConvert.SerializeObject(scheme.AllowedActivities),
                StartingTransition = scheme.StartingTransition,
                IsObsolete         = scheme.IsObsolete
            };

            cache.Put(newProcessScheme.Id, newProcessScheme);
        }
Exemplo n.º 3
0
        public SchemeDefinition <XElement> GetProcessSchemeBySchemeId(Guid schemeId)
        {
            var cache =
                Store.GetOrCreateCache <Guid, WorkflowProcessScheme>(IgniteConstants.WorkflowProcessSchemeCacheName);

            WorkflowProcessScheme processScheme = null;

            try
            {
                processScheme = cache.Get(schemeId);
            }
            catch (KeyNotFoundException)
            {
            }

            if (processScheme == null || string.IsNullOrEmpty(processScheme.Scheme))
            {
                throw SchemeNotFoundException.Create(schemeId, SchemeLocation.WorkflowProcessScheme);
            }

            return(ConvertToSchemeDefinition(processScheme));
        }