2021-04-30 10:28:37 +08:00
|
|
|
|
namespace BLL
|
|
|
|
|
{
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Web.Security;
|
|
|
|
|
using System.Web;
|
|
|
|
|
using EmitMapper;
|
|
|
|
|
using Model;
|
|
|
|
|
|
|
|
|
|
public static class LoginService
|
|
|
|
|
{
|
|
|
|
|
public static SGGLDB db = Funs.DB;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20>û<EFBFBD><C3BB><EFBFBD>¼<EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="loginname"><3E><>¼<EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD></param>
|
|
|
|
|
/// <param name="password">δ<><CEB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD></param>
|
|
|
|
|
/// <param name="rememberMe"><3E><>ס<EFBFBD>ҿ<EFBFBD><D2BF><EFBFBD></param>
|
|
|
|
|
/// <param name="page"><3E><><EFBFBD><EFBFBD>ҳ<EFBFBD><D2B3></param>
|
|
|
|
|
/// <returns><3E>Ƿ<EFBFBD><C7B7><EFBFBD>¼<EFBFBD>ɹ<EFBFBD></returns>
|
|
|
|
|
public static bool UserLogOn(string account, string password, bool rememberMe, System.Web.UI.Page page)
|
|
|
|
|
{
|
|
|
|
|
List<Sys_User> x = (from y in Funs.DB.Sys_User
|
|
|
|
|
where y.Account == account && y.IsPost == true && y.Password == Funs.EncryptionPassword(password)
|
|
|
|
|
select y).ToList();
|
|
|
|
|
if (x.Any())
|
|
|
|
|
{
|
|
|
|
|
string accValue = HttpUtility.UrlEncode(account);
|
|
|
|
|
FormsAuthentication.SetAuthCookie(accValue, false);
|
|
|
|
|
page.Session[SessionName.CurrUser] = x.First();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-17 15:22:38 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// OA <20><><EFBFBD>˺ŵ<CBBA>½
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="account"></param>
|
|
|
|
|
/// <param name="password"></param>
|
|
|
|
|
/// <param name="rememberMe"></param>
|
|
|
|
|
/// <param name="page"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static bool UserLogOn_OA(string account, bool rememberMe, System.Web.UI.Page page)
|
|
|
|
|
{
|
|
|
|
|
List<Sys_User> x = (from y in Funs.DB.Sys_User
|
|
|
|
|
where y.Account == account && y.IsPost == true
|
|
|
|
|
select y).ToList();
|
|
|
|
|
if (x.Any())
|
|
|
|
|
{
|
|
|
|
|
string accValue = HttpUtility.UrlEncode(account);
|
|
|
|
|
FormsAuthentication.SetAuthCookie(accValue, false);
|
|
|
|
|
page.Session[SessionName.CurrUser] = x.First();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-30 10:28:37 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20>û<EFBFBD><C3BB><EFBFBD>¼<EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="loginname"><3E><>¼<EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD></param>
|
|
|
|
|
/// <param name="password">δ<><CEB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD></param>
|
|
|
|
|
/// <param name="rememberMe"><3E><>ס<EFBFBD>ҿ<EFBFBD><D2BF><EFBFBD></param>
|
|
|
|
|
/// <param name="page"><3E><><EFBFBD><EFBFBD>ҳ<EFBFBD><D2B3></param>
|
|
|
|
|
/// <returns><3E>Ƿ<EFBFBD><C7B7><EFBFBD>¼<EFBFBD>ɹ<EFBFBD></returns>
|
|
|
|
|
public static bool UserLogOn(string account, bool rememberMe, System.Web.UI.Page page)
|
|
|
|
|
{
|
|
|
|
|
List<Sys_User> x = (from y in Funs.DB.Sys_User
|
|
|
|
|
where y.Account == account && y.IsPost == true
|
|
|
|
|
select y).ToList();
|
|
|
|
|
if (x.Any())
|
|
|
|
|
{
|
|
|
|
|
string accValue = HttpUtility.UrlEncode(account);
|
|
|
|
|
FormsAuthentication.SetAuthCookie(accValue, false);
|
|
|
|
|
page.Session[SessionName.CurrUser] = x.First();
|
|
|
|
|
if (rememberMe)
|
|
|
|
|
{
|
|
|
|
|
System.Web.HttpCookie u = new System.Web.HttpCookie("UserInfo");
|
|
|
|
|
u["username"] = accValue;
|
|
|
|
|
//u["password"] = password;
|
|
|
|
|
// Cookies<65><73><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊһ<CEAA><D2BB>.
|
|
|
|
|
u.Expires = DateTime.Now.AddYears(1);
|
|
|
|
|
page.Response.Cookies.Add(u);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// <20><>ѡ<EFBFBD><EFBFBD><F1B2BBB1><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD>ʱ,Cookies<65><73><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>.
|
|
|
|
|
page.Response.Cookies["UserInfo"].Expires = DateTime.Now.AddDays(-1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|