本文整理汇总了C#中Slickflow.Engine.Service.WorkflowService.StartProcess方法的典型用法代码示例。如果您正苦于以下问题:C# WorkflowService.StartProcess方法的具体用法?C# WorkflowService.StartProcess怎么用?C# WorkflowService.StartProcess使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Slickflow.Engine.Service.WorkflowService
的用法示例。
在下文中一共展示了WorkflowService.StartProcess方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: StartProcess
/// <summary>
/// 启动流程
/// </summary>
public WfExecutedResult StartProcess(WfAppRunner runner)
{
//启动流程
var wfService = new WorkflowService();
var result = wfService.StartProcess(runner);
return result;
}
示例2: WfAppRunner
private void btn开始_Click(object sender, EventArgs e)
{
WfAppRunner appRunner = new WfAppRunner();
appRunner.ProcessGUID = process_guid;
appRunner.AppInstanceID = application_instance_id;
//指定第一步的处理人
appRunner.AppName = "officeIn";
appRunner.UserID = "1";
appRunner.UserName = "user1";
IWorkflowService wfService = new WorkflowService();
var result = wfService.StartProcess(appRunner);
var msg = string.Format("流程运行结果:{0}\r\n{1}\r\n", result.Status, result.Message);
tBoxResult.Text += msg;
}
示例3: btnPrintOrder_Click
/// <summary>
/// 打单节点
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnPrintOrder_Click(object sender, EventArgs e)
{
WfAppRunner appRunner = new WfAppRunner();
appRunner.ProcessGUID = process_guid;
appRunner.AppInstanceID = application_instance_id;
appRunner.AppName = application_name;
appRunner.UserID = per_dict["yiran"];
appRunner.UserName = "yiran";
//先启动流程
var wfService = new WorkflowService();
var r1 = wfService.StartProcess(appRunner);
var msg = string.Format("生产订单流程开始:{0}, {1}\r\n", r1.Status, r1.Message);
WriteText(msg);
if (r1.Status == WfExecutedStatus.Success)
{
//打单环节加入条件,运行流程
var cond = new Dictionary<string, string>();
cond["CanUseStock"] = chkStock.Checked.ToString().ToLower();
cond["IsHavingWeight"] = chkWeight.Checked.ToString().ToLower();
appRunner.Conditions = cond;
string message = string.Empty;
var nextSteps = wfService.GetNextActivityTree(appRunner, cond);
if (nextSteps != null)
{
appRunner.NextActivityPerformers = CreateNextActivityPerformers(nextSteps);
var r2 = wfService.RunProcessApp(appRunner);
message = r2.Message;
WriteText(string.Format("执行【打单】: {0}, {1}\r\n", r2.Status, r2.Message));
if (r2.Status == WfExecutedStatus.Success)
{
WriteText(string.Format("任务已经发送到下一节点:{0}\r\n\r\n", nextSteps[0].ActivityName));
}
}
else
{
message = "下一步节点不匹配!";
WriteText(string.Format("{0}\r\n", message));
}
}
}
示例4: StartProcess
public ResponseResult StartProcess(WfAppRunner starter)
{
IWorkflowService wfService = new WorkflowService();
IDbConnection conn = SessionFactory.CreateConnection();
IDbTransaction trans = null;
try
{
trans = conn.BeginTransaction();
WfExecutedResult result = wfService.StartProcess(conn, starter, trans);
if (result.Status == WfExecutedStatus.Success)
{
trans.Commit();
int newProcessInstanceID = result.ProcessInstanceIDStarted;
IList<NodeView> nextSteps = wfService.GetNextActivityTree(starter);
return ResponseResult.Success();
}
else
{
trans.Rollback();
return ResponseResult.Error(result.Message);
}
}
catch (WorkflowException w)
{
trans.Rollback();
return ResponseResult.Error(w.Message);
}
finally
{
trans.Dispose();
if (conn.State == ConnectionState.Open)
conn.Close();
}
}
示例5: StartupRunEnd
public void StartupRunEnd()
{
IDbConnection conn = new SqlConnection(DBConfig.ConnectionString);
conn.Open();
////StarterA:
////{"UserID":"10","UserName":"Long","AppName":"SamplePrice","AppInstanceID":"100","ProcessGUID":"072af8c3-482a-4b1c-890b-685ce2fcc75d"}
var initiator = new WfAppRunner();
initiator.AppName = "SamplePrice";
initiator.AppInstanceID = 100;
initiator.ProcessGUID = Guid.Parse("072af8c3-482a-4b1c-890b-685ce2fcc75d");
initiator.UserID = 10;
initiator.UserName = "Long";
IWorkflowService service = new WorkflowService();
//流程开始->业务员提交
IDbTransaction trans = conn.BeginTransaction();
try
{
service.StartProcess(conn, initiator, trans);
trans.Commit();
}
catch
{
trans.Rollback();
throw;
}
finally
{
trans.Dispose();
}
//业务员提交->板房签字
var banFangNodeGuid = "fc8c71c5-8786-450e-af27-9f6a9de8560f";
PerformerList pList = new PerformerList();
pList.Add(new Performer(20, "Zhang"));
initiator.NextActivityPerformers = new Dictionary<Guid, PerformerList>();
initiator.NextActivityPerformers.Add(Guid.Parse(banFangNodeGuid), pList);
trans = conn.BeginTransaction();
try
{
service.RunProcessApp(conn, initiator, trans);
trans.Commit();
}
catch
{
trans.Rollback();
throw;
}
finally
{
trans.Dispose();
}
//板房签字->业务员签字
//登录用户身份
initiator.UserID = 20;
initiator.UserName = "Zhang";
var salesGuid = "39c71004-d822-4c15-9ff2-94ca1068d745";
pList.Clear();
pList.Add(new Performer(10, "Long"));
initiator.NextActivityPerformers.Clear();
initiator.NextActivityPerformers.Add(Guid.Parse(salesGuid), pList);
trans = conn.BeginTransaction();
try
{
service.RunProcessApp(conn, initiator, trans);
trans.Commit();
}
catch
{
trans.Rollback();
throw;
}
finally
{
trans.Dispose();
}
//业务员签字->结束
//登录用户身份
initiator.UserID = 10;
initiator.UserName = "Lhang";
var endGuid = "b70e717a-08da-419f-b2eb-7a3d71f054de";
pList.Clear();
pList.Add(new Performer(10, "Long"));
initiator.NextActivityPerformers.Clear();
initiator.NextActivityPerformers.Add(Guid.Parse(endGuid), pList);
trans = conn.BeginTransaction();
try
{
service.RunProcessApp(conn, initiator, trans);
trans.Commit();
//.........这里部分代码省略.........
示例6: btnStartup_Click
/// <summary>
/// 启动流程
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnStartup_Click(object sender, EventArgs e)
{
WfAppRunner appRunner = new WfAppRunner();
appRunner.ProcessGUID = process_guid;
appRunner.AppInstanceID = application_instance_id;
appRunner.AppName = "WallwaOrder";
appRunner.UserID = "1";
appRunner.UserName = "admin";
IWorkflowService wfService = new WorkflowService();
var result = wfService.StartProcess(appRunner);
var msg = string.Format("流程启动结果:{0}\r\n", result.Status);
textBox1.Text += msg;
}
示例7: btnSave_Click
//提交请假信息
protected void btnSave_Click(object sender, EventArgs e)
{
try
{
string processGUID = this.txtProcessGUID.Value.ToString();
string stepGuid = this.hiddenStepGuid.Value.ToString();
int stepUserID = Helper.ConverToInt32(this.hiddenStepUser.Value.ToString().Trim());
decimal days = Helper.ConverToDecimal(this.txtDays.Value);
int leaveType = Helper.ConverToInt32(selectLeaveType.Value);
int nextUserID = 0;
string nextUserName = string.Empty;
SysUserEntity userEntity = WorkFlows.GetSysUserModel(stepUserID);
if (userEntity != null && userEntity.ID > 0)
{
nextUserID = userEntity.ID;
nextUserName = userEntity.UserName;
}
DateTime now = DateTime.Now;
//请假业务数据
HrsLeaveEntity hrsLeaveEntity = new HrsLeaveEntity();
hrsLeaveEntity.LeaveType = leaveType;
hrsLeaveEntity.Days = days;
try
{
hrsLeaveEntity.FromDate = Helper.ConvertToDateTime(this.txtFromDate.Value, now);
}
catch (Exception ex)
{
hrsLeaveEntity.FromDate = now;
}
try
{
hrsLeaveEntity.ToDate = Helper.ConvertToDateTime(this.txtToDate.Value, now);
}
catch (Exception ex)
{
hrsLeaveEntity.ToDate = now;
}
hrsLeaveEntity.CurrentActivityText = string.Empty;
hrsLeaveEntity.Status = 0;
hrsLeaveEntity.CreatedUserID = LoginUserID;
hrsLeaveEntity.CreatedUserName = this.LoginUserName;
hrsLeaveEntity.CreatedDate = now;
int instanceId = WorkFlows.AddHrsLeave(hrsLeaveEntity);
if (instanceId > 0)
{
//调用流程
IWorkflowService service = new WorkflowService();
WfAppRunner initiator = new WfAppRunner();
initiator.AppName = "请假流程";
initiator.AppInstanceID = instanceId.ToString();
initiator.ProcessGUID = processGUID;
initiator.UserID = LoginUserID.ToString();
initiator.UserName = LoginUserName;
initiator.Conditions = GetCondition(string.Format("days-{0}", days));
WfExecutedResult startedResult = service.StartProcess(initiator);
if (startedResult.Status != WfExecutedStatus.Success)
{
base.RegisterStartupScript("", "<script>alert('" + startedResult.Message + "');</script>");
return;
}
//送往下一步
PerformerList pList = new PerformerList();
pList.Add(new Performer(nextUserID.ToString(), nextUserName));
initiator.NextActivityPerformers = new Dictionary<String, PerformerList>();
initiator.NextActivityPerformers.Add(stepGuid, pList);
WfExecutedResult runAppResult = service.RunProcessApp(initiator);
if (runAppResult.Status != WfExecutedStatus.Success)
{
base.RegisterStartupScript("", "<script>alert('" + runAppResult.Message + "');</script>");
return;
}
//保存业务数据
BizAppFlowEntity AppFlowEntity = new Entity.BizAppFlowEntity();
AppFlowEntity.AppName = "流程发起";
AppFlowEntity.AppInstanceID = instanceId.ToString();
AppFlowEntity.ActivityName = "流程发起";
AppFlowEntity.Remark = string.Format("申请人:{0}-{1}", LoginUserID, LoginUserName);
AppFlowEntity.ChangedTime = now;
AppFlowEntity.ChangedUserID = LoginUserID;
AppFlowEntity.ChangedUserName = LoginUserName;
WorkFlows.AddBizAppFlow(AppFlowEntity);
base.RegisterStartupScript("", "<script>alert('流程发起成功');window.location.href='FlowList.aspx';</script>");
}
}
catch (Exception ex)
//.........这里部分代码省略.........
示例8: Add
public async Task<ActionResult> Add(LeaveViewModel leave)
{
string processGUID = leave.ProcessGUID;
//验证不通过,重新填写表单
if (!ModelState.IsValid)
{
return View();
}
IWorkflowService service = new WorkflowService();
//流程开始第一步
ActivityEntity firstActivity = service.GetFirstActivity(leave.ProcessGUID);
//该处较上一版本有变化,上一版本为GUID类型
string firstActivityGUID = firstActivity.ActivityGUID;
IList<NodeView> nextActivity = service.GetNextActivity(leave.ProcessGUID, firstActivityGUID, GetCondition("days-" + leave.Days));
//表示有下一位审批者
if (nextActivity.Count() > 0)
{
//下一步角色ID审批者
string outerId = nextActivity[0].Roles[0].ID.ToString();
//这里只取第一个审批者,WebDemo 是弹窗形式选择
//审批用户id
IEnumerable<int> userId = RoleManager.FindById(Convert.ToInt32(outerId)).Users.Select(t => t.UserId);
ApplicationUser user = await UserManager.FindByIdAsync(Convert.ToInt32(userId.ToList()[0]));
//提交请假信息
LeaveEntity leaveE = new LeaveEntity()
{
FromDate = leave.BeginTime,
ToDate = leave.EndTime,
Days = leave.Days,
LeaveType = leave.LeaveType,
CurrentActivityText = "",
Status = 0,
CreatedUserID = Convert.ToInt32(User.Identity.GetUserId()),
CreatedUserName = User.Identity.Name,
CreatedDate = DateTime.Now
};
HrsLeaveResult result = new WorkFlowManager().Insert(leaveE);
if (result.Successed)
{
WfAppRunner initiator = new WfAppRunner();
initiator.AppName = "请假流程";
initiator.AppInstanceID = result.ResultIdentities.ToString();
initiator.ProcessGUID = processGUID;
initiator.UserID = User.Identity.GetUserId();
initiator.UserName = User.Identity.Name;
initiator.Conditions = GetCondition(string.Format("days-{0}", leave.Days));
WfExecutedResult startedResult = service.StartProcess(initiator);
if (startedResult.Status != WfExecutedStatus.Success)
{
//给出提示
}
//送往下一步
PerformerList pList = new PerformerList();
//这里使用真实姓名代替
pList.Add(new Performer(user.Id.ToString(), user.RealName));
initiator.NextActivityPerformers = new Dictionary<String, PerformerList>();
initiator.NextActivityPerformers.Add(nextActivity[0].ActivityGUID, pList);
WfExecutedResult runAppResult = service.RunProcessApp(initiator);
if (runAppResult.Status != WfExecutedStatus.Success)
{
this.Content("<script>alert('" + runAppResult.Message + "');</script>");
}
//保存业务数据
BizAppFlowEntity AppFlowEntity = new BizAppFlowEntity();
AppFlowEntity.AppName = "流程发起";
AppFlowEntity.AppInstanceID = result.ResultIdentities.ToString();
AppFlowEntity.ActivityName = "流程发起";
AppFlowEntity.Remark = string.Format("申请人:{0}-{1}", User.Identity.GetUserId(), User.Identity.Name);
AppFlowEntity.ChangedTime = DateTime.Now;
AppFlowEntity.ChangedUserID = User.Identity.GetUserId();
AppFlowEntity.ChangedUserName = User.Identity.Name;
HrsLeaveResult resultBiz = new WorkFlowManager().Insert(AppFlowEntity);
if (resultBiz.Successed)
{
//给出前台提示
this.Content("", "<script>alert('流程发起成功');</script>");
}
}
}
else
{
//显示前台错误,人事人员审批失败
ModelState.AddModelError("Human", "该用户暂时不可提交审批,未查询到该用户的下一位审批者");
return View();
}
return RedirectToAction("MySlickflow", "Slickflow");
}