public IActionResult Index() { var alarms = alarmRepository.GetAll(); var alarmViewModels = mapper.Map <IEnumerable <SampleTimeViewModel> >(alarms).ToList(); return(View(alarmViewModels)); }
public static int ImportAlarmStats(this HttpPostedFileBase httpPostedFile, IAlarmRepository repository) { IEnumerable<AlarmStat> statList = httpPostedFile.ImportCsvInfo( x => { StreamReader reader = new StreamReader(x, Encoding.GetEncoding("GB2312")); List<AlarmStatCsv> infoList = CsvContext.Read<AlarmStatCsv>(reader, CsvFileDescription.CommaDescription).ToList(); return infoList.Select(info => new AlarmStat(info)); }); int result = 0; foreach (AlarmStat stat in statList) { AlarmStat item = repository.GetAll().FirstOrDefault(x => x.ENodebId == stat.ENodebId && x.SectorId == stat.SectorId && x.AlarmId == stat.AlarmId); if (item == null || item.HappenTime > stat.HappenTime.AddDays(1) || item.HappenTime < stat.HappenTime.AddDays(-1)) { repository.Insert(stat); result++; } } return result; }
public ActionResult AddAlarmForm(int modelID) { AlarmDescriptionDisplay viewModel = new AlarmDescriptionDisplay(); //viewModel.Alarms = db.Alarms.ToList(); viewModel.Alarms = alarmRepository.GetAll().ToList(); //viewModel.MyAlarms = db.AlarmDescriptions.Where(c => c.ModelID == modelID).Select(a => a.Alarm).ToList(); viewModel.MyAlarms = alarmDescriptionRepository.GetAll().Where(c => c.ModelID == modelID).Select(a => a.Alarm).ToList(); viewModel.AlarmDescription = new AlarmDescription(); viewModel.AlarmDescription.ModelID = modelID; return(PartialView(viewModel)); }
public string GetAll() { var alarms = alarmRepository.GetAll(); return(string.Join(',', alarms.Select(a => a.Description))); }