private void bindTaskInfo() { lbl_taskName.Text = taskInfo.taskName; lbl_taskExecutor.Text = taskInfo.taskExecutor; lbl_taskClass.Text = CodeCache.getClass().FirstOrDefault(c => c.id == taskInfo.taskClass).codeName; lbl_taskCode.Text = taskInfo.taskCode; lbl_taskType.Text = CodeCache.getType().FirstOrDefault(c => c.id == taskInfo.taskType).codeName; lbl_brandModel.Text = string.Join(Environment.NewLine, from brandCode in CodeCache.getBrand() from modelCode in CodeCache.getModel() from taskModelMap in TaskModelMapCache.getCache() where taskModelMap.taskId == taskInfo.id && taskModelMap.brandId == brandCode.id && taskModelMap.ModelId == modelCode.id select brandCode.codeName + " " + modelCode.codeName); }
private Tb_code getSelectedModel() { var selectedBrand = getSelectedBrand(); if (selectedBrand != null) { return(CodeCache.getModel().FirstOrDefault(c => c.codeName == ip_model.SelectedItem.ToString() && c.parentId == selectedBrand.id)); } else { return(null); } }
private void btn_save_Click(object sender, EventArgs e) { if (txt_value.Text.Trim() == string.Empty) { MessageBoxEx.Show("名称不能为空,请输入一个名称", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else { switch (codeType) { case CodeTypeEnum.Brand: if (brandCode == null) { brandCode = new Tb_code(); brandCode.id = CodeCache.getBrand().Count == 0 ? 1000 : CodeCache.getBrand().Max(c => c.id) + 1;//品牌默认从1000开始 brandCode.codeType = (int)CodeTypeEnum.Brand; brandCode.parentId = classCode.id; } brandCode.codeName = txt_value.Text.Trim(); CodeCache.addCache(brandCode); break; case CodeTypeEnum.Model: if (modelCode == null) { modelCode = new Tb_code(); modelCode.id = CodeCache.getModel().Count == 0 ? 2000 : CodeCache.getModel().Max(c => c.id) + 1;//型号从2000开始 modelCode.codeType = (int)CodeTypeEnum.Model; modelCode.parentId = brandCode.id; } modelCode.codeName = txt_value.Text.Trim(); CodeCache.addCache(modelCode); break; case CodeTypeEnum.Class: if (classCode == null) { classCode = new Db.Entity.Tb_code(); classCode.id = CodeCache.getClass().Count == 0 ? 3000 : CodeCache.getClass().Max(c => c.id) + 1;//分类默认从3000开始 classCode.codeType = (int)CodeTypeEnum.Class; } classCode.codeName = txt_value.Text.Trim(); CodeCache.addCache(classCode); break; default: break; } this.Close(); } }
private void loadModel() { if (ip_brand.SelectedItems.Count > 0) { var selectedBrand = getSelectedBrand(); ip_model.Items.Clear(); if (selectedBrand != null) { var modelList = CodeCache.getModel().Where(c => c.parentId == selectedBrand.id); foreach (var modelItem in modelList) { ip_model.Items.Add(modelItem.codeName); } } } }
public void initTree() { var brands = CodeCache.getBrand().Where(c => c.parentId == classId); foreach (var brand in brands) { DevComponents.AdvTree.Node node = new DevComponents.AdvTree.Node(); node.Text = brand.id.ToString(); CheckBoxItem cbi = new CheckBoxItem() { Text = brand.codeName }; cbi.CheckedChanged += Cbi_CheckedChanged; if (selectedDic.ContainsKey(brand.id)) { cbi.Checked = true; } node.HostedItem = cbi; var models = CodeCache.getModel().Where(c => c.parentId == brand.id); if (models.Count() == 0) { cbi.Enabled = false; } tree.Nodes.Add(node); foreach (var model in models) { DevComponents.AdvTree.Node subNode = new DevComponents.AdvTree.Node(); subNode.Text = model.id.ToString(); CheckBoxItem subCbi = new CheckBoxItem() { Text = model.codeName }; if (selectedDic.ContainsKey(brand.id)) { if (selectedDic[brand.id].Contains(model.id)) { subCbi.Checked = true; } } subNode.HostedItem = subCbi; node.Nodes.Add(subNode); } } tree.ExpandAll(); }
public void init(int[] taskStateArray, TaskGridShownStyle style) { this._taskStateArray = taskStateArray; this._style = style; var classList = CodeCache.getClass(); var brandList = CodeCache.getBrand(); var modelList = CodeCache.getModel(); var taskList = TaskCache.getCache(); var tasklifecycleList = TaskLifecycleCache.getCache(); var taskModelMapList = TaskModelMapCache.getCache(); taskModelAllList = (from task in taskList from classCode in classList from tasklifecycle in tasklifecycleList //from brandCode in brandList //from taskModelMap in taskModelMapList //where (taskStateArray == (int)TaskStateEnum.Completed ? // (task.taskState == taskStateArray || task.taskState == (int)TaskStateEnum.Rejected || task.taskState == (int)TaskStateEnum.Closed) // : (task.taskState == taskStateArray))//如果是展示已完成任务,则需要附带已关闭、已驳回的任务 where taskStateArray.Contains(task.taskState) && task.taskClass == classCode.id //&& taskModelMap.taskId == task.id && taskModelMap.brandId == brandCode.id //todo 跟当前用户相关 && task.id == tasklifecycle.taskId && tasklifecycle.taskState == 5001 && (task.taskExecutor.Contains(User.currentUser.name) || tasklifecycle.taskStateChangeExecutor == User.currentUser.name) //当前用户创建或测试人包含当前用户 orderby task.createTime descending select new TaskModel { taskId = task.id, taskName = task.taskName, taskStateId = task.taskState, taskStateName = taskStateDic[task.taskState], taskBrandModelName = string.Join(Environment.NewLine, from brandCode in brandList from modelCode in modelList from taskModelMap in taskModelMapList where taskModelMap.taskId == task.id && taskModelMap.brandId == brandCode.id && taskModelMap.ModelId == modelCode.id select brandCode.codeName + " " + modelCode.codeName), taskClassName = classCode.codeName, taskStartTime = task.createTime, taskCode = task.taskCode, percent = task.percent, taskRound = task.taskRound }).ToList(); doQuery(new TaskQueryItem()); showStyle(style); }
private void showBrandModelText() { List <string> brandModelTextList = new List <string>(); foreach (int brandId in brandModelIdDic.Keys) { var brand = CodeCache.getBrand().FirstOrDefault(c => c.id == brandId); if (brand != null) { foreach (int modelId in brandModelIdDic[brandId]) { var model = CodeCache.getModel().FirstOrDefault(c => c.id == modelId); if (model != null) { brandModelTextList.Add(brand.codeName + " " + model.codeName); } } } } lbl_brandModel.Text = string.Join(Environment.NewLine, brandModelTextList); if (brandModelIdDic.Keys.Count == 0) { lbl_taskType.Text = ""; } else if (brandModelIdDic.Keys.Count == 1) { lbl_taskType.Text = "单品牌测试"; taskType = 4001; } else { lbl_taskType.Text = "多品牌测试"; taskType = 4002; } }
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 List <TaskResultModel> GetReportInfo(int step, int round) { var taskIndicatorMapList = TaskIndicatorMapCache.getCache().Where(i => i.taskId == taskInfoId).ToList(); var indicatorList = IndicatorCache.getCache(); var brandList = CodeCache.getBrand(); var modelList = CodeCache.getModel(); var taskModelList = TaskModelMapCache.getCache(); 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 == taskInfoId && taskModel.taskId == taskInfoId && 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(); var 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 }).ToList(); return(allResultModelList); }