public bool Save() { ISqlMapper mapper = MapperHelper.GetMapper(); WorkflowDefinitionDao wddao = new WorkflowDefinitionDao(mapper); ActivityDefinitionDao addao = new ActivityDefinitionDao(mapper); LinkDefinitionDao linkdao = new LinkDefinitionDao(mapper); ActivityAuthDefinitionDao aadd = new ActivityAuthDefinitionDao(mapper); var workflowdefinition = wddao.Query(new WorkflowDefinitionQueryForm { ID = this.value.ID }).FirstOrDefault(); if (workflowdefinition == null) { wddao.Add(this.value); } else { wddao.Update(new WorkflowDefinitionUpdateForm { Entity = this.value, WorkflowDefinitionQueryForm = new WorkflowDefinitionQueryForm { ID = this.value.ID } }); } var activityList = this.Root.GetList(); foreach (var a in activityList) { var acitivitydefinitioninstance = a as ActivityDefinitionModel; acitivitydefinitioninstance.Save(mapper); } foreach (var link in LinkDefinitionList) { link.Save(mapper); } var item = cache.GetItem(this.value.ID); if (item == null) { item = new CacheItem(this.value.ID, this); cache.AddItem(item, 30 * 60); } else { item.Value = this; cache.UpdateItem(item); } return(true); }
public static WorkflowDefinitionModel LoadByName(string name) { var mapper = MapperHelper.GetMapper(); WorkflowDefinitionModel wfdm = null; WorkflowDefinitionDao wfdao = new WorkflowDefinitionDao(mapper); var wfd = wfdao.Query(new WorkflowDefinitionQueryForm { Name = name }).FirstOrDefault(); if (wfd != null) { wfdm = Load(wfd.ID); } return(wfdm); }
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); }
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; }
public bool Save() { ISqlMapper mapper = MapperHelper.GetMapper(); WorkflowDefinitionDao wddao = new WorkflowDefinitionDao(mapper); ActivityDefinitionDao addao = new ActivityDefinitionDao(mapper); LinkDefinitionDao linkdao = new LinkDefinitionDao(mapper); ActivityAuthDefinitionDao aadd = new ActivityAuthDefinitionDao(mapper); var workflowdefinition = wddao.Query(new WorkflowDefinitionQueryForm { ID = this.value.ID }).FirstOrDefault(); if (workflowdefinition == null) { wddao.Add(this.value); } else { wddao.Update(new WorkflowDefinitionUpdateForm { Entity = this.value, WorkflowDefinitionQueryForm = new WorkflowDefinitionQueryForm { ID = this.value.ID } }); } var activityList = this.Root.GetList(); foreach (var a in activityList) { var acitivitydefinitioninstance = a as ActivityDefinitionModel; acitivitydefinitioninstance.Save(mapper); } foreach (var link in LinkDefinitionList) { link.Save(mapper); } var item = cache.GetItem(this.value.ID); if (item == null) { item = new CacheItem(this.value.ID, this); cache.AddItem(item, 30 * 60); } else { item.Value = this; cache.UpdateItem(item); } return true; }
public static WorkflowDefinitionModel LoadByName(string name) { var mapper = MapperHelper.GetMapper(); WorkflowDefinitionModel wfdm = null; WorkflowDefinitionDao wfdao = new WorkflowDefinitionDao(mapper); var wfd = wfdao.Query(new WorkflowDefinitionQueryForm { Name = name }).FirstOrDefault(); if (wfd != null) { wfdm = Load(wfd.ID); } return wfdm; }