Example #1
0
		protected void Page_Load(object sender, EventArgs e)
		{
            if (_Request.Get("ignore", Method.Get) != null)
            {
                ChatBO.Instance.IgnoreAllMessage(MyUserID);
                Response.Clear();
                Response.End();
                return;
            }

            if (_Request.Get("ignoresession", Method.Get) != null)
            {
                IsPostBack = 1;
                ChatBO.Instance.IgnoreSession(MyUserID, _Request.Get<int>("userid", Method.Get, -1));
            }

            if (My.UnreadMessages > 0)
            {
                UserBO.Instance.FillSimpleUsers(SessionList, 0);
            }
            else
            {
                m_SessionList = new ChatSessionCollection();
            }
		}
Example #2
0
        public override ChatSessionCollection GetChatSessions(int userID, int pageNumber, int pageSize)
        {
            ChatSessionCollection results = new ChatSessionCollection();
            using (SqlQuery query = new SqlQuery())
            {
                query.Pager.TableName = "bx_ChatSessions";
                query.Pager.PrimaryKey = "ChatSessionID";
                query.Pager.SortField = "UpdateDate";
                query.Pager.PageNumber = pageNumber;
                query.Pager.PageSize = pageSize;
                query.Pager.IsDesc = true;
                query.Pager.SelectCount = true;
                query.Pager.Condition = "UserID = @UserID";

                query.CreateParameter<int>("@UserID", userID, SqlDbType.Int);

                using (XSqlDataReader reader = query.ExecuteReader())
                {
                    results = new ChatSessionCollection(reader);
                    while (reader.NextResult())
                    {
                        while (reader.Read())
                        {
                            results.TotalRecords = reader.Get<int>(00);
                        }
                    }
                }
            }
            return results;
        }
Example #3
0
        public override ChatSessionCollection AdminGetSessions(ChatSessionFilter filter, int pageNumber, IEnumerable<Guid> excludeRoleIds)
        {
            ChatSessionCollection sessions;
            using (SqlQuery query = new SqlQuery())
            {
                string excludeRoleCondition = DaoUtil.GetExcludeRoleSQL("UserID", excludeRoleIds, query);
                StringBuffer buffer = new StringBuffer();

                if (filter.UserID != null)
                {
                    buffer += " AND UserID = @UserID";
                    query.CreateParameter<int>("@UserID", filter.UserID.Value, SqlDbType.Int);
                }

                if (!string.IsNullOrEmpty(filter.Username))
                {
                    buffer += " AND UserID IN( SELECT UserID FROM bx_Users WHERE Username LIKE '%'[email protected]+'%' ) OR  TargetUserID IN( SELECT UserID FROM bx_Users WHERE Username LIKE '%'[email protected]+'%' )";
                    query.CreateParameter<string>("@Username", filter.Username, SqlDbType.NVarChar, 50);
                }
                //if (!string.IsNullOrEmpty(filter.TargetUsername))
                //{
                //    buffer += " AND TargetUserID IN( SELECT UserID FROM bx_Users WHERE Username LIKE '%'[email protected]+'%' )";
                //    query.CreateParameter<string>("@TargetUser", filter.TargetUsername, SqlDbType.NVarChar, 50);
                //}

                //if (!string.IsNullOrEmpty(filter.Contains))
                //{
                //    buffer +=" AND ChatSessionID IN( SELECT  ) "
                //}

                if (filter.BeginDate != null)
                {
                    buffer += " AND CreateDate >= @BeginDate";
                    query.CreateParameter<DateTime>("@BeginDate", filter.BeginDate.Value, SqlDbType.DateTime);
                }
                if (filter.EndDate != null)
                {
                    buffer += " AND UpdateDate <= @EndDate";
                    query.CreateParameter<DateTime>("@EndDate", filter.EndDate.Value, SqlDbType.DateTime);
                }

                if (!string.IsNullOrEmpty(excludeRoleCondition))
                {
                    buffer += " AND " + excludeRoleCondition;
                    excludeRoleCondition = DaoUtil.GetExcludeRoleSQL("TargetUserID", excludeRoleIds, query);
                    buffer += " AND " + excludeRoleCondition;
                }

                if (buffer.Length > 0)
                    buffer.Remove(0, 5);

                //query.CommandText = "SELECT * FROM bx_ChatSessions";
                query.Pager.TableName = "bx_ChatSessions";
                query.Pager.PrimaryKey = "ChatSessionID";
                query.Pager.PageNumber = pageNumber;
                query.Pager.PageSize = filter.PageSize;
                query.Pager.SortField = "ChatSessionID";
                query.Pager.IsDesc = true;
                query.Pager.SelectCount = true;
                query.Pager.Condition = buffer.ToString();

                using (XSqlDataReader reader = query.ExecuteReader())
                {
                    sessions = new ChatSessionCollection(reader);
                    while (reader.NextResult())
                        if (reader.Read())
                            sessions.TotalRecords = reader.GetInt32(0);
                }
            }
            return sessions;
        }
