コード例 #1
0
 private void btn_save_Click(object sender, EventArgs e)
 {
     try
     {
         int        templateId = (int)cbb_exitsTemplate.SelectedValue;
         List <int> selectedIndicatorIdList = selectedIndicatorModelList.Select(i => i.indicatorId).ToList();
         IndicatorTemplateMapCache.addCache(templateId, selectedIndicatorIdList);
         MessageBoxEx.Show("保存成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     catch (Exception ex)
     {
         MessageBoxEx.Show("保存失败。" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
コード例 #2
0
        private async Task getData(int templateId, string className, IProgress <string> progress)
        {
            //获取某分类下所有指标
            var anyClassIndicatorList = IndicatorCache.getCache().Where(i => i.classId == cbb_classId);

            progress.Report("获取全部指标");
            //获取所选模板的已选指标
            var selectedIndicatorList = IndicatorTemplateMapCache.getCache().Where(i => i.templateId == templateId);

            progress.Report("获取已选指标");
            await Task.Factory.StartNew(() =>
            {
                Stopwatch sw = new Stopwatch();
                sw.Start();
                var childOne = Task.Factory.StartNew(() =>
                {
                    //生成已选指标model对象列表
                    selectedIndicatorModelList = (from indicatorMap in selectedIndicatorList
                                                  from indicator in anyClassIndicatorList
                                                  //from classType in classList
                                                  from detection in detectionList
                                                  from subDetection in subDetectionList
                                                  where indicatorMap.indicatorId == indicator.id &&// && indicator.classId == classType.id
                                                  indicator.detectionId == detection.id && indicator.subDetectionId == subDetection.id
                                                  select new IndicatorForTemplateModel()
                    {
                        classId = indicator.classId,
                        className = className,                              //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,
                    }).ToList();
                    progress.Report("指标计算中……");
                    Debug.WriteLine("one");
                }, TaskCreationOptions.AttachedToParent);
                var childTwo = Task.Factory.StartNew(() =>
                {
                    //已选指标id列表
                    var selectedIndicatorIdList = selectedIndicatorList.Select(i => i.indicatorId).ToList();
                    //计算出所选模板的待选指标
                    var unselectIndicatorList = anyClassIndicatorList.Where(ii => selectedIndicatorIdList.Contains(ii.id) == false).ToList();
                    //unselectedIndicatorModelList = anyClassIndicatorList.AsEnumerable<Tb_indicator>().Except<Tb_indicator>(selectedIndicatorModelList);
                    unselectedIndicatorModelList = (from unselectedIndicator in unselectIndicatorList
                                                    from indicator in anyClassIndicatorList
                                                    //from classType in classList
                                                    from detection in detectionList
                                                    from subDetection in subDetectionList
                                                    where unselectedIndicator.id == indicator.id && //&& indicator.classId == classType.id
                                                    indicator.detectionId == detection.id && indicator.subDetectionId == subDetection.id
                                                    select new IndicatorForTemplateModel()
                    {
                        classId = indicator.classId,
                        className = className,                                // 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,
                    }).ToList();
                    progress.Report("指标计算中……");
                    Debug.WriteLine("two");
                }, TaskCreationOptions.AttachedToParent);
                sw.Stop();
                Debug.WriteLine(sw.ElapsedMilliseconds);
                progress.Report("指标获取中……");
            });

            bindDgv();
            progressBar.Visible       = false;
            cbb_exitsTemplate.Enabled = true;
        }