public void UpdateDataFields(int procInstID, Dictionary <string, string> dict) { Connection k2Conn = new Connection(); try { k2Conn.Open(K2ServerName, WorkflowHelper.GetConnString()); SourceCode.Workflow.Client.ProcessInstance inst = k2Conn.OpenProcessInstance(procInstID); if (inst != null) { foreach (string s in dict.Keys) { inst.DataFields[s].Value = dict[s]; } } else { Response.Redirect("ProcessesManage_List.aspx", false); } inst.Update(); k2Conn.Close(); } catch { k2Conn.Close(); } }
/// <summary> /// 绑定默认DataFields /// </summary> /// <param name="procInstID"></param> private void LoadDataFields(int procInstID) { List <BPMListItem> items = new List <BPMListItem>(); Connection k2Conn = new Connection(); try { k2Conn.Open(K2ServerName, WorkflowHelper.GetConnString()); SourceCode.Workflow.Client.ProcessInstance inst = k2Conn.OpenProcessInstance(procInstID); if (inst != null) { foreach (DataField df in inst.DataFields) { items.Add(new BPMListItem { Name = df.Name, Value = df.Value.ToString() }); } rptList.DataSource = items; rptList.DataBind(); k2Conn.Close(); } else { k2Conn.Close(); } } catch (Exception ex) { k2Conn.Close(); lblException.Text = "异常信息:" + ex.Message; lblException.Visible = true; } }
/// <summary> /// 是否DataField /// </summary> /// <param name="procInstID"></param> /// <returns></returns> bool ExistDataField(int procInstID) { bool flag = false; Connection k2Conn = new Connection(); try { k2Conn.Open(K2ServerName, WorkflowHelper.GetConnString()); SourceCode.Workflow.Client.ProcessInstance inst = k2Conn.OpenProcessInstance(procInstID); if (inst != null) { foreach (DataField item in inst.DataFields) { if (item.Name == "IsPass") { flag = true; break; } } } k2Conn.Close(); } catch { k2Conn.Close(); } return(flag); }
public static bool ModifyDataField(string sn, NameValueCollection dataFields) { Connection k2Conn = new Connection(); try { k2Conn.Open(K2ServerName, WorkflowHelper.GetConnString()); SourceCode.Workflow.Client.ProcessInstance inst = k2Conn.OpenProcessInstance(Convert.ToInt32(sn.Split('_')[0])); if (inst != null) { foreach (string s in dataFields) { inst.DataFields[s].Value = dataFields[s]; } inst.Update(); } return(true); } catch (Exception ex) { return(false); } finally { k2Conn.Close(); } }
/// <summary> /// 是否存在实例 /// </summary> /// <param name="procInstID"></param> /// <returns></returns> bool ExistprocInst(int procInstID) { Connection k2Conn = new Connection(); try { k2Conn.Open(K2ServerName, WorkflowHelper.GetConnString()); SourceCode.Workflow.Client.ProcessInstance inst = k2Conn.OpenProcessInstance(procInstID); k2Conn.Close(); return(inst != null); } catch { k2Conn.Close(); return(false); } }