/// <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); }
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); }