📄 room.cs
字号:
using System;
using System.Data;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;
/// <summary>
/// room 的摘要说明
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class room : System.Web.Services.WebService {
public room () {
//如果使用设计的组件,请取消注释以下行
//InitializeComponent();
}
[WebMethod(Description = "返回当前房间列表信息", EnableSession = true)]
public DataTable li_rm()
{
if (Session["ID"] != null)
{
DataTable table = DataManager.database.Room.Copy();
table.Columns.Remove("AdminID");
return table;
}
else
{
return null;
}
}
[WebMethod(Description = "创建房间输入信息Name,返回房间ID", EnableSession = true)]
public string set_rm(string name)
{
if (Session["ID"] != null&&Session["Admin"] != null)
{
if (DataManager.CallID("Room", name) == string.Empty)
{
DataBase.RoomRow row = DataManager.database.Room.NewRoomRow();
row["Name"] = name;
row["Admin"] = Session["Name"].ToString();
row["AdminID"] = Session["ID"].ToString();
row["Time"] = DateTime.Now;
string id = DataManager.Add("Room", row);
ArrayList ms = new ArrayList();
Message me = new Message();
me.color = "red";
me.face = "1";
me.hiden = false;
me.sender = Session["Name"].ToString();
me.size = "6";
me.text = "欢迎进入房间(" + name + "),管理员是" + Session["Name"].ToString() + "。";
me.time = DateTime.Now;
me.receiver = "所有人";
ms.Add(me);
Application.Lock();
Application["Room" + id] = ms;
Application.UnLock();
return id;
}
else
{
return "0";
}
}
else
{
return null;
}
}
[WebMethod(Description = "删除指定ID房间,需要房主或管理员账号", EnableSession = true)]
public bool del_rm(string id)
{
if (Session["ID"] != null)
{
string AdminID = Session["ID"].ToString();
if (DataManager.CallColumn("Room", "AdminID", id) == AdminID || AdminID == System.Configuration.ConfigurationManager.AppSettings["adminid"].ToString())
{
if (DataManager.Del("Room", id))
{
Application.Remove("Room"+id);
return true;
}
else
return false;
}
else
return false;
}
else
return false;
}
[WebMethod(Description = "修改房间信息,需要房主或管理员账号", EnableSession = true)]
public bool reset_rminf(string id, string Name, string AdminID)
{
if (Session["ID"] != null)
{
if (DataManager.CallColumn("Room", "AdminID", id) == AdminID || AdminID == System.Configuration.ConfigurationManager.AppSettings["adminid"].ToString())
{
if (DataManager.Replace("Room", "ID = '" + id + "'", "Name", Name))
{
return true;
}
else
return false;
}
else
return false;
}
else
return false;
}
[WebMethod(Description = "根据ID查看房间的信息", EnableSession = true)]
public DataTable sel_rminf(string id)
{
if (Session["ID"] != null)
{
DataTable table = DataManager.database.Room.Copy();
table.Columns.Remove("AdminID");
for (int i = 0; i < table.Rows.Count; i++)
{
if (table.Rows[i]["ID"].ToString() != id)
table.Rows[i].Delete();
}
if (table.Rows.Count == 0)
return null;
return table;
}
else
return null;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -