Пример #1
0
        public void SaveScheme(string schemaCode, bool canBeInlined, List <string> inlinedSchemes, string scheme, List <string> tags)
        {
            var dbcoll   = Store.GetCollection <WorkflowScheme>(MongoDBConstants.WorkflowSchemeCollectionName);
            var wfScheme = dbcoll.Find(c => c.Code == schemaCode).FirstOrDefault();

            if (wfScheme == null)
            {
                wfScheme = new WorkflowScheme
                {
                    Id             = schemaCode,
                    Code           = schemaCode,
                    Scheme         = scheme,
                    InlinedSchemes = inlinedSchemes,
                    CanBeInlined   = canBeInlined,
                    Tags           = tags
                };
                dbcoll.InsertOne(wfScheme);
            }
            else
            {
                wfScheme.Scheme         = scheme;
                wfScheme.InlinedSchemes = inlinedSchemes;
                wfScheme.CanBeInlined   = canBeInlined;
                wfScheme.Tags           = tags;
                Save(dbcoll, wfScheme, doc => doc.Id == wfScheme.Id);
            }
        }
Пример #2
0
        public XElement GetScheme(string code)
        {
            var            dbcoll = Store.GetCollection <WorkflowScheme>(MongoDBConstants.WorkflowSchemeCollectionName);
            WorkflowScheme scheme = dbcoll.FindOne(Query <WorkflowScheme> .Where(c => c.Code == code));

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

            return(XElement.Parse(scheme.Scheme));
        }
Пример #3
0
        public void SaveScheme(string schemaCode, string scheme)
        {
            var dbcoll   = Store.GetCollection <WorkflowScheme>(MongoDBConstants.WorkflowSchemeCollectionName);
            var wfScheme = dbcoll.Find(c => c.Code == schemaCode).FirstOrDefault();

            if (wfScheme == null)
            {
                wfScheme = new WorkflowScheme {
                    Id = schemaCode, Code = schemaCode, Scheme = scheme
                };
                dbcoll.InsertOne(wfScheme);
            }
            else
            {
                wfScheme.Scheme = scheme;
                Save(dbcoll, wfScheme, doc => doc.Id == wfScheme.Id);
            }
        }
Пример #4
0
        private void UpdateSchemeTags(string schemeCode, Func <List <string>, List <string> > getNewTags)
        {
            IMongoCollection <WorkflowScheme> dbcoll =
                Store.GetCollection <WorkflowScheme>(MongoDBConstants.WorkflowSchemeCollectionName);
            WorkflowScheme scheme = dbcoll.Find(c => c.Code == schemeCode).FirstOrDefault();

            if (scheme == null)
            {
                throw SchemeNotFoundException.Create(schemeCode, SchemeLocation.WorkflowScheme);
            }

            List <string> newTags = getNewTags.Invoke(scheme.Tags);

            scheme.Scheme = _runtime.Builder.ReplaceTagsInScheme(scheme.Scheme, newTags);
            scheme.Tags   = newTags;

            Save(dbcoll, scheme, doc => doc.Id == scheme.Id);
        }
Пример #5
0
        public void SaveScheme(string schemaCode, string scheme)
        {
            var dbcoll   = Store.GetCollection <WorkflowScheme>(MongoDBConstants.WorkflowSchemeCollectionName);
            var wfScheme = dbcoll.FindOne(Query <WorkflowScheme> .Where(c => c.Code == schemaCode));

            if (wfScheme == null)
            {
                wfScheme = new WorkflowScheme {
                    Id = schemaCode, Code = schemaCode, Scheme = scheme
                };
                dbcoll.Insert(wfScheme);
            }
            else
            {
                wfScheme.Scheme = scheme;
                dbcoll.Save(wfScheme);
            }
        }
Пример #6
0
        public XElement Generate(string schemeCode, Guid schemeId, IDictionary <string, object> parameters)
        {
            if (parameters.Count > 0)
            {
                throw new InvalidOperationException("Parameters not supported");
            }

            var            code   = !TemplateTypeMapping.ContainsKey(schemeCode.ToLower()) ? schemeCode : TemplateTypeMapping[schemeCode.ToLower()];
            WorkflowScheme scheme = null;
            var            dbcoll = Store.GetCollection <WorkflowScheme>(MongoDBConstants.WorkflowSchemeCollectionName);

            {
                scheme = dbcoll.FindOne(Query <WorkflowScheme> .Where(c => c.Code == code));
            }

            if (scheme == null)
            {
                throw new InvalidOperationException(string.Format("Scheme with Code={0} not found", code));
            }

            return(XElement.Parse(scheme.Scheme));
        }