Ejemplo n.º 1
0
        public int CountAll(IMongoFilter <Device, Alarm> filter)
        {
            DeviceAlarmFilter alarmFilter = new DeviceAlarmFilter
            {
                Context   = (filter as AlarmFilter).Context,
                AlarmType = (filter as AlarmFilter).AlarmType,
                Gravity   = (filter as AlarmFilter).Gravity,
                DeviceId  = string.Empty,
                IsRead    = (filter as AlarmFilter).IsRead,
                IsActive  = (filter as AlarmFilter).IsActive
            };

            return(alarmRepository.Count(alarmFilter));
        }
Ejemplo n.º 2
0
        public PaginatedItems <Alarm> GetByDevice(string deviceId, IMongoFilter <Device, Alarm> filter, int rowsPerPage, int pageNumber)
        {
            DeviceAlarmFilter alarmFilter = new DeviceAlarmFilter
            {
                Context   = (filter as AlarmFilter).Context,
                AlarmType = (filter as AlarmFilter).AlarmType,
                Gravity   = (filter as AlarmFilter).Gravity,
                DeviceId  = deviceId,
                IsRead    = (filter as AlarmFilter).IsRead,
                IsActive  = (filter as AlarmFilter).IsActive
            };

            var totalCount = alarmRepository.CountByDevice(deviceId, alarmFilter);
            var pageCount  = rowsPerPage == 0 ? 1 : (int)Math.Ceiling((double)totalCount / rowsPerPage);

            return(new PaginatedItems <Alarm>
            {
                PageCount = pageCount,
                TotalItemsCount = totalCount,
                Items = alarmRepository.GetByDevice(deviceId, alarmFilter, rowsPerPage, pageNumber)
            });
        }
 public static IMongoQueryable <TResult> Filter <TSource, TResult>(this IMongoQueryable <TSource> source, IMongoFilter <TSource, TResult> filter)
 {
     return(filter.FilterSource(source));
 }
 public PaginatedItems <Site> GetAllPaginated(IMongoFilter <Site> filter, int rowsPerPage, int pageNumber)
 {
     return(collection.AsQueryable()
            .Filter(filter)
            .Paginate(rowsPerPage, pageNumber));
 }
Ejemplo n.º 5
0
 public PaginatedItems <Site> Get(IMongoFilter <Site> filter, int rowsPerPage, int pageNumber)
 {
     return(siteRepository.GetAllPaginated(filter, rowsPerPage, pageNumber));
 }