mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-07-16 16:50:54 +08:00
fix issue #I62Y58 更新流程实例时,同时更新拖拽表单关联的数据库表(或自定义表单定义的表)
This commit is contained in:
parent
f55ceba171
commit
bb7bb2675f
@ -116,7 +116,8 @@ namespace OpenAuth.App
|
|||||||
flowInstance.PreviousId = wfruntime.currentNodeId;
|
flowInstance.PreviousId = wfruntime.currentNodeId;
|
||||||
flowInstance.CreateUserId = user.User.Id;
|
flowInstance.CreateUserId = user.User.Id;
|
||||||
flowInstance.CreateUserName = user.User.Account;
|
flowInstance.CreateUserName = user.User.Account;
|
||||||
flowInstance.MakerList = (wfruntime.GetNextNodeType() != 4 ? GetNextMakers(wfruntime, addFlowInstanceReq) : "");
|
flowInstance.MakerList =
|
||||||
|
(wfruntime.GetNextNodeType() != 4 ? GetNextMakers(wfruntime, addFlowInstanceReq) : "");
|
||||||
flowInstance.IsFinish = (wfruntime.GetNextNodeType() == 4
|
flowInstance.IsFinish = (wfruntime.GetNextNodeType() == 4
|
||||||
? FlowInstanceStatus.Finished
|
? FlowInstanceStatus.Finished
|
||||||
: FlowInstanceStatus.Running);
|
: FlowInstanceStatus.Running);
|
||||||
@ -232,12 +233,70 @@ namespace OpenAuth.App
|
|||||||
throw new Exception("只能修改【草稿】和【驳回】状态的流程");
|
throw new Exception("只能修改【草稿】和【驳回】状态的流程");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var form = _formApp.Get(flowinstance.FrmId);
|
||||||
|
|
||||||
|
if (form != null)
|
||||||
|
{
|
||||||
|
if (form.FrmType == 1) //如果是开发者自定义的表单,更新对应数据库表数据
|
||||||
|
{
|
||||||
|
var t = Type.GetType("OpenAuth.App." + req.DbName + "App");
|
||||||
|
ICustomerForm icf = (ICustomerForm) _serviceProvider.GetService(t);
|
||||||
|
icf.Update(req.Id, req.FrmData);
|
||||||
|
}
|
||||||
|
else if (form.FrmType == 2 && !string.IsNullOrEmpty(form.DbName)) //拖拽表单定义了关联数据库
|
||||||
|
{
|
||||||
|
var dbcolumns = _dbExtension.GetDbTableStructure(form.DbName);
|
||||||
|
var json = JsonHelper.Instance.Deserialize<JObject>(req.FrmData);
|
||||||
|
var updatestr = string.Empty; //字段
|
||||||
|
|
||||||
|
foreach (var column in dbcolumns)
|
||||||
|
{
|
||||||
|
if (column.ColumnName == "Id" || column.ColumnName == "id")
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
//讲流程实例ID赋值到表单数据表中,实现表单记录与流程实例关联
|
||||||
|
if (column.ColumnName == Define.DEFAULT_FORM_INSTANCE_ID_NAME)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
var val = json[column.ColumnName];
|
||||||
|
if (val == null)
|
||||||
|
{
|
||||||
|
switch (column.EntityType)
|
||||||
|
{
|
||||||
|
case "int":
|
||||||
|
val = 0;
|
||||||
|
break;
|
||||||
|
case "string":
|
||||||
|
val = "";
|
||||||
|
break;
|
||||||
|
case "DateTime":
|
||||||
|
val = DateTime.Now.ToString("yyyy-MM-dd");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (val == null) continue;
|
||||||
|
updatestr += $"{column.ColumnName} = '{val}',";
|
||||||
|
}
|
||||||
|
|
||||||
|
updatestr = updatestr.TrimEnd(',');
|
||||||
|
var sql =
|
||||||
|
$"update {form.DbName} set {updatestr} where {Define.DEFAULT_FORM_INSTANCE_ID_NAME}='{req.Id}'";
|
||||||
|
UnitWork.ExecuteSql(sql);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
flowinstance.Description = req.Description;
|
flowinstance.Description = req.Description;
|
||||||
flowinstance.Code = req.Code;
|
flowinstance.Code = req.Code;
|
||||||
flowinstance.FrmData = req.FrmData;
|
flowinstance.FrmData = req.FrmData;
|
||||||
flowinstance.DbName = req.DbName;
|
flowinstance.DbName = req.DbName;
|
||||||
flowinstance.CustomName = req.CustomName;
|
flowinstance.CustomName = req.CustomName;
|
||||||
Repository.Update(flowinstance);
|
UnitWork.Update(flowinstance);
|
||||||
|
UnitWork.Save();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -502,20 +561,24 @@ namespace OpenAuth.App
|
|||||||
makerList = GetForkNodeMakers(wfruntime, wfruntime.nextNodeId);
|
makerList = GetForkNodeMakers(wfruntime, wfruntime.nextNodeId);
|
||||||
}
|
}
|
||||||
else if (wfruntime.nextNode.setInfo.NodeDesignate == Setinfo.RUNTIME_SPECIAL_ROLE)
|
else if (wfruntime.nextNode.setInfo.NodeDesignate == Setinfo.RUNTIME_SPECIAL_ROLE)
|
||||||
{ //如果是运行时指定角色
|
{
|
||||||
|
//如果是运行时指定角色
|
||||||
if (wfruntime.nextNode.setInfo.NodeDesignate != request.NodeDesignateType)
|
if (wfruntime.nextNode.setInfo.NodeDesignate != request.NodeDesignateType)
|
||||||
{
|
{
|
||||||
throw new Exception("前端提交的节点权限类型异常,请检查流程");
|
throw new Exception("前端提交的节点权限类型异常,请检查流程");
|
||||||
}
|
}
|
||||||
|
|
||||||
var users = _revelanceApp.Get(Define.USERROLE, false, request.NodeDesignates);
|
var users = _revelanceApp.Get(Define.USERROLE, false, request.NodeDesignates);
|
||||||
makerList = GenericHelpers.ArrayToString(users, makerList);
|
makerList = GenericHelpers.ArrayToString(users, makerList);
|
||||||
}
|
}
|
||||||
else if (wfruntime.nextNode.setInfo.NodeDesignate == Setinfo.RUNTIME_SPECIAL_USER)
|
else if (wfruntime.nextNode.setInfo.NodeDesignate == Setinfo.RUNTIME_SPECIAL_USER)
|
||||||
{ //如果是运行时指定用户
|
{
|
||||||
|
//如果是运行时指定用户
|
||||||
if (wfruntime.nextNode.setInfo.NodeDesignate != request.NodeDesignateType)
|
if (wfruntime.nextNode.setInfo.NodeDesignate != request.NodeDesignateType)
|
||||||
{
|
{
|
||||||
throw new Exception("前端提交的节点权限类型异常,请检查流程");
|
throw new Exception("前端提交的节点权限类型异常,请检查流程");
|
||||||
}
|
}
|
||||||
|
|
||||||
makerList = GenericHelpers.ArrayToString(request.NodeDesignates, makerList);
|
makerList = GenericHelpers.ArrayToString(request.NodeDesignates, makerList);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -647,6 +710,7 @@ namespace OpenAuth.App
|
|||||||
{
|
{
|
||||||
CheckNodeDesignate(request);
|
CheckNodeDesignate(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isReject = TagState.Reject.Equals((TagState) Int32.Parse(request.VerificationFinally));
|
bool isReject = TagState.Reject.Equals((TagState) Int32.Parse(request.VerificationFinally));
|
||||||
if (isReject) //驳回
|
if (isReject) //驳回
|
||||||
{
|
{
|
||||||
@ -692,6 +756,7 @@ namespace OpenAuth.App
|
|||||||
resp.NextNodeDesignateType = runtime.nextNode.setInfo.NodeDesignate;
|
resp.NextNodeDesignateType = runtime.nextNode.setInfo.NodeDesignate;
|
||||||
resp.CanWriteFormItemIds = runtime.currentNode.setInfo.CanWriteFormItemIds;
|
resp.CanWriteFormItemIds = runtime.currentNode.setInfo.CanWriteFormItemIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
return resp;
|
return resp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -715,7 +780,8 @@ namespace OpenAuth.App
|
|||||||
|
|
||||||
result.count = await UnitWork.Find(waitExp).CountAsync();
|
result.count = await UnitWork.Find(waitExp).CountAsync();
|
||||||
|
|
||||||
result.data =await UnitWork.Find(request.page, request.limit, "CreateDate descending", waitExp).ToListAsync();
|
result.data = await UnitWork.Find(request.page, request.limit, "CreateDate descending", waitExp)
|
||||||
|
.ToListAsync();
|
||||||
}
|
}
|
||||||
else if (request.type == "disposed") //已办事项(即我参与过的流程)
|
else if (request.type == "disposed") //已办事项(即我参与过的流程)
|
||||||
{
|
{
|
||||||
@ -833,6 +899,7 @@ namespace OpenAuth.App
|
|||||||
{
|
{
|
||||||
throw new Exception("当前流程不是草稿状态,不能启动");
|
throw new Exception("当前流程不是草稿状态,不能启动");
|
||||||
}
|
}
|
||||||
|
|
||||||
var wfruntime = new FlowRuntime(flowInstance);
|
var wfruntime = new FlowRuntime(flowInstance);
|
||||||
var user = _auth.GetCurrentUser();
|
var user = _auth.GetCurrentUser();
|
||||||
|
|
||||||
@ -843,6 +910,7 @@ namespace OpenAuth.App
|
|||||||
}
|
}
|
||||||
|
|
||||||
#region 根据运行实例改变当前节点状态
|
#region 根据运行实例改变当前节点状态
|
||||||
|
|
||||||
flowInstance.ActivityId = wfruntime.nextNodeId;
|
flowInstance.ActivityId = wfruntime.nextNodeId;
|
||||||
flowInstance.ActivityType = wfruntime.GetNextNodeType();
|
flowInstance.ActivityType = wfruntime.GetNextNodeType();
|
||||||
flowInstance.ActivityName = wfruntime.nextNode.name;
|
flowInstance.ActivityName = wfruntime.nextNode.name;
|
||||||
@ -855,6 +923,7 @@ namespace OpenAuth.App
|
|||||||
: FlowInstanceStatus.Running);
|
: FlowInstanceStatus.Running);
|
||||||
|
|
||||||
UnitWork.Update(flowInstance);
|
UnitWork.Update(flowInstance);
|
||||||
|
|
||||||
#endregion 根据运行实例改变当前节点状态
|
#endregion 根据运行实例改变当前节点状态
|
||||||
|
|
||||||
#region 流程操作记录
|
#region 流程操作记录
|
||||||
|
Loading…
Reference in New Issue
Block a user