📄 users.cs
字号:
using System;
using System.Data;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;
/// <summary>
/// users 的摘要说明
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class users : System.Web.Services.WebService
{
public users()
{
//如果使用设计的组件,请取消注释以下行
//InitializeComponent();
}
private string code_ex(string src)
{
src = src.ToString().Trim();
src = src.Replace("<", "<");
src = src.Replace(">", ">");
src = src.Replace("\"", """);
src = src.Replace("\'", "´");
src = src.Replace("\0", " ");
return src;
}
[WebMethod(Description = "查询条件查询用户信息", EnableSession = true)]
public DataTable sel_usinf(string Name)
{
if (Session["ID"] != null)
{
DataTable table = DataManager.database.User.Copy();
table.Columns.Remove("IP");
for (int i = 0; i < table.Rows.Count; i++)
{
if (table.Rows[i]["Name"].ToString() != Name)
table.Rows[i].Delete();
if (table.Rows[i]["Hiden"].ToString() == "true")
table.Rows[i].Delete();
}
if (table.Rows.Count == 0)
return null;
return table;
}
else
return null;
}
[WebMethod(Description = "返回用户所有列表,可以指定房间ID", EnableSession = true)]
public DataTable li_allus(string roomid)
{
if (Session["ID"] != null)
{
DataRow row1;
DataTable table = DataManager.database.User.Copy();
table.Columns.Remove("IP");
if (roomid != "0")
{
int totle = table.Rows.Count;
for (int i = 0; i < totle; i++)
{
if (table.Rows[i]["ID"].ToString() == Session["ID"].ToString() || table.Rows[i]["RoomID"].ToString() != roomid || table.Rows[i]["Hiden"].ToString() == "True" && table.Rows[i]["ID"].ToString() != Session["ID"].ToString())
{
table.Rows[i].Delete();
i--;
totle--;
}
}
row1 = table.NewRow();
row1["ID"] = Session["ID"].ToString();
row1["Name"] = Session["Name"].ToString();
table.Rows.InsertAt(row1, 0);
return table;
}
return table;
}
else
{
return null;
}
}
[WebMethod(Description = "返回用户所有列表,根据进入房间ID", EnableSession = true)]
public DataTable li_us()
{
if (Session["ID"] != null)
{
DataRow row1;
string roomid = DataManager.CallColumn("User", "RoomID", Session["ID"].ToString());
DataTable table = DataManager.database.User.Copy();
table.Columns.Remove("IP");
int totle = table.Rows.Count;
if (roomid != "0")
{
for (int i = 0; i < totle; i++)
{
string row = table.Rows[i]["Hiden"].ToString();
if (table.Rows[i]["ID"].ToString() == Session["ID"].ToString() || table.Rows[i]["RoomID"].ToString() != roomid || table.Rows[i]["Hiden"].ToString() == "True" && table.Rows[i]["ID"].ToString() != Session["ID"].ToString())
{
table.Rows[i].Delete();
i--;
totle--;
}
}
row1 = table.NewRow();
row1["ID"] = Session["ID"].ToString();
row1["Name"] = Session["Name"].ToString();
table.Rows.InsertAt(row1, 0);
return table;
}
return table;
}
else
{
return null;
}
}
[WebMethod(Description = "修改昵称", EnableSession = true)]
public bool reset_usinf(string name)
{
if (Session["ID"] != null)
{
name = code_ex(name);
Session["Name"] = name;
if (DataManager.CallID("User", name) != string.Empty)
return false;
return DataManager.Replace("User", "ID = '" + Session["ID"].ToString() + "'", "Name", name);
}
else
return false;
}
[WebMethod(Description = "修改状态", EnableSession = true)]
public bool reset_ussta(string sta)
{
if (Session["ID"] != null)
{
return DataManager.Replace("User", "ID = '" + Session["ID"].ToString() + "'", "Hiden", sta);
}
else
return false;
}
[WebMethod(Description = "用户进入房间修改状态信息房间号", EnableSession = true)]
public bool reset_usrm(string roomid)
{
if (Session["ID"] != null)
{
string ID = Session["ID"].ToString();
string RoomID = DataManager.CallColumn("User", "RoomID", ID);
//检查用户所在房间是否为空,如果为空则删除;
if (RoomID != "0" && RoomID != "1")
{
int count = DataManager.FindRow("User", "RoomID = " + RoomID).Length;
if (count < 2)
{
DataManager.Del("Room", RoomID);
Application.Remove("Room" + RoomID);
}
}
if (DataManager.Replace("User", "ID = '" + Session["ID"].ToString() + "'", "RoomID", roomid))
return true;
else
return false;
}
else
return false;
}
[WebMethod(Description = "查询用户自己所在房间", EnableSession = true)]
public string sel_usrm()
{
if (Session["ID"] != null)
{
return DataManager.CallColumn("User", "RoomID", Session["ID"].ToString());
}
else
return null;
}
[WebMethod(Description = "退出系统", EnableSession = true)]
public void login_out()
{
if (Session["ID"] != null)
{
Session.Abandon();
}
}
[WebMethod(Description = "踢出用户", EnableSession = true)]
public bool kick_us(string id, string nameid)
{
if (Session["ID"] != null)
{
if (Session["Admin"] == null)
return false;
if (nameid == Session["ID"].ToString())
return false;
string AdminID = Session["ID"].ToString();
if (Session["Admin"].ToString() == "1" || AdminID == System.Configuration.ConfigurationManager.AppSettings["adminid"].ToString())
{
if (DataManager.Replace("User", "ID = '" + nameid + "'", "RoomID", 0))
return true;
else
return false;
}
else
return false;
}
else
return false;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -