コード例 #1
0
        private void solveVotingWorkflowCompleted(WorkflowApplicationCompletedEventArgs e)
        {
            //保存到解决投票表里面
            MyWorkflowInstance.removeSolveVotingWorkflowApplication(e.InstanceId.ToString());

            CrowdTask crowdTask = new CrowdTask();


            CrowdTaskService crowdTaskService = new CrowdTaskService();

            crowdTask = crowdTaskService.findCrowdTaskByWorkflowId(e.InstanceId.ToString());

            //将当前流程的投票的分解的工作流ID写入数据库
            int result = crowdTaskService.saveSolveVoteResult1(e.InstanceId.ToString(), (string)e.Outputs["out_bestSolutionWorkflowId"]);

            //如果所有的解决投票任务完成了。开启投票
            if (MyWorkflowInstance.getSolveVotingWorkflowApplications().Count == 0)
            {
                //更新得到最佳答案;

                ArrayList allSolveCompeletedCrowdTask = crowdTaskService.findAllSolveCompeletedCrowdTaskByMainTaskId(crowdTask.mainTaskId);
                //得到每一个解决任务的名字,然后根据名字和描述再去加载解决任务的ID,得到ID之后再去判断是不是最佳答案

                foreach (SolveResult sr in allSolveCompeletedCrowdTask)
                {
                    ArrayList al = crowdTaskService.finSolveResultByMainTaskIdAndTaskName(crowdTask.mainTaskId, sr.taskName);

                    int[]    supportedNumber     = new int[ConstantDefine.solvingNumber];
                    string[] supportedWorkflowId = new string[ConstantDefine.solvingNumber];
                    int      i = 0;

                    foreach (SolveResult item in al)
                    {
                        //拿到每一个ID 当做supportedId,去数据库里面比对
                        supportedNumber[i]     = crowdTaskService.getSolveVoteResultBySupportedId(item.taskWorkflowId);
                        supportedWorkflowId[i] = item.taskWorkflowId;
                        i++;
                    }
                    int    maxNumber     = supportedNumber[0];
                    string maxWorkflowId = supportedWorkflowId[0];

                    for (int j = 0; j < al.Count; j++)
                    {
                        if (supportedNumber[j] > maxNumber)
                        {
                            maxNumber     = supportedNumber[j];
                            maxWorkflowId = supportedWorkflowId[j];
                        }
                    }

                    //找到了最佳答案,更新。
                    crowdTaskService.updateSolveResultBestAnswer(maxWorkflowId);
                }
                //更新书签
                MyWorkflowInstance.getWorkflowApplication(crowdTask.mainTaskId).ResumeBookmark(BookmarkName.SolveVoting, null);

                //生成分解树。
                crowdTaskService.writeDecomposeTree(crowdTask.mainTaskId);
            }
        }
コード例 #2
0
 public CrowdTask findCrowdTaskByParentWorkflowId(string parent_workflow_id)
 {
     CrowdTask crowdTask = new CrowdTask();
     SqlCommand com = null;
     try
     {
         conn.Open();
         string sql = "";
         com = new SqlCommand(sql, conn);
     }
     catch (Exception e)
     {
         throw e;
     }
     finally
     {
         if (com != null)
         {
             com.Dispose();
         }
         if (conn != null)
         {
             conn.Close();
         }
     }
     return crowdTask;
 }
コード例 #3
0
    protected void Button1_Click(object sender, EventArgs e)

    {
     
           //设置参数
            Dictionary<string,object> para=new  Dictionary<string, object>();
            CrowdTask task = new CrowdTask(TextBox1.Text,TextBox2.Text);
            para.Add("task", task);

            //启动工作流
           WorkflowApplication crowdsourcing = new WorkflowApplication(new mainTask1(),para);
           task.taskType= TaskType.mainTask;
           crowdsourcing.Run();
           task.taskWorkflowId = crowdsourcing.Id.ToString();
           try
           {
               crowdTaskService = new CrowdTaskService();
               int result = crowdTaskService.insert(task);
               if(result==1){
                   //插入成功,保存对应的工作流实例
                   MyWorkflowInstance.setWorkflowApplication(crowdsourcing.Id.ToString(),crowdsourcing);
                   crowdTaskService.mainTaskSetCrowdTaskMainTaskIdByWorkflowId(crowdsourcing.Id.ToString());
                   Server.Transfer("viewMyTask.aspx?workflowId=" + task.taskWorkflowId);
               }
           }
           catch (Exception exception)
           {
               throw exception ;
           }
          
        
    }
コード例 #4
0
 public int insert(CrowdTask crowdTask)
 {
     int result = 0;
     SqlCommand com=null;
     try
     {
         conn.Open();
         string sql = string.Format("insert into crowdTask(taskName,taskDescription,taskType,workflow_id,parent_workflow_id) values('{0}','{1}','{2}','{3}','{4}')", crowdTask.taskName, crowdTask.taskDescription, crowdTask.taskType, crowdTask.taskWorkflowId, crowdTask.taskParentWorkflowId);
         com = new SqlCommand(sql, conn);
         result = com.ExecuteNonQuery();
     }catch(Exception e){
         throw e;
     }
     finally
     {
         if (com != null)
         {
             com.Dispose();
         }
         if (conn != null)
         {
             conn.Close();
         }
     }
     return result;
 }
コード例 #5
0
        public void startDevideVotingProcess(Dictionary <string, ArrayList> solutionTasks)
        {
            //创建输入参数
            Dictionary <string, object> para = new Dictionary <string, object>();

            para.Add("solutionTasks", solutionTasks);

            //创建实例对象
            WorkflowApplication currentWorkflowInstance = new WorkflowApplication(new decomposeVoting(), para);

            //委托流程结束时候调用的方法
            currentWorkflowInstance.Completed = new Action <WorkflowApplicationCompletedEventArgs>(DevideVotingWorkflowCompleted);

            //启动实例
            currentWorkflowInstance.Run();

            CrowdTaskService crowdTaskService = new CrowdTaskService();
            //分解任务
            CrowdTask divideTask = crowdTaskService.findCrowdTaskByWorkflowId(solutionTasks.First().Key);


            CrowdTask crowdTask = new CrowdTask();

            crowdTask.taskName        = divideTask.taskName;
            crowdTask.taskDescription = divideTask.taskDescription;
            crowdTask.taskType        = TaskType.decomposeVotingTask;

            crowdTask.taskWorkflowId = currentWorkflowInstance.Id.ToString();

            crowdTask.taskParentWorkflowId = crowdTaskService.findCrowdTaskByWorkflowId(solutionTasks.Keys.First().ToString()).taskParentWorkflowId;


            int result = crowdTaskService.insert(crowdTask);

            //更新每个实例的主工作流Id
            crowdTaskService.updateCrowdTaskMainTaskIdByWorkflowId(currentWorkflowInstance.Id.ToString());


            if (result == 1)
            {
                //将当前实例加入到分解任务集合中
                MyWorkflowInstance.setDecomposeVotingWorkflowApplication(currentWorkflowInstance.Id.ToString(), currentWorkflowInstance);
            }
        }
コード例 #6
0
        public void startSubDivideProcess(Guid parentWorkflowId, CrowdTask task)
        {
            //创建输入参数
            Dictionary <string, object> para = new Dictionary <string, object>();

            CrowdTask crowdTask = new CrowdTask();

            crowdTask.taskName             = task.taskName;
            crowdTask.taskDescription      = task.taskDescription;
            crowdTask.taskParentWorkflowId = parentWorkflowId.ToString();
            crowdTask.taskType             = TaskType.decomposeTask;

            para.Add("parentWorkflowId", parentWorkflowId);
            para.Add("task", crowdTask);
            //创建实例对象
            WorkflowApplication currentWorkflowInstance = new WorkflowApplication(new decompose(), para);

            //委托流程结束时候调用的方法
            currentWorkflowInstance.Completed = new Action <WorkflowApplicationCompletedEventArgs>(SubDivideWorkflowCompleted);

            //启动实例
            currentWorkflowInstance.Run();

            //继续绑定crowdTask 参数
            crowdTask.taskWorkflowId = currentWorkflowInstance.Id.ToString();

            //将这个任务插入到到数据库

            CrowdTaskService crowdTaskService = new CrowdTaskService();
            int result = crowdTaskService.insert(crowdTask);

            //更新每个实例的主工作流Id
            crowdTaskService.updateCrowdTaskMainTaskIdByWorkflowId(currentWorkflowInstance.Id.ToString());

            if (result == 1)
            {
                //将当前实例加入到分解任务集合中
                MyWorkflowInstance.setDecomposeWorkflowApplication(currentWorkflowInstance.Id.ToString(), currentWorkflowInstance);
            }
        }
コード例 #7
0
        public void startSubDivideProcess(Guid parentWorkflowId,CrowdTask task)
        {
            //创建输入参数
           Dictionary<string, object> para = new Dictionary<string, object>();
           
            CrowdTask crowdTask = new CrowdTask();
            crowdTask.taskName = task.taskName;
            crowdTask.taskDescription = task.taskDescription;
            crowdTask.taskParentWorkflowId=parentWorkflowId.ToString();
            crowdTask.taskType = TaskType.decomposeTask;
            
            para.Add("parentWorkflowId", parentWorkflowId);
            para.Add("task", crowdTask);
            //创建实例对象
             WorkflowApplication  currentWorkflowInstance = new WorkflowApplication(new decompose(), para);

            //委托流程结束时候调用的方法
             currentWorkflowInstance.Completed = new Action<WorkflowApplicationCompletedEventArgs>(SubDivideWorkflowCompleted);

            //启动实例
            currentWorkflowInstance.Run();

            //继续绑定crowdTask 参数
            crowdTask.taskWorkflowId = currentWorkflowInstance.Id.ToString();
            
            //将这个任务插入到到数据库

            CrowdTaskService crowdTaskService = new CrowdTaskService();
            int result = crowdTaskService.insert(crowdTask);

            //更新每个实例的主工作流Id
            crowdTaskService.updateCrowdTaskMainTaskIdByWorkflowId(currentWorkflowInstance.Id.ToString());

            if (result == 1)
            {
                //将当前实例加入到分解任务集合中
                MyWorkflowInstance.setDecomposeWorkflowApplication(currentWorkflowInstance.Id.ToString(), currentWorkflowInstance);
            }
        }
コード例 #8
0
    protected void Page_Load(object sender, EventArgs e)
    {
       
        taskWorkflowId = Request.Params["taskWorkflowId"];
        crowdTaskService = new CrowdTaskService();
        currentCrowdTask = crowdTaskService.findCrowdTaskByWorkflowId(taskWorkflowId);
        TextBox1.Text = currentCrowdTask.taskName;
        TextBox2.Text = currentCrowdTask.taskDescription; 
        TextBox3.Text = taskWorkflowId;

        if (!IsPostBack)
        {
            ArrayList arrayList = new ArrayList();
            arrayList.Add("请选择分解步数");
            arrayList.Add(2);
            arrayList.Add(3);
            arrayList.Add(4);
            arrayList.Add(5);
            DropDownList1.DataSource = arrayList;
            DropDownList1.DataBind();
        }
    }
コード例 #9
0
        public void startSolveVoteProcess(Dictionary <string, SolveResult> solveResutDic)
        {
            //开启解决投票实例
            //创建输入参数
            Dictionary <string, object> para = new Dictionary <string, object>();

            para.Add("sovleResultDic", solveResutDic);

            //创建实例对象
            WorkflowApplication currentWorkflowInstance = new WorkflowApplication(new solveVoting(), para);

            //委托流程结束时候调用的方法
            currentWorkflowInstance.Completed = new Action <WorkflowApplicationCompletedEventArgs>(solveVotingWorkflowCompleted);

            //启动实例
            currentWorkflowInstance.Run();

            CrowdTaskService crowdTaskService = new CrowdTaskService();



            CrowdTask crowdTask = new CrowdTask();

            crowdTask.taskName        = solveResutDic.Values.First().taskName;
            crowdTask.taskDescription = solveResutDic.Values.First().taskDescription;
            crowdTask.taskType        = TaskType.solveVotingTask;
            crowdTask.taskWorkflowId  = currentWorkflowInstance.Id.ToString();

            int result = crowdTaskService.insert(crowdTask);

            //更新每个实例的主工作流Id
            crowdTaskService.updateCrowdTaskMainTaskIdByWorkflowId(currentWorkflowInstance.Id.ToString());

            if (result == 1)
            {
                //将当前实例加入到分解任务集合中
                MyWorkflowInstance.setSolveVotingWorkflowApplication(currentWorkflowInstance.Id.ToString(), currentWorkflowInstance);
            }
        }
コード例 #10
0
 public CrowdTask findCrowdTaskByWorkflowId(string workflow_id)
 {
     CrowdTask crowdTask = new CrowdTask();
     SqlCommand com = null;
     try
     {
         conn.Open();
         //查询到这个数据,将数据填入crowdtask
         string sql = string.Format("select * from crowdTask where workflow_id='{0}'",workflow_id);
         com = new SqlCommand(sql, conn);
         SqlDataReader dr = com.ExecuteReader();
         if (dr.Read())
         {
             crowdTask.taskName = dr[1].ToString();
             crowdTask.taskDescription = dr[2].ToString();
             crowdTask.taskType = dr[3].ToString();
             crowdTask.taskWorkflowId = dr[4].ToString();
             crowdTask.taskParentWorkflowId = dr[5].ToString();
             crowdTask.mainTaskId = dr[6].ToString();
         }
     }
     catch (Exception e)
     {
         throw e;
     }
     finally
     {
         if (com != null)
         {
             com.Dispose();
         }
         if (conn != null)
         {
             conn.Close();
         }
     }
     return crowdTask;
 }
コード例 #11
0
        void SubDivideWorkflowCompleted(WorkflowApplicationCompletedEventArgs e)
        {
            //流程结束,将流程实例移除
            MyWorkflowInstance.removeDecomposeWorkflowApplication(e.InstanceId.ToString());


            CrowdTaskService crowdTaskService = new CrowdTaskService();
            //将当前流程的分解解决方案写入数据库
            int result = crowdTaskService.saveDecomposeResult(e.InstanceId.ToString(), (ArrayList)e.Outputs["out_arraylist_task"]);

            //得到当前分解任务的内容
            CrowdTask crowdTask = new CrowdTask();

            crowdTask = crowdTaskService.findCrowdTaskByWorkflowId(e.InstanceId.ToString());

            //通过当前分解任务的父工作流ID ,获得该父工作流的所有子工作流,如果都完成了则开启分解判断过程
            ArrayList allSonCrowdTask = crowdTaskService.findAllSonCrowdTaskByParentWorkflowIdAndTaskName(crowdTask.taskParentWorkflowId, crowdTask.taskName, crowdTask.mainTaskId);

            Dictionary <string, ArrayList> solutionTasks = new Dictionary <string, ArrayList>();

            int count = 0;

            //遍历看看这个任务的同一级的分解任务是否都结束了
            foreach (CrowdTask ct in allSonCrowdTask)
            {
                WorkflowApplication wa = MyWorkflowInstance.getDecomposeWorkflowApplication(ct.taskWorkflowId);
                if (wa != null)
                {
                    break;
                }
                else
                {
                    count++;
                }
            }
            //如果都结束了
            if (count == ConstantDefine.divideNumber)
            {
                //获得每一个分解任务给出的解决方案
                foreach (CrowdTask ct in allSonCrowdTask)
                {
                    ArrayList solutions = crowdTaskService.findDecomposeResultByWorkflowId(ct.taskWorkflowId, ct.mainTaskId);
                    if (solutions.Count != 0)
                    {
                        //表示当前工作流Id给出了分解方案
                        solutionTasks.Add(ct.taskWorkflowId, solutions);
                    }
                }
                //表示至少有一个分解任务给出了解决方案
                if (solutionTasks.Count != 0)
                {
                    //开启5个投票流程  工作流实例
                    for (int i = 0; i < ConstantDefine.decomposeVotingNumber; i++)
                    {
                        StartSubProcess ssp = new StartSubProcess();
                        ssp.startDevideVotingProcess(solutionTasks);
                    }
                }
                //表示所有的当前这几个分解任务都认为这个任务是简单任务,设置简单标记
                else
                {
                    //当前一个任务判定为简单,是要等这一层级的所有任务都判定完了在根据情况,把这一层是简单的任务抛出去
                    foreach (CrowdTask ct in allSonCrowdTask)
                    {
                        int h = crowdTaskService.updateDecomposeResultByWokflowIdAndTaskName(ct.taskParentWorkflowId, ct.taskName, ct.mainTaskId);
                    }
                }


                /*
                 * //等待这一层的所有任务都分解完成了,把这一层的简单任务选出来,分发出去
                 * ArrayList ThisLayerAllSonCrowdTask = crowdTaskService.findCrowdTaskByParentWorkflowIdAndTaskType(crowdTask.taskParentWorkflowId, TaskType.decomposeTask);
                 * int count1 = 0;
                 * //遍历这一层的任务,看看是否都完成了
                 * foreach (CrowdTask ct in ThisLayerAllSonCrowdTask)
                 * {
                 *  WorkflowApplication wa = MyWorkflowInstance.getDecomposeWorkflowApplication(ct.taskWorkflowId);
                 *  if (wa != null)
                 *  {
                 *      break;
                 *  }
                 *  else
                 *  {
                 *      count1++;
                 *  }
                 * }
                 * //这一层的所有任务都完成了
                 * if (ThisLayerAllSonCrowdTask.Count == count1)
                 * {
                 *  ArrayList al_simple = crowdTaskService.getAllThisLayerNeedSolvedCrowTaskInDecomposeResult(crowdTask.taskParentWorkflowId);
                 *  //可以得到这一层一共有多少个简单任务
                 *  //将每一个简单任务分发出去启动解决流程
                 *  foreach (DecomposeResult al in al_simple)
                 *  {
                 *      for (int k = 0; k < ConstantDefine.solvingNumber; k++)
                 *      {
                 *          //将这个任务分发出去
                 *          CrowdTask ct = new CrowdTask();
                 *          ct.taskName = al.taskName;
                 *          ct.taskDescription = al.taskDescription;
                 *          ct.taskType = TaskType.solveTask;
                 *          StartSubProcess ssp = new StartSubProcess();
                 *          ssp.startSolveProcess(ct);
                 *      }
                 *  }
                 * }
                 * */
            }

            //如果分解的工作流为空。

            if (MyWorkflowInstance.getdecomposeWorkflowApplications().Count == 0 && MyWorkflowInstance.getdecomposeVotingWorkflowApplications().Count == 0)
            {
                //加载所有的需要解决的任务,作为解决任务发放出去

                ArrayList li = crowdTaskService.getAllNeedSolvedCrowTaskInDecomposeResult1(crowdTask.mainTaskId);
                foreach (DecomposeResult dr in li)
                {
                    for (int k = 0; k < ConstantDefine.solvingNumber; k++)
                    {
                        //将这个任务分发出去
                        CrowdTask ct = new CrowdTask();
                        ct.taskName             = dr.taskName;
                        ct.taskDescription      = dr.taskDescription;
                        ct.taskType             = TaskType.solveTask;
                        ct.taskParentWorkflowId = dr.parent_workflow_id;
                        StartSubProcess ssp = new StartSubProcess();
                        ssp.startSolveProcess(ct);
                    }
                }

                MyWorkflowInstance.getWorkflowApplication(crowdTask.mainTaskId).ResumeBookmark(BookmarkName.Decomposing, null);;
            }
        }
