Fix alarm history

This commit is contained in:
Lucio Maranta
2019-02-08 16:41:25 +01:00
parent 491113f71a
commit a0be095759
6 changed files with 20 additions and 8 deletions
@@ -54,7 +54,7 @@ namespace Step.Database.Controllers
var occurrencesQuery = dbCtx
.AlarmOccurrences
.OrderBy(x => x.AlarmOccurrenceId)
.Include("Users")
.Include("Users")
.Where(x =>
x.TimeStamp >= startDate && x.TimeStamp <= endDate // Filter by date
&& sources.Contains(x.Source) // Check source
@@ -62,10 +62,10 @@ namespace Step.Database.Controllers
&&
((x.Source == ALARM_SOURCE.NC && ncAlarmDescIds.Contains(x.AlarmDescriptionId.Value)) // Check if message is contained in NC messages
|| (x.Source == ALARM_SOURCE.PLC && plcAlarmDescIds.Contains(x.AlarmId))) // Check if message is contained in PLC messages
);
pages = occurrencesQuery.Count() / pageSize;
).OrderByDescending(t => t.TimeStamp);
double tmpPages = occurrencesQuery.Count() / pageSize;
pages = (int)Math.Ceiling(tmpPages);
var paginatedQuery = occurrencesQuery
.Skip(page * pageSize) // Paginate