📄 accessdbcom.cs
字号:
using System;
using Motion.DZ;
namespace Motion.DZ.DB
{
public class AccessDbCom : SqlServerDbCom
{
public override bool Login(string username, string password, int expDays, bool inVisisble, string reFerer)
{
string Sql = String.Format("select top 1 tpp,ppp,pmsound,invisible,sigstatus,uid from [{1}users] where username='{0}'", username, Motion.DZ.Command.RC.Tableprefix);
System.Data.DataTable myDt = Motion.DZ.Command.DBC.vDataTable(Sql);
if (Object.Equals(myDt, null) || myDt.Rows.Count <= 0)
{
Motion.DZ.Command.Register(username, 0, String.Empty, password, 11, String.Empty);
myDt = Motion.DZ.Command.DBC.vDataTable(Sql);
}
GetUserInfo userinfo = new GetUserInfo(myDt);
if (Object.Equals(myDt, null) || myDt.Rows.Count <= 0) return false;
Motion.DZ.Command.DBC.vExecuteNonQuery(String.Format("UPDATE [{0}users] SET [lastvisit]=Now(), [lastip]='{2}' WHERE [username]='{1}'", Motion.DZ.Command.RC.Tableprefix, username, Motion.DZ.Command.RC.UserIP));
return Motion.DZ.Command.WriteLoginCookie(userinfo, inVisisble, reFerer, expDays, password);
}
public override void LoginOut()
{
try
{
System.Web.HttpCookie cookie = System.Web.HttpContext.Current.Request.Cookies["dnt"];
if (Object.Equals(cookie, null))
{
cookie = new System.Web.HttpCookie("dnt");
}
else
{
if (!Object.Equals(cookie.Values["userid"], null))
{
string Uid = cookie.Values["userid"].ToString();
if (!String.IsNullOrEmpty(Uid))
{
int uid;
Int32.TryParse(Uid, out uid);
Motion.DZ.Command.DBC.vExecuteNonQuery(String.Format("UPDATE [{0}users] SET [oltime] = [oltime] + DATEDIFF(n,[lastvisit],Now()) WHERE [uid]={1};delete from [{0}online] where userid={1};", Motion.DZ.Command.RC.Tableprefix, uid));
}
}
}
cookie.Values.Clear();
cookie.Expires = DateTime.Now.AddYears(-1);
if (Motion.DZ.Command.IsValidDomain(Motion.DZ.Command.RC.doMain))
{
cookie.Domain = Motion.DZ.Command.RC.doMain;
}
System.Web.HttpContext.Current.Response.AppendCookie(cookie);
}
catch
{ }
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -