示例#1
0
        private void CreateBuildRow(QaReportDataRow row)
        {
            // 增加单元测试结果行
            for (int j = 0; j < GroupNames.Length; j++)
            {
                // 取各小组的扫描数据
                GroupDailySummary2 summary = this.TodaySummary.FirstOrDefault(x => x.GroupName == GroupNames[j]);

                if (summary != null)
                {
                    // 早期没有数据,或者没有启用编译任务
                    if (summary.Data.BuildIsOK.HasValue == false)
                    {
                        row.Cells[j] = new QaReportDataCell("--", "#999");
                    }

                    else if (summary.Data.BuildIsOK.Value)
                    {
                        row.Cells[j] = new QaReportDataCell("PASS", "green");
                    }

                    // 编译失败
                    else
                    {
                        row.Cells[j] = new QaReportDataCell("ERROR", "red");
                    }
                }
                else
                {
                    // 未知场景,也按没有采集数据来处理
                    row.Cells[j] = new QaReportDataCell("--", "#999");
                }
            }
        }
        /// <summary>
        /// 重新计算某一天的小组日汇总数据
        /// URL: /ajax/scan/Admin/RefreshDailySummary.ppx?day=2016-04-28
        /// </summary>
        /// <param name="day"></param>
        /// <returns></returns>
        public string RefreshDailySummary(DateTime day)
        {
            List <GroupDailySummary2> list = new List <GroupDailySummary2>();

            foreach (JobOption job in JobManager.Jobs)
            {
                // 计算当天的汇总数据
                TotalResult data = ScanResultCache.LoadTotalResult(job.Id, day, true);

                GroupDailySummary2 summary = new GroupDailySummary2();
                summary.GroupName = job.Name;
                summary.Data      = ToSummary2(data);
                list.Add(summary);
            }

            string filename = GetDataFileName(day);

            string savepath = Path.GetDirectoryName(filename);

            if (Directory.Exists(savepath) == false)
            {
                Directory.CreateDirectory(savepath);
            }


            string json = list.ToJson();

            File.WriteAllText(filename, json);

            return(json);
        }
示例#3
0
        private void CreateCodeCoverRow(QaReportDataRow row)
        {
            // 增加单元测试结果行
            for (int j = 0; j < GroupNames.Length; j++)
            {
                // 取各小组的扫描数据
                GroupDailySummary2 summary = this.TodaySummary.FirstOrDefault(x => x.GroupName == GroupNames[j]);

                if (summary != null)
                {
                    string text = summary.Data.CodeCover.ToString() + "%";

                    // 单元测试如果执行失败,就以 -1 表示
                    if (summary.Data.CodeCover < 0)
                    {
                        row.Cells[j] = new QaReportDataCell("ERROR", "red");
                    }

                    else if (summary.Data.CodeCover == 0)
                    {
                        if (_isExistUnitTestData)
                        {
                            row.Cells[j] = new QaReportDataCell("0", "red");
                        }
                        else
                        {
                            // 老数据中,没有采集单元数据,需要特殊处理
                            row.Cells[j] = new QaReportDataCell("--", "#999");
                        }
                    }


                    else if (summary.Data.CodeCover < 60)
                    {
                        row.Cells[j] = new QaReportDataCell(text, "red");
                    }

                    else if (summary.Data.CodeCover >= 80)
                    {
                        row.Cells[j] = new QaReportDataCell(text, "green");
                    }

                    else
                    {
                        row.Cells[j] = new QaReportDataCell(text, null);
                    }
                }
                else
                {
                    // 未知场景,也按没有采集数据来处理
                    row.Cells[j] = new QaReportDataCell("--", "#999");
                }
            }
        }
示例#4
0
        private void CreateUnitTestRow(QaReportDataRow row)
        {
            // 增加单元测试结果行
            for (int j = 0; j < GroupNames.Length; j++)
            {
                // 取各小组的扫描数据
                GroupDailySummary2 summary = this.TodaySummary.FirstOrDefault(x => x.GroupName == GroupNames[j]);

                if (summary != null)
                {
                    string text = $"{summary.Data.UnitTestPassed}/{summary.Data.UnitTestTotal}";

                    // 单元测试如果执行失败,就以 -1 表示
                    if (summary.Data.UnitTestTotal < 0)
                    {
                        row.Cells[j] = new QaReportDataCell("ERROR", "red");
                    }

                    else if (summary.Data.UnitTestTotal == 0)
                    {
                        if (_isExistUnitTestData)
                        {
                            row.Cells[j] = new QaReportDataCell("0", "red");
                        }
                        else
                        {
                            // 老数据中,没有采集单元数据,需要特殊处理
                            row.Cells[j] = new QaReportDataCell("--", "#999");
                        }
                    }

                    else
                    {
                        if (summary.Data.UnitTestPassed == summary.Data.UnitTestTotal)
                        {
                            row.Cells[j] = new QaReportDataCell(text, "green");
                        }

                        else                         // 如果单元测试不能 100% 通过,就用红字显示
                        {
                            row.Cells[j] = new QaReportDataCell(text, "red");
                        }
                    }
                }
                else
                {
                    // 未知场景,也按没有采集数据来处理
                    row.Cells[j] = new QaReportDataCell("--", "#999");
                }
            }
        }
