public void Client_SetUserUnreadNotifies(UnreadNotifies unreadNotifies) { AuthUser user = UserBO.Instance.GetUserFromCache <AuthUser>(unreadNotifies.UserID); if (user == null) { return; } user.UnreadNotify = unreadNotifies; }
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); }
public override void Execute(int targetID, DateTime instructDateTime, string datas) { UnreadNotifies unreadNotifies = new UnreadNotifies(); MaxLabs.Passport.Proxy.UnreadNotifiesProxy proxy = DataReadWrap.Get <MaxLabs.Passport.Proxy.UnreadNotifiesProxy>(datas); unreadNotifies.UserID = proxy.UserID; foreach (MaxLabs.Passport.Proxy.UnreadNotifyItemProxy item in proxy.Items) { unreadNotifies[item.TypeID] = item.Count; } NotifyBO.Instance.Client_SetUserUnreadNotifies(unreadNotifies); }
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); }
public override bool IgnoreNotify(int userID, IEnumerable <int> notifyIDs, out UnreadNotifies unreadNotifies) { using (SqlQuery query = new SqlQuery()) { query.CommandText = "bx_IgnoreNotifies"; query.CommandType = CommandType.StoredProcedure; query.CreateParameter <int>("@UserID", userID, SqlDbType.Int); query.CreateParameter <string>("@NotifyIDs", StringUtil.Join(notifyIDs), SqlDbType.VarChar, 8000); using (XSqlDataReader reader = query.ExecuteReader()) { unreadNotifies = new UnreadNotifies(reader); } } return(true); }
/// <summary> /// 删除通知 /// </summary> /// <param name="userID">通知的用户ID</param> /// <param name="messageID">要删除的通知的ID</param> public override bool DeleteNotify(int?userID, int notifyID, out UnreadNotifies unreadNotifies) { unreadNotifies = null; IEnumerable <int> notifies = new int[] { notifyID }; UnreadNotifyCollection unreads; bool success = DeleteNotifies(userID, notifies, out unreads); foreach (UnreadNotifies un in unreads) { unreadNotifies = un; } return(success); }
public override bool IgnoreNotifyByType(int userID, int typeID, out UnreadNotifies unreads) { using (SqlQuery query = new SqlQuery()) { query.CommandText = "bx_IgnoreNotifyByType"; query.CommandType = CommandType.StoredProcedure; query.CreateParameter <int>("@UserID", userID, SqlDbType.Int); query.CreateParameter <int>("@TypeID", typeID, SqlDbType.Int); using (XSqlDataReader reader = query.ExecuteReader()) { unreads = new UnreadNotifies(reader); } } return(true); }
/// <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); }
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); }
public override bool AddNotify(int userID, int typeID, string Content, string keyword, string datas, int clientID, string actions, out UnreadNotifies unreadNotifies) { using (SqlQuery query = new SqlQuery()) { query.CommandText = "bx_AddNotify"; query.CommandType = CommandType.StoredProcedure; query.CreateParameter <int>("@TypeID", typeID, SqlDbType.TinyInt); query.CreateParameter <int>("@UserID", userID, SqlDbType.Int); query.CreateParameter <string>("@Keyword", keyword, SqlDbType.VarChar, 1000); query.CreateParameter <string>("@Content", Content, SqlDbType.NVarChar, 1000); query.CreateParameter <string>("@NotifyDatas", datas, SqlDbType.NText); query.CreateParameter <int>("@ClientID", clientID, SqlDbType.Int); query.CreateParameter <string>("@Actions", actions, SqlDbType.NVarChar, 2000); using (XSqlDataReader reader = query.ExecuteReader()) { unreadNotifies = new UnreadNotifies(reader); } } return(true); }
public override void Execute(int targetID, DateTime instructDateTime, string datas) { UnreadNotifies unreadNotifies = new UnreadNotifies(); MaxLabs.Passport.Proxy.UnreadNotifiesProxy proxy = DataReadWrap.Get<MaxLabs.Passport.Proxy.UnreadNotifiesProxy>(datas); unreadNotifies.UserID = proxy.UserID; foreach (MaxLabs.Passport.Proxy.UnreadNotifyItemProxy item in proxy.Items) { unreadNotifies[item.TypeID] = item.Count; } NotifyBO.Instance.Client_SetUserUnreadNotifies(unreadNotifies); }
void NotifyBO_OnUserNotifyCountChanged(UnreadNotifies unreads) { CreateInstruct(unreads.UserID, InstructType.Notify_UserNotifyCountChanged, ProxyConverter.GetUnreadNotifiesProxy(unreads)); }
/// <summary> /// 忽略通知 /// </summary> /// <param name="userID"></param> /// <param name="notifyIDs"></param> /// <param name="unreadNotifies"></param> /// <returns></returns> public abstract bool IgnoreNotify(int userID, IEnumerable <int> notifyIDs, out UnreadNotifies unreadNotifies);
/// <summary> /// 删除通知 /// </summary> /// <param name="userID">通知的用户ID</param> /// <param name="notifyID">要删除的通知的ID</param> public abstract bool DeleteNotify(int?userID, int notifyID, out UnreadNotifies unreadNotifies);
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); }
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; }
public abstract bool IgnoreNotifyByType(int userID, int typeID, out UnreadNotifies unreads);
////<summary> ////发送通知 ////</summary> ////<param name="userID">所有者ID</param> ////<param name="relatedUserID">触发通知的用户ID</param> ////<param name="uniteNotify">是否合并同类的通知</param> ////<param name="tagetID">目标内容的ID,比如说回帖的话就是帖子ID</param> ////<param name="notifyType">通知类型</param> ////<param name="senderIP">IP地址</param> ////<param name="parameters">参数</param> ////<returns></returns> public abstract bool AddNotify(int userID, int typeID, string Content, string keyword, string datas, int passportClientID, string actions, out UnreadNotifies unreadNotifies);