public static async Task<NotificationTypes> GetTypes()
 {
     string cacheKey = "MemberNotificationTypes";
     NotificationTypes m = HttpContext.Current.Cache[cacheKey] as NotificationTypes;
     if (m == null)
     {
         m = new NotificationTypes();
         MemberNotificationTypeServiceProxy tsvc = new MemberNotificationTypeServiceProxy();
         var categs = await tsvc.QueryDatabaseAsync(Cntx, new MemberNotificationTypeSet(), null);
         List<NotificationType> l = new List<NotificationType>();
         foreach (var c in categs)
             l.Add(new NotificationType { ID = c.ID, Name = MapCategoryName(c) });
         m.Types = l.ToArray();
         HttpContext.Current.Cache.Add(cacheKey, m, null, DateTime.Now.AddMinutes(30), System.Web.Caching.Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.Normal, null);
     }
     return m;
 }
Beispiel #2
0
        public static async Task <NotificationTypes> GetTypes()
        {
            string            cacheKey = "MemberNotificationTypes";
            NotificationTypes m        = HttpContext.Current.Cache[cacheKey] as NotificationTypes;

            if (m == null)
            {
                m = new NotificationTypes();
                MemberNotificationTypeServiceProxy tsvc = new MemberNotificationTypeServiceProxy();
                var categs = await tsvc.QueryDatabaseAsync(Cntx, new MemberNotificationTypeSet(), null);

                List <NotificationType> l = new List <NotificationType>();
                foreach (var c in categs)
                {
                    l.Add(new NotificationType {
                        ID = c.ID, Name = MapCategoryName(c)
                    });
                }
                m.Types = l.ToArray();
                HttpContext.Current.Cache.Add(cacheKey, m, null, DateTime.Now.AddMinutes(30), System.Web.Caching.Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.Normal, null);
            }
            return(m);
        }
 public static async Task<List<MemberNotificationType>> GetRecentCategorized(string userId, SimpleMessage[] msgs, int? typeId, int max)
 {
     var cntx = Cntx;
     MembershipPlusServiceProxy svc = new MembershipPlusServiceProxy();
     MemberNotificationTypeServiceProxy tsvc = new MemberNotificationTypeServiceProxy();
     MemberNotificationServiceProxy nsvc = new MemberNotificationServiceProxy();
     var categs = await tsvc.QueryDatabaseAsync(cntx, new MemberNotificationTypeSet(), null);
     List<MemberNotificationType> tlist = new List<MemberNotificationType>();
     DateTime dt = DateTime.UtcNow.AddDays(-1);
     foreach (var categ in categs)
     {
         if (typeId.HasValue && categ.ID != typeId.Value)
             continue;
         var cond = new MemberNotificationSetConstraints
         {
             ApplicationIDWrap = new ForeignKeyData<string> { KeyValue = AppId },
             UserIDWrap = new ForeignKeyData<string> { KeyValue = userId },
             TypeIDWrap = new ForeignKeyData<int> { KeyValue = categ.ID }
         };
         QueryExpresion qexpr = new QueryExpresion();
         qexpr.OrderTks = new List<QToken>(new QToken[] { 
             new QToken { TkName = "PriorityLevel" },
             new QToken { TkName = "desc" },
             new QToken { TkName = "CreatedDate" },
             new QToken { TkName = "desc" }
         });
         qexpr.FilterTks = new List<QToken>(new QToken[] { 
             new QToken { TkName = "ReadCount == 0 && CreatedDate >= " + svc.FormatRepoDateTime(dt) }
         });
         foreach (var msg in msgs)
         {
             qexpr.FilterTks.Add(new QToken
             {
                 TkName = " && ID != \"" + msg.Id + "\""
             });
         }
         var list = (await nsvc.ConstraintQueryLimitedAsync(cntx, new MemberNotificationSet(), cond, qexpr, max)).ToList();
         if (list.Count > 0)
         {
             categ.ChangedMemberNotifications = list.ToArray();
             tlist.Add(categ);
         }
     }
     return tlist;
 }
Beispiel #4
0
        public static async Task <List <MemberNotificationType> > GetRecentCategorized(string userId, SimpleMessage[] msgs, int?typeId, int max)
        {
            var cntx = Cntx;
            MembershipPlusServiceProxy         svc  = new MembershipPlusServiceProxy();
            MemberNotificationTypeServiceProxy tsvc = new MemberNotificationTypeServiceProxy();
            MemberNotificationServiceProxy     nsvc = new MemberNotificationServiceProxy();
            var categs = await tsvc.QueryDatabaseAsync(cntx, new MemberNotificationTypeSet(), null);

            List <MemberNotificationType> tlist = new List <MemberNotificationType>();
            DateTime dt = DateTime.UtcNow.AddDays(-1);

            foreach (var categ in categs)
            {
                if (typeId.HasValue && categ.ID != typeId.Value)
                {
                    continue;
                }
                var cond = new MemberNotificationSetConstraints
                {
                    ApplicationIDWrap = new ForeignKeyData <string> {
                        KeyValue = AppId
                    },
                    UserIDWrap = new ForeignKeyData <string> {
                        KeyValue = userId
                    },
                    TypeIDWrap = new ForeignKeyData <int> {
                        KeyValue = categ.ID
                    }
                };
                QueryExpresion qexpr = new QueryExpresion();
                qexpr.OrderTks = new List <QToken>(new QToken[] {
                    new QToken {
                        TkName = "PriorityLevel"
                    },
                    new QToken {
                        TkName = "desc"
                    },
                    new QToken {
                        TkName = "CreatedDate"
                    },
                    new QToken {
                        TkName = "desc"
                    }
                });
                qexpr.FilterTks = new List <QToken>(new QToken[] {
                    new QToken {
                        TkName = "ReadCount == 0 && CreatedDate >= " + svc.FormatRepoDateTime(dt)
                    }
                });
                foreach (var msg in msgs)
                {
                    qexpr.FilterTks.Add(new QToken
                    {
                        TkName = " && ID != \"" + msg.Id + "\""
                    });
                }
                var list = (await nsvc.ConstraintQueryLimitedAsync(cntx, new MemberNotificationSet(), cond, qexpr, max)).ToList();
                if (list.Count > 0)
                {
                    categ.ChangedMemberNotifications = list.ToArray();
                    tlist.Add(categ);
                }
            }
            return(tlist);
        }