• 使用C#代码发起K2 Blackpearl流程


    使用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>");
    }

    流程图如下:

  • 相关阅读:
    笔试题系列001
    算法系列001---dfs|多叉|解空间树理解
    leetcode--014 Gas station
    leetcode--012 single number I
    leetcode--011 copy list with random pointer
    leetcode--010 Linked List Cycle II
    leetcode--009 Linked List Cycle I
    leetcode--007 word break I
    leetcode-006 detect cycle
    alex鸡汤回信
  • 原文地址:https://www.cnblogs.com/dannyli/p/2125285.html
Copyright © 2020-2023  润新知