protected void LoadItems()
    {
        if (!HasEditPermission)
        {
            dgNotifications.Columns[dgNotifications.Columns.Count - 1].Visible = false;
        }
        var allNotifications = NotificationFilterCollection.FetchAll().Where(x => x.Deleted == null);

        dgNotifications.VirtualItemCount = allNotifications.Count();
        if (dgNotifications.VirtualItemCount == 0)
        {
            phHasItems.Visible   = false;
            phHasNoItems.Visible = true;
            lblNoItems.Text      = NotificationStrings.GetText(@"MessageNoNotificationsFound");
        }
        else
        {
            phHasItems.Visible   = true;
            phHasNoItems.Visible = false;
            if (dgNotifications.PageSize * dgNotifications.CurrentPageIndex > dgNotifications.VirtualItemCount)
            {
                dgNotifications.CurrentPageIndex         = 0;
                hfCurrentPageIndex_dgNotifications.Value = dgNotifications.CurrentPageIndex.ToString();
            }

            BindList(allNotifications.ToList());
        }
    }
Beispiel #2
0
        public static List <NotificationFilter> GetAllNotifications()
        {
            if (_notificationsCache == null)
            {
                lock (_lock)
                {
                    if (_notificationsCache == null)
                    {
                        _notificationsCache = new List <NotificationFilter>();
                        _lastUpdated        = DateTime.MinValue;
                    }
                }
            }
            var now = DateTime.Now;

            if (_lastUpdated.AddSeconds(60) < now)
            {
                lock (_lock)
                {
                    if (_lastUpdated.AddSeconds(60) < now)
                    {
                        _notificationsCache = NotificationFilterCollection.FetchAll().Where(x => x.Deleted == null && !x.IsAuto).ToList();
                        _lastUpdated        = DateTime.Now;
                    }
                }
            }
            return(_notificationsCache);
        }