Пример #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);
            }
        }
        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);
            }
        }