private void ServerManager() { if (Request["serverType"] != null) { Application.Lock(); //加锁 //实例化Xml数据管理对象 string userID = Session["UserID"].ToString(); xdm = new XmlDataManager((XmlDocument)Application["chatMessageList"], (XmlDocument)Application["userList"], (XmlDocument)Application[userID]); string type = Request["serverType"].ToString().ToLower(); switch (type) { case "userlogin": userLoginManager(); //用户登陆处理方法 break; case "onlinerenew": OnlineRenewManager();//在线更新处理方法 break; case "messagesend": MessageSendManager(); //信息发送处理方法 break; default: Response.Write("Error: 未定义的服务类型:" + type); Application.UnLock(); //解锁 break; } } else { Response.Write("Error: 未指定服务类型。"); } }
protected void LoginBtn_Click(object sender, EventArgs e) { Logic.Login mlogin = new Logic.Login(); int mFlag1 = mlogin.CheckLogin(txtUserEmail.Text, txtUserPassword.Text); //判断邮箱是否存在 if (mFlag1 == 1)//如果存在,跳转到个人主页 { AddFriend adf = new AddFriend(); string userid = txtUserEmail.Text.ToString(); Session["UserID"] = userid; Session["UserName"] = adf.SearchName(userid); if (Application[userid] == null) { XmlDataManager xdm = new XmlDataManager(); Application[userid] = xdm.InitialChatPrivateMessageXml; Response.Redirect("ChatPerhome.aspx");//跳转到个人主页 } else Response.Redirect("ChatPerhome.aspx");//跳转到个人主页 //Page.ClientScript.RegisterStartupScript(Page.GetType(), "Message", "<script Language='javascript'>alert('用户已登录,不可以重复登录!')</script>"); } else//如果不存在,输出用户名或密码错误 { Page.ClientScript.RegisterStartupScript(Page.GetType(), "Message", "<script Language='javascript'>alert('用户名或密码错误,请重新输入!')</script>"); } }