📄 chatroom.aspx.cs
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.OleDb;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace xajh.chat
{
/// <summary>
/// chatroom 的摘要说明。
/// </summary>
public class chatroom : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Literal asp_namelist;
protected System.Web.UI.WebControls.Literal asp_selfname;
protected System.Web.UI.WebControls.Literal asp_sex;
protected System.Web.UI.WebControls.Literal asp_grade;
protected System.Web.UI.WebControls.Literal asp_figthgrade;
protected System.Web.UI.WebControls.Literal asp_class;
protected System.Web.UI.WebControls.Literal asp_head;
protected System.Web.UI.WebControls.Literal asp_job;
protected System.Web.UI.WebControls.Literal asp_leave;
protected System.Web.UI.WebControls.Literal asp_bg;
protected System.Web.UI.WebControls.Literal asp_roomid;
protected System.Web.UI.WebControls.Literal asp_roomname;
protected System.Web.UI.WebControls.Literal asp_roomautoman;
protected System.Web.UI.WebControls.Literal asp_image;
protected System.Web.UI.WebControls.Literal asp_title;
protected System.Web.UI.WebControls.Literal asp_admin;
protected System.Web.UI.WebControls.Literal asp_xajh_name;
protected System.Web.UI.WebControls.Literal asp_xajh_user;
protected System.Web.UI.WebControls.Literal asp_xajh_sn;
private string roomid;
private x.UserInfo info;
private x.RoomInfo roominfo;
private void Page_Load(object sender, System.EventArgs e)
{
if (this.Session["info"] == null)
{
this.Server.Transfer ("../error.aspx?v=relogin");
}
roomid = this.Request.QueryString["roomid"];
if (roomid == null || roomid.Trim() == "")
{
this.Server.Transfer ("../error.aspx?v=请指定房间的ID号!");
}
roomid = roomid.Trim();
if (var.public_roomlist.IndexOf(roomid) == -1)
{
this.Server.Transfer ("../error.aspx?v=不存在该房间!");
}
roominfo = (x.RoomInfo) this.Application["byts_xajh_chat_roominfo_" + roomid];
ArrayList online;
Hashtable onlineinfo = var.public_onlineinfo;
info = (x.UserInfo) this.Session["info"];
if (info.RoomID != "false")
{
if (info.RoomID != roomid)
{
checkinto();
info.MsgLine = (int) this.Application["byts_xajh_chat_line_" + roomid];
string byts_oldroom = "<font style=\\\"color:#0000FF\\\">" + ((x.RoomInfo) this.Application["byts_xajh_chat_roominfo_" + info.RoomID]).RoomName + "</font>";
string byts_newroom = "<font style=\\\"color:#0000FF\\\">" + roominfo.RoomName + "</font>";
string[] aword = new string[9];
aword[0] = "del";
aword[1] = info.UserName;
aword[2] = "";
aword[3] = "";
aword[4] = "";
aword[5] = "";
aword[6] = var.public_delroom.Replace("(old)",byts_oldroom).Replace("(new)",byts_newroom);
aword[7] = "退出";
aword[8] = DateTime.Now.ToLongTimeString();
this.Application.Lock();
//删除原房间
((ArrayList) this.Application["byts_xajh_chat_online_" + info.RoomID]).Remove(info.UserName);
//结束
ArrayList words = (ArrayList) this.Application["byts_xajh_chat_words_" + info.RoomID];
words.Add(aword);
words.RemoveAt(0);
this.Application["byts_xajh_chat_line_" + info.RoomID] = (int) this.Application["byts_xajh_chat_line_" + info.RoomID] + 1;
aword = new string[9];
aword[0] = "add";
aword[1] = info.UserName;
aword[2] = "";
aword[3] = var.public_onlineinfo[info.UserName].ToString();
aword[4] = "";
aword[5] = "";
aword[6] = var.public_addroom.Replace("(old)",byts_oldroom).Replace("(new)",byts_newroom);
aword[7] = "进入";
aword[8] = DateTime.Now.ToLongTimeString();
words = (ArrayList) this.Application["byts_xajh_chat_words_" + roomid];
words.Add(aword);
words.RemoveAt(0);
this.Application["byts_xajh_chat_line_" + roomid] = (int) this.Application["byts_xajh_chat_line_" + roomid] + 1;
//加入新房间
online = (ArrayList) this.Application["byts_xajh_chat_online_" + roomid];
online.Add(info.UserName);
//结束
this.Application.UnLock();
}
else
{
info.MsgLine = (int) this.Application["byts_xajh_chat_line_" + roomid];
online = (ArrayList) this.Application["byts_xajh_chat_online_" + roomid];
}
}
else
{
checkinto();
info.MsgLine = (int) this.Application["byts_xajh_chat_line_" + roomid];
string[] aword = new string[9];
aword[0] = "add";
aword[1] = info.UserName;
aword[2] = "";
aword[3] = var.public_onlineinfo[info.UserName].ToString();
aword[4] = "";
aword[5] = "";
aword[6] = var.public_add;
aword[7] = "进入";
aword[8] = DateTime.Now.ToLongTimeString();
this.Application.Lock();
ArrayList words = (ArrayList) this.Application["byts_xajh_chat_words_" + roomid];
words.Add(aword);
words.RemoveAt(0);
this.Application["byts_xajh_chat_line_" + roomid] = (int) this.Application["byts_xajh_chat_line_" + roomid] + 1;
online = (ArrayList) this.Application["byts_xajh_chat_online_" + roomid];
online.Add(info.UserName);
var.public_inchat ++;
this.Application.UnLock();
info.LastSave = DateTime.Now;
info.CloseDoor = false;
}
info.RoomID = roomid;
info.LastSaid = DateTime.Now;
this.Session["info"] = info;
string namelist = "\"" + onlineinfo[online[0]] + "\"";
int j = online.Count;
for (int i = 1; i < j; i ++)
{
namelist += ",\"" + onlineinfo[online[i]] + "\"";
}
if (info.Ico > 84)
{
this.asp_leave.Text = "true";
}
else
{
this.asp_leave.Text = "false";
}
this.asp_xajh_name.Text = var.public_name;
this.asp_xajh_user.Text = var.public_user;
this.asp_xajh_sn.Text = var.public_sn;
this.asp_selfname.Text = info.UserName;
this.asp_sex.Text = info.Sex;
this.asp_grade.Text = info.Grade.ToString();
this.asp_figthgrade.Text = info.FGrade.ToString();
this.asp_class.Text = info.MyClass;
this.asp_head.Text = info.MyHead;
this.asp_job.Text = info.MyJob;
this.asp_bg.Text = info.CloseDoor.ToString().ToLower();
this.asp_roomid.Text = roomid;
this.asp_roomname.Text = roominfo.RoomName;
this.asp_roomautoman.Text = roominfo.AutoMan;
this.asp_namelist.Text = namelist;
this.asp_title.Text = var.public_title.ToString();
this.asp_image.Text = var.public_pbc.ToString();
this.asp_admin.Text = var.public_adminclass;
}
private void checkinto()
{
if (roominfo.MaxOnline != -1 && ((ArrayList) this.Application["byts_xajh_chat_online_" + roomid]).Count >= roominfo.MaxOnline)
{
this.Server.Transfer ("../error.aspx?v=该房间已经满员,请选择其他的房间进入!");
}
if (roominfo.MinGrade != -1 && info.Grade < roominfo.MinGrade)
{
this.Server.Transfer ("../error.aspx?v=本房间禁止等级小于 {" + roominfo.MinGrade + "} 的用户进入!");
}
if (roominfo.MaxGrade != -1 && info.Grade > roominfo.MaxGrade)
{
this.Server.Transfer ("../error.aspx?v=本房间禁止等级大于 {" + roominfo.MaxGrade + "} 的用户进入!");
}
if (roominfo.MinFGrade != -1 && info.FGrade < roominfo.MinFGrade)
{
this.Server.Transfer ("../error.aspx?v=本房间禁止战斗等级小于 {" + roominfo.MinFGrade + "} 的用户进入!");
}
if (roominfo.MaxFGrade != -1 && info.FGrade > roominfo.MaxFGrade)
{
this.Server.Transfer ("../error.aspx?v=本房间禁止战斗等级大于 {" + roominfo.MaxFGrade + "} 的用户进入!");
}
if (roominfo.MinGGrade != -1 && info.Gold < roominfo.MinGGrade)
{
this.Server.Transfer ("../error.aspx?v=本房间禁止会员等级小于 {" + roominfo.MinGGrade + "} 的用户进入!");
}
if (roominfo.MaxGGrade != -1 && info.Gold > roominfo.MaxGGrade)
{
this.Server.Transfer ("../error.aspx?v=本房间禁止会员等级大于 {" + roominfo.MaxGGrade + "} 的用户进入!");
}
if (roominfo.CheckSex == "boy" && info.Sex != "boy")
{
this.Server.Transfer ("../error.aspx?v=本房间只允许性别为 {男} 的用户进入!");
}
if (roominfo.CheckSex == "girl" && info.Sex != "girl")
{
this.Server.Transfer ("../error.aspx?v=本房间只允许性别为 {女} 的用户进入!");
}
if (roominfo.CheckIn != "(无)")
{
OleDbConnection MyConn = new OleDbConnection(var.public_conn);
MyConn.Open();
OleDbCommand MyComm = new OleDbCommand(@"select null from [注册用户] where [id]=" + info.DataID + " and " + roominfo.CheckIn, MyConn);
OleDbDataReader dr = MyComm.ExecuteReader();
if (!dr.Read())
{
dr.Close();
MyConn.Close();
MyConn.Dispose();
this.Server.Transfer ("../error.aspx?v=进入本房间必须符合 {" + roominfo.CheckIn + "} 的条件!");
}
else
{
dr.Close();
MyConn.Close();
MyConn.Dispose();
}
}
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -