本文整理汇总了C#中Connection.OpenProcessInstance方法的典型用法代码示例。如果您正苦于以下问题:C# Connection.OpenProcessInstance方法的具体用法?C# Connection.OpenProcessInstance怎么用?C# Connection.OpenProcessInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Connection
的用法示例。
在下文中一共展示了Connection.OpenProcessInstance方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: btnLoadPI_Click
private void btnLoadPI_Click(object sender, EventArgs e)
{
try
{
Connection cnx = new Connection();
cnx.Open(ConfigurationManager.AppSettings["K2ServerName"]);
SourceCode.Workflow.Client.ProcessInstance pi = cnx.OpenProcessInstance(int.Parse(txtProcInstanceId.Text));
txtFolio.Text = pi.Folio;
lblStatus.Text = pi.Status1.ToString();
txtProcessFullName.Text = pi.FullName;
DataTable dt = new DataTable("Datafields");
dt.Columns.Add("Name");
dt.Columns.Add("Value");
foreach (DataField df in pi.DataFields)
{
dt.Rows.Add(new object[] { df.Name, df.Value });
}
displayActivity();
dgvDatafields.DataSource = dt;
dgvDatafields.Refresh();
dgvDatafields.AutoResizeColumn(0);
dgvDatafields.Columns[0].ReadOnly = true;
dgvDatafields.AutoResizeColumn(1);
cnx.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "PI Manager eror");
}
}
示例2: ApprovalProcess
/// <summary>
/// 审批流程
/// </summary>
/// <param name="userName"></param>
/// <param name="sn"></param>
/// <param name="actionString"></param>
/// <param name="memo"></param>
/// <param name="dataFields"></param>
public WorklistItem ApprovalProcess(string userName, string sn, string actionString, string memo, Dictionary<string, string> dataFields)
{
Connection k2Connection = new Connection();
try
{
k2Connection.Open(ConfigurationBase.Web.K2Server, ConfigurationBase.Web.K2LoginString);
k2Connection.ImpersonateUser(userName);
//根据SN打开工作项
WorklistItem workList = k2Connection.OpenWorklistItem(sn);
if (workList != null)
{
#region 更新Datafield
if (dataFields != null && dataFields.Count > 0)
{
ProcessInstance currentProcessInst = k2Connection.OpenProcessInstance(workList.ProcessInstance.ID);
//更新Datafields
foreach (string key in dataFields.Keys)
{
if (currentProcessInst.DataFields[key] != null)
{
if (currentProcessInst.DataFields[key].Value!= dataFields[key])
{
currentProcessInst.DataFields[key].Value = dataFields[key];
}
}
}
currentProcessInst.Update();
}
#endregion
#region 审批任务
//批量审批没有actionString,默认第一个操作
if (string.IsNullOrEmpty(actionString))
{
if (workList.Actions[0].Name == REJECTACTION)
{
workList.GotoActivity("流程未通过");
}
else if (workList.Actions[0].Name == UNDOACTION)
{
workList.GotoActivity("流程撤销");
}
else
{
workList.Actions[0].Execute();
}
}
else
{
//执行匹配的操作
if (actionString == UNDOACTION)
{
workList.GotoActivity("流程撤销");
}
else if (actionString == REJECTACTION)
{
workList.GotoActivity("流程未通过");
}
else
{
bool isExcuted = false;
for (int i = 0; i < workList.Actions.Count; i++)
{
if (workList.Actions[i].Name == actionString)
{
workList.Actions[i].Execute();
isExcuted = true;
break;
}
}
}
}
#endregion
}
return workList;
}
catch (Exception)
{
return null;
}
finally
{
if (k2Connection != null)
{
k2Connection.Close();
}
}
}