public IEnumerable <Alarm> GetByDevice(string deviceId, DeviceAlarmFilter filter, int rowsPerPage, int pageNumber) { IEnumerable <BsonDocument> pipeline = filter.SkipedAlarmsPipeline(rowsPerPage, pageNumber); PipelineDefinition <Site, BsonDocument> pipelineDefinition = PipelineDefinition <Site, BsonDocument> .Create(pipeline); return(Iterate <IList <Alarm> >(pipelineDefinition, (e, alarms) => { if (alarms == null) { alarms = new List <Alarm>(); } alarms.Add(JsonConvert.DeserializeObject <BsonAlarmRoot>(e).Alarms); return alarms; })); }
public IEnumerable <Alarm> Get(DeviceAlarmFilter filter, int rowsPerPage, int pageNumber) { filter.DeviceId = string.Empty; IEnumerable <BsonDocument> pipeline = filter.SkipedAlarmsPipeline(rowsPerPage, pageNumber); PipelineDefinition <Site, BsonDocument> pipelineDefinition = PipelineDefinition <Site, BsonDocument> .Create(pipeline); return(BsonIterator.Iterate(collection, pipelineDefinition, (BsonDocument e, IList <Alarm> alarms) => { if (alarms == null) { alarms = new List <Alarm>(); } alarms.Add(BsonSerializer.Deserialize <BsonAlarmRoot>(e).Alarms); return alarms; })); }