& alarm Fixes
This commit is contained in:
Lucio Maranta
2018-11-21 17:26:58 +01:00
parent 929f8ffa53
commit 0e009dc6ec
7 changed files with 88 additions and 67 deletions
+12 -13
View File
@@ -8,6 +8,7 @@ using System.IO;
using System.Linq;
using static Step.Model.Constants;
using static Step.Config.ServerConfig;
using System.Diagnostics;
namespace Step.Database.Controllers
{
@@ -47,21 +48,19 @@ namespace Step.Database.Controllers
.OrderBy(x => x.AlarmOccurrenceId)
.Include("Users")
.Where(x =>
x.TimeStamp >= startDate && x.TimeStamp <= endDate
&& types.Contains(x.Type)
&& x.Users.Any(y => userIds.Any(z => z == y.UserId))
x.TimeStamp >= startDate && x.TimeStamp <= endDate // Filter by date
&& types.Contains(x.Type) // Type
&& x.Users.Any(y => userIds.Any(z => z == y.UserId)) // Check user
&&
((x.Source == ALARM_SOURCE.NC && ncAlarmDescIds.Contains(x.AlarmDescriptionId.Value))
|| (x.Source == ALARM_SOURCE.PLC && plcAlarmDescIds.Contains(x.PlcMessageId.Value)))
);
var occurrences = occurrencesQuery
.Skip(page * pageSize)
.Take(pageSize)
.Include("AlarmDescription")
.ToList();
((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.PlcMessageId.Value))) // Check if message is contained in PLC messages
)
.Skip(page * pageSize) // Paginate
.Take(pageSize)
.Include("AlarmDescription") // Include foreign key
.ToList();
return occurrences
return occurrencesQuery
.Select(x => (DTOAlarmHistoricModel)x)
.ToList();
}