Exemplo n.º 1
0
        public bool Save(ISqlMapper mapper)
        {
            LinkDefinitionDao dao = new LinkDefinitionDao(mapper);
            var link = dao.Query(new LinkDefinitionQueryForm {
                ID = this.value.ID
            }).FirstOrDefault();

            if (link == null)
            {
                dao.Add(this.value);
            }
            else
            {
                dao.Update(new LinkDefinitionUpdateForm {
                    Entity = this.value, LinkDefinitionQueryForm = new LinkDefinitionQueryForm {
                        ID = this.value.ID
                    }
                });
            }
            return(true);
        }
        public static WorkflowDefinitionModel Load(string id)
        {
            var mapper = MapperHelper.GetMapper();
            WorkflowDefinitionDao         wfdao        = new WorkflowDefinitionDao(mapper);
            ActivityDefinitionDao         addao        = new ActivityDefinitionDao(mapper);
            LinkDefinitionDao             linkdao      = new LinkDefinitionDao(mapper);
            ActivityAuthDefinitionDao     aadd         = new ActivityAuthDefinitionDao(mapper);
            WorkflowDefinition            workflow     = null;
            List <ActivityDefinition>     activityList = new List <ActivityDefinition>();
            List <LinkDefinition>         linkList     = new List <LinkDefinition>();
            List <ActivityAuthDefinition> authList     = new List <ActivityAuthDefinition>();
            WorkflowDefinitionModel       model        = null;
            var item = cache.GetItem(id);

            if (item != null)
            {
                model = item.Value as WorkflowDefinitionModel;
                return(model);
            }
            workflow = wfdao.Query(new WorkflowDefinitionQueryForm {
                ID = id, Enabled = 1
            }).FirstOrDefault();
            activityList = addao.Query(new ActivityDefinitionQueryForm {
                WorkflowDefinitionID = id, Enabled = 1
            });
            linkList = linkdao.Query(new LinkDefinitionQueryForm {
                WorkflowDefinitionID = id
            });
            authList = aadd.Query(new ActivityAuthDefinitionQueryForm {
                WorkflowDefinitionID = id
            });
            if (workflow != null)
            {
                List <ActivityDefinitionModel> activityModelList = new List <ActivityDefinitionModel>();
                List <LinkDefinitionModel>     linkModelList     = new List <LinkDefinitionModel>();
                model = new WorkflowDefinitionModel
                {
                    value = workflow,
                };
                bool foundRoot = false;
                foreach (var link in linkList)
                {
                    linkModelList.Add(new LinkDefinitionModel
                    {
                        Value = link,
                    });
                }
                foreach (var activity in activityList)
                {
                    List <LinkDefinitionModel> preLinks = new List <LinkDefinitionModel>();
                    var preLinksTemp = linkModelList.FindAll(t => t.Value.ToActivityDefinitionID == activity.ID);

                    List <LinkDefinitionModel> nextLinks = new List <LinkDefinitionModel>();
                    var nextLinksTemp = linkModelList.FindAll(t => t.Value.FromActivityDefinitionID == activity.ID);


                    ActivityDefinitionModel activitymodel = new ActivityDefinitionModel
                    {
                        Value = activity,
                    };
                    if (authList != null)
                    {
                        activitymodel.AuthDefinition = authList.FindAll(t => t.ActivityDefinitionID == activity.ID);
                    }
                    activitymodel.PreLinks  = preLinksTemp;
                    activitymodel.NextLinks = nextLinksTemp;
                    activityModelList.Add(activitymodel);
                    //没有父连接说明是根节点
                    if (!foundRoot && preLinksTemp.Count == 0)
                    {
                        model.Root = activitymodel;
                        foundRoot  = true;
                    }
                }
                item = new CacheItem(id, model);
                cache.AddItem(item, 30 * 60);
            }

            return(model);
        }
Exemplo n.º 3
0
 public bool Save(ISqlMapper mapper)
 {
     LinkDefinitionDao dao = new LinkDefinitionDao(mapper);
     var link = dao.Query(new LinkDefinitionQueryForm { ID = this.value.ID }).FirstOrDefault();
     if (link == null)
     {
         dao.Add(this.value);
     }
     else
     {
         dao.Update(new LinkDefinitionUpdateForm { Entity = this.value, LinkDefinitionQueryForm = new LinkDefinitionQueryForm { ID = this.value.ID } });
     }
     return true;
 }
        public static WorkflowDefinitionModel Load(string id)
        {
            var mapper = MapperHelper.GetMapper();
            WorkflowDefinitionDao wfdao = new WorkflowDefinitionDao(mapper);
            ActivityDefinitionDao addao = new ActivityDefinitionDao(mapper);
            LinkDefinitionDao linkdao = new LinkDefinitionDao(mapper);
            ActivityAuthDefinitionDao aadd = new ActivityAuthDefinitionDao(mapper);
            WorkflowDefinition workflow = null;
            List<ActivityDefinition> activityList = new List<ActivityDefinition>();
            List<LinkDefinition> linkList = new List<LinkDefinition>();
            List<ActivityAuthDefinition> authList = new List<ActivityAuthDefinition>();
            WorkflowDefinitionModel model = null;
            var item = cache.GetItem(id);
            if (item != null)
            {
                model = item.Value as WorkflowDefinitionModel;
                return model;
            }
            workflow = wfdao.Query(new WorkflowDefinitionQueryForm { ID = id, Enabled = 1 }).FirstOrDefault();
            activityList = addao.Query(new ActivityDefinitionQueryForm { WorkflowDefinitionID = id, Enabled = 1 });
            linkList = linkdao.Query(new LinkDefinitionQueryForm { WorkflowDefinitionID = id });
            authList = aadd.Query(new ActivityAuthDefinitionQueryForm { WorkflowDefinitionID = id });
            if (workflow != null)
            {
                List<ActivityDefinitionModel> activityModelList = new List<ActivityDefinitionModel>();
                List<LinkDefinitionModel> linkModelList = new List<LinkDefinitionModel>();
                model = new WorkflowDefinitionModel
                {
                    value = workflow,
                };
                bool foundRoot = false;
                foreach (var link in linkList)
                {
                    linkModelList.Add(new LinkDefinitionModel
                    {
                        Value = link,
                    });
                }
                foreach (var activity in activityList)
                {
                    List<LinkDefinitionModel> preLinks = new List<LinkDefinitionModel>();
                    var preLinksTemp = linkModelList.FindAll(t => t.Value.ToActivityDefinitionID == activity.ID);

                    List<LinkDefinitionModel> nextLinks = new List<LinkDefinitionModel>();
                    var nextLinksTemp = linkModelList.FindAll(t => t.Value.FromActivityDefinitionID == activity.ID);

                    ActivityDefinitionModel activitymodel = new ActivityDefinitionModel
                    {
                        Value = activity,
                    };
                    if (authList != null)
                    {
                        activitymodel.AuthDefinition = authList.FindAll(t => t.ActivityDefinitionID == activity.ID);
                    }
                    activitymodel.PreLinks = preLinksTemp;
                    activitymodel.NextLinks = nextLinksTemp;
                    activityModelList.Add(activitymodel);
                    //没有父连接说明是根节点
                    if (!foundRoot && preLinksTemp.Count == 0)
                    {
                        model.Root = activitymodel;
                        foundRoot = true;
                    }
                }
                item = new CacheItem(id, model);
                cache.AddItem(item, 30 * 60);
            }

            return model;
        }