public string RefreshDailySummary(DateTime day) { DailySummaryHelper helper = new DailySummaryHelper(); return(helper.RefreshDailySummary(day)); }
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 }); }
public string RefreshAllDailySummary() { DailySummaryHelper helper = new DailySummaryHelper(); return(helper.RefreshAllDailySummary()); }
public string UploadResult(string base64, int branchId) { string authkey = ConfigurationManager.AppSettings["authentication-key"]; if (this.GetHeader("authentication-key") != authkey) { return("authentication-key is invalid."); } string appVersion = this.GetHeader("app-version"); if (appVersion != SpecChecker.CoreLibrary.Config.JobManager.AppVersion) { return("客户端版本不匹配。"); } // 为了防止提交的数据过大,所以采用压缩的方式提交数据(大约可压缩10倍), // 为了方便调试,将压缩后的数据以BASE64方式传输 string json = CompressHelper.GzipDecompress(base64); TotalResult result = json.FromJson <TotalResult>(); // 设置问题分类 result.SetIssueCategory(); json = result.ToJson(); // 上面的调用会修改数据,所以重新生成JSON DateTime today = DateTime.Today; string filename = ScanResultCache.GetTotalResultFilePath(branchId, today); string uploadPath = Path.GetDirectoryName(filename); if (Directory.Exists(uploadPath) == false) { Directory.CreateDirectory(uploadPath); } // JSON文本的体积小,序列化/反序列化更快,而且特殊字符的支持更好,所以这里使用JSON,不再使用XML //XmlHelper.XmlSerializeToFile(result, filename, Encoding.UTF8); //File.WriteAllText(filename, json, Encoding.UTF8); SpecChecker.CoreLibrary.Common.ZipHelper.CreateZipFileFromText(filename, json); // 刷新小组汇总数据 // 这个任务只能放在服务端完成,因为客户端没有完整的数据 DailySummaryHelper helper = new DailySummaryHelper(); helper.RefreshDailySummary(today); // 清除缓存 ScanResultCache.RemoveCache(branchId, today); //// 发送通知邮件 //Uri requestUri = this.HttpContext.Request.Url; //SendEmailHelper.Send(today, branchId, requestUri); return("200"); }