You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.7 KiB
51 lines
1.7 KiB
using System;
|
|
namespace NFine.Code
|
|
{
|
|
public class OperatorProvider
|
|
{
|
|
public static OperatorProvider Provider
|
|
{
|
|
get { return new OperatorProvider(); }
|
|
}
|
|
private string LoginUserKey = "nfine_loginuserkey_2016";
|
|
private string LoginProvider = Configs.GetValue("LoginProvider");
|
|
|
|
public OperatorModel GetCurrent()
|
|
{
|
|
OperatorModel operatorModel = new OperatorModel();
|
|
if (LoginProvider == "Cookie")
|
|
{
|
|
operatorModel = DESEncrypt.Decrypt(WebHelper.GetCookie(LoginUserKey).ToString()).ToObject<OperatorModel>();
|
|
}
|
|
else
|
|
{
|
|
operatorModel = DESEncrypt.Decrypt(WebHelper.GetSession(LoginUserKey).ToString()).ToObject<OperatorModel>();
|
|
}
|
|
return operatorModel;
|
|
}
|
|
public void AddCurrent(OperatorModel operatorModel)
|
|
{
|
|
if (LoginProvider == "Cookie")
|
|
{
|
|
WebHelper.WriteCookie(LoginUserKey, DESEncrypt.Encrypt(operatorModel.ToJson()), 60);
|
|
}
|
|
else
|
|
{
|
|
WebHelper.WriteSession(LoginUserKey, DESEncrypt.Encrypt(operatorModel.ToJson()));
|
|
}
|
|
WebHelper.WriteCookie("nfine_mac", Md5.md5(Net.GetMacByNetworkInterface().ToJson(), 32));
|
|
WebHelper.WriteCookie("nfine_licence", Licence.GetLicence());
|
|
}
|
|
public void RemoveCurrent()
|
|
{
|
|
if (LoginProvider == "Cookie")
|
|
{
|
|
WebHelper.RemoveCookie(LoginUserKey.Trim());
|
|
}
|
|
else
|
|
{
|
|
WebHelper.RemoveSession(LoginUserKey.Trim());
|
|
}
|
|
}
|
|
}
|
|
}
|