コード例 #12
0
    protected void Page_Load(object sender, EventArgs e)
    {
        /*
         * 
         * 得到系统所有的工作流程实例,并且显示出来
         * 
         */
       

        //加载主任务
        //加载所有的主任务实例
        Dictionary<string, WorkflowApplication> mainTaskinstances = MyWorkflowInstance.getWorkflowApplications();
        int mainTaskCount = mainTaskinstances.Count;
        //加载单个的主任务实例
        ReadOnlyCollection<BookmarkInfo>[] mainTaskBookmarks = new ReadOnlyCollection<BookmarkInfo>[mainTaskCount];
        WorkflowApplication[] mainTaskInstance = new WorkflowApplication[mainTaskCount];
        string[] mainTaskBookmarkName = new string[mainTaskCount];


        CrowdTask[] mainTasks = new CrowdTask[mainTaskCount];

        int i = 0;
         foreach (KeyValuePair<string, WorkflowApplication> kvp in mainTaskinstances)
         {
             //得到每个主任务实例的书签信息
             mainTaskBookmarks[i] = kvp.Value.GetBookmarks();

             mainTasks[i] = crowdTaskService.findCrowdTaskByWorkflowId(kvp.Value.Id.ToString());
             int bookmarkCount = mainTaskBookmarks[i].Count;
             if (bookmarkCount == 1)
             {
                 mainTaskBookmarkName[i] = kvp.Value.GetBookmarks().First().BookmarkName;
             }
             else
             {
                 mainTaskBookmarkName[i] = "end";
             }
             mainTaskInstance[i] = kvp.Value;
             i++;
         }

        //创建显示主任务的表格
         for (int j = 0; j < mainTaskCount; j++)
         {
             TableRow tr = new TableRow();

             TableCell tc1 = new TableCell();
             tc1.Text = "任务名:";

             TableCell tc2 = new TableCell();

             HyperLink hl = new HyperLink();

             switch (mainTaskBookmarkName[j])
             {
                 case BookmarkName.WaitJudgement:

                     hl.NavigateUrl = "waitJudgement.aspx?taskWorkflowId=" + mainTasks[j].taskWorkflowId;
                     break;
                 case BookmarkName.Decomposing:
                     hl.NavigateUrl = "decomposing.aspx?&taskWorkflowId=" + mainTasks[j].taskWorkflowId;
                     break;
                 case BookmarkName.Solving:
                     hl.NavigateUrl = "solving.aspx";
                     break;
                 case BookmarkName.SolveVoting:
                     hl.NavigateUrl = "solveVoting.aspx";
                     break;
                 case BookmarkName.Merging:
                     hl.NavigateUrl = "subMerging.aspx";
                     break;

             }
             hl.Text = mainTasks[j].taskName + "  (  " + mainTaskBookmarkName[j] + "  )     工作流ID: " + mainTasks[j].taskWorkflowId;

             tc2.Controls.Add(hl);
             tr.Cells.Add(tc1);
             tr.Cells.Add(tc2);
             mainTaskTable.Rows.Add(tr);
         }



        //加载分解任务
        
      Dictionary<string, WorkflowApplication> decomposeInstances = MyWorkflowInstance.getdecomposeWorkflowApplications();

      int decomposeCount = decomposeInstances.Count;

       WorkflowApplication[] decomposeInstance = new WorkflowApplication[decomposeCount];

       ReadOnlyCollection<BookmarkInfo>[] decomposeBookmarks = new ReadOnlyCollection<BookmarkInfo>[decomposeCount];

      string[] decomposeBookmarkName = new string[decomposeCount];
      
      //需要分解的众包任务
      CrowdTask[] decomposeTasks = new CrowdTask[decomposeCount];

       i=0;
        foreach (KeyValuePair<string, WorkflowApplication> kvp in decomposeInstances)
        {
            decomposeBookmarks[i] = kvp.Value.GetBookmarks();

            decomposeTasks[i]=crowdTaskService.findCrowdTaskByWorkflowId(kvp.Key);

            int bookmarkCount = decomposeBookmarks[i].Count;
            if (bookmarkCount == 1)
            {
                decomposeBookmarkName[i] = kvp.Value.GetBookmarks().First().BookmarkName;
            }
            else
            {
                decomposeBookmarkName[i] = "end";
            }

          
            decomposeInstance[i]=kvp.Value;
            i++;
        }

        //创建显示分解任务的表格
        for (int j = 0; j < decomposeCount; j++)
        {
            TableRow tr = new TableRow();

            TableCell tc1 = new TableCell();
            tc1.Text = "任务名:";

            TableCell tc2 = new TableCell();

            HyperLink hl = new HyperLink();

            switch (decomposeBookmarkName[j])
            {
                    case BookmarkName.WaitJudgement:
                       
                         hl.NavigateUrl = "subTaskJudgement.aspx?taskWorkflowId=" + decomposeTasks[j].taskWorkflowId;
                        break;
                    case BookmarkName.Decomposing:
                        hl.NavigateUrl = "subTaskDecomposing.aspx?taskWorkflowId=" + decomposeTasks[j].taskWorkflowId;
                         break;
                }
            hl.Text = decomposeTasks[j].taskName+"  (  "+ decomposeBookmarkName[j]+ "  )     工作流ID: "+decomposeTasks[j].taskWorkflowId;

            tc2.Controls.Add(hl);
            tr.Cells.Add(tc1);
            tr.Cells.Add(tc2);
            decomposeTable.Rows.Add(tr);
        }




        //加载分解投票任务;
        Dictionary<string, WorkflowApplication> decomposeVotingInstances = MyWorkflowInstance.getdecomposeVotingWorkflowApplications();

        int decomposeVotingCount = decomposeVotingInstances.Count;
        WorkflowApplication[] decomposeVotingInstance = new WorkflowApplication[decomposeVotingCount];

        ReadOnlyCollection<BookmarkInfo>[] decomposeVotingBookmarks = new ReadOnlyCollection<BookmarkInfo>[decomposeVotingCount];
        string[] decomposeVotingBookmarkName = new string[decomposeVotingCount];


        //需要分解投票的众包任务
        CrowdTask[] decomposeVotingTasks = new CrowdTask[decomposeVotingCount];

        //父任务的问题投票
        i = 0;
        foreach (KeyValuePair<string, WorkflowApplication> kvp in decomposeVotingInstances)
        {
            decomposeVotingBookmarks[i] = kvp.Value.GetBookmarks();
            decomposeVotingTasks[i] = crowdTaskService.findCrowdTaskByWorkflowId(kvp.Key);
            int bookmarkCount = decomposeVotingBookmarks[i].Count;
            if (bookmarkCount == 1)
            {
                decomposeVotingBookmarkName[i] = kvp.Value.GetBookmarks().First().BookmarkName;
            }
            else
            {
                decomposeVotingBookmarkName[i] = "end";
            }


            decomposeVotingInstance[i] = kvp.Value;
            i++;
        }

        //创建分解投票问题的表格
        for (int j = 0; j < decomposeVotingCount; j++)
        {
            TableRow tr = new TableRow();

            TableCell tc1 = new TableCell();
            tc1.Text = "任务名:";

            TableCell tc2 = new TableCell();

            HyperLink hl = new HyperLink();

           // CrowdTask parentTask = crowdTaskService.findCrowdTaskByParentWorkflowIdAnd(decomposeVotingTasks[j].taskParentWorkflowId);

            switch (decomposeVotingBookmarkName[j])
            {
              

                case BookmarkName.DecomposeVoting:

                    hl.NavigateUrl = "subTaskDecomposeVoting.aspx?taskWorkflowId=" + decomposeVotingInstance[j].Id.ToString() + "&parentWorkflowId=" + decomposeVotingTasks[j].taskParentWorkflowId;
                    break;

            }
            hl.Text = decomposeVotingTasks[j].taskName + "    的分解方案投票 (  " + decomposeVotingBookmarkName[j] + "  ) ";
            //hl.Text = "分解投票";
            tc2.Controls.Add(hl);
            tr.Cells.Add(tc1);
            tr.Cells.Add(tc2);
            decomposeVotingTable.Rows.Add(tr);
        }




        //加载解决任务;
        Dictionary<string, WorkflowApplication> solveInstances = MyWorkflowInstance.getSolveWorkflowApplications();

        int solveCount = solveInstances.Count;
        WorkflowApplication[] solveInstance = new WorkflowApplication[solveCount];

        ReadOnlyCollection<BookmarkInfo>[] solveBookmarks = new ReadOnlyCollection<BookmarkInfo>[solveCount];
        string[] solveBookmarkName = new string[solveCount];


        //需要解决的的众包任务
        CrowdTask[] solveTasks = new CrowdTask[solveCount];

       
        i = 0;
        foreach (KeyValuePair<string, WorkflowApplication> kvp in solveInstances)
        {
            solveBookmarks[i] = kvp.Value.GetBookmarks();
            solveTasks[i] = crowdTaskService.findCrowdTaskByWorkflowId(kvp.Key);
            int bookmarkCount = solveBookmarks[i].Count;
            if (bookmarkCount == 1)
            {
                solveBookmarkName[i] = kvp.Value.GetBookmarks().First().BookmarkName;
            }
            else
            {
                solveBookmarkName[i] = "end";
            }


            solveInstance[i] = kvp.Value;
            i++;
        }

        //创建解决问题的表格
        for (int j = 0; j < solveCount; j++)
        {
            TableRow tr = new TableRow();

            TableCell tc1 = new TableCell();
            tc1.Text = "任务名:";

            TableCell tc2 = new TableCell();

            HyperLink hl = new HyperLink();

            //CrowdTask parentTask = crowdTaskService.findCrowdTaskByWorkflowId(solveTasks[j].taskParentWorkflowId);

            switch (solveBookmarkName[j])
            {


                case BookmarkName.Solving:

                    hl.NavigateUrl = "subTaskSolving.aspx?taskWorkflowId=" + solveInstance[j].Id.ToString();
                    break;
                default:

                    break;

            }
            hl.Text = solveTasks[j].taskName + "  (  " + solveBookmarkName[j] + "  ) ";
            //hl.Text = "分解投票";
            tc2.Controls.Add(hl);
            tr.Cells.Add(tc1);
            tr.Cells.Add(tc2);
           solveTable.Rows.Add(tr);

        }

        //加载解决投票任务;
        Dictionary<string, WorkflowApplication> solveVotingInstances = MyWorkflowInstance.getSolveVotingWorkflowApplications();

        int solveVotingCount = solveVotingInstances.Count;
        WorkflowApplication[] solveVotingInstance = new WorkflowApplication[solveVotingCount];

        ReadOnlyCollection<BookmarkInfo>[] solveVotingBookmarks = new ReadOnlyCollection<BookmarkInfo>[solveVotingCount];
        string[] solveVotingBookmarkName = new string[solveVotingCount];


        //需要解决投票的众包任务
        CrowdTask[] solveVotingTasks = new CrowdTask[solveVotingCount];

        //需要解决的众包任务的投票投票
        i = 0;
        foreach (KeyValuePair<string, WorkflowApplication> kvp in solveVotingInstances)
        {
            solveVotingBookmarks[i] = kvp.Value.GetBookmarks();
            solveVotingTasks[i] = crowdTaskService.findCrowdTaskByWorkflowId(kvp.Key);
            int bookmarkCount = solveVotingBookmarks[i].Count;
            if (bookmarkCount == 1)
            {
                solveVotingBookmarkName[i] = kvp.Value.GetBookmarks().First().BookmarkName;
            }
            else
            {
                solveVotingBookmarkName[i] = "end";
            }


            solveVotingInstance[i] = kvp.Value;
            i++;
        }

        //创建分解投票问题的表格
        for (int j = 0; j < solveVotingCount; j++)
        {
            TableRow tr = new TableRow();

            TableCell tc1 = new TableCell();
            tc1.Text = "任务名:";

            TableCell tc2 = new TableCell();

            HyperLink hl = new HyperLink();

           // CrowdTask parentTask = crowdTaskService.findCrowdTaskByWorkflowId(decomposeVotingTasks[j].taskParentWorkflowId);

            switch (solveVotingBookmarkName[j])
            {


                case BookmarkName.SolveVoting:

                    hl.NavigateUrl = "subTaskSolveVoting.aspx?taskWorkflowId=" + solveVotingInstance[j].Id.ToString();
                    break;

            }
            hl.Text = solveVotingTasks[j].taskName + "    的解决结果投票 (  " + solveVotingBookmarkName[j] + "  ) ";
            //hl.Text = "分解投票";
            tc2.Controls.Add(hl);
            tr.Cells.Add(tc1);
            tr.Cells.Add(tc2);
            solveVotingTable.Rows.Add(tr);

        }













    }
コード例 #13
0
        void solveWorkflowCompleted(WorkflowApplicationCompletedEventArgs e)
        {
            MyWorkflowInstance.removeSolveWorkflowApplication(e.InstanceId.ToString());

            CrowdTask crowdTask = new CrowdTask();

            CrowdTaskService crowdTaskService = new CrowdTaskService();

            crowdTask = crowdTaskService.findCrowdTaskByWorkflowId(e.InstanceId.ToString());

            //将当前流程的解决结果写入数据库
            int result = crowdTaskService.saveSolveResult(crowdTask, (string)e.Outputs["out_solution"]);

            /*
             *
             * //通过当前解决任务的工作流ID ,获得该工作流的所有同一任务的不同工作流,如果都完成了则开启解决判断过程;
             * int count = 0;
             *
             * ArrayList allSonCrowdTask = crowdTaskService.findAllSonCrowdTaskByParentTaskNameAndTaskDescriptionAndTaskType(crowdTask.taskName, crowdTask.taskDescription,crowdTask.taskType);
             *
             * foreach (CrowdTask ct in allSonCrowdTask)
             * {
             *  WorkflowApplication wa = MyWorkflowInstance.getSolveWorkflowApplication(ct.taskWorkflowId);
             *  if (wa != null)
             *  {
             *      break;
             *  }
             *  else
             *  {
             *      count++;
             *  }
             * }
             * if (count == ConstantDefine.solvingNumber)
             * {
             *  //都已经解决完成,可以开始投票了
             *  //通过当前获得到的workflowId ,加载解决方案,然后保存在一个list里面,开启投票流程
             *
             *  Dictionary<string,SolveResult> solveResutDic = new Dictionary<string,SolveResult>();
             *
             *  //得到所有的解决结果
             *      foreach (CrowdTask ct in allSonCrowdTask)
             *      {
             *        SolveResult sr = crowdTaskService.findSolveResultByWorkflowId(ct.taskWorkflowId);
             *
             *          solveResutDic.Add(ct.taskWorkflowId,sr);
             *      }
             *  if(solveResutDic.Count!=0)
             *  {
             *      //开启5个解决投票流程  工作流实例
             *      for (int i = 0; i < ConstantDefine.solveVotingNumber; i++)
             *      {
             *          StartSubProcess ssp = new StartSubProcess();
             *          ssp.startSolveVoteProcess(solveResutDic);
             *      }
             *  }
             *
             * }
             */


            //如果所有的解决任务完成了。开启投票
            if (MyWorkflowInstance.getSolveWorkflowApplications().Count == 0)
            {
                ArrayList allSolveCompeletedCrowdTask = crowdTaskService.findAllSolveCompeletedCrowdTaskByMainTaskId(crowdTask.mainTaskId);
                //得到所有的解决结果
                foreach (SolveResult sr in allSolveCompeletedCrowdTask)
                {
                    //开启投票过程
                    Dictionary <string, SolveResult> solveResutDic = new Dictionary <string, SolveResult>();

                    ArrayList abc = crowdTaskService.finSolveResultByMainTaskIdAndTaskName(crowdTask.mainTaskId, sr.taskName);
                    foreach (SolveResult sdr in abc)
                    {
                        solveResutDic.Add(sdr.taskWorkflowId, sdr);
                    }
                    if (solveResutDic.Count != 0)
                    {
                        //开启5个解决投票流程  工作流实例
                        for (int i = 0; i < ConstantDefine.solveVotingNumber; i++)
                        {
                            StartSubProcess ssp = new StartSubProcess();
                            ssp.startSolveVoteProcess(solveResutDic);
                        }
                    }
                }

                MyWorkflowInstance.getWorkflowApplication(crowdTask.mainTaskId).ResumeBookmark(BookmarkName.Solving, null);
            }
        }
