zoukankan      html  css  js  c++  java
  • 【转载】使用C#代码审批/转签K2 Blackpearl流程

    以下是使用代码审批、转签k2 blackpearl流程,初探K2 Blackpearl,望高人多多包涵、指点. 

     //执行动作
            private void MyAction(string argAction)
            {
                //创建连接对象
                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);
                
                //当前用户打开
                wfcon.ImpersonateUser(HttpContext.Current.User.Identity.Name);

                //获取流程列表
                SourceCode.Workflow.Client.WorklistItem worklistitem = wfcon.OpenWorklistItem(SN);

                /*
                //获取流程实例编号
                string[] _SN = SN.Split('_');
                int _ID = int.Parse(_SN[0]);
                //获取流程实例
                SourceCode.Workflow.Client.ProcessInstance proInst = wfcon.OpenProcessInstance(_ID);
                //DataFields赋值
                proInst.DataFields["TaskUsers"].Value = ddlTaskUsers.SelectedValue;
                //更新DataFields
                procinst.Update();
                
    */

                //查找action(执行动作)
                foreach (SourceCode.Workflow.Client.Action action in worklistitem.Actions)
                {
                    if (action.Name.Equals(argAction))
                    {
                        //执行动作
                        action.Execute();
                    }
                }
                wfcon.Dispose();
            }

            //转签
            protected void ProcRedirect(string argEmpName)
            {
                //创建连接对象
                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);

                wfcon.ImpersonateUser(HttpContext.Current.User.Identity.Name);

                //获取流程列表
                SourceCode.Workflow.Client.WorklistItem worklistitem = wfcon.OpenWorklistItem(SN);
                //转签
                worklistitem.Redirect(argEmpName);
                //释放资源
                wfcon.Dispose();  } 

     流程图如下:

     
  • 相关阅读:
    HDU 1969 Pie(二分查找)
    HDU 1896 Stones (优先队列)
    HDU 1548 A strange lift(BFS)
    HDU 1518 Square(DFS)
    CDOJ1085 基爷与加法等式 爆搜DFS
    Codeforces Round #245 (Div. 2) C. Xor-tree DFS
    Codeforces ZeptoLab Code Rush 2015 B. Om Nom and Dark Park DFS
    Codeforces Round #297 (Div. 2)E. Anya and Cubes 折半搜索
    Codeforces Round #401 (Div. 2)A B C
    Codeforces Round #297 (Div. 2)D. Arthur and Walls 搜索bfs
  • 原文地址:https://www.cnblogs.com/voidxy/p/2376466.html
Copyright © 2011-2022 走看看