现在的位置: 首页 > 综合 > 正文

【转载】使用C#代码发起K2 Blackpearl流程

2012年09月26日 ⁄ 综合 ⁄ 共 1456字 ⁄ 字号 评论关闭

使用C#代码,发起一个K2的流程,其形式和链接SQL Server数据库的代码差不多,都是通过连接字符串,然后OPEN,然后....你懂的。

下面是K2流程发起的代码,仅供参考。同时,如果有K2方面的高手,还请多多指教小弟。

 

 protected void ProcessSubmit_Click(object sender, EventArgs e)
        {
            //创建连接对象
            SourceCode.Workflow.Client.Connection wfcon = new SourceCode.Workflow.Client.Connection();

            //打开链接(传入K2服务器及其端口)
            string k2Server = System.Configuration.ConfigurationManager.AppSettings["K2Server"];
            string workflowServicePort = System.Configuration.ConfigurationManager.AppSettings["WorkflowServicePort"];
            wfcon.Open(k2Server + ":" + workflowServicePort);

            //创建流程实例
            SourceCode.Workflow.Client.ProcessInstance proInst = wfcon.CreateProcessInstance(@"TestProcess\ProcessDHFKSQ");
            
            //指定流程单号
            proInst.Folio = Folio.Text;

            //为流程中 DataField 赋值
            proInst.DataFields["HigherLevelApprover"].Value = HigherLevelApprover.Text;
            proInst.DataFields["FinanceApprover"].Value = FinanceApprover.Text;
            proInst.DataFields["ApprovalPage"].Value = System.Configuration.ConfigurationManager.AppSettings["ApprovalPage"];
            
            //发起流程
            wfcon.StartProcessInstance(proInst);

            //存储数据到 SmartObject
            SaveData(proInst.ID);

            //结束
            wfcon.Dispose();
            Response.Write("<script language='javascript' type='text/javascript'>window.close()</script>"); }  

 流程图如下:

 

       

抱歉!评论已关闭.