public ActionResult Index(int id) { var workflowConfig = TheWorkflowConfigService.GetConfiguration(id); var taskTypes = TheHelper.TypesImplementingInterface(typeof(IWorkflowTask)); var tasks = taskTypes.Select(taskType => TheWorkflowTaskFactory.CreateTask(taskType)).ToList(); var adapter = new WorkflowTaskCollectionUiAdapter(tasks); var ids = workflowConfig.Tasks.Select(task => task.Id.ToString()).ToList(); var points = ThePointCollectionFactory.Create(ThePointService.GetPoints(ids)); var instanceTasks = TheUiWorkflowTaskCollectionFactory.Create(workflowConfig.Tasks, points); var view = new WorkflowDesignViewModel { Id = id, GuidsJson = TheHelper.JsSerializer.Serialize(TheGuidPool.CreateGuids(500)), TaskInfoJson = TheHelper.JsSerializer.Serialize(adapter), AvailableTasks = adapter.Tasks.Values, ConfigurationTasks = instanceTasks.UiTasks.Values, ConfigJson = TheHelper.JsSerializer.Serialize(instanceTasks) }; return(View(view)); }
protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); var workflowConfig = TheWorkflowConfigService.GetConfiguration(_workflowId); var ids = workflowConfig.Tasks.Select(task => task.Id.ToString()).ToList(); var points = ThePointCollectionFactory.Create(ThePointService.GetPoints(ids)); var tasks = TheUiWorkflowTaskCollectionFactory.Create(workflowConfig.Tasks, points); WorkflowConfigLiteral.Text = TheHelper.JsSerializer.Serialize(tasks); TaskInstanceRepeater.DataSource = tasks.UiTasks.Values; TaskInstanceRepeater.DataBind(); TaskMessageLiteral.Visible = (tasks.UiTasks.Values.Count == 0); }
public ActionResult Save(int id, FormCollection formCollection) { var taskInfo = TheTaskInfoCollectionFactory.Parse(formCollection["taskInfo"]); var transitionInfo = TheTransitionInfoCollectionFactory.Parse(formCollection["transitionInfo"]); var ids = taskInfo.Tasks.Select(task => task.Id).ToList(); ThePointService.DeletePoints(ids); TheWorkflowConfigService.RemoveTasks(id); TheWorkflowConfigService.RemoveTransitions(id); foreach (var task in taskInfo.Tasks) { var props = new Dictionary <string, object> { { "Name", task.Name }, { "Id", new Guid(task.Id) }, { "Description", task.Description }, { "IsStartTask", task.IsStartTask }, }; foreach (var item in task.CustomProperties) { props.Add(item.Key, item.Value); } ThePointService.AddPoint(task.Id, task.Top, task.Left); TheWorkflowConfigService.AddTask(id, task.AssemblyQualifiedTypeName, props); } foreach (var trans in transitionInfo.Transitions) { TheWorkflowConfigService.AddTransition(id, trans.Source, trans.Target, trans.Transition); } return(View("Close")); }
protected void SaveButtonClick(object sender, EventArgs e) { var taskInfo = TheTaskInfoCollectionFactory.Parse(Tasks.Value); var transitionInfo = TheTransitionInfoCollectionFactory.Parse(Transitions.Value); var ids = taskInfo.Tasks.Select(task => task.Id).ToList(); ThePointService.DeletePoints(ids); TheWorkflowConfigService.RemoveTasks(_workflowId); TheWorkflowConfigService.RemoveTransitions(_workflowId); foreach (var task in taskInfo.Tasks) { var props = new Dictionary <string, object> { { "Name", task.Name }, { "Id", new Guid(task.Id) }, { "Description", task.Description }, { "IsStartTask", task.IsStartTask }, }; foreach (var item in task.CustomProperties) { props.Add(item.Key, item.Value); } ThePointService.AddPoint(task.Id, task.Top, task.Left); TheWorkflowConfigService.AddTask(_workflowId, task.AssemblyQualifiedTypeName, props); } foreach (var trans in transitionInfo.Transitions) { TheWorkflowConfigService.AddTransition(_workflowId, trans.Source, trans.Target, trans.Transition); } CloseWindowLiteral.Visible = true; }