Ejemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Guid guid = new Guid();
            if (Session["Guid"] != null) {
                guid = (Guid)Session["Guid"];
                try { m_chatter = Chatter.ActiveChatters()[guid]; } catch { Response.Redirect("Default.aspx"); }
                m_chat = m_chatter.MainChat;

                _UpdateChatterList();
                _UpdateChatMessageList();
                WelcomeLabel.Text = "Hallo " + m_chatter.Name;
            } else {
                Response.Redirect("Default.aspx");
                return;
            }

            if (IsPostBack) {
                if (m_chatter != null && m_chat != null) {
                    String n = FriendRequestId.Value;
                    if (!String.IsNullOrEmpty(n)) {
                        if (Session["PrevHiddenValue"] == null || n != Session["PrevHiddenValue"].ToString()) {
                            Session["PrevHiddenValue"] = n;

                            List<Record> userList = DBConnectionHelper.ReadUserRecords();
                            Record userRecord = null;
                            foreach (Record record in userList) {
                                if (record.Entries[DBConnectionHelper._columnName].ToLower() == n.ToLower()) {
                                    userRecord = record;
                                    break;
                                }
                            }

                            if (userRecord != null) {
                                int friendId = Convert.ToInt32(userRecord.Entries["ID"]);

                                if (!m_chatter.buddyList.Contains(friendId)) {
                                    if (DBConnectionHelper.FriendUsers(m_chatter.intId, friendId)) {
                                        m_chatter.buddyList.Add(friendId);
                                        foreach (Chatter chatter in Chatter.ActiveChatters().Values) {
                                            if (chatter.intId == friendId) {
                                                chatter.buddyList.Add(m_chatter.intId);
                                                m_chatter.myBuddies.Add(chatter);
                                                chatter.myBuddies.Add(m_chatter);
                                                updateAll();
                                                break;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void updateAll()
        {
            m_chat = m_chatter.MainChat;
            _UpdateChatterList();
            _UpdateChatMessageList();
            _UpdateAllChatter();
            m_chat.iAmUpToDate(m_chatter.intId);

            _UpdateChatRooms();
            if (m_chatter.mainChat == 0)
                ChatRoomNameLabel.Text = "[0] Main Chatroom";
            else
                ChatRoomNameLabel.Text = String.Format("[{0}] {1}", m_chatter.mainChat, m_chat);
            ChatUpdatePanel.Update();
            NewMessageTextBox.Focus();
        }