private void UpdateForumsData() { MessageDisplay msgDisplay = CreateMessageDisplay(); int[] forumIDs = _Request.GetList<int>("forumIDs", Method.Post, new int[0]); if (forumIDs.Length == 0) { msgDisplay.AddError("您还未选择要更新数据的版块"); return; } StringTable tempForumIDs = new StringTable(); foreach (int forumID in forumIDs) { tempForumIDs.Add(forumID.ToString(), forumID.ToString()); } if (TaskManager.BeginTask(MyUserID, new UpdateForumDataTask(), tempForumIDs.ToString())) { } }
public bool Server_SendNotify(int userID, string typeName, string content, string datas, string keyword, List< NotifyAction> actions,int clientID) { if (string.IsNullOrEmpty(typeName)) return false; NotifyType type = AllNotifyTypes[typeName]; if (type == null) RegisterNotifyType(typeName, true, string.Empty, out type); if (!CheckUserNotifySettings(userID, type.TypeID)) //用户通知设置 return false; if (NotifyJumpFlagRegex.IsMatch(content)) { StringTable st = new StringTable(); string sUrl = string.Empty; MatchCollection jumpMatchs = NotifyJumpFlagRegex.Matches(content); int i = 0; foreach (Match m in jumpMatchs) { sUrl += string.Concat(m.Groups[1].Value, "|"); content = content.Replace(m.Value, string.Concat("href=\"", Notify.GlobalHandlerUrl + "&ui=" + i++, "\"")); } sUrl = sUrl.Remove(sUrl.Length - 1); st.Add("Url", sUrl); datas = st.ToString(); //如果有JUMPTO的地址,就会覆盖原来的DATAS } //int jIndex; //do //{ // jIndex = content.IndexOf(jumpFlag); // if (jIndex > -1) // { // Notify n = new Notify(); // n.Url = ""; // } //}while(jIndex>-1); StringTable actionsTable = new StringTable(); if (actions != null) { foreach (NotifyAction na in actions) { if (string.IsNullOrEmpty(na.Title) || string.IsNullOrEmpty(na.Url)) continue; actionsTable.Add(na.Title, (na.IsDialog ? "*" : "") + na.Url); } } UnreadNotifies unread; bool success = NotifyDao.Instance.AddNotify(userID, type.TypeID, content, keyword, datas,clientID,actionsTable.ToString() , out unread); if (!unread.IsEmpty) { AuthUser user = UserBO.Instance.GetUserFromCache<AuthUser>(userID); if (user != null) { user.UnreadNotify = unread; } } RemoveCacheByType(userID, 0); if (success && !unread.IsEmpty) if (OnUserNotifyCountChanged != null) OnUserNotifyCountChanged(unread); return success; }
public bool Server_SendNotify(int userID, string typeName, string content, string datas, string keyword, List <NotifyAction> actions, int clientID) { if (string.IsNullOrEmpty(typeName)) { return(false); } NotifyType type = AllNotifyTypes[typeName]; if (type == null) { RegisterNotifyType(typeName, true, string.Empty, out type); } if (!CheckUserNotifySettings(userID, type.TypeID)) //用户通知设置 { return(false); } if (NotifyJumpFlagRegex.IsMatch(content)) { StringTable st = new StringTable(); string sUrl = string.Empty; MatchCollection jumpMatchs = NotifyJumpFlagRegex.Matches(content); int i = 0; foreach (Match m in jumpMatchs) { sUrl += string.Concat(m.Groups[1].Value, "|"); content = content.Replace(m.Value, string.Concat("href=\"", Notify.GlobalHandlerUrl + "&ui=" + i++, "\"")); } sUrl = sUrl.Remove(sUrl.Length - 1); st.Add("Url", sUrl); datas = st.ToString(); //如果有JUMPTO的地址,就会覆盖原来的DATAS } //int jIndex; //do //{ // jIndex = content.IndexOf(jumpFlag); // if (jIndex > -1) // { // Notify n = new Notify(); // n.Url = ""; // } //}while(jIndex>-1); StringTable actionsTable = new StringTable(); if (actions != null) { foreach (NotifyAction na in actions) { if (string.IsNullOrEmpty(na.Title) || string.IsNullOrEmpty(na.Url)) { continue; } actionsTable.Add(na.Title, (na.IsDialog ? "*" : "") + na.Url); } } UnreadNotifies unread; bool success = NotifyDao.Instance.AddNotify(userID, type.TypeID, content, keyword, datas, clientID, actionsTable.ToString(), out unread); if (!unread.IsEmpty) { AuthUser user = UserBO.Instance.GetUserFromCache <AuthUser>(userID); if (user != null) { user.UnreadNotify = unread; } } RemoveCacheByType(userID, 0); if (success && !unread.IsEmpty) { if (OnUserNotifyCountChanged != null) { OnUserNotifyCountChanged(unread); } } return(success); }
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); }