private void recursionWrite(ArrayList decomposList) { //遍历decomposeList foreach (CrowdTask item in decomposList) { //根据每一个分解的Id,去查找对应的分解结果 ArrayList decomposeResultList = findDecomposeResultByWorkflowIdAndVote(item.taskWorkflowId, item.mainTaskId); if (decomposeResultList.Count != 0 && decomposeResultList != null) { //将这个分解结果写入到数据库 foreach (DecomposeResult dr in decomposeResultList) { CrowdTask ct = findCrowdTaskByWorkflowId(item.taskWorkflowId); DecomposeTree dt = findDecomposeTreeByTaskNameAndTaskDescription(ct.taskName, ct.taskDescription, ct.mainTaskId); insertDecomposeTree(dr.taskName, dr.taskDescription, dr.taskOrder, null, dt.id, dr.mainTaskId); if (dr.simple == "yes") { int dtId = findDecomposeTreeByTaskNameAndTaskDescription(dr.taskName, dr.taskDescription, dr.mainTaskId).id; string taskSolution = findSolveResultByTaskNameAndBestAnswer(dr.taskName, dr.mainTaskId).taskSolution; updateDecomposeTreeSetSolution(taskSolution, dtId); } } foreach (DecomposeResult dr in decomposeResultList) { //遍历当前分解结果list里面的每一个任务,看看是否还有分解,然后再写入到数据库 ArrayList subDecomposeList = findCrowdTaskByParentWorkflowIdAndTaskTypeAndTaskName(dr.workflow_id, dr.taskName, TaskType.decomposeTask, dr.mainTaskId); recursionWrite(subDecomposeList); } } } }
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); }
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; } }
public void buildTree(ArrayList al, ResultNode[] rn, int parentId, int currentId) { for (int i = 0; i < al.Count; i++) { CrowdTask ctl = al[i] as CrowdTask; ArrayList alist = findDecomposeResultByWorkflowIdAndVote(ctl.taskWorkflowId, ctl.mainTaskId); if (alist.Count != 0) { int t = currentId; //记录下分解内rong for (int k = 0; k < alist.Count; k++) { t++; DecomposeResult dr = alist[k] as DecomposeResult; rn[t].taskName = dr.taskName; rn[t].parentId = parentId; if (dr.simple == "yes") { rn[t].taskSolution = findSolveResultByTaskNameAndBestAnswer(dr.taskName, dr.mainTaskId).taskSolution; } } int r = currentId; for (int k = 0; k < alist.Count; k++) { DecomposeResult dr = alist[k] as DecomposeResult; if (dr.simple != "yes") { ArrayList klist = findCrowdTaskByParentWorkflowIdAndTaskTypeAndTaskName(dr.workflow_id, dr.taskName, TaskType.decomposeTask, dr.mainTaskId); buildTree(klist, rn, k + currentId + 1, currentId + alist.Count); } } } } }
public ResultNode[] getDivideTree(string workflow_id) { CrowdTask ct = findCrowdTaskByWorkflowId(workflow_id); ArrayList al = new ArrayList(); al = findCrowdTaskByParentWorkflowIdAndTaskType(ct.taskWorkflowId, TaskType.decomposeTask, ct.mainTaskId); int count = findallDecomposeResultByVoted(ct.mainTaskId).Count; ResultNode[] rn = new ResultNode[count + 1]; for (int j = 0; j < rn.Length; j++) { rn[j] = new ResultNode(null, null); } rn[0].taskName = ct.taskName; rn[0].parentId = rn.Length; //根据al里面的每个分解,去decomposeResult里面去寻找vote的东西。 buildTree(al, rn, 0, 0); return(rn); }
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); }
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); }
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; }
protected void Page_Load(object sender, EventArgs e) { crowdTaskService = new CrowdTaskService(); workflowId = Request.Params["workflowId"]; CrowdTask mainTask = crowdTaskService.findCrowdTaskByWorkflowId(workflowId); String taskName = mainTask.taskName; String taskDescription = mainTask.taskDescription; TextBox1.Text = taskName; TextBox2.Text = taskDescription; TextBox3.Text = workflowId; }
public void writeDecomposeTree(string workflow_id) { CrowdTask ct = findCrowdTaskByWorkflowId(workflow_id); ArrayList decomposList = new ArrayList(); insertDecomposeTree(ct.taskName, ct.taskDescription, null, null, 0, ct.mainTaskId); decomposList = findCrowdTaskByParentWorkflowIdAndTaskType(ct.taskWorkflowId, TaskType.decomposeTask, ct.mainTaskId); recursionWrite(decomposList); }
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(); } }
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); }
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); }
protected void Page_Load(object sender, EventArgs e) { //根据传过来的工作流ID,加载对应的实例 crowdTaskService = new CrowdTaskService(); //taskParentWorkflowId = Request.Params["parentWorkflowId"]; taskWorkflowId = Request.Params["taskWorkflowId"]; //得到任务实例 CrowdTask crowdTask = crowdTaskService.findCrowdTaskByWorkflowId(taskWorkflowId); TextBox1.Text = crowdTask.taskName; TextBox2.Text = crowdTask.taskDescription; //通过解决任务实例得到解决任务的同几个实例 //不应该根据分解任务的个数来生成表格,应该根据分解结果的个数来生成表格 list = crowdTaskService.findAllSonCrowdTaskByParentTaskNameAndTaskDescriptionAndTaskType(crowdTask.taskName, crowdTask.taskDescription, TaskType.solveTask, crowdTask.mainTaskId); foreach (CrowdTask ct in list) { SolveResult solveResult = crowdTaskService.findSolveResultByWorkflowId(ct.taskWorkflowId, crowdTask.mainTaskId); //创建显示解决结果的表格 Table table = new Table(); table.BorderWidth = 1; TableHeaderRow tableHeaderRow = new TableHeaderRow(); TableHeaderCell tableHeaderCell1 = new TableHeaderCell(); tableHeaderCell1.Text = "工作流ID:"; TableHeaderCell tableHeaderCell2 = new TableHeaderCell(); tableHeaderCell2.Text = ct.taskWorkflowId; TableHeaderCell tableHeaderCell3 = new TableHeaderCell(); RadioButton radioButton = new RadioButton(); radioButton.GroupName = "vote"; radioButton.ID = ct.taskWorkflowId; tableHeaderCell3.Controls.Add(radioButton); tableHeaderRow.Cells.Add(tableHeaderCell1); tableHeaderRow.Cells.Add(tableHeaderCell2); tableHeaderRow.Cells.Add(tableHeaderCell3); table.Rows.Add(tableHeaderRow); TableRow tr = new TableRow(); TableCell tc = new TableCell(); tc.Text = "解决方案"; TableCell tc1 = new TableCell(); tc1.Text = solveResult.taskSolution; tr.Cells.Add(tc); tr.Cells.Add(tc1); table.Rows.Add(tr); panel.Controls.Add(table); } }
protected void Page_Load(object sender, EventArgs e) { //根据传过来的工作流ID,加载对应的实例 crowdTaskService = new CrowdTaskService(); taskParentWorkflowId = Request.Params["parentWorkflowId"]; taskWorkflowId = Request.Params["taskWorkflowId"]; //得到需要分解任务实例 CrowdTask crowdTask = crowdTaskService.findCrowdTaskByWorkflowId(taskWorkflowId); TextBox1.Text = crowdTask.taskName; TextBox2.Text = crowdTask.taskDescription; TextBox3.Text = crowdTask.taskWorkflowId; //根据当前投票任务的名字,来查找分解任务有哪些,在根据这些分解任务的ID,去decomposeResult 里面查找对应的结果 list = crowdTaskService.findAllSonCrowdTaskByParentTaskNameAndTaskDescriptionAndTaskType(crowdTask.taskName, crowdTask.taskDescription, TaskType.decomposeTask, crowdTask.mainTaskId); foreach (CrowdTask ct in list) { ArrayList decomposeResult = crowdTaskService.findDecomposeResultByWorkflowId(ct.taskWorkflowId, crowdTask.mainTaskId); //创建显示分解结果的表格 Table table = new Table(); table.BorderWidth = 1; TableHeaderRow tableHeaderRow = new TableHeaderRow(); TableHeaderCell tableHeaderCell1 = new TableHeaderCell(); tableHeaderCell1.Text = "工作流ID:"; TableHeaderCell tableHeaderCell2 = new TableHeaderCell(); tableHeaderCell2.Text = ct.taskWorkflowId; TableHeaderCell tableHeaderCell3 = new TableHeaderCell(); RadioButton radioButton = new RadioButton(); radioButton.GroupName = "vote"; radioButton.ID = ct.taskWorkflowId; tableHeaderCell3.Controls.Add(radioButton); tableHeaderRow.Cells.Add(tableHeaderCell1); tableHeaderRow.Cells.Add(tableHeaderCell2); tableHeaderRow.Cells.Add(tableHeaderCell3); foreach (DecomposeResult dr in decomposeResult) { if (dr != null) { table.Rows.Add(tableHeaderRow); } } foreach (DecomposeResult dr in decomposeResult) { TableRow tr = new TableRow(); TableCell tc = new TableCell(); tc.Text = dr.taskOrder; TableCell tc1 = new TableCell(); tc1.Text = dr.taskName; TableCell tc2 = new TableCell(); tc2.Text = dr.taskDescription; tr.Cells.Add(tc); tr.Cells.Add(tc1); tr.Cells.Add(tc2); table.Rows.Add(tr); } panel.Controls.Add(table); } }
public void Post(CrowdTask task) { }
public CrowdTask Get(bool nextSuggestion) { using (CrowdCorrectEntities db = new CrowdCorrectEntities()) { int index = PickTweet(nextSuggestion); if (index == 0) { return(new CrowdTask()); } Tweet tw = db.Tweets.FirstOrDefault(t => t.Id == index); // CrowdTask task = new CrowdTask() { Id = tw.Id, Text = tw.Text }; // if (nextSuggestion) { var keywords = tw.Keywords.Where(ke => ke.UserKeywordTags.Count() > 0); int id = new Random().Next(keywords.Count()); var keyword = keywords.ElementAt(id); int tagId = new Random().Next(keyword.UserKeywordTags.Count()); var tag = keyword.UserKeywordTags.ElementAt(tagId); // task.Description = "In the above tweet, the keyword \'" + keyword.Keyword1 + "\' is marked as being a " + tag.Tag.Name + ". Which of the below suggestion is appropraite ?"; task.KeywordData.Id = keyword.Id; task.KeywordData.Name = keyword.Keyword1; // task.CorrectionQuestion.Tag.TagId = tag.Tag.Id; task.CorrectionQuestion.Tag.TagName = tag.Tag.Name; task.CorrectionQuestion.Tag.IsMarked = true; task.CorrectionQuestion.Tag.TagCount = 1; foreach (string suggestion in GetSuggestions(task.KeywordData, tag)) { task.CorrectionQuestion.Suggestions.Add(new Suggestion() { Text = suggestion, IsMarked = false }); } } else { var keywords = tw.Keywords.Where(ke => ke.UserKeywordTags.Count() == 0); int id = new Random().Next(keywords.Count()); var keyword = keywords.ElementAt(id); // task.Description = "In the above tweet, please mark the keyword \'" + keyword.Keyword1 + "\' as one of the below"; task.KeywordData.Id = keyword.Id; task.KeywordData.Name = keyword.Keyword1; // foreach (Tag t in db.Tags) { task.TagQuestion.Tags.Add(new Models.TagInfo() { IsMarked = false, TagCount = 1, TagId = t.Id, TagName = t.Name }); } } return(task); } }
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); } }
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"); }