using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace GDNXFD.Data.Repositories { public class CustomRepository { public static IList GetAlertHistorys() { IList ret = null; using (GDNXFDDbContext ctx = new GDNXFDDbContext()) { ret = ctx.AlertInfo.ToList(); } return ret; } public static IList GetStationPieChartData() { DateTime dt = DateTime.Now.AddDays(-1); using (GDNXFDDbContext ctx = new GDNXFDDbContext()) { var query = ctx.AlertInfo .Where(q=>q.AlertTime > dt) .GroupBy(q=>q.StationName) .Select(g => new RankingModel { ObjectName = g.Key, Total = g.Count() }); return query.OrderByDescending(a => a.Total).Take(10).ToList(); } } public static IList GetRankListData() { IList results = new List(); DateTime dt = DateTime.Now.AddDays(-1); using (GDNXFDDbContext ctx = new GDNXFDDbContext()) { var query = ctx.AlertInfo .Where(q => q.AlertTime > dt) .GroupBy(q => new GroupModel { StationName = q.StationName, ProjectName = q.ProjectName, LineName = q.LineName, WindturbineName = q.WindturbineName }) .Select(g => new GroupRankModel { GM = g.Key, Total = g.Count() }); var tmp = query.OrderByDescending(a => a.Total).Take(10).ToArray(); if (tmp != null) { for(int i=0;i GetWindturbineInputWindSpeed() { using (GDNXFDDbContext ctx = new GDNXFDDbContext()) { string sql = @"select id, windturbineid, recorddate, inputsmall from inputoroutputspeedtotal t where t.recorddate = (select max(recorddate) from inputoroutputspeedtotal)"; return ctx.InputOrOutputSpeedTotal.SqlQuery(sql, new object[] { }).ToList(); } } public static IList GetWindturbineCFTSpeed() { using (GDNXFDDbContext ctx = new GDNXFDDbContext()) { return ctx.WindturbineCFTSpeed.ToList(); } } } }