コード例 #14
0
        void DevideVotingWorkflowCompleted(WorkflowApplicationCompletedEventArgs e)
        {
            MyWorkflowInstance.removeVotingDecomposeWorkflowApplication(e.InstanceId.ToString());


            CrowdTask        crowdTask        = new CrowdTask();
            CrowdTaskService crowdTaskService = new CrowdTaskService();

            //将当前流程的投票的分解的工作流ID写入数据库
            int result = crowdTaskService.saveDecomposeVoteResult(e.InstanceId.ToString(), (string)e.Outputs["out_bestSolutionWorkflowId"]);


            crowdTask = crowdTaskService.findCrowdTaskByWorkflowId(e.InstanceId.ToString());

            //通过当前任务的父工作流ID ,获得该父工作流的所有子工作流,如果都完成了则开启分解判断过程
            int count = 0;

            ArrayList allSonCrowdTask = crowdTaskService.findCrowdTaskByParentWorkflowIdAndTaskTypeAndTaskName(crowdTask.taskParentWorkflowId, crowdTask.taskName, TaskType.decomposeVotingTask, crowdTask.mainTaskId);

            // Dictionary<string, ArrayList> solutionTasks = new Dictionary<string, ArrayList>();
            //   Dictionary<string, int> dic=null;
            foreach (CrowdTask ct in allSonCrowdTask)
            {
                WorkflowApplication wa = MyWorkflowInstance.getDecomposeVotingWorkflowApplication(ct.taskWorkflowId);
                if (wa != null)
                {
                    //有一个不为空就表示改父工作流的所有子工作流没有都完成
                    break;
                }
                else
                {
                    //表示完成了
                    count++;
                }
            }
            if (count == ConstantDefine.decomposeVotingNumber)
            {
                //得到这个投票任务的结果

                ArrayList arraylist1 = crowdTaskService.findCrowdTaskByParentWorkflowIdAndTaskTypeAndTaskName(crowdTask.taskParentWorkflowId, crowdTask.taskName, TaskType.decomposeTask, crowdTask.mainTaskId);

                //将arrayList1里面的每个任务取出来,将其ID获得,然后根据ID去decomposeResult 里面取值

                int[]    nums    = new int[ConstantDefine.divideNumber];
                string[] votedId = new string[ConstantDefine.divideNumber];
                int      i       = 0;
                foreach (CrowdTask ct in arraylist1)
                {
                    //在这里将去检索数据库
                    Dictionary <string, int> dict = crowdTaskService.findSupportThisIdNumber(ct.taskWorkflowId);
                    if (dict.Count != 0)
                    {
                        nums[i]    = dict.First().Value;
                        votedId[i] = dict.First().Key;
                    }
                    else
                    {
                        nums[i]    = 0;
                        votedId[i] = "";
                    }
                    i++;
                }
                string bestSolutionWorkflowId = votedId[0];
                int    max = nums[0];
                for (int t = 0; t < nums.Length; t++)
                {
                    if (nums[t] > max)
                    {
                        max = nums[t];
                        bestSolutionWorkflowId = votedId[t];
                    }
                }
                ArrayList bestSolutionArrayList = crowdTaskService.findDecomposeResultByWorkflowId(bestSolutionWorkflowId, crowdTask.mainTaskId);

                //设置投票标记
                crowdTaskService.updateDecomposeResultVotedByWorkflowId(bestSolutionWorkflowId);



                foreach (DecomposeResult dr in bestSolutionArrayList)
                {
                    //开启5个投票流程  工作流实例
                    for (int m = 0; m < ConstantDefine.divideNumber; m++)
                    {
                        CrowdTask task = new CrowdTask();
                        task.taskName             = dr.taskName;
                        task.taskDescription      = dr.taskDescription;
                        task.taskParentWorkflowId = bestSolutionWorkflowId;
                        task.taskType             = TaskType.decomposeTask;
                        StartSubProcess ssp = new StartSubProcess();
                        ssp.startSubDivideProcess(new Guid(bestSolutionWorkflowId), task);
                    }
                }
            }
        }
コード例 #15
0
        public void startDevideVotingProcess(Dictionary<string, ArrayList> solutionTasks)
        {
            //创建输入参数
            Dictionary<string, object> para = new Dictionary<string, object>();
            para.Add("solutionTasks", solutionTasks);

            //创建实例对象
            WorkflowApplication  currentWorkflowInstance = new WorkflowApplication(new decomposeVoting(), para);

            //委托流程结束时候调用的方法
            currentWorkflowInstance.Completed = new Action<WorkflowApplicationCompletedEventArgs>(DevideVotingWorkflowCompleted);

            //启动实例
            currentWorkflowInstance.Run();

            CrowdTaskService crowdTaskService = new CrowdTaskService();
            //分解任务
            CrowdTask divideTask = crowdTaskService.findCrowdTaskByWorkflowId(solutionTasks.First().Key);

         
            CrowdTask crowdTask = new CrowdTask();
            crowdTask.taskName = divideTask.taskName;
            crowdTask.taskDescription = divideTask.taskDescription;
            crowdTask.taskType = TaskType.decomposeVotingTask;

            crowdTask.taskWorkflowId = currentWorkflowInstance.Id.ToString();

            crowdTask.taskParentWorkflowId = crowdTaskService.findCrowdTaskByWorkflowId(solutionTasks.Keys.First().ToString()).taskParentWorkflowId;


            int result = crowdTaskService.insert(crowdTask);

            //更新每个实例的主工作流Id
            crowdTaskService.updateCrowdTaskMainTaskIdByWorkflowId(currentWorkflowInstance.Id.ToString());


            if (result == 1)
            {
                //将当前实例加入到分解任务集合中
                MyWorkflowInstance.setDecomposeVotingWorkflowApplication(currentWorkflowInstance.Id.ToString(), currentWorkflowInstance);
            }
        }
コード例 #16
0
        void DevideVotingWorkflowCompleted(WorkflowApplicationCompletedEventArgs e)
        {

          
            MyWorkflowInstance.removeVotingDecomposeWorkflowApplication(e.InstanceId.ToString());


            CrowdTask crowdTask = new CrowdTask();
            CrowdTaskService crowdTaskService = new CrowdTaskService();

            //将当前流程的投票的分解的工作流ID写入数据库
            int result = crowdTaskService.saveDecomposeVoteResult(e.InstanceId.ToString(), (string)e.Outputs["out_bestSolutionWorkflowId"]);


            crowdTask = crowdTaskService.findCrowdTaskByWorkflowId(e.InstanceId.ToString());

            //通过当前任务的父工作流ID ,获得该父工作流的所有子工作流,如果都完成了则开启分解判断过程
            int count = 0;

            ArrayList allSonCrowdTask = crowdTaskService.findCrowdTaskByParentWorkflowIdAndTaskTypeAndTaskName(crowdTask.taskParentWorkflowId, crowdTask.taskName,TaskType.decomposeVotingTask,crowdTask.mainTaskId);

           // Dictionary<string, ArrayList> solutionTasks = new Dictionary<string, ArrayList>();
         //   Dictionary<string, int> dic=null;
            foreach (CrowdTask ct in allSonCrowdTask)
            {
                WorkflowApplication wa = MyWorkflowInstance.getDecomposeVotingWorkflowApplication(ct.taskWorkflowId);
                if (wa != null)
                {
                    //有一个不为空就表示改父工作流的所有子工作流没有都完成
                    break;
                }
                else
                {
                    //表示完成了
                    count++;
                }
            }
            if (count == ConstantDefine.decomposeVotingNumber)
            {

                //得到这个投票任务的结果

               ArrayList arraylist1=  crowdTaskService.findCrowdTaskByParentWorkflowIdAndTaskTypeAndTaskName(crowdTask.taskParentWorkflowId,crowdTask.taskName,TaskType.decomposeTask,crowdTask.mainTaskId);

                //将arrayList1里面的每个任务取出来,将其ID获得,然后根据ID去decomposeResult 里面取值

               int[] nums = new int[ConstantDefine.divideNumber];
               string[] votedId = new string[ConstantDefine.divideNumber];
               int i=0;
               foreach ( CrowdTask ct in arraylist1)
               {
                   //在这里将去检索数据库
                   Dictionary<string,int> dict =  crowdTaskService.findSupportThisIdNumber(ct.taskWorkflowId);
                   if(dict.Count!=0){
                          nums[i] = dict.First().Value;
                          votedId[i] =dict.First().Key;
                   }
                   else
                   {
                       nums[i] = 0;
                       votedId[i] = "";
                   }
                     i++;
               }
               string bestSolutionWorkflowId = votedId[0];
               int max = nums[0];
               for (int t = 0; t < nums.Length; t++)
               {
                   if (nums[t] > max)
                   {
                       max = nums[t];
                       bestSolutionWorkflowId = votedId[t];
                   }

               }
                ArrayList bestSolutionArrayList = crowdTaskService.findDecomposeResultByWorkflowId(bestSolutionWorkflowId,crowdTask.mainTaskId);

                //设置投票标记
                crowdTaskService.updateDecomposeResultVotedByWorkflowId(bestSolutionWorkflowId);



                foreach(DecomposeResult dr in bestSolutionArrayList){
                    //开启5个投票流程  工作流实例
                    for (int m = 0; m < ConstantDefine.divideNumber; m++)
                    {
                        CrowdTask task = new CrowdTask();
                        task.taskName=dr.taskName;
                        task.taskDescription=dr.taskDescription;
                        task.taskParentWorkflowId=bestSolutionWorkflowId;
                        task.taskType=TaskType.decomposeTask;
                        StartSubProcess ssp = new StartSubProcess();
                        ssp.startSubDivideProcess(new Guid(bestSolutionWorkflowId),task);
                    }
                }
            }
        }
