public void init(int taskId)
 {
     taskInfo = TaskCache.getCacheById(taskId);
     if (taskInfo == null)
     {
         MessageBoxEx.Show("未能查询到测试任务");
     }
     else
     {
         bindTaskInfo();
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// 新增任务,及任务相关的表(任务指标映射表、任务型号映射表、任务生命周期表)
 /// </summary>
 /// <param name="task"></param>
 /// <param name="indicatorIdList"></param>
 public static void createTask(Tb_taskInfo task, List <int> indicatorIdList, Dictionary <int, List <int> > brandModelIdDic)
 {
     try
     {
         TaskAdapter.createTask(task, indicatorIdList, brandModelIdDic);
         list.Add(task);//更新任务信息缓存
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 3
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.º 4
0
        /// <summary>
        /// 保存一次任务处理结果
        /// </summary>
        /// <param name="task"></param>
        //public static void saveTask(Tb_taskInfo task, List<Tb_taskResult> resultList)
        //{
        //    TaskAdapter.saveTask(task,resultList);
        //}

        /// <summary>
        /// 添加任务生命周期,同时更新任务信息中的任务最新状态
        /// </summary>
        /// <param name="taskLifecycle"></param>
        //public static void updateTaskLifecycle(Tb_taskLifecycle taskLifecycle)
        //{
        //    TaskAdapter.updateTaskLifecycle(taskLifecycle);
        //}

        public static void addCache(Tb_taskInfo taskInfo)
        {
            try
            {
                var foundTaskInfo = list.FirstOrDefault(i => i.id == taskInfo.id);
                if (foundTaskInfo == null)
                {
                    BaseAdapter.save(taskInfo);
                    list.Add(taskInfo);
                }
                else
                {
                    BaseAdapter.edit(taskInfo);
                    //IndicatorAdapter.edit(indicator);
                    foundTaskInfo = taskInfo;
                }
            }
            catch (Exception ex)
            {
                MessageBoxEx.Show(ex.Message);
            }
        }
Exemplo n.º 5
0
 /// <summary>
 /// 新增任务,及任务相关的表(任务指标映射表、任务生命周期表)
 /// </summary>
 /// <param name="task"></param>
 /// <param name="indicatorIdList"></param>
 public static void createTask(Tb_taskInfo task, List <int> indicatorIdList, Dictionary <int, List <int> > brandModelIdDic)
 {
     using (EFMySqlDbContext context = new Db.EFMySqlDbContext())
     {
         using (var transaction = context.Database.BeginTransaction())
         {
             try
             {
                 //新增任务信息
                 context.Tb_taskInfos.Add(task);
                 context.SaveChanges();
                 context.Entry(task);
                 int taskId = task.id;
                 //添加任务生命周期
                 Tb_taskLifecycle lifecycle = new Tb_taskLifecycle();
                 lifecycle.taskId                  = taskId;
                 lifecycle.taskStateDateTime       = DateTime.Now;
                 lifecycle.taskStateChangeExecutor = User.currentUser.name;
                 lifecycle.taskState               = (int)TaskStateEnum.Created;
                 lifecycle.remark                  = string.Empty;
                 context.Tb_taskLifecycles.Add(lifecycle);
                 context.SaveChanges();
                 //添加任务型号映射
                 List <Tb_taskModelMap> tmmList = new List <Entity.Tb_taskModelMap>();
                 foreach (int brandId in brandModelIdDic.Keys)
                 {
                     foreach (int modelId in brandModelIdDic[brandId])
                     {
                         Tb_taskModelMap tmm = new Tb_taskModelMap();
                         tmm.taskId  = taskId;
                         tmm.brandId = brandId;
                         tmm.ModelId = modelId;
                         tmmList.Add(tmm);
                     }
                 }
                 context.Tb_taskModelMaps.AddRange(tmmList);
                 context.SaveChanges();
                 //添加任务指标映射
                 List <Tb_taskIndicatorMap> timList = new List <Tb_taskIndicatorMap>();
                 foreach (int indicatorId in indicatorIdList)
                 {
                     Tb_taskIndicatorMap tim = new Tb_taskIndicatorMap();
                     tim.taskId      = taskId;
                     tim.indicatorId = indicatorId;
                     timList.Add(tim);
                 }
                 context.Tb_taskIndicatorMaps.AddRange(timList);
                 context.SaveChanges();
                 //提交数据库
                 transaction.Commit();
                 //更新任务生命周期缓存
                 TaskLifecycleCache.addCacheOnly(lifecycle);
                 //更新品牌型号映射缓存
                 foreach (var tmm in tmmList)
                 {
                     TaskModelMapCache.addCacheOnly(tmm);
                 }
                 //更新指标映射缓存
                 foreach (var tim in timList)
                 {
                     TaskIndicatorMapCache.addCacheOnly(tim);
                 }
             }
             catch (Exception ex)
             {
                 transaction.Rollback();
                 throw ex;
             }
         }
     }
 }