示例#5
0
        private QaReportDataCell CreateCell(string scanKind, string groupName)
        {
            string       propertyName = s_propertyDict[scanKind];
            PropertyInfo property     = typeof(TotalSummary2).GetProperty(propertyName, BindingFlags.Instance | BindingFlags.Public);


            GroupDailySummary2 todaySummary = this.TodaySummary.Find(x => x.GroupName == groupName);
            int todayValue = todaySummary?.Data != null ? (int)property.GetValue(todaySummary.Data, null) : 0;


            GroupDailySummary2 lastdaySummary = this.LastdaySummary.Find(x => x.GroupName == groupName);

            int lastdayValue = lastdaySummary?.Data != null ? (int)property.GetValue(lastdaySummary.Data, null) : 0;

            return(new QaReportDataCell(todayValue, lastdayValue));
        }
示例#6
0
        private QaReportDataCell CreateTotalCell(string groupName)
        {
            GroupDailySummary2 todaySummary = this.TodaySummary.Find(x => x.GroupName == groupName);
            int todayValue = 0;

            if (todaySummary?.Data != null)
            {
                todayValue = todaySummary.Data.BaseTotal;
            }

            GroupDailySummary2 lastdaySummary = this.LastdaySummary.Find(x => x.GroupName == groupName);
            int lastdayValue = 0;

            if (lastdaySummary?.Data != null)
            {
                lastdayValue = lastdaySummary.Data.BaseTotal;
            }

            return(new QaReportDataCell(todayValue, lastdayValue));
        }
示例#7
0
        public object GetKindTotal(string flag, string kind)
        {
            if (string.IsNullOrEmpty(kind))
            {
                kind = "BaseTotal";
            }

            // 1、根据参数名找到对应的属性,后续将读取这个属性的值
            PropertyInfo p = typeof(TotalSummary2).GetProperty(kind, BindingFlags.Instance | BindingFlags.Public);

            if (p == null)
            {
                throw new ArgumentException($"kind参数值 {kind} 不是有效的属性名称。");
            }


            // 2、确定开始和结束日期
            DateTime start, end;

            GetDateRnage(flag, out start, out end);

            // 保存有效的日期值(有数据文件)
            List <string> dayList = new List <string>();

            HighchartsDataSeries[] series = (from b in JobManager.Jobs
                                             let h = new HighchartsDataSeries {
                Name = b.Name,
                Data = new List <int>()
            }
                                             select h).ToArray();

            // 3、加载日期范围内的数据
            DailySummaryHelper helper = new DailySummaryHelper();

            for ( ; start <= end; start = start.AddDays(1))
            {
                // 加载每一天的汇总数据
                List <GroupDailySummary2> data = helper.LoadData(start);
                if (data == null)
                {
                    continue;
                }

                // 将日期保存下来,做为X轴
                dayList.Add(start.ToDateString());

                // 根据小组来循环匹配数据(填充每行的数据)
                foreach (var s in series)
                {
                    GroupDailySummary2 group = data.FirstOrDefault(x => x.GroupName == s.Name);
                    if (group != null)
                    {
                        int value = (int)p.GetValue(group.Data);
                        s.Data.Add(value);
                    }
                    else
                    {
                        s.Data.Add(0);                          // 没有找到就用【零】来填充
                    }
                }
            }


            // 4、构造Highcharts控件所需要的数据对象
            return(new {
                chart = new { type = "line" },
                title = new { text = "代码扫描问题趋势分析表" },
                xAxis = new {
                    categories = (from x in dayList let s = x.Substring(5) select s).ToArray()
                },
                yAxis = new {
                    title = new { text = "基础问题小计数量" }
                },
                series = series
            });
        }