예제 #1
0
        /// <summary>
        /// 判断用户的通知设置
        /// </summary>
        /// <param name="userID">用户</param>
        /// <param name="notifyType">类型</param>
        /// <returns></returns>
        private bool CheckUserNotifySettings(int userID, int notifyType)
        {
            NotifyState SysState = AllSettings.Current.NotifySettings.GetNotifySystemState(notifyType);

            SystemNotifyProvider.Update();

            //判断系统设置
            switch (SysState)
            {
            case NotifyState.AlwaysClose:
                return(false);

            case NotifyState.DefaultClose:
            case NotifyState.DefaultOpen:
                //判断用户设置
                UserNotifySetting userSetting = UserBO.Instance.GetNotifySetting(userID);
                if (userSetting != null && userSetting.GetNotifyState(notifyType) == NotifyState.DefaultClose)
                {
                    return(false);
                }
                break;
            }

            return(true);
        }
예제 #2
0
        public void UpdateSystemNotify(int operatorUserID, string subject, int notifyID, string Content, IEnumerable <Guid> receiveRoles, IEnumerable <int> receiveUserIDs, DateTime beginDate, DateTime endDate)
        {
            if (subject == string.Empty)
            {
                subject = string.Format("{0:yyyy-MM-dd HH:mm}", DateTimeUtil.Now);
            }

            if (AllSettings.Current.BackendPermissions.Can(operatorUserID, BackendPermissions.Action.Manage_SystemNotify))
            {
                if (ValidateSystemNotifyData(Content, receiveRoles, receiveUserIDs, beginDate, endDate))
                {
                    SystemNotify notify = NotifyDao.Instance.UpdateSystemNotify(notifyID, subject, Content, receiveRoles, receiveUserIDs, beginDate, endDate, operatorUserID, IPUtil.GetCurrentIP());
                    SystemNotifyProvider.Update();

                    if (OnSystemNotifyUpdated != null)
                    {
                        OnSystemNotifyUpdated(notify);
                    }
                }
            }
            else
            {
                ThrowError(new NoPermissionManageSystemNoyify());
            }
        }
예제 #3
0
 public void IgnoreSystemNotify(int userID, int systemNotifyID)
 {
     SystemNotifyProvider.IgnoreNotify(userID, systemNotifyID);
     if (OnUserIgnoreSystemNotify != null)
     {
         OnUserIgnoreSystemNotify(userID, systemNotifyID);
     }
 }
예제 #4
0
        public void DeleteSystemNotifys(int operatorUserID, IEnumerable <int> notifyIDs)
        {
            if (AllSettings.Current.BackendPermissions.Can(operatorUserID, BackendPermissions.Action.Manage_SystemNotify))
            {
                if (ValidateUtil.HasItems <int>(notifyIDs))
                {
                    NotifyDao.Instance.DeleteSystemNotifys(notifyIDs);
                    SystemNotifyProvider.Update();

                    if (OnSystemNotifyDeleted != null)
                    {
                        OnSystemNotifyDeleted(notifyIDs);
                    }
                }
            }
            else
            {
                ThrowError(new NoPermissionManageSystemNoyify());
            }
        }
예제 #5
0
 static SystemNotifyProvider()
 {
     Instance = new SystemNotifyProvider();
 }
예제 #6
0
        public bool AddNotify(AuthUser oprateUser, Notify notify)
        {
            #region 基础参数检查

            if (notify == null)
            {
                return(false);
            }


            if (notify.UserID <= 0)
            {
                return(false);
            }

            if (notify.UserID == oprateUser.UserID)
            {
                return(true);
            }

            #endregion

            UnreadNotifies UnreadNotifies = null;
#if !Passport
            PassportClientConfig setting = Globals.PassportClient;

            if (setting.EnablePassport)
            {
                NotifyType type = AllNotifyTypes[notify.TypeID];


                NotifyActionProxy[] proxys = new NotifyActionProxy[notify.Actions.Count];
                int i = 0;
                foreach (NotifyAction action in notify.Actions)
                {
                    NotifyActionProxy nap = new NotifyActionProxy();
                    nap.Url      = "{clienturl}" + action.Url;
                    nap.Title    = action.Title;
                    nap.IsDialog = action.IsDialog;
                    proxys[i]    = nap;
                    i++;
                }

                ThreadPool.QueueUserWorkItem(delegate(object a) {
                    try
                    {
                        setting.PassportService.Notify_Send(notify.UserID, type.TypeName, notify.Content, notify.DataTable.ToString(), proxys, notify.Keyword);
                    }
                    catch
                    {
                    }
                });
            }
            else
#endif
            {
                NotifyState SysState = AllSettings.Current.NotifySettings.GetNotifySystemState(notify.TypeID);
                SystemNotifyProvider.Update();

                //判断系统设置
                switch (SysState)
                {
                case NotifyState.AlwaysClose:
                    return(false);

                case NotifyState.DefaultClose:
                case NotifyState.DefaultOpen:
                    //判断用户设置
                    UserNotifySetting userSetting = UserBO.Instance.GetNotifySetting(notify.UserID);
                    if (userSetting != null && userSetting.GetNotifyState(notify.TypeID) == NotifyState.DefaultClose)
                    {
                        return(false);
                    }
                    break;
                }

                StringTable actions = new StringTable();
                if (notify.Actions != null)
                {
                    foreach (NotifyAction na in notify.Actions)
                    {
                        actions.Add(na.Title, (na.IsDialog ? "*" : "") + na.Url);
                    }
                }
                NotifyDao.Instance.AddNotify(notify.UserID, notify.TypeID, notify.Content, notify.Keyword, notify.DataTable.ToString(), 0, actions.ToString(), out UnreadNotifies);

                AuthUser user;
                user = UserBO.Instance.GetUserFromCache <AuthUser>(notify.UserID);
                if (user != null)
                {
                    user.UnreadNotify = UnreadNotifies;
                }

                if (OnUserNotifyCountChanged != null)
                {
                    OnUserNotifyCountChanged(UnreadNotifies);
                }

                RemoveCacheByType(notify.UserID, 0);
                return(true);
            }

            return(true);
        }
예제 #7
0
        public SystemNotifyCollection GetUserSystemNotifies(AuthUser operateUser, out List <int> unreadIDs)
        {
            SystemNotifyCollection results = SystemNotifyProvider.GetMyAllSystemNotifies(operateUser, out unreadIDs);

            return(results);
        }
예제 #8
0
 static SystemNotifyProvider() {
     Instance = new SystemNotifyProvider();
 }