/// <summary> /// 跳转 /// </summary> /// <param name="procInstID"></param> /// <param name="activityName"></param> /// <returns></returns> bool GoToActitvy(int procInstID, string activityName) { WorkflowManagementServer svr = new WorkflowManagementServer(); svr.CreateConnection(); svr.Connection.Open(WorkflowHelper.GetConnString4Management()); bool flag = svr.GotoActivity(procInstID, activityName); svr.Connection.Close(); return(flag); }
/// <summary> /// 获取下一个审批人(处理人/处理步骤/接收时间) /// </summary> /// <param name="formId"></param> /// <returns></returns> public static SourceCode.Workflow.Management.WorklistItems GetNextApprover(string formId) { WorkflowManagementServer wms = new WorkflowManagementServer(); try { wms.Open(WorkflowHelper.GetConnString4Management()); SourceCode.Workflow.Management.Criteria.WorklistCriteriaFilter wcf = new SourceCode.Workflow.Management.Criteria.WorklistCriteriaFilter(); wcf.AddRegularFilter(WorklistFields.Folio, SourceCode.Workflow.Management.Criteria.Comparison.Like, formId); WorklistItems wlis = wms.GetWorklistItems(wcf); wms.Connection.Close(); return(wlis); } catch { wms.Connection.Close(); return(null); } finally { } }
/// <summary> /// 绑定流程步骤 /// </summary> /// <param name="procInstID"></param> private void LoadSteps(int procInstID) { List <StepListItem> items = new List <StepListItem>(); WorkflowManagementServer svr = new WorkflowManagementServer(); svr.CreateConnection(); svr.Connection.Open(WorkflowHelper.GetConnString4Management()); Activities activities = svr.GetProcInstActivities(procInstID); foreach (Activity activity in activities) { items.Add(new StepListItem { Name = activity.Name, ID = activity.ID }); } rbtnListSteps.DataSource = items; rbtnListSteps.DataValueField = "ID"; rbtnListSteps.DataTextField = "Name"; rbtnListSteps.DataBind(); svr.Connection.Close(); }
void Stop() { int procInstID = Convert.ToInt32(lblId.Text); bool isExist = ExistprocInst(procInstID); //1-停止K2流程 WorkflowManagementServer svr = new WorkflowManagementServer(); svr.CreateConnection(); svr.Connection.Open(WorkflowHelper.GetConnString4Management()); if (isExist) { try { bool flag = svr.StopProcessInstances(procInstID); } catch (Exception ex) { Logger.Write(this.GetType(), EnumLogLevel.Info, "*****StopProcessInstances:" + ex.Message); } } svr.Connection.Close(); bool isExistDataField = ExistDataField(procInstID); //2-更新K2的ispass=2; if (isExistDataField) { try { NameValueCollection dataFields = new NameValueCollection(); dataFields.Add("IsPass", "2"); WorkflowHelper.UpdateDataFields(procInstID.ToString(), dataFields, "founder\\zybpmadmin"); } catch (Exception ex) { Logger.Write(this.GetType(), EnumLogLevel.Info, "*****UpdateDataFields:" + ex.Message); } } //3-更新实例状态为5 new Pkurg.PWorldBPM.Business.Controls.Management().StopActitvy(procInstID); //4-调用业务系统更新状态 int k2Sn = procInstID; string instanceID = ""; string formId = ""; string appId = ""; DataTable dt = new Pkurg.PWorldBPM.Business.Controls.Management().GetFlowInstance(k2Sn); if (dt != null && dt.Rows.Count > 0) { instanceID = dt.Rows[0]["InstanceID"].ToString(); formId = dt.Rows[0]["FormID"].ToString(); appId = dt.Rows[0]["AppID"].ToString(); } try { new Invoke().StopWorkFlow(k2Sn, instanceID, formId, appId); } catch (Exception ex) { Logger.Write(this.GetType(), EnumLogLevel.Info, "*****StopActitvy:" + ex.Message); } Logger.Write(this.GetType(), EnumLogLevel.Info, "*****终止流程操作结束"); BPMHelp.InsertInstanceLog("终止流程", formId.Replace("-", "").Trim(), "", Employee_Name + " - " + CurrentEmployee.EmployeeCode, HttpContext.Current.User.Identity.Name.Replace("founder\\", "")); }