private void TaskExecuteForm_Shown(object sender, EventArgs e) { //maxTaskStep = List <Tb_taskResult> resultList = TaskResultCache.getCache().Where(t => t.taskId == taskInfoId && t.taskRound == currentRound).ToList(); try { maxTaskStep = resultList.Max(x => x.taskStep); } catch (Exception ex) { } if (currentRound == 1) { btn_previous.Enabled = false; } else { btn_previous.Enabled = true; } if (currentRound == maxRound) { btn_next.Enabled = false; } else { btn_next.Enabled = true; } }
/// <summary> /// 轮次进行切换的时候,初始化步骤, /// </summary> private void roundSwitch(int round) { List <Tb_taskResult> taskResult = TaskResultCache.getCache().Where(t => t.taskId == taskInfoId && t.taskRound == round).ToList(); maxStep = 0; try { maxStep = taskResult.Max(x => x.taskStep); } catch (Exception ex) { } currentStep = 1; if (currentStep >= maxStep) { btn_next.Enabled = false; } else { btn_next.Enabled = true; } if (currentStep <= 1) { btn_previous.Enabled = false; } else { btn_previous.Enabled = true; } lbl_current.Text = 1 + "/" + maxStep; }
private void reportCreate_Click(object sender, EventArgs e) { //taskInfoId taskResultMapList = TaskResultCache.getCache().Where(t => t.taskId == taskInfoId && t.taskRound == 1).ToList(); int maxResultStep = 0; try { maxResultStep = taskResultMapList.Max(x => x.taskStep); } catch (Exception ex) { } List <TaskResultModel> resultList = GetReportInfo(maxResultStep, 1); DialogSeleFile(resultList, taskInfoId.ToString()); }
private void btn_moveToUnselected_Click(object sender, EventArgs e) { List <int[]> checkedIndicatorId = new List <int[]>(); foreach (DataGridViewRow row in dgv_selected.Rows) { if (row.Cells[0].Value.ToString() == "True") { int[] cellVal = new int[] { (int)row.Cells[4].Value, (int)row.Cells[6].Value }; checkedIndicatorId.Add(cellVal); } } if (checkedIndicatorId.Count == 0) { MessageBoxEx.Show("您没有选中任何指标", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else { List <Tb_taskResult> currentIndicatorList = new List <Tb_taskResult>(); bool flag = true; foreach (var item in checkedIndicatorId)//遍历选择的所有指标,判断其中是否存在未通过的指标,该指标无法移到待选指标 { currentIndicatorList = TaskResultCache.getCache().Where(r => r.indicatorId == item[1] && r.taskId == taskInfoId && r.modelId == item[0] && r.taskStep == maxTaskStep && r.taskRound == currentRound).ToList(); if (currentIndicatorList[0].taskResult == 1) { flag = false; break; } } if (flag) { foreach (var checkItem in checkedIndicatorId) { moveIndicator(selectedIndicatorModelList, unselectedIndicatorModelList, checkItem[1], checkItem[0]); } chk_selected.Checked = false; bindDgv(); } else { MessageBoxEx.Show("当前选择的指标中存在未通过的指标", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); //表示当前选择的指标中存在未通过的指标 } } }
private void btn_save_Click(object sender, EventArgs e) { try { //List<int> selectedIndicatorIdList = selectedIndicatorModelList.Select(i => i.indicatorId).ToList(); //IndicatorTemplateMapCache.addCache(templateId, selectedIndicatorIdList); List <Tb_taskResult> resultList = new List <Tb_taskResult>(); int id = TaskResultCache.getCache().Count; if (selectedIndicatorModelList.Count == 0) { MessageBox.Show("保存失败,未选择任务指标", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } foreach (var item in selectedIndicatorModelList) { //Tb_taskIndicatorMap indicatorMap = new Tb_taskIndicatorMap(); //indicatorMap.taskId = taskInfoId; //indicatorMap.indicatorId = item; //indicatorMap.taskRound = currentRound; //TaskIndicatorMapCache.addCacheOnly(indicatorMap); Tb_taskResult taskResult = new Tb_taskResult(); taskResult.taskId = taskInfoId; taskResult.taskStep = 1;//新增轮次的步骤默认都是从1开始 taskResult.taskExecutor = User.currentUser.name; taskResult.taskDateTime = DateTime.Now; taskResult.modelId = item.modelId; taskResult.indicatorId = item.indicatorId; taskResult.taskRecord = ""; taskResult.taskResult = 0; taskResult.taskRemark = ""; taskResult.attachment = ""; taskResult.supplement = ""; taskResult.taskRound = currentRound + 1; resultList.Add(taskResult); } TaskResultCache.addCache(resultList); MessageBoxEx.Show("保存成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); this.DialogResult = DialogResult.Yes; } catch (Exception ex) { MessageBoxEx.Show("保存失败。" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); this.DialogResult = DialogResult.No; } }
/// <summary> /// 加载任务指标及测试结果 /// </summary> /// <param name="taskInfoId"></param> public void init(int taskInfoId, bool readOnly = false, int taskRound = 1) { taskId = taskInfoId; this.taskRound = taskRound; taskResultMapList = TaskResultCache.getCache().Where(t => t.taskId == taskId && t.taskRound == taskRound).ToList(); maxResultStep = 0; try { maxResultStep = taskResultMapList.Max(x => x.taskStep); currentResultStep = maxResultStep; } catch (Exception ex) { } dgv.DataSource = null; dgv.DataSource = getData(maxResultStep, this.taskRound); dgv.AutoGenerateColumns = false; setReadOnly(readOnly); }
private void swapIndicatro(DataGridViewX dgv, int indicatorId, int modelId) { if (dgv.Name == "dgv_selected")//已选-》待选 { var currentRoundIndicatorList = TaskResultCache.getCache().Where(r => r.indicatorId == indicatorId && r.modelId == modelId && r.taskId == taskInfoId && r.taskStep == maxTaskStep && r.taskRound == currentRound).ToList(); if (currentRoundIndicatorList[0].taskResult == 2) //表示已通过 { moveIndicator(selectedIndicatorModelList, unselectedIndicatorModelList, indicatorId, modelId); } else//1表示未通过,无法将该指标移到已选队列 { MessageBoxEx.Show("该指标未通过,无法移到待选", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } } else//待选=》已选 { moveIndicator(unselectedIndicatorModelList, selectedIndicatorModelList, indicatorId, modelId); } bindDgv(); }
/// <summary> /// 绑定轮次显示 /// </summary> private void bindTaskRound() { var orderRoundList = TaskResultCache.getCache().Where(r => r.taskId == taskInfoId).GroupBy(r => r.taskRound).OrderBy(r => r.Key).ToList(); if (orderRoundList.Count == 0) { currentRound = 1; maxRound = 1; lbl_round.Text = string.Format("{0}/{1}", currentRound, maxRound); //ButtonItem btn_round = new ButtonItem(); //btn_round.ShowSubItems = false; //btn_round.SubItemsExpandWidth = 14; //btn_round.Text = "1"; //btn_round.Click += new System.EventHandler(btn_round_Click); //btn_round.Checked = true; //this.ribbonBar_taskRound.Items.Add(btn_round); } else { lbl_round.Text = string.Format("{0}/{1}", currentRound, orderRoundList.Count); //foreach (var tr in orderRoundList) //{ // int round = tr.Key; // ButtonItem btn_round = new ButtonItem(); // btn_round.ShowSubItems = false; // btn_round.SubItemsExpandWidth = 14; // btn_round.Text = round.ToString(); // btn_round.Click += new System.EventHandler(btn_round_Click); // if (round == currentRound) // { // btn_round.Checked = true; // } // this.ribbonBar_taskRound.Items.Add(btn_round); //} maxRound = orderRoundList.Count; } }
public void init(int taskStateId) { this._taskStateId = taskStateId; if (taskStateId == (int)TaskStateEnum.Created)//如果是新建任务,则显示通过、驳回 { btn_done.Visible = false; btn_save.Visible = false; btn_close.Visible = false; btn_newRound.Visible = false; trp.init(taskInfoId, true, currentRound); //此时只读 showTaskRound_Panel.Visible = false; //不显示轮次操作 } else//如果是处理中的任务,显示保存、完成、关闭 { btn_pass.Visible = false; btn_reject.Visible = false; List <Tb_taskResult> resultList = TaskResultCache.getCache().Where(t => t.taskId == taskInfoId).ToList(); try { maxRound = resultList.Max(x => x.taskRound); } catch (Exception ex) { } if (maxRound == currentRound) { trp.init(taskInfoId, false, currentRound); } else { trp.init(taskInfoId, true, currentRound); } } bindTaskRound(); tdbip.init(taskInfoId); checkAndSignFirstOpen(); }
public List <TaskResultModel> getData(int step, int round) { var taskIndicatorMapList = TaskIndicatorMapCache.getCache().Where(i => i.taskId == taskId).ToList(); var indicatorList = IndicatorCache.getCache(); var brandList = CodeCache.getBrand(); var modelList = CodeCache.getModel(); var taskModelList = TaskModelMapCache.getCache(); taskResultMapList = TaskResultCache.getCache().Where(t => t.taskId == taskId && t.taskRound == taskRound).ToList(); if (round == 1) { //todo ***************确定后将下列ToList都去掉****************** var brand_model_list = (from brand in brandList from model in modelList where brand.id == model.parentId select new { modelId = model.id, modelName = model.codeName, brandId = brand.id, brandName = brand.codeName }).ToList(); var task_model_indicator_list = (from taskIndicator in taskIndicatorMapList from taskModel in taskModelList from bm in brand_model_list where taskIndicator.taskId == taskId && taskModel.taskId == taskId && taskModel.ModelId == bm.modelId select new { taskIndicator, bm.brandId, bm.brandName, bm.modelId, bm.modelName }).ToList(); var list_indicator = (from indicator in task_model_indicator_list join result in taskResultMapList.Where(r => r.taskStep == step && r.taskRound == round) on new { indicator.taskIndicator.indicatorId, indicator.modelId } equals new { result.indicatorId, result.modelId } into temp from tt in temp.DefaultIfEmpty() select new { indicator, taskRecord = tt == null ? "" : tt.taskRecord, taskResult = tt == null ? 0 : tt.taskResult, taskRemark = tt == null ? "" : tt.taskRemark, attachment = tt == null ? "" : tt.attachment, taskExecutor = tt == null ? "" : tt.taskExecutor, taskDateTime = tt == null ? "" : tt.taskDateTime.ToString(), taskStep = tt == null ? 0 : tt.taskStep, modelId = tt == null ? 0 : tt.modelId, taskResultId = tt == null ? 0 : tt.id, supplement = tt == null ? "" : tt.supplement }).ToList(); allResultModelList = (from temp in list_indicator from indicator in indicatorList where temp.indicator.taskIndicator.indicatorId == indicator.id select new TaskResultModel { indicatorId = indicator.id, indicatorName = indicator.indicatorName, indicatorDesc = indicator.indicatorDesc, indicatorInstr = indicator.indicatorInstr, taskDateTime = temp.taskDateTime, taskStep = temp.taskStep, taskExecutor = temp.taskExecutor, taskRecord = temp.taskRecord, taskRemark = temp.taskRemark, attachment = temp.attachment, attachmentCount = (temp.attachment == string.Empty ? "" : temp.attachment.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries).Count() + "个") + (temp.supplement == "" ? "" : "(补)"), taskResult = temp.taskResult, modelId = temp.indicator.modelId, modelName = temp.indicator.modelName, brandId = temp.indicator.brandId, brandName = temp.indicator.brandName, taskResultId = temp.taskResultId, supplement = temp.supplement, isFillFinish = (temp.taskResult == 0 && temp.taskRecord == "") ? 0 : 1, isHaveModi = ((temp.taskResult != 0 || temp.taskRecord != "" || temp.taskRemark != "" || temp.attachment != "" || temp.supplement != "") ? 1:0) }).ToList(); } else { var initStepList = TaskResultCache.getCache().Where(r => r.taskId == taskId && r.taskRound == taskRound && r.taskResult == 0 && r.taskStep == 1).ToList(); var a = (from initStep in initStepList join result in TaskResultCache.getCache().Where(r => r.taskId == taskId && r.taskRound == taskRound && r.taskStep == step).ToList() on new { initStep.modelId, initStep.indicatorId } equals new { result.modelId, result.indicatorId } into temp from tt in temp.DefaultIfEmpty() select new Tb_taskResult { id = initStep.id, taskRecord = (tt == null?"": tt.taskRecord), attachment = (tt == null ?"":tt.attachment), taskResult = (tt == null?0:tt.taskResult), taskId = initStep.taskId, taskStep = step, taskRound = round, taskExecutor = initStep.taskExecutor, taskDateTime = tt == null? DateTime.Now: tt.taskDateTime, modelId = initStep.modelId, indicatorId = initStep.indicatorId, taskRemark = (tt == null ? "" : tt.taskRemark), supplement = (tt == null ? "" : tt.supplement), }).ToList(); allResultModelList = (from resultList in a from indicator in indicatorList from brand in brandList from model in modelList where resultList.modelId == model.id && model.parentId == brand.id && resultList.indicatorId == indicator.id && resultList.taskId == taskId && resultList.taskRound == round && resultList.taskStep == step select new TaskResultModel { indicatorId = resultList.indicatorId, indicatorName = indicator.indicatorName, indicatorDesc = indicator.indicatorDesc, indicatorInstr = indicator.indicatorInstr, brandId = brand.id, brandName = brand.codeName, modelId = model.id, modelName = model.codeName, taskStep = resultList.taskStep, taskExecutor = resultList.taskExecutor, taskDateTime = resultList.taskDateTime.ToString(), taskRecord = resultList.taskRecord, taskResult = resultList.taskResult, taskResultId = resultList.id, taskRemark = resultList.taskRemark, attachment = resultList.attachment, attachmentCount = (resultList.attachment == string.Empty ? "" : resultList.attachment.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries).Count() + "个") + (resultList.supplement == "" ? "" : "(补)"), supplement = resultList.supplement, isFillFinish = (resultList.taskResult == 0 && resultList.taskRecord == "") ? 0 : 1, isHaveModi = ((resultList.taskResult != 0 || resultList.taskRecord != "" || resultList.taskRemark != "" || resultList.attachment != "" || resultList.supplement != "") ? 1 : 0) }).ToList(); } pagingPanel.setDetail(allResultModelList.Count); return(allResultModelList.Skip(pageSize * (pageNum - 1)).Take(pageSize).ToList()); }
public void maxRoundInit(int taskInfoId, bool readOnly = false, int taskRound = 1) { taskId = taskInfoId; this.taskRound = taskRound; taskResultMapList = TaskResultCache.getCache().Where(t => t.taskId == taskId && t.taskRound == taskRound && t.taskStep == 1).ToList(); List <Tb_taskResult> allResult = TaskResultCache.getCache().Where(t => t.taskId == taskId && t.taskRound == taskRound).ToList(); maxResultStep = 0; try { maxResultStep = allResult.Max(x => x.taskStep); currentResultStep = maxResultStep; } catch (Exception ex) { } var result = (from resultList in taskResultMapList join resultAll in TaskResultCache.getCache().Where(r => r.taskId == taskInfoId && r.taskStep == maxResultStep && r.taskRound == taskRound) on new { resultList.indicatorId, resultList.modelId } equals new { resultAll.indicatorId, resultAll.modelId } into temp from tt in temp.DefaultIfEmpty() select new { attachment = tt == null? resultList.attachment: tt.attachment, resultList.id, resultList.indicatorId, resultList.modelId, supplement = tt == null? resultList.supplement: tt.supplement, taskDateTime = tt == null? resultList.taskDateTime: tt.taskDateTime, resultList.taskExecutor, resultList.taskId, taskRecord = tt == null? resultList.taskRecord: tt.taskRecord, taskRemark = tt == null? resultList.taskRemark: tt.taskRemark, taskResult = tt == null? resultList.taskResult: tt.taskResult, taskRound = taskRound, taskStep = maxResultStep //resultList.taskRecord = tt.taskRecord }).ToList(); var indicatorList = IndicatorCache.getCache(); var brandList = CodeCache.getBrand(); var modelList = CodeCache.getModel(); allResultModelList = (from resultList in result from indicator in indicatorList from brand in brandList from model in modelList where resultList.modelId == model.id && model.parentId == brand.id && resultList.indicatorId == indicator.id select new TaskResultModel { indicatorId = resultList.indicatorId, indicatorName = indicator.indicatorName, indicatorDesc = indicator.indicatorDesc, indicatorInstr = indicator.indicatorInstr, brandId = brand.id, brandName = brand.codeName, modelId = model.id, modelName = model.codeName, taskStep = resultList.taskStep, taskExecutor = resultList.taskExecutor, taskDateTime = resultList.taskDateTime.ToString(), taskRecord = resultList.taskRecord, taskResult = resultList.taskResult, taskResultId = resultList.id, taskRemark = resultList.taskRemark, attachment = resultList.attachment, attachmentCount = (resultList.attachment == string.Empty ? "" : resultList.attachment.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries).Count() + "个") + (resultList.supplement == "" ? "" : "(补)"), supplement = resultList.supplement, isFillFinish = (resultList.taskResult == 0 && resultList.taskRecord == "") ? 0 : 1, isHaveModi = ((resultList.taskResult != 0 || resultList.taskRecord != "" || resultList.taskRemark != "" || resultList.attachment != "" || resultList.supplement != "") ? 1 : 0) }).ToList(); dgv.DataSource = null; pagingPanel.setDetail(allResultModelList.Count); //return allResultModelList.Skip(pageSize * (pageNum - 1)).Take(pageSize).ToList(); dgv.DataSource = allResultModelList.Skip(pageSize * (pageNum - 1)).Take(pageSize).ToList(); setReadOnly(readOnly); }
private async Task getData(IProgress <string> progress) { var taskInfo = TaskCache.getCacheById(taskInfoId); var classInfo = CodeCache.getClass().FirstOrDefault(c => c.id == taskInfo.taskClass); var brandList = CodeCache.getBrand(); //全部品牌 var modelList = CodeCache.getModel(); //全部型号 //获取某任务下某轮次的所有指标测试结果 var currentRoundIndicatorList = TaskResultCache.getCache().Where(r => r.taskId == taskInfoId && r.taskRound == currentRound && r.taskStep == maxTaskStep).ToList(); progress.Report("获取前序轮次全部指标"); await Task.Factory.StartNew(() => { Stopwatch sw = new Stopwatch(); sw.Start(); var childOne = Task.Factory.StartNew(() => { //所有未通过的测试结果 var currentUnIndicatList = currentRoundIndicatorList.Where(r => r.taskResult == 1).ToList(); selectedIndicatorModelList = (from unIndicat in currentUnIndicatList from brand in brandList from model in modelList from indicator in indicatorList from detection in detectionList from subDetection in subDetectionList where unIndicat.modelId == model.id && model.parentId == brand.id && unIndicat.indicatorId == indicator.id && indicator.detectionId == detection.id && indicator.subDetectionId == subDetection.id select new RoundIndicatorModel { classId = indicator.classId, className = (classInfo == null ? "" : classInfo.codeName), //classType.codeName, detectionId = detection.id, detectionName = detection.codeName, indicatorDesc = indicator.indicatorDesc, indicatorInstr = indicator.indicatorInstr, indicatorId = indicator.id, indicatorName = indicator.indicatorName, isObsolete = indicator.isObsolete == 1 ? "已废弃" : "生效中", isSelected = false, subDetectionId = subDetection.id, subDetectionName = subDetection.codeName, modelId = model.id, modelName = model.codeName, brandId = brand.id, brandName = brand.codeName, taskStep = unIndicat.taskStep }).ToList(); progress.Report("指标计算中……"); Debug.WriteLine("one"); }, TaskCreationOptions.AttachedToParent); var childTwo = Task.Factory.StartNew(() => { var currentUnIndicatList = currentRoundIndicatorList.Where(r => r.taskResult == 2).ToList(); unselectedIndicatorModelList = (from unIndicat in currentUnIndicatList from brand in brandList from model in modelList from indicator in indicatorList from detection in detectionList from subDetection in subDetectionList where unIndicat.modelId == model.id && model.parentId == brand.id && unIndicat.indicatorId == indicator.id && indicator.detectionId == detection.id && indicator.subDetectionId == subDetection.id select new RoundIndicatorModel { classId = indicator.classId, className = (classInfo == null ? "" : classInfo.codeName), //classType.codeName, detectionId = detection.id, detectionName = detection.codeName, indicatorDesc = indicator.indicatorDesc, indicatorInstr = indicator.indicatorInstr, indicatorId = indicator.id, indicatorName = indicator.indicatorName, isObsolete = indicator.isObsolete == 1 ? "已废弃" : "生效中", isSelected = false, subDetectionId = subDetection.id, subDetectionName = subDetection.codeName, modelId = model.id, modelName = model.codeName, brandId = brand.id, brandName = brand.codeName }).ToList(); progress.Report("指标计算中……"); Debug.WriteLine("two"); }, TaskCreationOptions.AttachedToParent); sw.Stop(); Debug.WriteLine(sw.ElapsedMilliseconds); progress.Report("指标获取中……"); }); bindDgv(); progressBar.Visible = false; }
private void lbl_showHistory_Click(object sender, EventArgs e) { panel_history.Visible = true; //代码添加button按钮,查看页面布局 List <Tb_taskResult> resultList = TaskResultCache.getCache().Where(t => t.taskId == taskInfoId).ToList(); try { maxRound = resultList.Max(x => x.taskRound); } catch (Exception ex) { } currentRound = 1; currentStep = 1; Point point = new Point(); if (maxRound >= 10) { point.X = 158; point.Y = Btn_nextRound.Location.Y; Btn_nextRound.Location = point; } else { point.X = 148; point.Y = Btn_nextRound.Location.Y; Btn_nextRound.Location = point; } if (maxRound > 0) { lbl_roundText.Text = string.Format("{0}/{1}", currentRound, maxRound); } else { lbl_roundText.Text = string.Format("{0}/{1}", currentRound, 1); } if (currentRound == maxRound || maxRound == 0) { Btn_nextRound.Enabled = false; } else { Btn_nextRound.Enabled = true; } if (currentRound == 1) { Btn_lastRound.Enabled = false; } else { Btn_lastRound.Enabled = true; } //taskRound_BtnColl.AutoSize = true; //this.task maxStep = trp.getHistory();//显示第一轮,并返回总步骤 if (maxStep > 0) { lbl_current.Text = "1/" + maxStep; btn_previous.Enabled = false; if (maxStep > 1) { btn_next.Enabled = true; } else { btn_next.Enabled = false; } } else { lbl_current.Text = "尚无步骤"; btn_next.Enabled = false; btn_previous.Enabled = false; point.X = 350; point.Y = btn_next.Location.Y; btn_next.Location = point; point.X = 388; point.Y = ben_closeHistory.Location.Y; ben_closeHistory.Location = point; } }