Esempio n. 1
0
        /// <summary>
        /// 从缓存层获取指标
        /// </summary>
        private void getIndicator()
        {
            indicatorList    = IndicatorCache.getCache();
            classList        = CodeCache.getClass();
            detectionList    = CodeCache.getDetection();
            subDetectionList = CodeCache.getSubDetection();
            indicatorModels  = (from indicator in indicatorList
                                from classType in classList
                                from detection in detectionList
                                from subDetection in subDetectionList
                                where indicator.classId == classType.id && indicator.detectionId == detection.id && indicator.subDetectionId == subDetection.id
                                select new IndicatorModel()
            {
                indicatorId = indicator.id,
                classId = indicator.classId,
                className = classType.codeName,
                detectionId = indicator.detectionId,
                detectionName = detection.codeName,
                subDetectionId = indicator.subDetectionId,
                subDetectionName = subDetection.codeName,
                indicatorName = indicator.indicatorName,
                indicatorDesc = indicator.indicatorDesc,
                indicatorInstr = indicator.indicatorInstr,
                isObsolete = indicator.isObsolete == 1 ? "已废弃" : "生效中"
            }).ToList();

            pagingPanel.setDetail(indicatorModels.Count);
            dgv_indicator.DataSource = indicatorModels.Skip(pageSize * (pageNum - 1)).Take(pageSize).ToList();
        }
Esempio n. 2
0
 public void Setup(InprocDebugger debugger)
 {
     _debugger  = debugger;
     _codeCache = debugger.CodeCache;
     this.CalculateSize();
     this.Invalidate();
 }
Esempio n. 3
0
 private void getAllList()
 {
     indicatorList    = IndicatorCache.getCache();
     classList        = CodeCache.getClass();
     detectionList    = CodeCache.getDetection();
     subDetectionList = CodeCache.getSubDetection();
 }
Esempio n. 4
0
        private void bindCbb()
        {
            List <Tb_code> classes = CodeCache.getClass();

            cbb_class.DataSource    = classes;
            cbb_class.DisplayMember = "codeName";
            cbb_class.ValueMember   = "id";
        }
        private void loadClass()
        {
            var classList = CodeCache.getClass().OrderBy(c => c.id);

            ip_class.Items.Clear();
            foreach (var classItem in classList)
            {
                ip_class.Items.Add(classItem.codeName);
            }
        }
        //protected override CreateParams CreateParams
        //{
        //    get
        //    {
        //        var parms = base.CreateParams;
        //        parms.Style &= ~0x02000000; // Turn off WS_CLIPCHILDREN
        //        return parms;
        //    }
        //}
        public TaskQueryPanel()
        {
            InitializeComponent();
            var taskStateList = CodeCache.getState();

            cbb_taskState.DisplayMember = "codeName";
            cbb_taskState.ValueMember   = "id";
            cbb_taskState.DataSource    = taskStateList;
            cbb_taskState.SelectedItem  = null;
        }
 private Tb_code getSelectedClass()
 {
     if (ip_class.SelectedItem != null)
     {
         return(CodeCache.getClass().FirstOrDefault(c => c.codeName == ip_class.SelectedItem.ToString()));
     }
     else
     {
         return(null);
     }
 }
Esempio n. 8
0
 private void cbb_class_SelectedIndexChanged(object sender, EventArgs e)
 {
     cbb_detection.DataSource = null;
     if (cbb_class.DataSource != null)
     {
         List <Tb_code> detections = CodeCache.getDetection().Where(c => c.parentId == ((Tb_code)cbb_class.SelectedItem).id).ToList();
         cbb_detection.DataSource    = detections;
         cbb_detection.DisplayMember = "codeName";
         cbb_detection.ValueMember   = "id";
     }
 }
 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();
            }
        }