コード例 #17
0
 public int saveSolveResult(CrowdTask crowdTask ,string solution)
 {
     int result = 0;
     SqlCommand com = null;
     try
     {
         conn.Open();
         string sql = string.Format("insert into solveResult(taskName,taskDescription,workflow_id,solutions,mainTaskId) values('{0}','{1}','{2}','{3}','{4}')", crowdTask.taskName, crowdTask.taskDescription, crowdTask.taskWorkflowId,solution,crowdTask.mainTaskId);
         com = new SqlCommand(sql, conn);
         int k = com.ExecuteNonQuery();
     }
     catch (Exception e)
     {
         throw e;
     }
     finally
     {
         if (com != null)
         {
             com.Dispose();
         }
         if (conn != null)
         {
             conn.Close();
         }
       
     }
     return result;
 }
コード例 #18
0
        void solveWorkflowCompleted(WorkflowApplicationCompletedEventArgs e)
        {
            MyWorkflowInstance.removeSolveWorkflowApplication(e.InstanceId.ToString());

            CrowdTask crowdTask = new CrowdTask();

            CrowdTaskService crowdTaskService = new CrowdTaskService();

            crowdTask = crowdTaskService.findCrowdTaskByWorkflowId(e.InstanceId.ToString());

            //将当前流程的解决结果写入数据库
            int result = crowdTaskService.saveSolveResult(crowdTask, (string)e.Outputs["out_solution"]);

            /*

            //通过当前解决任务的工作流ID ,获得该工作流的所有同一任务的不同工作流,如果都完成了则开启解决判断过程;
            int count = 0;

            ArrayList allSonCrowdTask = crowdTaskService.findAllSonCrowdTaskByParentTaskNameAndTaskDescriptionAndTaskType(crowdTask.taskName, crowdTask.taskDescription,crowdTask.taskType);

            foreach (CrowdTask ct in allSonCrowdTask)
            {
                WorkflowApplication wa = MyWorkflowInstance.getSolveWorkflowApplication(ct.taskWorkflowId);
                if (wa != null)
                {
                    break;
                }
                else
                {
                    count++;
                }
            }
            if (count == ConstantDefine.solvingNumber)
            {
                //都已经解决完成,可以开始投票了
                //通过当前获得到的workflowId ,加载解决方案,然后保存在一个list里面,开启投票流程

                Dictionary<string,SolveResult> solveResutDic = new Dictionary<string,SolveResult>();
                
                //得到所有的解决结果
                    foreach (CrowdTask ct in allSonCrowdTask)
                    {
                      SolveResult sr = crowdTaskService.findSolveResultByWorkflowId(ct.taskWorkflowId);

                        solveResutDic.Add(ct.taskWorkflowId,sr);
                    }
                if(solveResutDic.Count!=0)
                {
                    //开启5个解决投票流程  工作流实例
                    for (int i = 0; i < ConstantDefine.solveVotingNumber; i++)
                    {
                        StartSubProcess ssp = new StartSubProcess();
                        ssp.startSolveVoteProcess(solveResutDic);
                    }
                }

            }
            */


            //如果所有的解决任务完成了。开启投票
            if (MyWorkflowInstance.getSolveWorkflowApplications().Count == 0)
            {
                ArrayList allSolveCompeletedCrowdTask = crowdTaskService.findAllSolveCompeletedCrowdTaskByMainTaskId(crowdTask.mainTaskId);
                //得到所有的解决结果
                foreach (SolveResult sr in allSolveCompeletedCrowdTask)
                {
                    //开启投票过程
                    Dictionary<string, SolveResult> solveResutDic = new Dictionary<string, SolveResult>();

                    ArrayList abc = crowdTaskService.finSolveResultByMainTaskIdAndTaskName(crowdTask.mainTaskId, sr.taskName);
                    foreach (SolveResult sdr in abc)
                    {
                        solveResutDic.Add(sdr.taskWorkflowId, sdr);
                    }
                    if (solveResutDic.Count != 0)
                    {
                        //开启5个解决投票流程  工作流实例
                        for (int i = 0; i < ConstantDefine.solveVotingNumber; i++)
                        {
                            StartSubProcess ssp = new StartSubProcess();
                            ssp.startSolveVoteProcess(solveResutDic);
                        }
                    }
                }

                MyWorkflowInstance.getWorkflowApplication(crowdTask.mainTaskId).ResumeBookmark(BookmarkName.Solving,null);

            }
        }
コード例 #19
0
 public ArrayList findAllSonCrowdTaskByParentTaskNameAndTaskDescriptionAndTaskType(string taskName, string taskDescription,string taskType,string mainTaskId)
 {
     ArrayList arrayList = new ArrayList();
     SqlCommand com = null;
     try
     {
         conn.Open();
         string sql = string.Format("select * from crowdTask where taskName='{0}' and taskDescription='{1}' and taskType='{2}' and mainTaskId='{3}'", taskName, taskDescription,taskType,mainTaskId);
         com = new SqlCommand(sql, conn);
         SqlDataReader dr = com.ExecuteReader();
         while (dr.Read())
         {
             CrowdTask crowdTask = new CrowdTask();
             crowdTask.taskName = dr["taskName"].ToString();
             crowdTask.taskDescription = dr["taskDescription"].ToString();
             crowdTask.taskType = dr["taskType"].ToString();
             crowdTask.taskWorkflowId = dr["workflow_id"].ToString();
             crowdTask.taskParentWorkflowId = dr["parent_workflow_id"].ToString();
             crowdTask.mainTaskId = dr["mainTaskId"].ToString();
             arrayList.Add(crowdTask);
         }
        
     }
     catch (Exception e)
     {
         throw e;
     }
     finally
     {
         if (com != null)
         {
             com.Dispose();
         }
         if (conn != null)
         {
             conn.Close();
         }
     }
     return arrayList;
      }
