public ResponseResult ReverseProcess(WfAppRunner runner) { IWorkflowService wfService = new WorkflowService(); IDbConnection conn = new SqlConnection(DBConfig.ConnectionString); conn.Open(); IDbTransaction trans = null; try { trans = conn.BeginTransaction(); var result = wfService.ReverseProcess(conn, runner, trans); trans.Commit(); if (result.Status == WfExecutedStatus.Success) return ResponseResult.Success(); else 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(); } }
/// <summary> /// 生产节点 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnMade_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["limu"]; appRunner.UserName = "******"; var wfService = new WorkflowService(); var nextSteps = wfService.GetNextActivityTree(appRunner); if (nextSteps != null) { //构造下一步办理人的信息 appRunner.NextActivityPerformers = CreateNextActivityPerformers(nextSteps); var r2 = wfService.RunProcessApp(appRunner); var msg2 = string.Format("执行【生产】:{0}, {1}\r\n", r2.Status, r2.Message); WriteText(msg2); if (r2.Status == WfExecutedStatus.Success) { WriteText(string.Format("任务已经发送到下一节点:{0}\r\n\r\n", nextSteps[0].ActivityName)); } } else { WriteText("您当前没有办理任务!\r\n"); } }
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 = "******"; IWorkflowService wfService = new WorkflowService(); //外部变量条件 Dictionary<string, string> dictCondition = new Dictionary<string, string>(); dictCondition.Add("surplus", cBoxSurplus.Text); appRunner.Conditions = dictCondition; //动态获取下一跳转后的节点 NodeView nv = wfService.GetNextActivity(appRunner, dictCondition); //指定对象执行者 PerformerList list = new PerformerList(); list.Add(new Performer("3", "user3")); Dictionary<String, PerformerList> dictPerformer = new Dictionary<String, PerformerList>(); dictPerformer.Add(nv.ActivityGUID, list); appRunner.NextActivityPerformers = dictPerformer; var result = wfService.RunProcessApp(appRunner); var msg = string.Format("流程运行结果:{0}\r\n{1}\r\n", result.Status, result.Message); tBoxResult.Text += msg; }
public ResponseResult EntrustTask(TaskEntrustedEntity entity) { IWorkflowService service = new WorkflowService(); service.EntrustTask(entity); return ResponseResult.Success(); }
public ResponseResult DiscardProcess(WfAppRunner discarder) { IWorkflowService service = new WorkflowService(); var result = service.DiscardProcess(discarder); return ResponseResult.Success(); }
/// <summary> /// 启动流程 /// </summary> public WfExecutedResult StartProcess(WfAppRunner runner) { //启动流程 var wfService = new WorkflowService(); var result = wfService.StartProcess(runner); return result; }
private void button1_Click(object sender, EventArgs e) { TaskQueryEntity query = new TaskQueryEntity(); query.AppInstanceID = "4612"; query.AppName = "order"; query.UserID = "2"; var wfService = new WorkflowService(); wfService.GetRunningTasks(query); }
/// <summary> /// 当前用户代办任务列表(一次加载所有数据) /// </summary> /// <returns></returns> public ActionResult FlowList() { IWorkflowService service = new WorkflowService(); TaskQueryEntity en = new TaskQueryEntity { UserID = User.Identity.GetUserId() }; IList<TaskViewEntity> taskViewList = service.GetReadyTasks(en); return View(taskViewList); }
/// <summary> /// 检查流程是否已经运行 /// </summary> /// <param name="runner">流程查询属性</param> /// <returns></returns> public Boolean CheckProcessInstanceRunning(WfAppRunner runner) { var isRunning = false; var wfService = new WorkflowService(); var instance = wfService.GetRunningProcessInstance(runner); if (instance != null) { isRunning = true; } return isRunning; }
protected void InitFlowXmlInfo() { String ProcessGUID = Request.QueryString["ProcessGUID"] == null ? String.Empty : Request.QueryString["ProcessGUID"].ToString(); if (ProcessGUID != String.Empty) { IWorkflowService wfService = new WorkflowService(); ProcessFileEntity processFileEntity = wfService.GetProcessFile(ProcessGUID); if (processFileEntity != null) { this.txtProcessGUID.Value = processFileEntity.ProcessGUID.ToString(); this.wfxml.InnerHtml = processFileEntity.XmlContent; } } }
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 = "******"; 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; }
public void SetTaskRead2000() { WfAppRunner taskRunner = new WfAppRunner(); taskRunner.TaskID = 18014; taskRunner.UserID = 10; taskRunner.UserName = "******"; IWorkflowService serviceA; for (var i = 0; i < 2000; i++) { serviceA = new WorkflowService(); serviceA.SetTaskRead(taskRunner); } }
/// <summary> /// 获取任务办理人列表 /// </summary> /// <param name="processInstanceID"></param> /// <param name="roles"></param> /// <returns></returns> public PerformerList GetPerformerList(int processInstanceID, List<Role> roles) { PerformerList performers = null; //获取流程发起人信息,在xml定义中有role变量:-1 if (roles.Count == 1 && roles[0].RoleCode == "-1") { IWorkflowService service = new WorkflowService(); Performer initiator = service.GetProcessInitiator(processInstanceID); performers = new PerformerList(); performers.Add(initiator); } return performers; }
/// <summary> /// 获取当前用户待办任务列表 /// </summary> private void GetReadyTasks() { IWorkflowService wfService = new WorkflowService(); TaskQueryEntity en = new TaskQueryEntity { UserID = LoginUserID.ToString() }; IList<TaskViewEntity> taskViewList = wfService.GetReadyTasks(en); if (taskViewList != null) { Repeater2.DataSource = taskViewList; Repeater2.DataBind(); } }
/// <summary> /// 读取XML文件 /// </summary> /// <param name="id"></param> /// <returns></returns> public ResponseResult<ProcessFileEntity> QueryProcessFile(ProcessFileQuery query) { var result = ResponseResult<ProcessFileEntity>.Default(); try { var wfService = new WorkflowService(); var entity = wfService.GetProcessFile(query.ProcessGUID, query.Version); result = ResponseResult<ProcessFileEntity>.Success(entity); } catch (System.Exception ex) { result = ResponseResult<ProcessFileEntity>.Error(string.Format("获取流程XML文件失败!{0}", ex.Message)); } return result; }
/// <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 = "******"; //先启动流程 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)); } } }
public ResponseResult DeleteProcess(ProcessEntity entity) { var result = ResponseResult.Default(); try { var wfService = new WorkflowService(); wfService.DeleteProcess(entity.ProcessGUID, entity.Version); result = ResponseResult.Success(); } catch (System.Exception ex) { result = ResponseResult.Error(string.Format("删除流程记录失败,错误:{0}", ex.Message)); } return result; }
public ResponseResult<List<NodeView>> GetNextStepRoleUserTree(WfAppRunner runner) { var result = ResponseResult<List<NodeView>>.Default(); try { var wfservice = new WorkflowService(); var nodeViewList = wfservice.GetNextActivityRoleUserTree(runner).ToList<NodeView>(); result = ResponseResult<List<NodeView>>.Success(nodeViewList, "获取流程下一步信息成功!"); } catch (System.Exception ex) { result = ResponseResult<List<NodeView>>.Error(string.Format( " 请确认角色身份是否切换?! {0}", ex.Message)); } return result; }
public ResponseResult<ProcessEntity> CreateProcess(ProcessEntity entity) { var result = ResponseResult<ProcessEntity>.Default(); try { var wfService = new WorkflowService(); var processID = wfService.CreateProcess(entity); entity.ID = processID; result = ResponseResult<ProcessEntity>.Success(entity); } catch (System.Exception ex) { result = ResponseResult<ProcessEntity>.Error(string.Format("创建流程记录失败,错误:{0}", ex.Message)); } return result; }
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 = "3"; appRunner.UserName = "******"; IWorkflowService wfService = new WorkflowService(); PerformerList list = new PerformerList(); list.Add(new Performer("4", "user4")); NodeView nv = wfService.GetNextActivity(appRunner); Dictionary<String, PerformerList> dictPerformer = new Dictionary<String, PerformerList>(); dictPerformer.Add(nv.ActivityGUID, list); appRunner.NextActivityPerformers = dictPerformer; var result = wfService.RunProcessApp(appRunner); var msg = string.Format("流程运行结果:{0}\r\n{1}\r\n", result.Status, result.Message); tBoxResult.Text += msg; }
public ResponseResult UpdateProcess(ProcessEntity entity) { var result = ResponseResult.Default(); try { var wfService = new WorkflowService(); var processEntity = wfService.GetProcessByVersion(entity.ProcessGUID, entity.Version); processEntity.ProcessName = entity.ProcessName; processEntity.XmlFileName = entity.XmlFileName; processEntity.AppType = entity.AppType; processEntity.Description = entity.Description; wfService.UpdateProcess(processEntity); result = ResponseResult.Success(); } catch (System.Exception ex) { result = ResponseResult.Error(string.Format("更新流程记录失败,错误:{0}", ex.Message)); } return result; }
public ResponseResult<List<TaskViewEntity>> QueryCompletedTasks(TaskQueryEntity query) { var result = ResponseResult<List<TaskViewEntity>>.Default(); try { var taskList = new List<TaskViewEntity>(); var wfService = new WorkflowService(); var itemList = wfService.GetCompletedTasks(query); if (itemList != null) { taskList = itemList.ToList(); } result = ResponseResult<List<TaskViewEntity>>.Success(taskList); } catch (System.Exception ex) { result = ResponseResult<List<TaskViewEntity>>.Error(string.Format( "获取已办任务数据失败, 异常信息:{0}", ex.Message)); } return result; }
public ResponseResult<List<Performer>> GetUserByRole(int id) { var result = ResponseResult<List<Performer>>.Default(); try { var performList = new List<Performer>(); var wfService = new WorkflowService(); var itemList = wfService.GetUserByRole(id).ToList(); foreach (var item in itemList) { Performer performer = new Performer(item.UserID.ToString(), item.UserName); performList.Add(performer); } result = ResponseResult<List<Performer>>.Success(performList, "成功获取流角色用户数据!"); } catch (System.Exception ex) { result = ResponseResult<List<Performer>>.Error(string.Format( "获取角色用户数据失败, 异常信息:{0}", ex.Message)); } return result; }
/// <summary> /// 退回流程 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnBackward_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 = "******"; //下一步执行人 PerformerList list = new PerformerList(); Performer p = new Performer("13", "andun");//下一步人ID,Name list.Add(p); Dictionary<String, PerformerList> dict = new Dictionary<String, PerformerList>(); dict.Add("fc8c71c5-8786-450e-af27-9f6a9de8560f", list); //print activity:"fc8c71c5-8786-450e-af27-9f6a9de8560f"下一步节点的标识ID appRunner.NextActivityPerformers = dict; IWorkflowService wfService = new WorkflowService(); var result = wfService.JumpProcess(appRunner); var msg = string.Format("流程跳转回退结果:{0}\r\n", result.Status); textBox1.Text += msg; }
/// <summary> /// 运行流程 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnRun_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 = "******"; IWorkflowService wfService = new WorkflowService(); TaskQueryEntity en = new TaskQueryEntity { UserID = "1" }; IList<TaskViewEntity> taskViewList = wfService.GetReadyTasks(en); if (taskViewList != null) { dataGridView1.DataSource = taskViewList; } ////下一步执行人 //PerformerList list = new PerformerList(); //Performer p = new Performer("3", "user3"); //下一步人ID,Name 注意有角色区分 //list.Add(p); //Dictionary<string, string> dictCondition = new Dictionary<string, string>(); //dictCondition.Add("IsHavingWeight", "true"); //dictCondition.Add("CanUseStock", "false"); //appRunner.Conditions = dictCondition; //NodeView nv = wfService.GetNextActivity(appRunner);//, dictCondition //Dictionary<String, PerformerList> dictPerformer = new Dictionary<String, PerformerList>(); //dictPerformer.Add(nv.ActivityGUID, list); //appRunner.NextActivityPerformers = dictPerformer; var result = wfService.RunProcessApp(appRunner); var msg = string.Format("流程运行结果:{0}\r\n", result.Status); textBox1.Text += msg; }
public IEnumerable<QueryResult> GetRunningTasks([FromODataUri]QueryEntity query) { IWorkflowService service = new WorkflowService(); Mapper.CreateMap<TaskViewEntity, QueryResult>(); Mapper.CreateMap<QueryEntity, TaskQueryEntity>(); var que = Mapper.Map<TaskQueryEntity>(query); try { var result = service.GetRunningTasks(que); if (result == null) { return new List<QueryResult>().AsEnumerable(); } else { var aa = Mapper.Map<IList<QueryResult>>(result); return aa.AsEnumerable(); } } catch { return new List<QueryResult>().AsEnumerable(); } }
/// <summary> /// 工作流运行 /// </summary> /// <param name="session"></param> /// <param name="runner"></param> /// <returns></returns> public WfExecutedResult RunProcess(IDbSession session, WfAppRunner runner, IDictionary<string, string> conditions = null) { var result = new WfExecutedResult(); var wfService = new WorkflowService(); var nodeViewList = wfService.GetNextActivityTree(runner, conditions).ToList<NodeView>(); foreach (var node in nodeViewList) { var performerList = wfService.GetPerformerList(node); //根据节点角色定义,读取执行者列表 Dictionary<string, PerformerList> dict = new Dictionary<string, PerformerList>(); dict.Add(node.ActivityGUID, performerList); runner.NextActivityPerformers = dict; if (node.IsSkipTo == true) { result = wfService.JumpProcess(session.Connection, runner, session.Transaction); } else { result = wfService.RunProcessApp(session.Connection, runner, session.Transaction); } } return result; }
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(); } }
public ResponseResult SendBackProcess(WfAppRunner runner) { IWorkflowService wfService = new WorkflowService(); IDbConnection conn = SessionFactory.CreateConnection(); IDbTransaction trans = null; try { trans = conn.BeginTransaction(); var result = wfService.SendBackProcess(conn, runner, trans); if (result.Status == WfExecutedStatus.Success) { trans.Commit(); 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(); } }
public void StartupRunEnd() { IDbConnection conn = new SqlConnection(DBConfig.ConnectionString); conn.Open(); ////StarterA: ////{"UserID":"10","UserName":"******","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 = "******"; 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 = "******"; 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 = "******"; 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(); } catch { trans.Rollback(); throw; } finally { trans.Dispose(); } if (conn.State == ConnectionState.Open) conn.Close(); }