Esempio n. 12
0
        public InprocDebugger(Host host)
        {
            this.Host      = host;
            this.DebugHost = host.Debugger;
            this.Window    = new DebuggerWindow(this);
            this.Tools     = new List <DebuggerTool>();

            this.State       = DebuggerState.Idle;
            this.Breakpoints = new BreakpointManager(this);
            this.CodeCache   = new CodeCache(this);
            this.UserData    = new UserDataStore();

            this.SetupNavigation();

            // Initialize tools...
            // ...
            this.CallstackTool = new CallstackTool(this);
            this.Tools.Add(this.CallstackTool);
            this.CodeTool = new CodeTool(this);
            this.Tools.Add(this.CodeTool);
            this.LogTool = new LogTool(this);
            this.Tools.Add(this.LogTool);
            this.MemoryTool = new MemoryTool(this);
            this.Tools.Add(this.MemoryTool);
            this.StatisticsTool = new StatisticsTool(this);
            this.Tools.Add(this.StatisticsTool);
            this.ThreadsTool = new ThreadsTool(this);
            this.Tools.Add(this.ThreadsTool);
            // ...

            this.Window.Show();

            this.CodeTool.Show(this.Window.DockPanel);
            this.LogTool.Show(this.Window.DockPanel);
            this.ThreadsTool.Show(this.Window.DockPanel);

            WeifenLuo.WinFormsUI.Docking.DockPane dp;
            dp = this.Window.DockPanel.DockPaneFactory.CreateDockPane(this.CodeTool, WeifenLuo.WinFormsUI.Docking.DockState.Document, true);
            this.StatisticsTool.Show(dp, WeifenLuo.WinFormsUI.Docking.DockAlignment.Right, 0.45);
            dp = this.Window.DockPanel.DockPaneFactory.CreateDockPane(this.LogTool, WeifenLuo.WinFormsUI.Docking.DockState.DockBottom, true);
            this.CallstackTool.Show(dp, WeifenLuo.WinFormsUI.Docking.DockAlignment.Right, 0.24);

            this.MemoryTool.Show(this.StatisticsTool.DockHandler.Pane, this.StatisticsTool);

            this.Host.Debugger.Activate(this, Environment.MachineName, Environment.UserName, "InprocDebugger 1.0");

            foreach (DebuggerTool tool in this.Tools)
            {
                tool.OnAttached();
            }
        }
 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);
             }
         }
     }
 }
 private void loadBrand()
 {
     if (ip_class.SelectedItems.Count > 0)
     {
         var selectedClass = getSelectedClass();
         ip_brand.Items.Clear();
         if (selectedClass != null)
         {
             var brandList = CodeCache.getBrand().Where(c => c.parentId == selectedClass.id);
             foreach (var brandItem in brandList)
             {
                 ip_brand.Items.Add(brandItem.codeName);
             }
         }
     }
 }
Esempio n. 15
0
        public void init()
        {
            its.init();
            cbb_taskClass.SelectedValueChanged -= cbb_taskClass_SelectedValueChanged;
            cbb_taskClass.DisplayMember         = "codeName";
            cbb_taskClass.ValueMember           = "id";
            cbb_taskClass.DataSource            = CodeCache.getClass();
            cbb_taskClass.SelectedValueChanged += cbb_taskClass_SelectedValueChanged;

            foreach (User user in User.list)
            {
                ccb_taskExecutor.Items.Add(user);
            }
            ccb_taskExecutor.ValueMember   = "id";
            ccb_taskExecutor.DisplayMember = "name";
        }
        private void InitChartDataSource()
        {
            List <string> xAxis = new List <string>();
            List <int>    yAxis = new List <int>();

            #region  面图表的绑定数据源代码
            List <queryDateResult> queryList = CountChartAdapter.selectEveryMonthTaskNum();
            chartMonthCountTask.Series.Clear();
            chartMonthCountTask.Series.Add("月");
            chartMonthCountTask.Series["月"].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Column;
            foreach (var item in queryList)
            {
                xAxis.Add(item.dateNum);
                yAxis.Add(item.number);
            }
            chartMonthCountTask.Series["月"].Points.DataBindXY(xAxis, yAxis);
            chartMonthCountTask.Series["月"].IsValueShownAsLabel = true;
            string title = "近6个月的任务数量情况";
            chartMonthCountTask.Titles.Add(title);
            chartMonthCountTask.Titles[0].Docking = System.Windows.Forms.DataVisualization.Charting.Docking.Top;
            #endregion
            #region  面图表的绑定数据源代码
            xAxis.Clear();
            yAxis.Clear();
            List <queryClassifyResult> clsssifyList = CountChartAdapter.selectClassifyNum();
            chartClassify.Series.Clear();
            chartClassify.Series.Add("测试分类");
            chartClassify.Series["测试分类"].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Column;
            foreach (var item in clsssifyList)
            {
                List <Db.Entity.Tb_code> codeList = CodeCache.getCache().Where(x => x.id == int.Parse(item.taskClass)).ToList();
                if (codeList != null)
                {
                    xAxis.Add(codeList[0].codeName);
                }
                yAxis.Add(item.number);
                //xAxis.Add()
                //xAxis.Add(item.dateNum);
                //yAxis.Add(item.number);
            }
            chartClassify.Series["测试分类"].Points.DataBindXY(xAxis, yAxis);
            chartClassify.Series["测试分类"].IsValueShownAsLabel = true;
            string classTitle = "测试分类的任务数量情况";
            chartClassify.Titles.Add(classTitle);
            chartClassify.Titles[0].Docking = System.Windows.Forms.DataVisualization.Charting.Docking.Top;
            #endregion
        }
        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);
        }
