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


C# Connection.OpenProcessInstance方法代码示例

本文整理汇总了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");
            }
        }
开发者ID:pierrot12,项目名称:K2France.PIManager,代码行数:34,代码来源:Form1.cs

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


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