本文整理汇总了C#中Connection.StartProcessInstance方法的典型用法代码示例。如果您正苦于以下问题:C# Connection.StartProcessInstance方法的具体用法?C# Connection.StartProcessInstance怎么用?C# Connection.StartProcessInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Connection
的用法示例。
在下文中一共展示了Connection.StartProcessInstance方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: btnDuplicate_Click
private void btnDuplicate_Click(object sender, EventArgs e)
{
try
{
Connection cnx = new Connection();
cnx.Open(ConfigurationManager.AppSettings["K2ServerName"]);
SourceCode.Workflow.Client.ProcessInstance pi = cnx.CreateProcessInstance(txtProcessFullName.Text);
pi.Folio = txtFolio.Text;
foreach (DataGridViewRow item in dgvDatafields.Rows)
{
pi.DataFields[item.Cells[0].Value.ToString()].Value = item.Cells[1].Value.ToString();
}
cnx.StartProcessInstance(pi);
int newProcId= pi.ID;
cnx.Close();
if (ddlActivities.SelectedIndex > 1)
{
WorkflowManagementServer wms = new WorkflowManagementServer();
wms.CreateConnection();
wms.Connection.Open(ConfigurationManager.AppSettings["K2MgmCnxString"]);
wms.GotoActivity(newProcId, ddlActivities.SelectedItem.ToString());
wms.Connection.Close();
}
MessageBox.Show("L'instance à été dupliquée. (ID: " + newProcId.ToString() + ")", "PI Management");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "PI Manager eror");
}
}
示例2: StartProcess
public ResultModel StartProcess(string processName, int loginId, string objectId, string folio, Dictionary<string, string> dataFields,out int procInstId)
{
Connection k2Connect = null;
WorklistItem workList = null;
ResultModel jr = new ResultModel() { Code = ResultCode.Fail };
procInstId = 0;
try
{
k2Connect = new Connection();
k2Connect.Open(ConfigurationManager.AppSettings["K2Server"], ConfigurationManager.AppSettings["K2LoginString"]);
k2Connect.ImpersonateUser(SecurityLable(loginId.ToString()));
//创建实例
ProcessInstance ProcessInst = k2Connect.CreateProcessInstance(processName);
if (!string.IsNullOrEmpty(folio))
{
ProcessInst.Folio = folio;
}
#region //赋值datafields
foreach (string key in dataFields.Keys)
{
if (ProcessInst.DataFields[key] != null)
{
ProcessInst.DataFields[key].Value = dataFields[key];
}
}
#endregion
k2Connect.StartProcessInstance(ProcessInst);
procInstId = ProcessInst.ID;
jr.Code = ResultCode.Sucess;
jr.Msg = procInstId.ToString();
}
catch (Exception ex)
{
jr.Msg = ex.Message;
}
finally
{
if (workList != null)
{
if (workList.Status == WorklistStatus.Open)
{
try
{
k2Connect.RevertUser();
workList.Release();
}
catch { }
}
}
if (k2Connect != null)
k2Connect.Close();
}
return jr;
//var result = (new K2Service.K2Service()).StartProcess(processCode, loginId, objectId, folio, jsonData, ConfigurationManager.AppSettings["APIKEY"]);
}
示例3: Execute
//.........这里部分代码省略.........
xmlName.InnerText = originatorUserEntity["domainname"] != null ? originatorUserEntity["domainname"].ToString() : "";
xmlItem.AppendChild(xmlName);
xmlName = EntityDoc.CreateElement("UserDisplayName");
xmlName.InnerText = originatorUserEntity["fullname"] != null ? originatorUserEntity["fullname"].ToString() : "";
xmlItem.AppendChild(xmlName);
//Add Item to main doc
EntElement.AppendChild(xmlItem);
EntityDoc.AppendChild(EntElement);
//Release node objects
EntElement = null;
xmlName = null;
#endregion Create XML Context
conn = new Connection();
//procInst = new ProcessInstance();
try
{
ConnectionSetup connectSetup = new ConnectionSetup();
connectSetup.ConnectionString = K2WorkflowServerConnectionString;
conn.Open(connectSetup);
if (originatorUserEntity != null && originatorUserEntity["domainname"] != null)
{
conn.ImpersonateUser(originatorUserEntity["domainname"].ToString());
}
//Create new process instance
procInst = conn.CreateProcessInstance(K2ProcessName);
//Set CRM context field value
if (!string.IsNullOrEmpty(K2ContextXMLDataField))
{
try
{
procInst.XmlFields[K2ContextXMLDataField].Value = EntityDoc.OuterXml.ToString();
}
catch (Exception ex)
{
System.Diagnostics.EventLog.WriteEntry("SourceCode.Logging.Extension.EventLogExtension", "K2 CRM Plugin - Entity Name - " + context.PrimaryEntityName.ToString() + " - " + "Error writing to XMLField " + K2ContextXMLDataField + " :::: " + ex.Message, System.Diagnostics.EventLogEntryType.Error);
}
}
if (!string.IsNullOrEmpty(K2EntityIdDataField))
{
try
{
procInst.DataFields[K2EntityIdDataField].Value = context.PrimaryEntityId;
}
catch (Exception ex)
{
System.Diagnostics.EventLog.WriteEntry("SourceCode.Logging.Extension.EventLogExtension", "K2 CRM Plugin - Entity Name - " + context.PrimaryEntityName.ToString() + " - " + "Error writing to DataField " + K2EntityIdDataField + " :::: " + ex.Message, System.Diagnostics.EventLogEntryType.Error);
}
}
if (!string.IsNullOrEmpty(K2EntityNameDataField))
{
try
{
procInst.DataFields[K2EntityNameDataField].Value = context.PrimaryEntityName.ToLower();
}
catch (Exception ex)
{
System.Diagnostics.EventLog.WriteEntry("SourceCode.Logging.Extension.EventLogExtension", "K2 CRM Plugin - Entity Name - " + context.PrimaryEntityName.ToString() + " - " + "Error writing to DataField " + K2EntityNameDataField + " :::: " + ex.Message, System.Diagnostics.EventLogEntryType.Error);
}
}
// start the K2 process
conn.StartProcessInstance(procInst);
try
{
System.Diagnostics.EventLog.WriteEntry("SourceCode.Logging.Extension.EventLogExtension", "Process Started: " + K2ProcessName, System.Diagnostics.EventLogEntryType.Information);
}
catch { }
}
catch (Exception ex)
{
System.Diagnostics.EventLog.WriteEntry("SourceCode.Logging.Extension.EventLogExtension", "Entity Name - " + context.PrimaryEntityName.ToString() + " - " + ex.Message, System.Diagnostics.EventLogEntryType.Error);
throw;
}
finally
{
if (service != null)
service = null;
if (conn != null)
conn.Dispose();
conn = null;
if (procInst != null)
procInst = null;
EntityDoc = null;
}
}