mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-07-17 01:46:30 +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);
|
||||||
@ -136,13 +137,13 @@ namespace OpenAuth.App
|
|||||||
{
|
{
|
||||||
var dbcolumns = _dbExtension.GetDbTableStructure(form.DbName);
|
var dbcolumns = _dbExtension.GetDbTableStructure(form.DbName);
|
||||||
var json = JsonHelper.Instance.Deserialize<JObject>(addFlowInstanceReq.FrmData);
|
var json = JsonHelper.Instance.Deserialize<JObject>(addFlowInstanceReq.FrmData);
|
||||||
var columnstr = string.Empty; //字段
|
var columnstr = string.Empty; //字段
|
||||||
var valstr = string.Empty; //值字符串
|
var valstr = string.Empty; //值字符串
|
||||||
|
|
||||||
|
|
||||||
foreach (var column in dbcolumns)
|
foreach (var column in dbcolumns)
|
||||||
{
|
{
|
||||||
if (column.ColumnName == "Id" || column.ColumnName=="id")
|
if (column.ColumnName == "Id" || column.ColumnName == "id")
|
||||||
{
|
{
|
||||||
var options = new IdGeneratorOptions()
|
var options = new IdGeneratorOptions()
|
||||||
{
|
{
|
||||||
@ -181,7 +182,7 @@ namespace OpenAuth.App
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(val == null) continue;
|
if (val == null) continue;
|
||||||
columnstr += column.ColumnName + ",";
|
columnstr += column.ColumnName + ",";
|
||||||
valstr += "'" + val + "',";
|
valstr += "'" + val + "',";
|
||||||
}
|
}
|
||||||
@ -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>
|
||||||
@ -374,7 +433,7 @@ namespace OpenAuth.App
|
|||||||
{
|
{
|
||||||
var t = Type.GetType("OpenAuth.App." + flowInstance.DbName + "App");
|
var t = Type.GetType("OpenAuth.App." + flowInstance.DbName + "App");
|
||||||
ICustomerForm icf = (ICustomerForm) _serviceProvider.GetService(t);
|
ICustomerForm icf = (ICustomerForm) _serviceProvider.GetService(t);
|
||||||
icf.Update(flowInstance.Id,flowInstance.FrmData);
|
icf.Update(flowInstance.Id, flowInstance.FrmData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -382,8 +441,8 @@ namespace OpenAuth.App
|
|||||||
UnitWork.Add(flowInstanceOperationHistory);
|
UnitWork.Add(flowInstanceOperationHistory);
|
||||||
|
|
||||||
//给流程创建人发送通知信息
|
//给流程创建人发送通知信息
|
||||||
_messageApp.SendMsgTo(flowInstance.CreateUserId,
|
_messageApp.SendMsgTo(flowInstance.CreateUserId,
|
||||||
$"你的流程[{flowInstance.CustomName}]已被{user.Name}处理。处理情况如下:{flowInstanceOperationHistory.Content}");
|
$"你的流程[{flowInstance.CustomName}]已被{user.Name}处理。处理情况如下:{flowInstanceOperationHistory.Content}");
|
||||||
|
|
||||||
UnitWork.Save();
|
UnitWork.Save();
|
||||||
|
|
||||||
@ -489,7 +548,7 @@ namespace OpenAuth.App
|
|||||||
/// 一般用于本节点审核完成后,修改流程实例的当前执行人,可以做到通知等功能
|
/// 一般用于本节点审核完成后,修改流程实例的当前执行人,可以做到通知等功能
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
private string GetNextMakers(FlowRuntime wfruntime, NodeDesignateReq request=null)
|
private string GetNextMakers(FlowRuntime wfruntime, NodeDesignateReq request = null)
|
||||||
{
|
{
|
||||||
string makerList = "";
|
string makerList = "";
|
||||||
if (wfruntime.nextNodeId == "-1")
|
if (wfruntime.nextNodeId == "-1")
|
||||||
@ -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) //驳回
|
||||||
{
|
{
|
||||||
@ -680,18 +744,19 @@ namespace OpenAuth.App
|
|||||||
public FlowVerificationResp GetForVerification(string id)
|
public FlowVerificationResp GetForVerification(string id)
|
||||||
{
|
{
|
||||||
var flowinstance = Get(id);
|
var flowinstance = Get(id);
|
||||||
var resp =flowinstance.MapTo<FlowVerificationResp>();
|
var resp = flowinstance.MapTo<FlowVerificationResp>();
|
||||||
var runtime = new FlowRuntime(flowinstance);
|
var runtime = new FlowRuntime(flowinstance);
|
||||||
if (runtime.currentNode != null && runtime.currentNode.setInfo !=null)
|
if (runtime.currentNode != null && runtime.currentNode.setInfo != null)
|
||||||
{
|
{
|
||||||
resp.CanWriteFormItemIds = runtime.currentNode.setInfo.CanWriteFormItemIds;
|
resp.CanWriteFormItemIds = runtime.currentNode.setInfo.CanWriteFormItemIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (runtime.nextNode != null && runtime.nextNode.setInfo !=null && runtime.nextNodeType != 4)
|
if (runtime.nextNode != null && runtime.nextNode.setInfo != null && runtime.nextNodeType != 4)
|
||||||
{
|
{
|
||||||
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") //已办事项(即我参与过的流程)
|
||||||
{
|
{
|
||||||
@ -734,7 +800,7 @@ namespace OpenAuth.App
|
|||||||
result.data = await query.OrderByDescending(u => u.CreateDate)
|
result.data = await query.OrderByDescending(u => u.CreateDate)
|
||||||
.Skip((request.page - 1) * request.limit)
|
.Skip((request.page - 1) * request.limit)
|
||||||
.Take(request.limit).ToListAsync();
|
.Take(request.limit).ToListAsync();
|
||||||
result.count =await instances.CountAsync();
|
result.count = await instances.CountAsync();
|
||||||
}
|
}
|
||||||
else //我的流程
|
else //我的流程
|
||||||
{
|
{
|
||||||
@ -746,7 +812,7 @@ namespace OpenAuth.App
|
|||||||
myFlowExp = myFlowExp.And(t => t.CustomName.Contains(request.key));
|
myFlowExp = myFlowExp.And(t => t.CustomName.Contains(request.key));
|
||||||
}
|
}
|
||||||
|
|
||||||
result.count =await UnitWork.Find(myFlowExp).CountAsync();
|
result.count = await UnitWork.Find(myFlowExp).CountAsync();
|
||||||
result.data = await UnitWork.Find(request.page, request.limit,
|
result.data = await UnitWork.Find(request.page, request.limit,
|
||||||
"CreateDate descending", myFlowExp).ToListAsync();
|
"CreateDate descending", myFlowExp).ToListAsync();
|
||||||
}
|
}
|
||||||
@ -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