/// <summary> /// 获取全部账号统计报告ISMP 使用 /// </summary> /// <param name="account"></param> /// <param name="beginTime"></param> /// <param name="endTime"></param> /// <returns></returns> public RPCResult <List <ReportStatistics> > GetStatisticsReportAll(DateTime beginTime, DateTime endTime) { DateTime cacheBeginTime = DateTime.MaxValue; if (DateTime.Compare(beginTime, endTime) > 0) { DateTime dt = beginTime; beginTime = endTime; endTime = dt; } if (DateTime.Compare(endTime, DateTime.Now) > 0) { endTime = DateTime.Now; } List <string> list = ReportStatisticsDB.GetTables(); var maxdate = list.Max(s => DateTime.Parse(s.Remove(0, 17).Insert(4, "-").Insert(7, "-"))); if (DateTime.Compare(endTime, maxdate) > 0) { endTime = maxdate; } var mindate = list.Min(s => DateTime.Parse(s.Remove(0, 17).Insert(4, "-").Insert(7, "-"))); if (DateTime.Compare(beginTime, mindate) < 0) { beginTime = mindate; } List <ReportStatistics> dbRS = ReportStatisticsDB.GetStatisticsByDate(beginTime, endTime); return(new RPCResult <List <ReportStatistics> >(true, dbRS, "")); }
/// <summary> /// 统计报告表 /// </summary> void LoadStatisticsReportTables() { List <string> tables = ReportStatisticsDB.GetTables(); if (tables.Count == 0) { string name = "ReportStatistics_" + DateTime.Now.ToString("yyyyMMdd"); ReportStatisticsDB.CloneTable(name); statisticsReportTables.Add(name.ToLower()); return; } int min = 99991231; foreach (var table in tables) { statisticsReportTables.Add(table.ToLower()); if (min > int.Parse(table.Remove(0, 17))) { min = int.Parse(table.Remove(0, 17)); } } string date = min.ToString(); date = date.Insert(4, "-"); date = date.Insert(7, "-"); DateTime beginTime = DateTime.Parse(date).AddDays(1); while (DateTime.Compare(DateTime.Now, beginTime) > 0) { string name = "ReportStatistics_" + beginTime.ToString("yyyyMMdd"); if (!statisticsReportTables.Contains(name.ToLower())) { ReportStatisticsDB.CloneTable(name); statisticsReportTables.Add(name.ToLower()); } beginTime = beginTime.AddDays(1); } }
public void GetTablesTest() { var l = ReportStatisticsDB.GetTables(); Assert.IsTrue(l.Count > 0); }