public void init(int taskId)
 {
     taskInfo = TaskCache.getCacheById(taskId);
     if (taskInfo == null)
     {
         MessageBoxEx.Show("未能查询到测试任务");
     }
     else
     {
         bindTaskInfo();
     }
 }
Exemplo n.º 2
0
 private void btn_newRound_Click(object sender, EventArgs e)
 {
     if (checkCanDone() == false)
     {
         MessageBoxEx.Show("您尚有未填写的指标测试结果,无法开始下一轮测试。", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     else
     {
         if (maxRound != currentRound)
         {
             MessageBoxEx.Show("请先切换到最新的轮次,并确保其测试结果填写完整", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
             return;
         }
         maxTaskStep = (int)(trp.dgv.Rows[0].Cells["taskStep"].Value);
         TaskNewRoundDefine tnrd = new TaskNewRoundDefine(taskInfoId, maxRound, maxTaskStep);
         tnrd.init();
         tnrd.getTemplateIndicators();
         DialogResult result = tnrd.ShowDialog(this);
         if (result == DialogResult.Yes)
         {
             currentRound++;
             maxRound++;
             ModiRoundText(currentRound);
             trp.init(taskInfoId, false, currentRound);
             if (trp.dgv.Rows.Count > 0)
             {
                 maxTaskStep = (int)(trp.dgv.Rows[0].Cells["taskStep"].Value);//轮次切换后,会进行页面刷新,获取当前轮次页面的最大步骤
             }
             //新增轮次后,task的最新轮次更新,且进度重置为0
             Tb_taskInfo task = TaskCache.getCacheById(taskInfoId);
             if (task != null)
             {
                 task.taskRound = maxRound;
                 task.percent   = 0;
                 TaskCache.addCache(task);
             }
         }
         else
         {
         }
     }
 }
Exemplo n.º 3
0
        private void btn_save_Click(object sender, EventArgs e)
        {
            List <Tb_taskResult> resultList = new List <Db.Entity.Tb_taskResult>();

            //int oldRound = -1;
            if (currentRound != maxRound)
            {
                MessageBoxEx.Show("当前轮次不是最大轮次,无法保存", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            //foreach (DataGridViewRow dr in trp.dgv.Rows)
            //{
            //    if (dr.Cells["taskRecord"].Value == null)
            //    {
            //        dr.Cells["taskRecord"].Value = "";
            //    }
            //    if (dr.Cells["taskRemark"].Value == null)
            //    {
            //        dr.Cells["taskRemark"].Value = "";
            //    }
            //    if (dr.Cells["attachment"].Value == null)
            //    {
            //        dr.Cells["attachment"].Value = "";
            //    }
            //    //如果修改过测试结果,或是测试结果内有内容(无论是否本次输入),都保存
            //    if (dr.Cells["taskResult"].Style.BackColor == Color.LightSeaGreen
            //        || dr.Cells["taskRecord"].Style.BackColor == Color.LightSeaGreen
            //        || dr.Cells["taskRemark"].Style.BackColor == Color.LightSeaGreen
            //        || dr.Cells["attachmentCount"].Style.BackColor == Color.LightSeaGreen
            //        || dr.Cells["taskResult"].Value.ToString() != "0"
            //        || dr.Cells["taskRecord"].Value.ToString() != string.Empty
            //        || dr.Cells["taskRemark"].Value.ToString() != string.Empty
            //        || dr.Cells["attachment"].Value.ToString() != string.Empty)
            //    {
            //        Tb_taskResult result = new Tb_taskResult();
            //        result.indicatorId = (int)dr.Cells["indicatorId"].Value;
            //        result.modelId = (int)dr.Cells["modelId"].Value;
            //        result.taskDateTime = DateTime.Now;
            //        result.taskExecutor = User.currentUser.name;
            //        result.taskId = taskInfoId;
            //        result.taskRecord = dr.Cells["taskRecord"].Value == null ? "" : dr.Cells["taskRecord"].Value.ToString();
            //        result.taskRemark = dr.Cells["taskRemark"].Value.ToString();
            //        result.taskResult = (int)dr.Cells["taskResult"].Value;
            //        result.attachment = dr.Cells["attachment"].Value.ToString();
            //        result.supplement = dr.Cells["supplement"].Value == null ? "" : dr.Cells["supplement"].Value.ToString();
            //        result.taskStep = maxTaskStep + 1;
            //        result.taskRound = currentRound;
            //        //result.taskRound = int.Parse(labelItem2.Text);
            //        resultList.Add(result);

            //        //保存任务之时,判断当前项是否填写完整,如果填写完整,则修改该控件下的isFillFinish值
            //        if (result.taskResult != 0 && result.taskRecord != "")
            //        {
            //            dr.Cells["isFill"].Value = 1;
            //        }
            //    }
            //}
            foreach (var item in trp.allResultModelList)
            {
                if (item.isHaveModi == 1)
                {
                    Tb_taskResult result = new Tb_taskResult();
                    result.indicatorId = item.indicatorId;
                    result.modelId     = item.modelId;
                    DateTime taskDateTime;
                    result.taskDateTime = DateTime.TryParse(item.taskDateTime, out taskDateTime) ? taskDateTime : DateTime.Now;
                    //result.taskDateTime = DateTime.TryParse(dr.Cells["taskDateTime"].Value.ToString(), out taskDateTime) ? taskDateTime : DateTime.Now;//DateTime.Now;
                    result.taskExecutor = User.currentUser.name;
                    result.taskId       = taskInfoId;
                    result.taskRecord   = item.taskRecord;
                    result.taskRemark   = item.taskRemark;
                    result.taskResult   = item.taskResult;
                    result.attachment   = item.attachment;
                    result.supplement   = item.supplement;
                    result.taskStep     = maxTaskStep + 1;
                    result.taskRound    = currentRound;
                    //result.taskRound = int.Parse(labelItem2.Text);
                    resultList.Add(result);

                    if (result.taskResult != 0 && result.taskRecord != "")
                    {
                        item.isFillFinish = 1;
                    }
                }
            }
            if (resultList.Count > 0)
            {
                TaskResultCache.addCache(resultList);                         //添加测试记录
                var taskInfo            = TaskCache.getCacheById(taskInfoId); //更新任务进度字段
                var taskResultMainCount = trp.getAllResultModelCount();
                taskInfo.percent = resultList.Count * 100 / taskResultMainCount;
                TaskCache.addCache(taskInfo);
                //刷新单元格背景色为白色
                foreach (DataGridViewRow dr in trp.dgv.Rows)
                {
                    dr.Cells["taskResult"].Style.BackColor      = Color.White;
                    dr.Cells["taskRecord"].Style.BackColor      = Color.White;
                    dr.Cells["taskRemark"].Style.BackColor      = Color.White;
                    dr.Cells["attachmentCount"].Style.BackColor = Color.White;
                    dr.Cells["taskStep"].Value = int.Parse(dr.Cells["taskStep"].Value.ToString()) + 1;
                }
                MainFormAdapter.reloadTaskMainPanel();
                maxTaskStep++;//最大步骤编号,每次保存,都加1,如果切换轮次,需重新获取该轮次的最大步骤编号
                trp.maxResultStep     = maxTaskStep;
                trp.currentResultStep = maxTaskStep;
            }
        }
Exemplo n.º 4
0
        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;
        }