コード例 #20
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        ArrayList arrayList = new ArrayList();
        string steps = tb_step.Text;
        int number = Convert.ToInt32(steps);
        CrowdTask[] crowdTasks = new CrowdTask[number];
        DecomposeResult[] decomposeResults = new DecomposeResult[number];


        for (int i = 0; i < number; i++)
        {
            CrowdTask ct = new CrowdTask();
            crowdTasks[i] = ct;
            DecomposeResult dr = new DecomposeResult();
            decomposeResults[i] = dr;
        }  
        switch(steps){
            case "2":
               
                /*
                    crowdTasks[0].taskName = taskName_1.Text;
                    crowdTasks[0].taskDescription = taskDescription_1.Text;
                    crowdTasks[1].taskName = taskName_2.Text;
                    crowdTasks[1].taskDescription = taskDescription_2.Text;
                */
               
                    decomposeResults[0].taskName = taskName_1.Text;
                    decomposeResults[0].taskDescription = taskDescription_1.Text;
                    decomposeResults[0].taskOrder = "第一步";
                    decomposeResults[0].workflow_id = taskWorkflowId;
                    decomposeResults[0].parent_workflow_id = currentCrowdTask.taskParentWorkflowId;
                    decomposeResults[0].mainTaskId = currentCrowdTask.mainTaskId;

                    decomposeResults[1].taskName = taskName_2.Text;
                    decomposeResults[1].taskDescription = taskDescription_2.Text;
                    decomposeResults[1].taskOrder = "第二步";
                    decomposeResults[1].workflow_id = taskWorkflowId;
                    decomposeResults[1].parent_workflow_id = currentCrowdTask.taskParentWorkflowId;
                    decomposeResults[1].mainTaskId = currentCrowdTask.mainTaskId;

                    for (int i = 0; i < number; i++)
                    {
                        arrayList.Add(decomposeResults[i]);
                    } 
                break;
            case "3":
                 
                /*
                    crowdTasks[0].taskName = taskName_1.Text;
                    crowdTasks[0].taskDescription = taskDescription_1.Text;
                    crowdTasks[1].taskName = taskName_2.Text;
                    crowdTasks[1].taskDescription = taskDescription_2.Text;     
                    crowdTasks[2].taskName = taskName_3.Text;
                    crowdTasks[2].taskDescription = taskDescription_3.Text;  
                */

                   decomposeResults[0].taskName = taskName_1.Text;
                    decomposeResults[0].taskDescription = taskDescription_1.Text;
                    decomposeResults[0].taskOrder = "第一步";
                    decomposeResults[0].workflow_id = taskWorkflowId;
                    decomposeResults[0].parent_workflow_id = currentCrowdTask.taskParentWorkflowId;
                    decomposeResults[0].mainTaskId = currentCrowdTask.mainTaskId;

                    decomposeResults[1].taskName = taskName_2.Text;
                    decomposeResults[1].taskDescription = taskDescription_2.Text;
                    decomposeResults[1].taskOrder = "第二步";
                    decomposeResults[1].workflow_id = taskWorkflowId;
                    decomposeResults[1].parent_workflow_id = currentCrowdTask.taskParentWorkflowId;
                    decomposeResults[1].mainTaskId = currentCrowdTask.mainTaskId;

                    decomposeResults[2].taskName = taskName_3.Text;
                    decomposeResults[2].taskDescription = taskDescription_3.Text;
                    decomposeResults[2].taskOrder = "第三步";
                    decomposeResults[2].workflow_id = taskWorkflowId;
                    decomposeResults[2].parent_workflow_id = currentCrowdTask.taskParentWorkflowId;
                    decomposeResults[2].mainTaskId = currentCrowdTask.mainTaskId;
                    for (int i = 0; i < number; i++)
                    {
                        arrayList.Add(decomposeResults[i]);
                    } 
                break;
            case "4":
                /*
                  crowdTasks[0].taskName = taskName_1.Text;
                    crowdTasks[0].taskDescription = taskDescription_1.Text;
                    crowdTasks[1].taskName = taskName_2.Text;
                    crowdTasks[1].taskDescription = taskDescription_2.Text;     
                 crowdTasks[2].taskName = taskName_3.Text;
                    crowdTasks[2].taskDescription = taskDescription_3.Text;  
                    crowdTasks[3].taskName = taskName_4.Text;
                    crowdTasks[3].taskDescription = taskDescription_4.Text;  
                */
                      decomposeResults[0].taskName = taskName_1.Text;
                    decomposeResults[0].taskDescription = taskDescription_1.Text;
                    decomposeResults[0].taskOrder = "第一步";
                    decomposeResults[0].workflow_id = taskWorkflowId;
                    decomposeResults[0].parent_workflow_id = currentCrowdTask.taskParentWorkflowId;
                    decomposeResults[0].mainTaskId = currentCrowdTask.mainTaskId;

                    decomposeResults[1].taskName = taskName_2.Text;
                    decomposeResults[1].taskDescription = taskDescription_2.Text;
                    decomposeResults[1].taskOrder = "第二步";
                    decomposeResults[1].workflow_id = taskWorkflowId;
                    decomposeResults[1].parent_workflow_id = currentCrowdTask.taskParentWorkflowId;
                    decomposeResults[1].mainTaskId = currentCrowdTask.mainTaskId;

                    decomposeResults[2].taskName = taskName_3.Text;
                    decomposeResults[2].taskDescription = taskDescription_3.Text;
                    decomposeResults[2].taskOrder = "第三步";
                    decomposeResults[2].workflow_id = taskWorkflowId;
                    decomposeResults[2].parent_workflow_id = currentCrowdTask.taskParentWorkflowId;
                    decomposeResults[2].mainTaskId = currentCrowdTask.mainTaskId;

                    decomposeResults[3].taskName = taskName_4.Text;
                    decomposeResults[3].taskDescription = taskDescription_4.Text;
                    decomposeResults[3].taskOrder = "第四步";
                    decomposeResults[3].workflow_id = taskWorkflowId;
                    decomposeResults[3].parent_workflow_id = currentCrowdTask.taskParentWorkflowId;
                    decomposeResults[3].mainTaskId = currentCrowdTask.mainTaskId;
                    for (int i = 0; i < number; i++)
                    {
                        arrayList.Add(decomposeResults[i]);
                    } 
                break;
            case "5":
                /*
                  crowdTasks[0].taskName = taskName_1.Text;
                    crowdTasks[0].taskDescription = taskDescription_1.Text;
                    crowdTasks[1].taskName = taskName_2.Text;
                    crowdTasks[1].taskDescription = taskDescription_2.Text;     
                 crowdTasks[2].taskName = taskName_3.Text;
                    crowdTasks[2].taskDescription = taskDescription_3.Text;  
                    crowdTasks[3].taskName = taskName_4.Text;
                    crowdTasks[3].taskDescription = taskDescription_4.Text;   
                    crowdTasks[4].taskName = taskName_5.Text;
                    crowdTasks[4].taskDescription = taskDescription_5.Text; 
                */

                
                  
                      decomposeResults[0].taskName = taskName_1.Text;
                    decomposeResults[0].taskDescription = taskDescription_1.Text;
                    decomposeResults[0].taskOrder = "第一步";
                    decomposeResults[0].workflow_id = taskWorkflowId;
                    decomposeResults[0].parent_workflow_id = currentCrowdTask.taskParentWorkflowId;
                    decomposeResults[0].mainTaskId = currentCrowdTask.mainTaskId;

                    decomposeResults[1].taskName = taskName_2.Text;
                    decomposeResults[1].taskDescription = taskDescription_2.Text;
                    decomposeResults[1].taskOrder = "第二步";
                    decomposeResults[1].workflow_id = taskWorkflowId;
                    decomposeResults[1].parent_workflow_id = currentCrowdTask.taskParentWorkflowId;
                    decomposeResults[1].mainTaskId = currentCrowdTask.mainTaskId;

                    decomposeResults[2].taskName = taskName_3.Text;
                    decomposeResults[2].taskDescription = taskDescription_3.Text;
                    decomposeResults[2].taskOrder = "第三步";
                    decomposeResults[2].workflow_id = taskWorkflowId;
                    decomposeResults[2].parent_workflow_id = currentCrowdTask.taskParentWorkflowId;
                    decomposeResults[2].mainTaskId = currentCrowdTask.mainTaskId;

                    decomposeResults[3].taskName = taskName_4.Text;
                    decomposeResults[3].taskDescription = taskDescription_4.Text;
                    decomposeResults[3].taskOrder = "第四步";
                    decomposeResults[3].workflow_id = taskWorkflowId;
                    decomposeResults[3].parent_workflow_id = currentCrowdTask.taskParentWorkflowId;
                    decomposeResults[3].mainTaskId = currentCrowdTask.mainTaskId;

                    decomposeResults[4].taskName = taskName_5.Text;
                    decomposeResults[4].taskDescription = taskDescription_5.Text;
                    decomposeResults[4].taskOrder = "第五步";
                    decomposeResults[4].workflow_id = taskWorkflowId;
                    decomposeResults[4].parent_workflow_id = currentCrowdTask.taskParentWorkflowId;
                    decomposeResults[4].mainTaskId = currentCrowdTask.mainTaskId;


                    for (int i = 0; i < number; i++)
                    {
                        arrayList.Add(decomposeResults[i]);
                    } 

                break;
        }

        WorkflowApplication instance = MyWorkflowInstance.getDecomposeWorkflowApplication(taskWorkflowId);

        instance.ResumeBookmark(BookmarkName.Decomposing, arrayList);

        //跳转到分解完成页面
        Server.Transfer("decomposeCompeleted.aspx");


        
    }
コード例 #21
0
        public  void startSolveVoteProcess(Dictionary<string, SolveResult> solveResutDic)
        {
            //开启解决投票实例
            //创建输入参数
            Dictionary<string, object> para = new Dictionary<string, object>();
            para.Add("sovleResultDic", solveResutDic);

            //创建实例对象
            WorkflowApplication currentWorkflowInstance = new WorkflowApplication(new solveVoting(), para);

            //委托流程结束时候调用的方法
            currentWorkflowInstance.Completed = new Action<WorkflowApplicationCompletedEventArgs>(solveVotingWorkflowCompleted);

            //启动实例
            currentWorkflowInstance.Run();

            CrowdTaskService crowdTaskService = new CrowdTaskService();

          

            CrowdTask crowdTask = new CrowdTask();
            crowdTask.taskName =  solveResutDic.Values.First().taskName;
            crowdTask.taskDescription = solveResutDic.Values.First().taskDescription;
            crowdTask.taskType = TaskType.solveVotingTask;
            crowdTask.taskWorkflowId = currentWorkflowInstance.Id.ToString();

            int result = crowdTaskService.insert(crowdTask);
            //更新每个实例的主工作流Id
            crowdTaskService.updateCrowdTaskMainTaskIdByWorkflowId(currentWorkflowInstance.Id.ToString());

            if (result == 1)
            {
                //将当前实例加入到分解任务集合中
                MyWorkflowInstance.setSolveVotingWorkflowApplication(currentWorkflowInstance.Id.ToString(), currentWorkflowInstance);
            }
        }
コード例 #22
0
        void SubDivideWorkflowCompleted(WorkflowApplicationCompletedEventArgs e)
        {

            //流程结束,将流程实例移除
            MyWorkflowInstance.removeDecomposeWorkflowApplication(e.InstanceId.ToString());

           
            CrowdTaskService crowdTaskService = new CrowdTaskService();
            //将当前流程的分解解决方案写入数据库
            int result = crowdTaskService.saveDecomposeResult(e.InstanceId.ToString(),(ArrayList)e.Outputs["out_arraylist_task"]);

            //得到当前分解任务的内容
            CrowdTask crowdTask = new CrowdTask();
            crowdTask =  crowdTaskService.findCrowdTaskByWorkflowId(e.InstanceId.ToString());

            //通过当前分解任务的父工作流ID ,获得该父工作流的所有子工作流,如果都完成了则开启分解判断过程
            ArrayList allSonCrowdTask = crowdTaskService.findAllSonCrowdTaskByParentWorkflowIdAndTaskName(crowdTask.taskParentWorkflowId, crowdTask.taskName,crowdTask.mainTaskId);
            
            Dictionary<string, ArrayList> solutionTasks = new Dictionary<string, ArrayList>();

            int count = 0;
            //遍历看看这个任务的同一级的分解任务是否都结束了
            foreach (CrowdTask ct in allSonCrowdTask)
             {
                 WorkflowApplication wa = MyWorkflowInstance.getDecomposeWorkflowApplication(ct.taskWorkflowId);
                 if (wa != null)
                 {
                     break;
                 }
                 else
                 {
                     count++;
                 }
             }
            //如果都结束了
             if (count == ConstantDefine.divideNumber)
             {

                 //获得每一个分解任务给出的解决方案
                 foreach (CrowdTask ct in allSonCrowdTask)
                 {
                     ArrayList solutions = crowdTaskService.findDecomposeResultByWorkflowId(ct.taskWorkflowId,ct.mainTaskId);
                     if (solutions.Count != 0)
                     {
                         //表示当前工作流Id给出了分解方案
                         solutionTasks.Add(ct.taskWorkflowId, solutions);
                     }
                 }
                 //表示至少有一个分解任务给出了解决方案
                 if (solutionTasks.Count != 0)
                 {
                     //开启5个投票流程  工作流实例
                     for (int i = 0; i < ConstantDefine.decomposeVotingNumber; i++)
                     {
                         StartSubProcess ssp = new StartSubProcess();
                         ssp.startDevideVotingProcess(solutionTasks);
                     }
                 }
                 //表示所有的当前这几个分解任务都认为这个任务是简单任务,设置简单标记
                 else
                 {
                     //当前一个任务判定为简单,是要等这一层级的所有任务都判定完了在根据情况,把这一层是简单的任务抛出去
                     foreach (CrowdTask ct in allSonCrowdTask)
                     {
                         int h = crowdTaskService.updateDecomposeResultByWokflowIdAndTaskName(ct.taskParentWorkflowId, ct.taskName,ct.mainTaskId);
                     }

                 } 


                 /*
                 //等待这一层的所有任务都分解完成了,把这一层的简单任务选出来,分发出去
                 ArrayList ThisLayerAllSonCrowdTask = crowdTaskService.findCrowdTaskByParentWorkflowIdAndTaskType(crowdTask.taskParentWorkflowId, TaskType.decomposeTask);
                 int count1 = 0;
                 //遍历这一层的任务,看看是否都完成了
                 foreach (CrowdTask ct in ThisLayerAllSonCrowdTask)
                 {
                     WorkflowApplication wa = MyWorkflowInstance.getDecomposeWorkflowApplication(ct.taskWorkflowId);
                     if (wa != null)
                     {
                         break;
                     }
                     else
                     {
                         count1++;
                     }
                 }
                 //这一层的所有任务都完成了
                 if (ThisLayerAllSonCrowdTask.Count == count1)
                 {
                     ArrayList al_simple = crowdTaskService.getAllThisLayerNeedSolvedCrowTaskInDecomposeResult(crowdTask.taskParentWorkflowId);
                     //可以得到这一层一共有多少个简单任务
                     //将每一个简单任务分发出去启动解决流程
                     foreach (DecomposeResult al in al_simple)
                     {
                         for (int k = 0; k < ConstantDefine.solvingNumber; k++)
                         {
                             //将这个任务分发出去
                             CrowdTask ct = new CrowdTask();
                             ct.taskName = al.taskName;
                             ct.taskDescription = al.taskDescription;
                             ct.taskType = TaskType.solveTask;
                             StartSubProcess ssp = new StartSubProcess();
                             ssp.startSolveProcess(ct);
                         }
                     }
                 }
                  * */
             }

             //如果分解的工作流为空。

             if (MyWorkflowInstance.getdecomposeWorkflowApplications().Count == 0 && MyWorkflowInstance.getdecomposeVotingWorkflowApplications().Count==0)
             {
                 //加载所有的需要解决的任务,作为解决任务发放出去

                 ArrayList li = crowdTaskService.getAllNeedSolvedCrowTaskInDecomposeResult1(crowdTask.mainTaskId);
                 foreach (DecomposeResult dr in li)
                 {
                     for (int k = 0; k < ConstantDefine.solvingNumber; k++)
                     {
                         //将这个任务分发出去
                         CrowdTask ct = new CrowdTask();
                         ct.taskName = dr.taskName;
                         ct.taskDescription = dr.taskDescription;
                         ct.taskType = TaskType.solveTask;
                         ct.taskParentWorkflowId = dr.parent_workflow_id;
                         StartSubProcess ssp = new StartSubProcess();
                         ssp.startSolveProcess(ct);
                     }
                 }

                   MyWorkflowInstance.getWorkflowApplication(crowdTask.mainTaskId).ResumeBookmark(BookmarkName.Decomposing,null); ;
             }


        }
コード例 #23
0
        private void solveVotingWorkflowCompleted(WorkflowApplicationCompletedEventArgs e)
        {
           //保存到解决投票表里面
            MyWorkflowInstance.removeSolveVotingWorkflowApplication(e.InstanceId.ToString());

            CrowdTask crowdTask = new CrowdTask();
          

            CrowdTaskService crowdTaskService = new CrowdTaskService();

            crowdTask = crowdTaskService.findCrowdTaskByWorkflowId(e.InstanceId.ToString());

            //将当前流程的投票的分解的工作流ID写入数据库
            int result = crowdTaskService.saveSolveVoteResult1(e.InstanceId.ToString(), (string)e.Outputs["out_bestSolutionWorkflowId"]);

            //如果所有的解决投票任务完成了。开启投票
            if (MyWorkflowInstance.getSolveVotingWorkflowApplications().Count == 0)
            {
                //更新得到最佳答案;

                ArrayList allSolveCompeletedCrowdTask = crowdTaskService.findAllSolveCompeletedCrowdTaskByMainTaskId(crowdTask.mainTaskId);
                //得到每一个解决任务的名字,然后根据名字和描述再去加载解决任务的ID,得到ID之后再去判断是不是最佳答案

                foreach (SolveResult sr in allSolveCompeletedCrowdTask)
                {
                    ArrayList al = crowdTaskService.finSolveResultByMainTaskIdAndTaskName(crowdTask.mainTaskId,sr.taskName);

                    int[] supportedNumber = new int[ConstantDefine.solvingNumber];
                    string[] supportedWorkflowId = new string[ConstantDefine.solvingNumber];
                    int i = 0;

                    foreach (SolveResult item in al)
                    {
                        //拿到每一个ID 当做supportedId,去数据库里面比对
                        supportedNumber[i]= crowdTaskService.getSolveVoteResultBySupportedId(item.taskWorkflowId);
                        supportedWorkflowId[i] = item.taskWorkflowId;
                        i++;
                    }
                    int maxNumber = supportedNumber[0];
                    string maxWorkflowId = supportedWorkflowId[0];

                    for (int j = 0; j < al.Count; j++)
                    {
                        if (supportedNumber[j] > maxNumber)
                        {
                            maxNumber = supportedNumber[j];
                            maxWorkflowId = supportedWorkflowId[j];
                        }
                    }

                    //找到了最佳答案,更新。
                    crowdTaskService.updateSolveResultBestAnswer(maxWorkflowId);
                }
                //更新书签
                MyWorkflowInstance.getWorkflowApplication(crowdTask.mainTaskId).ResumeBookmark(BookmarkName.SolveVoting, null);

                //生成分解树。
                crowdTaskService.writeDecomposeTree(crowdTask.mainTaskId);
            }
        }