routine update

This commit is contained in:
yubaolee@163.com 2018-03-23 15:00:35 +08:00
parent 2c5a114d64
commit ce9f67c396
4 changed files with 42 additions and 37 deletions

View File

@ -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<string, FlowNode> GetNodeDictionary(dynamic schemeContentJson)
{
Dictionary<string, FlowNode> nodeDictionary = new Dictionary<string, FlowNode>();
foreach (var item in schemeContentJson.Flow.nodes)
foreach (JObject item in schemeContentJson.nodes)
{
if (!nodeDictionary.ContainsKey(item.id.Value))
var node = item.ToObject<FlowNode>();
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<string, List<FlowLine>> GetLineDictionary(dynamic schemeContentJson)
{
Dictionary<string, List<FlowLine>> lineDictionary = new Dictionary<string, List<FlowLine>>();
foreach (var item in schemeContentJson.Flow.lines)
foreach (JObject item in schemeContentJson.lines)
{
if (!lineDictionary.ContainsKey(item.from.Value))
var line = item.ToObject<FlowLine>();
if (!lineDictionary.ContainsKey(line.from))
{
List<FlowLine> d = new List<FlowLine> { item };
lineDictionary.Add(item.from.Value, d);
List<FlowLine> d = new List<FlowLine> { 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<string, List<FlowLine>> GetToLineDictionary(dynamic schemeContentJson)
{
Dictionary<string, List<FlowLine>> lineDictionary = new Dictionary<string, List<FlowLine>>();
foreach (var item in schemeContentJson.Flow.lines)
foreach (JObject item in schemeContentJson.lines)
{
if (!lineDictionary.ContainsKey(item.to.Value))
var line = item.ToObject<FlowLine>();
if (!lineDictionary.ContainsKey(line.to))
{
List<FlowLine> d = new List<FlowLine> { item };
lineDictionary.Add(item.to.Value, d);
List<FlowLine> d = new List<FlowLine> { line };
lineDictionary.Add(line.to, d);
}
else
{
lineDictionary[item.to.Value].Add(item);
lineDictionary[line.to].Add(line);
}
}
return lineDictionary;

View File

@ -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
/// <summary>
/// 创建一个实例
/// </summary>
/// <param name="processId">进程GUID</param>
/// <param name="schemeInfoId">模板信息ID</param>
/// <param name="wfLevel"></param>
/// <param name="code">进程编号</param>
/// <param name="customName">自定义名称</param>
/// <param name="description">备注</param>
/// <param name="frmData">表单数据信息</param>
/// <returns></returns>
public bool CreateInstance(FlowInstance flowInstance)
public bool CreateInstance(JObject obj)
{
var flowInstance = obj.ToObject<FlowInstance>();
//获取提交的表单数据
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;

View File

@ -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
{

View File

@ -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) {