Example #4
0
        public override ChatSessionCollection GetChatSessionsWithUnreadMessages(int userID, int topCount)
        {
            ChatSessionCollection result;

            using (SqlQuery query = new SqlQuery())
            {
                query.CommandText = "SELECT TOP (@TopCount) * FROM bx_ChatSessions WHERE UserID = @UserID AND UnreadMessages > 0 ORDER BY UpdateDate DESC";


                query.CreateTopParameter("@TopCount", topCount);

                query.CreateParameter<int>("@UserID", userID, SqlDbType.Int);

                using (XSqlDataReader reader = query.ExecuteReader())
                {
                    result = new ChatSessionCollection(reader);
                }
            }

            return result;
        }
Example #5
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            AddNavigationItem("对话");

            if (!EnableChatFunction)
            {
                ShowError("管理员已关闭对话功能!");
                return;
            }

            m_PageNumber = _Request.Get<int>("page", Method.All, 0);
            m_MessagePageNumber = _Request.Get<int>("msgpage", Method.All, 0);
            m_TargetUserID = _Request.Get<int>("to", Method.All, 0);

            if (m_TargetUserID > 0)
            {
                m_SelectedChatSession = ChatBO.Instance.GetChatSession(MyUserID, m_TargetUserID);

                if (m_SelectedChatSession == null)
                    m_TargetUserID = 0;

                else
                    WaitForFillSimpleUser<ChatSession>(m_SelectedChatSession, 0);

                bool updateIsReade = false;
                if (m_MessagePageNumber == 1)
                    updateIsReade = true;

                m_ChatMessageList = ChatBO.Instance.GetChatMessages(MyUserID, m_TargetUserID, m_MessagePageNumber, c_MessagePageSize, updateIsReade);

                m_ChatMessageList.Reverse();

                int totalPageNumber = (int)Math.Ceiling((double)m_ChatMessageList.TotalRecords / (double)c_MessagePageSize);
                if (m_MessagePageNumber == 0)
                {
                    m_MessagePageNumber = totalPageNumber;
                }
                else
                {
                    m_MessagePageNumber = (totalPageNumber + 1) - m_MessagePageNumber;
                }

                WaitForFillSimpleUsers<ChatMessage>(m_ChatMessageList, 0);

                SetPager("messagelist", BbsRouter.GetUrl("my/chat", "page=" + m_PageNumber + "&to=" + TargetUserID + "&msgpage={0}"), m_MessagePageNumber, c_MessagePageSize, m_ChatMessageList.TotalRecords);
            }

            if (_Request.IsClick("beginChat"))
            {
                ProcessBeginChat();
            }

            m_ChatSessionList = ChatBO.Instance.GetChatSessions(MyUserID, m_PageNumber, c_SessionPageSize);
            WaitForFillSimpleUsers<ChatSession>(m_ChatSessionList, 0);

            SetPager("chatlist", BbsRouter.GetUrl("my/chat", "page={0}"), m_PageNumber, c_SessionPageSize, m_ChatSessionList.TotalRecords);
        }