/// <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); }
private void SaveSetting() { UserNotifySetting setting = new UserNotifySetting(string.Empty); foreach (NotifySettingItem item in setting.AllNotify) { if (item.OpenState == NotifyState.DefaultClose || item.OpenState == NotifyState.DefaultOpen) { item.OpenState = _Request.Get <NotifyState>(item.NotifyType.ToString(), Method.Post, NotifyState.DefaultClose); } } UserBO.Instance.SetNotifySetting(MyUserID, setting); MessageDisplay msgDispaly = CreateMessageDisplay(); }
public List <KeyValueProxy> User_GetNotifySettings(int userID) { if (!CheckClient()) { return(null); } List <KeyValueProxy> settingResult = new List <KeyValueProxy>(); UserNotifySetting setting = UserBO.Instance.GetNotifySetting(userID); foreach (NotifySettingItem item in setting.AllNotify) { settingResult.Add(new KeyValueProxy(item.NotifyType, (int)item.OpenState)); } return(settingResult); }
public bool User_SetNotifySettings(int userID, List <KeyValueProxy> results) { if (!CheckClient()) { return(false); } UserNotifySetting setting = UserBO.Instance.GetNotifySetting(userID); foreach (NotifySettingItem item in setting.AllNotify) { foreach (KeyValueProxy proxy in results) { if (proxy.Key == item.NotifyType) { item.OpenState = (NotifyState)proxy.Value; } } } UserBO.Instance.SetNotifySetting(userID, setting); return(true); }
public abstract void SetUserNotifySetting(int userID, UserNotifySetting setting);
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); }