当前位置: 首页>>代码示例>>C#>>正文


C# Connection.CreateProcessInstance方法代码示例

本文整理汇总了C#中Connection.CreateProcessInstance方法的典型用法代码示例。如果您正苦于以下问题:C# Connection.CreateProcessInstance方法的具体用法?C# Connection.CreateProcessInstance怎么用?C# Connection.CreateProcessInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Connection的用法示例。


在下文中一共展示了Connection.CreateProcessInstance方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: StartProcess

        /// <summary>
        /// 调用k2的dll,生成流程
        /// <param name="dataFields">开启流程所需数据</param>
        /// <param name="processName">流程名称</param>
        /// </summary>
        public static int StartProcess(string processName, Dictionary<string, string> dataFields, string objectId, string folio, string userName)
        {
            int processInstId = 0;
            Connection k2Connection = new Connection();

            try
            {
                k2Connection.Open(ConfigurationBase.Web.K2Server, ConfigurationBase.Web.K2LoginString);
                k2Connection.ImpersonateUser(userName);

                //创建实例
                ProcessInstance processInst = k2Connection.CreateProcessInstance(processName);
                processInstId = processInst.ID;

                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
            }
            finally
            {
                if (k2Connection != null)
                {
                    k2Connection.Close();
                }
            }

            return processInstId;
        }
开发者ID:nanin,项目名称:k2-workflowapi,代码行数:43,代码来源:K2Helper.cs

示例2: 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");
            }

        }
开发者ID:pierrot12,项目名称:K2France.PIManager,代码行数:36,代码来源:Form1.cs

示例3: 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"]);
        }
开发者ID:nanin,项目名称:k2-workflowapi,代码行数:57,代码来源:K2ServiceProvider.cs

示例4: 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;
            }
        }
开发者ID:jonnoking,项目名称:K2-Dynamics-CRM-Extensions,代码行数:101,代码来源:K2CRMWorkflowActivity.cs


注:本文中的Connection.CreateProcessInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。