From ce9f67c3961ff47f19ad6b97790f710298115214 Mon Sep 17 00:00:00 2001 From: "yubaolee@163.com" Date: Fri, 23 Mar 2018 15:00:35 +0800 Subject: [PATCH] routine update --- OpenAuth.App/Flow/FlowRuntime.cs | 37 +++++++++++-------- OpenAuth.App/FlowInstanceApp.cs | 26 +++++++------ .../Controllers/FlowInstancesController.cs | 5 ++- OpenAuth.Mvc/userJs/flowInstanceEdit.js | 11 +----- 4 files changed, 42 insertions(+), 37 deletions(-) diff --git a/OpenAuth.App/Flow/FlowRuntime.cs b/OpenAuth.App/Flow/FlowRuntime.cs index 95e2f691..46b9cf07 100644 --- a/OpenAuth.App/Flow/FlowRuntime.cs +++ b/OpenAuth.App/Flow/FlowRuntime.cs @@ -1,6 +1,8 @@ using System; using System.Collections.Generic; +using System.Linq; using Infrastructure; +using Newtonsoft.Json.Linq; using OpenAuth.Repository.Domain; namespace OpenAuth.App.Flow @@ -19,8 +21,8 @@ namespace OpenAuth.App.Flow { _runtimeModel = new FlowRuntimeModel(); dynamic schemeContentJson = instance.SchemeContent.ToJson();//获取工作流模板内容的json对象; - _runtimeModel.schemeContentJson = schemeContentJson;//模板流程json对象 _runtimeModel.frmData = instance.FrmData; + _runtimeModel.schemeContentJson = schemeContentJson;//模板流程json对象 _runtimeModel.nodes = GetNodeDictionary(schemeContentJson);//节点集合 _runtimeModel.lines = GetLineDictionary(schemeContentJson);//线条集合 _runtimeModel.currentNodeId = (instance.ActivityId == "" ? _runtimeModel.startNodeId : instance.ActivityId); @@ -51,15 +53,16 @@ namespace OpenAuth.App.Flow private Dictionary GetNodeDictionary(dynamic schemeContentJson) { Dictionary nodeDictionary = new Dictionary(); - foreach (var item in schemeContentJson.Flow.nodes) + foreach (JObject item in schemeContentJson.nodes) { - if (!nodeDictionary.ContainsKey(item.id.Value)) + var node = item.ToObject(); + if (!nodeDictionary.ContainsKey(node.id)) { - nodeDictionary.Add(item.id.Value, item); + nodeDictionary.Add(node.id, node); } - if (item.type == FlowNode.START) + if (node.type == FlowNode.START) { - this._runtimeModel.startNodeId = item.id.Value; + this._runtimeModel.startNodeId = node.id; } } return nodeDictionary; @@ -72,16 +75,17 @@ namespace OpenAuth.App.Flow private Dictionary> GetLineDictionary(dynamic schemeContentJson) { Dictionary> lineDictionary = new Dictionary>(); - foreach (var item in schemeContentJson.Flow.lines) + foreach (JObject item in schemeContentJson.lines) { - if (!lineDictionary.ContainsKey(item.from.Value)) + var line = item.ToObject(); + if (!lineDictionary.ContainsKey(line.from)) { - List d = new List { item }; - lineDictionary.Add(item.from.Value, d); + List d = new List { line }; + lineDictionary.Add(line.from, d); } else { - lineDictionary[item.from.Value].Add(item); + lineDictionary[line.from].Add(line); } } return lineDictionary; @@ -94,16 +98,17 @@ namespace OpenAuth.App.Flow private Dictionary> GetToLineDictionary(dynamic schemeContentJson) { Dictionary> lineDictionary = new Dictionary>(); - foreach (var item in schemeContentJson.Flow.lines) + foreach (JObject item in schemeContentJson.lines) { - if (!lineDictionary.ContainsKey(item.to.Value)) + var line = item.ToObject(); + if (!lineDictionary.ContainsKey(line.to)) { - List d = new List { item }; - lineDictionary.Add(item.to.Value, d); + List d = new List { line }; + lineDictionary.Add(line.to, d); } else { - lineDictionary[item.to.Value].Add(item); + lineDictionary[line.to].Add(line); } } return lineDictionary; diff --git a/OpenAuth.App/FlowInstanceApp.cs b/OpenAuth.App/FlowInstanceApp.cs index 8a94e21e..c4b07fc5 100644 --- a/OpenAuth.App/FlowInstanceApp.cs +++ b/OpenAuth.App/FlowInstanceApp.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.Linq; using Infrastructure; +using Newtonsoft.Json.Linq; using OpenAuth.App.Flow; using OpenAuth.App.Request; using OpenAuth.App.Response; @@ -98,21 +99,24 @@ namespace OpenAuth.App /// /// һʵ /// - /// GUID - /// ģϢID - /// - /// ̱ - /// Զ - /// ע - /// Ϣ /// - public bool CreateInstance(FlowInstance flowInstance) + public bool CreateInstance(JObject obj) { + var flowInstance = obj.ToObject(); + + //ȡύı + var frmdata = new JObject(); + foreach (var property in obj.Properties().Where(U => U.Name.Contains("data_"))) + { + frmdata[property.Name] = property.Value; + } + flowInstance.FrmData = JsonHelper.Instance.Serialize(frmdata); + + //ʵ var wfruntime = new FlowRuntime(flowInstance); - - var user = AuthUtil.GetCurrentUser(); - #region ʵϢ + + #region ʵı䵱ǰڵ״̬ flowInstance.ActivityId = wfruntime.runtimeModel.nextNodeId; flowInstance.ActivityType = wfruntime.GetNextNodeType();//-1޷,0ǩʼ,1ǩ,2һڵ,4н flowInstance.ActivityName = wfruntime.runtimeModel.nextNode.name; diff --git a/OpenAuth.Mvc/Controllers/FlowInstancesController.cs b/OpenAuth.Mvc/Controllers/FlowInstancesController.cs index 9f69c102..8ca3df3f 100644 --- a/OpenAuth.Mvc/Controllers/FlowInstancesController.cs +++ b/OpenAuth.Mvc/Controllers/FlowInstancesController.cs @@ -1,7 +1,9 @@ using System; +using System.Linq; using System.Web.Http; using System.Web.Mvc; using Infrastructure; +using Newtonsoft.Json.Linq; using OpenAuth.App; using OpenAuth.App.Request; using OpenAuth.Mvc.Models; @@ -43,7 +45,8 @@ namespace OpenAuth.Mvc.Controllers //添加或修改 [System.Web.Mvc.HttpPost] - public string Add(FlowInstance obj) + [ValidateInput(false)] + public string Add(JObject obj) { try { diff --git a/OpenAuth.Mvc/userJs/flowInstanceEdit.js b/OpenAuth.Mvc/userJs/flowInstanceEdit.js index 7d7fe9f7..86562916 100644 --- a/OpenAuth.Mvc/userJs/flowInstanceEdit.js +++ b/OpenAuth.Mvc/userJs/flowInstanceEdit.js @@ -7,7 +7,6 @@ $ = layui.jquery; var table = layui.table; var openauth = layui.openauth; - var frmdata = {}; var index = parent.layer.getFrameIndex(window.name); //获取窗口索引 var id = $.getUrlParam("id"); //ID var update = (id !=null && id != ''); @@ -97,12 +96,6 @@ $("#FrmContentData").val(data.Result.ContentData); $("#FrmContentParse").val(data.Result.ContentParse); $("#frmPreview").html(data.Result.Content); - frmdata = $.arrayToObj(JSON.parse(data.Result.ContentData)); - $.extend(frmdata, vm.data); - vm = new Vue({ - el: "#formEdit", - data:frmdata - }); } }); @@ -163,9 +156,9 @@ $.extend(data.field, { - SchemeContent: JSON.stringify(content), - FrmData: JSON.stringify(frmdata) + SchemeContent: JSON.stringify(content) }); + $.post(url, data.field, function (result) {