Esempio n. 19
0
        private void bindCheckBox()
        {
            var classList = CodeCache.getClass();

            //foreach (var classItem in classList)
            //{
            //    CheckBox chk = new CheckBox();
            //    chk.Name = classItem.codeName;
            //    chk.Text = classItem.codeName;
            //    chk.Tag = classItem.id;
            //    chk.Checked = true;
            //    chk.CheckedChanged += chk_valueChange;
            //    tlp.Controls.Add(chk);
            //}
            cbb_class.ValueMember      = "id";
            cbb_class.DisplayMember    = "codeName";
            cbb_class.DataSource       = classList;
            cbb_Obsolete.SelectedIndex = 0;
        }
Esempio n. 20
0
        private void buildTree()
        {
            var classList        = CodeCache.getClass();
            var detectionList    = CodeCache.getDetection();
            var subDetectionList = CodeCache.getSubDetection();

            foreach (Tb_code classItem in classList)
            {
                var classNode = addNode(rootNode, classItem);
                foreach (Tb_code detectionItem in detectionList.Where(c => c.parentId == classItem.id))
                {
                    var detectionNode = addNode(classNode, detectionItem);
                    foreach (Tb_code subDetectionItem in subDetectionList.Where(c => c.parentId == detectionItem.id))
                    {
                        addNode(detectionNode, subDetectionItem);
                    }
                }
            }
        }
        public void init(int taskInfoId)
        {
            var taskLifeList  = TaskLifecycleCache.getCache().Where(t => t.taskId == taskInfoId).OrderBy(t => t.taskState).ToList();
            var taskStateList = CodeCache.getState();
            var tempList      = from life in taskLifeList
                                from state in taskStateList
                                where life.taskState == state.id
                                select new
            {
                life,
                state
            };
            List <String> textList = new List <string>();

            foreach (var taskLife in tempList)
            {
                textList.Add(taskLife.life.taskStateDateTime + "                  状态:" + taskLife.state.codeName + "                  操作人:" + taskLife.life.taskStateChangeExecutor + "                  备注:" + taskLife.life.remark);
            }
            lbl_taskLifecycle.Text = string.Join(Environment.NewLine, textList);
        }
Esempio n. 22
0
        public virtual async Task <CheckVerificationCodeResultDto> CheckVerificationCodeAsync(CheckVerificationCodeInputDto input)
        {
            var user = await UserManager.FindByEmailAsync(input.EmailAddress);

            if (user == null)
            {
                throw new UserFriendlyException(L["InvalidEmail"]);
            }
            var cacheItem = await CodeCache.GetAsync(user.Id);

            if (cacheItem == null)
            {
                throw new UserFriendlyException(L["InvalidVerification"]);
            }
            if (cacheItem.Code != input.Code)
            {
                throw new UserFriendlyException(L["InvalidVerification"]);
            }
            await CodeCache.RemoveAsync(user.Id);

            return(new CheckVerificationCodeResultDto(input.EmailAddress, await UserManager.GeneratePasswordResetTokenAsync(user)));
        }
