Ejemplo n.º 1
0
 public Dictionary <string, List <ChartMainModel> > GetMainChartJson(DbConn PubConn, int num, string key, int type)
 {
     return(SqlHelper.Visit(ps =>
     {
         Dictionary <string, List <ChartMainModel> > d = new Dictionary <string, List <ChartMainModel> >();
         DateTime date = DateTime.Now;
         string Stime = date.AddDays(num).ToString("yyyy-MM-dd");
         string Etime = date.ToString("yyyy-MM-dd");
         List <ChartMainModel> chartMainModel = new List <ChartMainModel>();
         ChartMainModel MainModel = new ChartMainModel();
         MainModel.Tkey = "avgtime";
         MainModel.Tvalue = 0;
         chartMainModel.Add(MainModel);
         MainModel = new ChartMainModel();
         MainModel.Tkey = "maxtime";
         MainModel.Tvalue = 0;
         chartMainModel.Add(MainModel);
         MainModel = new ChartMainModel();
         MainModel.Tkey = "mintime";
         MainModel.Tvalue = 0;
         chartMainModel.Add(MainModel);
         for (int i = num; i <= 0; i++)
         {
             d.Add(date.AddDays(i).ToString("yyyy-MM-dd"), chartMainModel);
         }
         ps.Add("Stime", Stime);
         ps.Add("Etime", Etime);
         ps.Add("key", key);
         string sql = "";
         if (type == 1)
         {
             sql = "select date,avgtime,maxtime,mintime from tb_timewatchlog_sql_dayreport where date>=@Stime and date<=@Etime and sqlhash=@key order by date";
         }
         else
         {
             sql = "select date,avgtime,maxtime,mintime from tb_timewatchlog_api_dayreport where date>=@Stime and date<=@Etime and url=@key order by date";
         }
         DataTable dt = PubConn.SqlToDataTable(sql, ps.ToParameters());
         foreach (DataRow dr in dt.Rows)
         {
             List <ChartMainModel> m = new List <ChartMainModel>();
             foreach (DataColumn c in dr.Table.Columns)
             {
                 if (c.ColumnName != "date")
                 {
                     ChartMainModel main = new ChartMainModel();
                     main.Tkey = c.ColumnName;
                     main.Tvalue = Convert.ToDecimal(dr[c.ColumnName]);
                     m.Add(main);
                 }
             }
             d[Convert.ToDateTime(dr["date"]).ToString("yyyy-MM-dd")] = m;
         }
         return d;
     }));
 }
 public Dictionary <string, List <ChartMainModel> > GetMainChartJson(DbConn PubConn, int num, string key)
 {
     return(SqlHelper.Visit(ps =>
     {
         Dictionary <string, List <ChartMainModel> > d = new Dictionary <string, List <ChartMainModel> >();
         DateTime date = DateTime.Now;
         string Stime = date.AddDays(num).ToString("yyyy-MM-dd");
         string Etime = date.ToString("yyyy-MM-dd");
         ps.Add("Stime", Stime);
         ps.Add("Etime", Etime);
         ps.Add("key", key);
         string sql = @"select date,avgcpu,maxcpu,mincpu,avgmemory,maxmemory,minmemory,
         avgnetworkupload,maxnetworkupload,minnetworkupload,avgnetworkdownload,
         maxnetworkdownload,miniowrite,avgiisrequest,maxiisrequest,miniisrequest,
         minnetworkdownload,avgioread,maxioread,minioread,avgiowrite,maxiowrite
         from tb_performance_dayreport where date>=@Stime and date<=@Etime and serverid=@key order by date";
         DataTable dt = PubConn.SqlToDataTable(sql, ps.ToParameters());
         List <ChartMainModel> chartMainModel = new List <ChartMainModel>();
         foreach (DataColumn c in dt.Columns)
         {
             if (c.ColumnName != "date")
             {
                 ChartMainModel MainModel = new ChartMainModel();
                 MainModel.Tkey = c.ColumnName;
                 MainModel.Tvalue = 0;
                 chartMainModel.Add(MainModel);
             }
         }
         for (int i = num; i <= 0; i++)
         {
             d.Add(date.AddDays(i).ToString("yyyy-MM-dd"), chartMainModel);
         }
         foreach (DataRow dr in dt.Rows)
         {
             List <ChartMainModel> m = new List <ChartMainModel>();
             foreach (DataColumn c in dr.Table.Columns)
             {
                 if (c.ColumnName != "date")
                 {
                     ChartMainModel main = new ChartMainModel();
                     main.Tkey = c.ColumnName;
                     main.Tvalue = Convert.ToDecimal(dr[c.ColumnName]);
                     m.Add(main);
                 }
             }
             d[Convert.ToDateTime(dr["date"]).ToString("yyyy-MM-dd")] = m;
         }
         return d;
     }));
 }