|
|
@ -127,8 +127,45 @@ public class FlowInstanceService : ServiceBase, IFlowInstanceService
|
|
|
|
if (instance == null)
|
|
|
|
if (instance == null)
|
|
|
|
return DataResult.Failed("该流程模板已不存在,请重新设计流程!", MultiLanguageConst.FlowTemplateNotExist);
|
|
|
|
return DataResult.Failed("该流程模板已不存在,请重新设计流程!", MultiLanguageConst.FlowTemplateNotExist);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var userName = Db.Queryable<SysUser>().Where(x => x.Id == long.Parse(User.UserId)).Select(x => x.UserName).First();
|
|
|
|
|
|
|
|
|
|
|
|
//创建运行实例
|
|
|
|
//创建运行实例
|
|
|
|
var runtime = CreateRuntimeService(instance);
|
|
|
|
var runtime = CreateRuntimeService(instance);
|
|
|
|
|
|
|
|
if (runtime.ShouldSkip)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
instance.FlowStatus = FlowStatusEnum.Approve;
|
|
|
|
|
|
|
|
instance.Note = "已设置为自动跳过工作流执行";
|
|
|
|
|
|
|
|
Db.Insertable(instance).ExecuteCommand();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var history1 = new FlowInstanceHistory
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
InstanceId = instance.Id,
|
|
|
|
|
|
|
|
Content = "【创建】"
|
|
|
|
|
|
|
|
+ userName
|
|
|
|
|
|
|
|
+ "创建了一个流程进程【"
|
|
|
|
|
|
|
|
+ instance.CustomName + "】",
|
|
|
|
|
|
|
|
UserName = userName
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var history2 = new FlowInstanceHistory
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
InstanceId = instance.Id,
|
|
|
|
|
|
|
|
Content = "【审核】"
|
|
|
|
|
|
|
|
+ userName
|
|
|
|
|
|
|
|
+ "流程条件触发自动审核【"
|
|
|
|
|
|
|
|
+ instance.CustomName + "】",
|
|
|
|
|
|
|
|
UserName = userName
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FlowInstanceHistory[] histories = [history1, history2];
|
|
|
|
|
|
|
|
Db.Insertable(histories).ExecuteCommand();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(instance.CallbackURL))
|
|
|
|
|
|
|
|
Task.Factory.StartNew(() => RunCallbackAsync(instance));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var result = DataResult.Successed("创建工作流实例成功!", instance, MultiLanguageConst.FlowInstanceCreateSuccess);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (runtime.CurrentNode is { AssigneeType: "user", Users.Count: > 0 })
|
|
|
|
if (runtime.CurrentNode is { AssigneeType: "user", Users.Count: > 0 })
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -158,8 +195,6 @@ public class FlowInstanceService : ServiceBase, IFlowInstanceService
|
|
|
|
instance.MakerList = GetCurrentMakers(runtime);
|
|
|
|
instance.MakerList = GetCurrentMakers(runtime);
|
|
|
|
instance.FlowStatus = FlowStatusEnum.Ready;
|
|
|
|
instance.FlowStatus = FlowStatusEnum.Ready;
|
|
|
|
|
|
|
|
|
|
|
|
runtime.FlowInstanceId = instance.Id;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion 根据运行实例改变当前节点状态
|
|
|
|
#endregion 根据运行实例改变当前节点状态
|
|
|
|
|
|
|
|
|
|
|
|
Db.Insertable(instance).ExecuteCommand();
|
|
|
|
Db.Insertable(instance).ExecuteCommand();
|
|
|
@ -170,22 +205,18 @@ public class FlowInstanceService : ServiceBase, IFlowInstanceService
|
|
|
|
Task.Factory.StartNew(() => RunCallbackAsync(instance));
|
|
|
|
Task.Factory.StartNew(() => RunCallbackAsync(instance));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var userInfo = Db.Queryable<SysUser>().First(x => x.Id == long.Parse(User.UserId));
|
|
|
|
|
|
|
|
var history = new FlowInstanceHistory
|
|
|
|
var history = new FlowInstanceHistory
|
|
|
|
{
|
|
|
|
{
|
|
|
|
InstanceId = instance.Id,
|
|
|
|
InstanceId = instance.Id,
|
|
|
|
Content = "【创建】"
|
|
|
|
Content = "【创建】"
|
|
|
|
+ userInfo.UserName
|
|
|
|
+ userName
|
|
|
|
+ "创建了一个流程进程【"
|
|
|
|
+ "创建了一个流程进程【"
|
|
|
|
+ instance.CustomName + "】",
|
|
|
|
+ instance.CustomName + "】",
|
|
|
|
UserName = userInfo.UserName
|
|
|
|
UserName = userName
|
|
|
|
};
|
|
|
|
};
|
|
|
|
Db.Insertable(history).ExecuteCommand();
|
|
|
|
Db.Insertable(history).ExecuteCommand();
|
|
|
|
// var info = db.Queryable<FlowInstance>().Where(x => x.Id == req.Id).First();
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// info = req.Adapt(info);
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// db.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
|
|
|
|
|
|
|
|
return DataResult.Successed("创建工作流实例成功!", instance, MultiLanguageConst.FlowInstanceCreateSuccess);
|
|
|
|
return DataResult.Successed("创建工作流实例成功!", instance, MultiLanguageConst.FlowInstanceCreateSuccess);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -219,11 +250,9 @@ public class FlowInstanceService : ServiceBase, IFlowInstanceService
|
|
|
|
instance.ActivityId = startNodeId;
|
|
|
|
instance.ActivityId = startNodeId;
|
|
|
|
instance.ActivityType = wfruntime.GetNodeType(startNodeId);
|
|
|
|
instance.ActivityType = wfruntime.GetNodeType(startNodeId);
|
|
|
|
instance.ActivityName = wfruntime.ChildNodes.First(x => x.Id == startNodeId).Name;
|
|
|
|
instance.ActivityName = wfruntime.ChildNodes.First(x => x.Id == startNodeId).Name;
|
|
|
|
instance.MakerList = (wfruntime.GetNextNodeType() != 4 ? GetCurrentMakers(wfruntime) : "1");
|
|
|
|
instance.MakerList = wfruntime.GetNextNodeType() != 4 ? GetCurrentMakers(wfruntime) : "1";
|
|
|
|
instance.FlowStatus = FlowStatusEnum.Draft;
|
|
|
|
instance.FlowStatus = FlowStatusEnum.Draft;
|
|
|
|
|
|
|
|
|
|
|
|
wfruntime.FlowInstanceId = instance.Id;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion 根据运行实例改变当前节点状态
|
|
|
|
#endregion 根据运行实例改变当前节点状态
|
|
|
|
var serializerSettings = new JsonSerializerSettings
|
|
|
|
var serializerSettings = new JsonSerializerSettings
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -289,8 +318,6 @@ public class FlowInstanceService : ServiceBase, IFlowInstanceService
|
|
|
|
instance.MakerList = wfruntime.GetNextNodeType() != 4 ? GetNextMakers(wfruntime) : "1";
|
|
|
|
instance.MakerList = wfruntime.GetNextNodeType() != 4 ? GetNextMakers(wfruntime) : "1";
|
|
|
|
instance.FlowStatus = (wfruntime.GetNextNodeType() == 4 ? FlowStatusEnum.Approve : FlowStatusEnum.Running);
|
|
|
|
instance.FlowStatus = (wfruntime.GetNextNodeType() == 4 ? FlowStatusEnum.Approve : FlowStatusEnum.Running);
|
|
|
|
|
|
|
|
|
|
|
|
wfruntime.FlowInstanceId = instance.Id;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion 根据运行实例改变当前节点状态
|
|
|
|
#endregion 根据运行实例改变当前节点状态
|
|
|
|
|
|
|
|
|
|
|
|
Db.Updateable(instance).ExecuteCommand();
|
|
|
|
Db.Updateable(instance).ExecuteCommand();
|
|
|
|