private PageModel InitPageModel(WarningAnalysisModel model) { WarningTypeModel wt = wt_List.Find(s => s.Value == model.SelectTypeId); if (wt == null) { throw new Exception("报警类型xml配置有误"); } if (string.IsNullOrEmpty(wt.CValue) || string.IsNullOrEmpty(wt.keycol)) { throw new Exception(wt.Text + "缺少数据库参数信息"); } PageModel pmodel = new PageModel(); DateTime starttime = model.StartDate; DateTime endtime = model.EndDate.AddDays(1); pmodel.tablename = wt.CValue; pmodel.keycol = wt.keycol; pmodel.page = model.PageCurrent; pmodel.pagesize = model.PageSize; pmodel.wherestr = " DATETIME >= '" + starttime.ToShortDateString() + "' and DATETIME < '" + endtime.ToShortDateString() + "'"; pmodel.wherestr += string.Format(@" and devicename in (select cname from tb_device where devarea in (SELECT a.id FROM tb_area a,f_Cid({0}) b WHERE a.id=b.ID ))", model.BuildId); pmodel.orderby = wt.keycol; return(pmodel); }
private PageModel InitPageModel(int pageIndex, int pageSize, string startTime, string endTime, string warningTypeId, int areaId) { WarningTypeModel wt = wt_List.Find(s => s.Value == warningTypeId); if (wt == null) { throw new Exception("报警类型xml配置有误"); } if (string.IsNullOrEmpty(wt.CValue) || string.IsNullOrEmpty(wt.keycol)) { throw new Exception(wt.Text + "缺少数据库参数信息"); } PageModel pmodel = new PageModel(); DateTime starttime = Convert.ToDateTime(startTime); DateTime endtime = Convert.ToDateTime(endTime).AddDays(1); pmodel.tablename = wt.CValue; pmodel.keycol = wt.keycol; pmodel.page = pageIndex; pmodel.pagesize = pageSize; pmodel.wherestr = " DATETIME >= '" + starttime.ToShortDateString() + "' and DATETIME < '" + endtime.ToShortDateString() + "'"; pmodel.wherestr += string.Format(@" and devicename in (select cname from tb_device where devarea in (SELECT a.id FROM tb_area a,f_Cid({0}) b WHERE a.id=b.ID ))", areaId); pmodel.orderby = wt.keycol; return(pmodel); }