public static DataTable GetReplies(this IRepository <PMessage> repository, PMessage message, int replyTo) { var messages = repository.ListAsDataTable(null, null, replyTo); var originalMessage = messages.GetFirstRow(); if (originalMessage == null) { return(messages); } var orginalPMMessage = new PMessage { ReplyTo = originalMessage["ReplyTo"].ToType <int>(), ID = originalMessage["PMessageID"].ToType <int>() }; if (message.ID == orginalPMMessage.ID) { messages.Rows.RemoveAt(0); } if (originalMessage["IsReply"].ToType <bool>()) { var replies1 = repository.GetReplies(orginalPMMessage, orginalPMMessage.ReplyTo.Value); if (replies1 != null) { messages.Merge(replies1); } } return(messages); }
private void Islevel(PMessage mess)//如果是离线消息 { if (mess.leave) { ulong ididid = mess.from; if (mess.from == modulePlayer.roleInfo.roleId) { ididid = mess.to; } bool o = friend_Id_key.Exists(a => a == ididid); Queue <ScChatPrivate> chat; ScChatPrivate scchat = SetPrivate(ididid, mess.type, mess.content, mess.tag); bool canaddlevel = past_mes.Exists(a => a == ididid); if (!canaddlevel) { moduleHome.UpdateIconState(HomeIcons.Friend, true); HavePastMes = true; past_mes.Add(ididid); } if (o) { friend_chat_record.TryGetValue(ididid, out chat); if (chat != null) { if (chat.Count >= ChatNum) { chat.Dequeue(); } chat.Enqueue(scchat); friend_chat_record.Remove(ididid); friend_chat_record.Add(ididid, chat); } } else { Queue <ScChatPrivate> ppp = new Queue <ScChatPrivate>(); ppp.Enqueue(scchat); friend_chat_record.Add(ididid, ppp); friend_Id_key.Add(ididid); } // Record(ididid.ToString(), typea.ToString(), conten, ididid.ToString()); } }
/// <summary> /// Binds the data. /// </summary> private void BindData() { using ( var dt = this.GetRepository <PMessage>().ListAsDataTable( Security.StringToLongOrRedirect(this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("pm")))) { if (dt.HasRows()) { var row = dt.Rows[0]; // if the pm isn't from or two the current user--then it's access denied /*if (row["ToUserID"].ToType<int>() != this.PageContext.PageUserID * && row["FromUserID"].ToType<int>() != this.PageContext.PageUserID) * { * YafBuildLink.AccessDenied(); * }*/ // Check if Message is Reply if (!row["ReplyTo"].IsNullOrEmptyDBField()) { var replyTo = row["ReplyTo"].ToType <int>(); var message = new PMessage { ReplyTo = row["ReplyTo"].ToType <int>(), ID = row["PMessageID"].ToType <int>() }; dt.Merge(this.GetRepository <PMessage>().GetReplies(message, replyTo)); } var dataView = dt.DefaultView; dataView.Sort = "Created ASC"; this.SetMessageView( row["FromUserID"], row["ToUserID"], Convert.ToBoolean(row["IsInOutbox"]), Convert.ToBoolean(row["IsArchived"])); // get the return link to the pm listing if (this.IsOutbox) { this.PageLinks.AddLink( this.GetText("SENTITEMS"), YafBuildLink.GetLink(ForumPages.cp_pm, "v=out")); } else if (this.IsArchived) { this.PageLinks.AddLink( this.GetText("ARCHIVE"), YafBuildLink.GetLink(ForumPages.cp_pm, "v=arch")); } else { this.PageLinks.AddLink(this.GetText("INBOX"), YafBuildLink.GetLink(ForumPages.cp_pm)); } this.PageLinks.AddLink(row["Subject"].ToString()); this.Inbox.DataSource = dataView; } else { YafBuildLink.Redirect(ForumPages.cp_pm); } } this.DataBind(); if (this.IsOutbox) { return; } var userPmessageId = this.Get <HttpRequestBase>().QueryString.GetFirstOrDefaultAs <int>("pm"); this.GetRepository <UserPMessage>().MarkAsRead(userPmessageId); this.Get <IDataCache>().Remove(Constants.Cache.ActiveUserLazyData.FormatWith(this.PageContext.PageUserID)); this.Get <IRaiseEvent>().Raise( new UpdateUserPrivateMessageEvent(this.PageContext.PageUserID, userPmessageId)); }
/// <summary> /// Binds the data. /// </summary> private void BindData() { using ( var dt = this.GetRepository <PMessage>().ListAsDataTable( Security.StringToLongOrRedirect(this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("pm")))) { if (dt.HasRows()) { var row = dt.GetFirstRow(); // Check if Message is Reply if (!row["ReplyTo"].IsNullOrEmptyDBField()) { var replyTo = row["ReplyTo"].ToType <int>(); var message = new PMessage { ReplyTo = row["ReplyTo"].ToType <int>(), ID = row["PMessageID"].ToType <int>() }; dt.Merge(this.GetRepository <PMessage>().GetReplies(message, replyTo)); } var dataView = dt.DefaultView; dataView.Sort = "Created ASC"; this.SetMessageView( row.Field <int>("FromUserID"), row.Field <int>("ToUserID"), row.Field <bool>("IsInOutbox"), row.Field <bool>("IsArchived")); // get the return link to the pm listing if (this.IsOutbox) { this.PageLinks.AddLink( this.GetText("SENTITEMS"), BuildLink.GetLink(ForumPages.MyMessages, "v=out")); } else if (this.IsArchived) { this.PageLinks.AddLink( this.GetText("ARCHIVE"), BuildLink.GetLink(ForumPages.MyMessages, "v=arch")); } else { this.PageLinks.AddLink(this.GetText("INBOX"), BuildLink.GetLink(ForumPages.MyMessages)); } this.PageLinks.AddLink(row["Subject"].ToString()); this.Inbox.DataSource = dataView; } else { BuildLink.Redirect(ForumPages.MyMessages); } } this.DataBind(); if (this.IsOutbox) { return; } var userMessageId = this.Get <HttpRequestBase>().QueryString.GetFirstOrDefaultAs <int>("pm"); this.GetRepository <UserPMessage>().MarkAsRead(userMessageId); this.Get <IDataCache>().Remove(string.Format(Constants.Cache.ActiveUserLazyData, this.PageContext.PageUserID)); this.Get <IRaiseEvent>().Raise( new UpdateUserPrivateMessageEvent(this.PageContext.PageUserID, userMessageId)); }