Esempio n. 23
0
 private void traversalNode(Node pNode)
 {
     if (pNode.HasChildNodes)
     {
         foreach (Node node in pNode.Nodes)
         {
             if (node.Style != null)
             {
                 if (node.Style.BackColor == Color.LawnGreen)//修改过的node
                 {
                     var tb_code = node.Tag as Tb_code;
                     tb_code.codeName = node.Text;
                     CodeCache.addCache(tb_code);
                     node.Style = null;
                 }
                 if (node.Style.BackColor == Color.Red)//新增的node
                 {
                     Tb_code tb_code = new Tb_code();
                     tb_code.codeName = node.Text;
                     if (node.Level == 2)//检测内容
                     {
                         tb_code.codeType = 6;
                         tb_code.id       = CodeCache.getDetection().Count == 0 ? 6000 : CodeCache.getDetection().Max(c => c.id) + 1; //检测内容从6000开始
                     }
                     if (node.Level == 3)                                                                                             //检测分项
                     {
                         tb_code.codeType = 7;
                         tb_code.id       = CodeCache.getSubDetection().Count == 0 ? 7000 : CodeCache.getSubDetection().Max(c => c.id) + 1;//检测分项从7000开始
                     }
                     tb_code.parentId = (node.Parent.Tag as Tb_code).id;
                     CodeCache.addCache(tb_code);
                     node.Style = null;
                     node.Tag   = tb_code;//将code赋给tag,以便在新增node的新增子node中,可以找到parentId
                 }
             }
             traversalNode(node);
         }
     }
 }
Esempio n. 24
0
        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;
            }
        }
Esempio n. 25
0
        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);
        }
Esempio n. 26
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;
        }
Esempio n. 27
0
        public virtual async Task <SendVerificationCodeResult> SendVerificationCodeAsync(SendVerificationCodeDto input)
        {
            var user = await UserManager.FindByEmailAsync(input.EmailAddress);

            if (user == null)
            {
                return(new SendVerificationCodeResult(SendVerificationCodeResultType.InvalidEmail));
            }
            var localizer = ServiceProvider.GetRequiredService(
                typeof(IStringLocalizer <>).MakeGenericType(LocalizationOptions.DefaultResourceType)
                ) as IStringLocalizer;

            var companyName = localizer == null ? "" : localizer["AppName"];
            var userName    = user.Name ?? user.UserName;
            var rnd         = new Random((int)DateTime.Now.Ticks);
            var code        = rnd.Next(100000, 999999);

            var cacheItem = await CodeCache.GetOrAddAsync(user.Id,
                                                          () => Task.FromResult(new VerificationCodeCacheItem(0, code.ToString())),
                                                          () => new DistributedCacheEntryOptions
            {
                AbsoluteExpiration = DateTimeOffset.Now.AddHours(1)
            });

            if (cacheItem.Count >= 5)
            {
                cacheItem.Code = "";
                await CodeCache.SetAsync(user.Id, cacheItem, new DistributedCacheEntryOptions()
                {
                    AbsoluteExpiration = DateTimeOffset.Now.AddHours(24)
                });

                return(new SendVerificationCodeResult(SendVerificationCodeResultType.MaxCount));
            }

            cacheItem.Code   = code.ToString();
            cacheItem.Count += 1;
            await CodeCache.SetAsync(user.Id, cacheItem, new DistributedCacheEntryOptions()
            {
                AbsoluteExpiration = DateTimeOffset.Now.AddHours(1)
            });

            var subject = string.Format(L["VerificationCodeMailSubject"], userName);
            var body    =
                await PasswordResetTemplateService.RunAsync(new PasswordResetModel(companyName, userName,
                                                                                   code.ToString()));

            try
            {
                await EmailSender.SendAsync(user.Email, subject, body);

                return(new SendVerificationCodeResult(SendVerificationCodeResultType.Success));
            }
            catch (Exception e)
            {
                Logger.LogDebug(e.Message, e);
                Logger.LogDebug(e.StackTrace, e);
                Logger.LogInformation($"Error mail message:{user.Email},{subject},{ body}");
                return(new SendVerificationCodeResult(SendVerificationCodeResultType.Error));
            }
        }
        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);
        }