/// <summary>
 /// 信息发送管理方法
 /// </summary>
 private void MessageSendManager()
 {
     string sendMsg = Request["userMessage"].ToString();
     string name = Request["userName"].ToString();
     string userID = Request["userID"].ToString();
     string receiverID = Request["ReceiverID"].ToString();
     DateTime renewTime = DateTime.Parse(Request["userListRenewTime"].ToString());
     string time = DateTime.Now.TimeOfDay.ToString();
     int pos = time.IndexOf('.');
     if (pos > -1)
         time = time.Substring(0, pos);
     string temp = "【" + name + "(" + userID + ")】说:" + time + "\n " + sendMsg;
     if (Application[receiverID] != null)
     {
         Application[receiverID] = xdm.AddMessage(userID, (XmlDocument)Application[receiverID], temp);    //新添加用户发送的信息
     }
     else
     {
         OfflineMessage ofm = new OfflineMessage();
         ofm.OffMessage(userID, receiverID, sendMsg);
     }
     string res = xdm.GetResponseText(userID, renewTime);
     Application["userList"] = xdm.XmlUserList;
     Application[userID] = xdm.InitialChatPrivateMessageXml;
     //Application["chatMessageList"] = xdm.XmlChatMessage;
     Application.UnLock();
     Response.Write(res);
 }
Example #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.Buffer = true;                                             //退出无法返回
            Response.ExpiresAbsolute = System.DateTime.Now.AddSeconds(-1);
            Response.Expires = 0;
            Response.CacheControl = "no-cache";
            if (Session["UserID"] == null)
            {
                Response.Redirect("ChatLogin.aspx");
            }
            if (!IsPostBack)
            {
                SelfMessage mSelfMessage = new SelfMessage();                    //显示个人信息
                DataTable mMess = mSelfMessage.ShowSelfMessage(Session["UserID"].ToString());
                this.text1.Text = mMess.Rows[0]["UserName"].ToString();
                this.text2.Text =Session["UserID"].ToString();
                this.text3.Text = mMess.Rows[0]["Remark"].ToString();
                AddFriend mAddFriend = new AddFriend();                         //显示添加信息
                DataTable mGetM = mAddFriend.GetAddMessage(Session["UserID"].ToString());
                if (mGetM.Rows.Count > 0)
                {
                    this.Button7.Visible = true;
                    DropDownList1.DataSource = mGetM;
                    DropDownList1.DataTextField = "UserEmail";
                    DropDownList1.DataValueField = "UserEmail";
                    DropDownList1.DataBind();
                }

                OfflineMessage mOfflineMessage = new OfflineMessage();          //显示离线信息
                DataTable mGOffM = mOfflineMessage.GetOffMessage(Session["UserID"].ToString());

                if (mGOffM.Rows.Count > 0)
                {
                    this.Button6.Visible = true;
                    this.TextBox3.Text = null;
                    for (int i = 0; i < mGOffM.Rows.Count; i++)
                    {

                        this.TextBox3.Text += mGOffM.Rows[i]["SenderEmail"].ToString() +mGOffM.Rows[i]["Time"].ToString() + "说:\n" + mGOffM.Rows[i]["Message"].ToString() + "\n";
                        mOfflineMessage.DeleteOffMessage(Session["UserID"].ToString(), mGOffM.Rows[i]["SenderEmail"].ToString());
                    }
                }

            }
        }