예제 #1
0
        private UnreadNotifies ProxyToUnreadNotifies(UnreadNotifiesProxy proxy)
        {
            UnreadNotifies unread = new UnreadNotifies();

            unread.UserID = proxy.UserID;
            foreach (UnreadNotifyItemProxy item in proxy.Items)
            {
                unread[item.TypeID] = item.Count;
            }

            return(unread);
        }
예제 #2
0
        public bool IgnoreNotifies(int oparetorUserID, IEnumerable <int> notifyIDs, out UnreadNotifies unread)
        {
            unread = new UnreadNotifies();

            if (!ValidateUtil.HasItems <int>(notifyIDs))
            {
                return(true);
            }
#if !Passport
            PassportClientConfig settings = Globals.PassportClient;
            if (settings.EnablePassport)
            {
                List <int> ids = new List <int>();
                foreach (int id in notifyIDs)
                {
                    ids.Add(id);
                }

                int[] t = new int[ids.Count];
                ids.CopyTo(t);

                UnreadNotifiesProxy proxy = settings.PassportService.Notify_IgnoreNotifies(oparetorUserID, t);

                unread = ProxyToUnreadNotifies(proxy);
            }
            else
#endif
            {
                NotifyDao.Instance.IgnoreNotify(oparetorUserID, notifyIDs, out unread);
            }

            if (!unread.IsEmpty || unread.UserID > 0)
            {
                if (OnUserNotifyCountChanged != null)
                {
                    OnUserNotifyCountChanged(unread);
                }

                AuthUser oparetorUser = UserBO.Instance.GetUserFromCache <AuthUser>(oparetorUserID);
                if (oparetorUser != null)
                {
                    oparetorUser.UnreadNotify = unread;
                }

                RemoveCacheByType(oparetorUserID, 0);
            }

            return(true);
        }
예제 #3
0
        public UnreadNotifiesProxy Notify_IgnoreNotifies(int userID, List <int> notifyIDs)
        {
            if (!CheckClient())
            {
                return(null);
            }
            UnreadNotifies unreads;

            using (ErrorScope es = new ErrorScope())
            {
                NotifyBO.Instance.IgnoreNotifies(userID, notifyIDs, out unreads);
            }

            UnreadNotifiesProxy proxy = ProxyConverter.GetUnreadNotifiesProxy(unreads);

            return(proxy);
        }
예제 #4
0
        /// <summary>
        /// 忽略所有通知
        /// </summary>
        /// <param name="userID"></param>
        /// <param name="typeID"></param>
        /// <returns></returns>
        public bool IgnoreNotifiesByType(int userID, int typeID, out UnreadNotifies unreads)
        {
            unreads = null;

            AuthUser user = UserBO.Instance.GetUserFromCache <AuthUser>(userID);

#if !Passport
            if (Globals.PassportClient.EnablePassport)
            {
                UnreadNotifiesProxy proxy = Globals.PassportClient.PassportService.Notify_IgnoreNotifiesByType(userID, typeID);

                if (proxy == null)
                {
                    return(false);
                }
                unreads = new UnreadNotifies();
                foreach (UnreadNotifyItemProxy item in proxy.Items)
                {
                    unreads[item.TypeID] = item.Count;
                }
            }
            else
#endif
            {
                NotifyDao.Instance.IgnoreNotifyByType(userID, typeID, out unreads);
            }

            if (user != null)
            {
                user.UnreadNotify = unreads;
            }
            if (OnUserNotifyCountChanged != null)
            {
                OnUserNotifyCountChanged(unreads);
            }

            RemoveCacheByType(userID, typeID);

            return(true);
        }
예제 #5
0
        public static UnreadNotifiesProxy GetUnreadNotifiesProxy(UnreadNotifies unreadnotifies)
        {
            if (unreadnotifies == null)
            {
                return(null);
            }
            UnreadNotifiesProxy proxy = new UnreadNotifiesProxy();

            proxy.Count  = unreadnotifies.Count;
            proxy.UserID = unreadnotifies.UserID;
            proxy.Items  = new List <UnreadNotifyItemProxy>();

            foreach (UnreadNotifyItem item in unreadnotifies.Items)
            {
                UnreadNotifyItemProxy proxyItem = new UnreadNotifyItemProxy();
                proxyItem.TypeID = item.TypeID;
                proxyItem.Count  = item.UnreadCount;
                proxy.Items.Add(proxyItem);
            }

            return(proxy);
        }