/// <summary> /// 根据用户名,获取报警记录,(默认查询当天的报警记录) /// </summary> /// <param name="userName"></param> /// <param name="pageIndex"></param> /// <param name="pageSize"></param> /// <returns></returns> public MeterAlarmViewModel GetAlarmLogViewModel(string userName) { MeterAlarmViewModel viewModel = new MeterAlarmViewModel(); int pageIndex = 1; int pageSize = 100; string beginDate = DateTime.Now.ToString("yyyy-MM-dd 00:00"); string endDate = DateTime.Now.ToString("yyyy-MM-dd 23:59"); string buildID = ""; viewModel.Builds = tvContext.GetBuildsByUserName(userName); viewModel.AlarmType = context.GetAlarmType(); if (viewModel.Builds.Count > 0) { buildID = viewModel.Builds.First().BuildID; } viewModel.PageInfos = context.GetAlarmLogPageInfo(userName, buildID, pageSize, beginDate, endDate); viewModel.PageInfos.CurrentPage = pageIndex; viewModel.PageInfos.PageSize = pageSize; viewModel.AlarmLogs = context.GetAlarmLogList(userName, buildID, pageIndex, pageSize, beginDate, endDate); return(viewModel); }
public MeterAlarmSetViewModel GetViewModel(string userName) { MeterAlarmSetViewModel viewModel = new MeterAlarmSetViewModel(); string buildID = ""; string energyCode = ""; viewModel.Builds = tvContext.GetBuildsByUserName(userName); if (viewModel.Builds.Count > 0) { buildID = viewModel.Builds.First().BuildID; } List <EnergyItemDict> energys = tvContext.GetEnergyItemDictByBuild(buildID); if (energys.Count > 0) { energyCode = energys.First().EnergyItemCode; } List <TreeViewModel> treeView = tvContext.GetCircuitTreeListViewModel(buildID, energyCode); List <MeterAlarmSet> data = context.GetMeterParamList(buildID, treeView.First().Id); viewModel.Energys = energys; viewModel.TreeView = treeView; viewModel.Data = data; return(viewModel); }
public object GetViewModel(string userName) { ToxicGasesViewModel viewModel = new ToxicGasesViewModel(); string buildID = ""; string meterID = ""; viewModel.Builds = tvContext.GetBuildsByUserName(userName); if (viewModel.Builds.Count > 0) { buildID = viewModel.Builds.First().BuildID; } viewModel.Devices = context.GetMeterList(buildID); if (viewModel.Devices.Count > 0) { meterID = viewModel.Devices.First().ID; } viewModel.CurrentData = context.GetOneMeterValue(meterID, buildID); return(viewModel); }