|
|
using System;
|
|
|
using System.Data;
|
|
|
using System.Web;
|
|
|
using DSWeb.EntityDA;
|
|
|
using DSWeb.Models;
|
|
|
using System.Xml;
|
|
|
using DSWeb.MvcShipping.DAL.MsSysParamSet;
|
|
|
using Microsoft.Practices.EnterpriseLibrary.Data;
|
|
|
using DSWeb.Areas.Mobile.DAL;
|
|
|
using DSWeb.SoftMng.DBUtility;
|
|
|
using DSWeb.SoftMng.BLL;
|
|
|
using DSWeb.SoftMng.Common;
|
|
|
using DSWeb.SoftMng.Model;
|
|
|
using System.Web.Script.Serialization;
|
|
|
using System.Linq;
|
|
|
using System.Text;
|
|
|
using DSWeb.SoftMng.Filter;
|
|
|
using System.Collections.Generic;
|
|
|
using DSWeb.Areas.MvcShipping.Comm;
|
|
|
using HcUtility.Comm;
|
|
|
using System.Web.Configuration;
|
|
|
using System.Runtime.Caching;
|
|
|
using DSWeb.MvcShipping.DAL.MsBaseInfoDAL;
|
|
|
|
|
|
namespace DSWeb
|
|
|
{
|
|
|
public partial class Login1 : System.Web.UI.Page
|
|
|
{
|
|
|
public string sSQL = String.Empty;
|
|
|
Cookies cookie = new Cookies();
|
|
|
UserDA UserDA = new UserDA();
|
|
|
public string PageMeta = "";
|
|
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
|
{
|
|
|
/*XmlDocument xmlDoc = new XmlDocument();
|
|
|
xmlDoc.Load(Server.MapPath("vote.xml")); //加载xml
|
|
|
XmlNodeList NodeList = xmlDoc.SelectNodes("/vote/item"); //xml节点的路径
|
|
|
string xmlName = NodeList[0].ChildNodes[0].InnerText; //获取第一个Student节点的StuName
|
|
|
if (xmlName == "2") { Response.Redirect("Login_new.aspx"); }*/
|
|
|
|
|
|
this.Page.Title = "用户登录";
|
|
|
PageMeta = this.Page.Title;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//D7注册功能判断
|
|
|
// sys_secCompanyBLL cbll = new sys_secCompanyBLL();
|
|
|
// sys_secCompany cmodel = cbll.GetModelList("").FirstOrDefault(); //获取客户端实例
|
|
|
|
|
|
// if (cmodel == null)
|
|
|
// {
|
|
|
// Page.ClientScript.RegisterStartupScript(this.GetType(), "key0",
|
|
|
//"<script>alert('没有配置模块注册信息,无法登录!');history.back();</script>");
|
|
|
// return;
|
|
|
|
|
|
// }
|
|
|
|
|
|
try
|
|
|
{
|
|
|
//同步公司配置表
|
|
|
|
|
|
//StringBuilder where = new StringBuilder();
|
|
|
////where.Append("select * from sys_secCompany where GID ='" + cmodel.GID + "'");
|
|
|
////var ds = DbHelperServerSQL.Query(where.ToString());
|
|
|
|
|
|
//var smodel = getServerCompanyREG(cmodel.GID); //服务端实例
|
|
|
//if (smodel.OperTime > cmodel.OperTime) //服务端最后更新时间大于客户端更新时间则更新
|
|
|
// cbll.Update(smodel);
|
|
|
|
|
|
////同步模块配置表(本公司)
|
|
|
//sys_secModuleBLL mbll = new sys_secModuleBLL();
|
|
|
|
|
|
//var list1 = getServerModelREG(cmodel.GID); //获取服务端数据
|
|
|
//foreach (var item in list1)
|
|
|
//{
|
|
|
// var cmodel1 = mbll.GetModel(item.GID);
|
|
|
// if (cmodel1 != null)
|
|
|
// {
|
|
|
// if (item.OperTime > cmodel1.OperTime) //服务端最后更新时间大于客户端更新时间则更新
|
|
|
// mbll.Update(item);
|
|
|
// }
|
|
|
// else
|
|
|
// mbll.Add(item);
|
|
|
//}
|
|
|
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
// Page.ClientScript.RegisterStartupScript(this.GetType(), "key0",
|
|
|
//"<script>alert('无法连接验证服务器,无法登录!');history.back();</script>");
|
|
|
// return;
|
|
|
|
|
|
//使用内网无法连接服务器地址会出现异常
|
|
|
//do something...
|
|
|
}
|
|
|
|
|
|
|
|
|
if (!Page.IsPostBack)
|
|
|
{
|
|
|
if (Request.Cookies["Lan"] != null)
|
|
|
{
|
|
|
string sel = Server.UrlDecode(cookie.getCookie("Lan").ToString().Trim());
|
|
|
sel = sel.Replace("Lan=", "");
|
|
|
this.selLan.SelectedValue = sel;
|
|
|
}
|
|
|
this.ipaddress.Text = "";
|
|
|
if (Request.Cookies["isCheckBox"] != null)
|
|
|
{
|
|
|
if (Server.UrlDecode(cookie.getCookie("isCheckBox").ToString().Trim()) == "0")
|
|
|
{
|
|
|
this.CheckBox1.Checked = false;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
this.CheckBox1.Checked = true;
|
|
|
if (Request.Cookies["COMPANYCODENAME"] != null)
|
|
|
{
|
|
|
this.list_subcompany.Text =
|
|
|
Server.UrlDecode(cookie.getCookie("COMPANYCODENAME").ToString().Trim());
|
|
|
}
|
|
|
if (Request.Cookies["COMPANYNAME"] != null)
|
|
|
{
|
|
|
this.lb_subcompany.Value =
|
|
|
Server.UrlDecode(cookie.getCookie("COMPANYNAME").ToString().Trim());
|
|
|
}
|
|
|
if (Request.Cookies["CODENAME"] != null)
|
|
|
{
|
|
|
this.list_CODENAME.Text = Server.UrlDecode(cookie.getCookie("CODENAME").ToString().Trim());
|
|
|
}
|
|
|
if (Request.Cookies["SHOWNAME"] != null)
|
|
|
{
|
|
|
this.lb_CODENAME.Value = Server.UrlDecode(cookie.getCookie("SHOWNAME").ToString().Trim());
|
|
|
}
|
|
|
if (Request.Cookies["PASSWORD"] != null &&
|
|
|
Server.UrlDecode(cookie.getCookie("PASSWORD").ToString().Trim()) != ""
|
|
|
) //Request.Cookies["PASSWORD"] != null && && Request.Cookies["RmbPassword"].ToString() == "1"
|
|
|
{
|
|
|
//tbpassword.Attributes.Add("value", Server.UrlDecode(cookie.getCookie("PASSWORD").ToString().Trim()));
|
|
|
//tbpassword.Value = Server.UrlDecode(cookie.getCookie("PASSWORD").ToString().Trim());
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "",
|
|
|
"<script type='text/javascript'>document.getElementById('tbpassword').value='" +
|
|
|
Server.UrlDecode(cookie.getCookie("PASSWORD").ToString().Trim()) + "';</script>");
|
|
|
this.CheckBox2.Checked = true;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//tbpassword.Attributes.Add("value", "");
|
|
|
//this.tbpassword.Attributes.Remove("value");
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "",
|
|
|
"<script type='text/javascript'>document.getElementById('tbpassword').value='';</script>");
|
|
|
this.CheckBox2.Checked = false;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
XmlDocument xmlDoc = new XmlDocument();
|
|
|
xmlDoc.Load(Server.MapPath("vote.xml")); //加载xml
|
|
|
XmlNodeList NodeList = xmlDoc.SelectNodes("/vote/password"); //xml节点的路径
|
|
|
string xmlName = NodeList[0].ChildNodes[0].InnerText; //获取第一个Student节点的StuName
|
|
|
if (xmlName == "1")
|
|
|
{
|
|
|
this.CheckBox2.Visible = true;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
this.CheckBox2.Visible = false;
|
|
|
//this.tbpassword.Attributes.Remove("value");
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "",
|
|
|
"<script type='text/javascript'>document.getElementById('tbpassword').value='';</script>");
|
|
|
}
|
|
|
//加载下拉框
|
|
|
//Page.ClientScript.RegisterStartupScript(this.GetType(), "key", "<script>initComboSubcompany();</script>");
|
|
|
|
|
|
}
|
|
|
|
|
|
//protected sys_secCompany getServerCompanyREG(string GID) {
|
|
|
// try
|
|
|
// {
|
|
|
// var IP = getConfigIP();
|
|
|
|
|
|
// var dic = new Dictionary<string, string>();
|
|
|
// dic.Add("GID", SoftMng.Common.Common.string_Encrypt(GID, ""));
|
|
|
// var rtn = WebRequestHelper.DoPost(IP + "GetSecCompany", dic, 5000);
|
|
|
|
|
|
// DBResult r = Newtonsoft.Json.JsonConvert.DeserializeObject<DBResult>(rtn);
|
|
|
|
|
|
// if (r.Success)
|
|
|
// {
|
|
|
// sys_secCompany companyREG = Newtonsoft.Json.JsonConvert.DeserializeObject<sys_secCompany>(r.Data.ToString());
|
|
|
// return companyREG;
|
|
|
// }
|
|
|
// else
|
|
|
// {
|
|
|
// return new sys_secCompany();
|
|
|
// }
|
|
|
// //sys_secCompany companyREG = Newtonsoft.Json.JsonConvert.DeserializeObject<sys_secCompany>(rtn);
|
|
|
|
|
|
// }
|
|
|
// catch (Exception e)
|
|
|
// {
|
|
|
// //var r = new sys_secCompany();
|
|
|
// //r.CompanySecretKey = e.Message;
|
|
|
// //return new sys_secCompany();
|
|
|
// try
|
|
|
// {
|
|
|
// sys_secCompanyBLL cbll = new sys_secCompanyBLL();
|
|
|
// StringBuilder where = new StringBuilder();
|
|
|
// where.Append("select * from sys_secCompany where GID ='" + GID + "'");
|
|
|
// var ds = DbHelperServerSQL.Query(where.ToString());
|
|
|
// var smodel = cbll.DataRowToModel(ds.Tables[0].Rows[0]); //服务端实例
|
|
|
// return smodel;
|
|
|
|
|
|
// }
|
|
|
// catch {
|
|
|
// return new sys_secCompany();
|
|
|
// }
|
|
|
// }
|
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
|
protected List<sys_secModule> getServerModelREG(string GID)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
var IP = getConfigIP();
|
|
|
|
|
|
var dic = new Dictionary<string, string>();
|
|
|
dic.Add("GID", SoftMng.Common.Common.string_Encrypt(GID, ""));
|
|
|
var rtn = WebRequestHelper.DoPost(IP + "GetSecModel", dic, 5000);
|
|
|
|
|
|
DBResult r = Newtonsoft.Json.JsonConvert.DeserializeObject<DBResult>(rtn);
|
|
|
|
|
|
if (r.Success)
|
|
|
{
|
|
|
List<sys_secModule> ModelREGList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<sys_secModule>>(r.Data.ToString());
|
|
|
return ModelREGList;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return new List<sys_secModule>();
|
|
|
}
|
|
|
//sys_secCompany companyREG = Newtonsoft.Json.JsonConvert.DeserializeObject<sys_secCompany>(rtn);
|
|
|
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
sys_secModuleBLL mbll = new sys_secModuleBLL();
|
|
|
StringBuilder where = new StringBuilder();
|
|
|
where.Append("select * from sys_secModule where PID ='" + GID + "'");
|
|
|
var ds = DbHelperServerSQL.Query(where.ToString());
|
|
|
if (ds.Tables.Count > 0)
|
|
|
{
|
|
|
var modelList = mbll.DataTableToList(ds.Tables[0]); //服务端实例
|
|
|
return modelList;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return new List<sys_secModule>();
|
|
|
}
|
|
|
}
|
|
|
catch {
|
|
|
return new List<sys_secModule>();
|
|
|
}
|
|
|
|
|
|
//var r = new sys_secCompany();
|
|
|
//r.CompanySecretKey = e.Message;
|
|
|
//return new List<sys_secModule>();
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
private string getConfigIP() {
|
|
|
|
|
|
string strConn = "";
|
|
|
|
|
|
try
|
|
|
{
|
|
|
strConn = WebConfigurationManager.AppSettings["RegServer"].ToString();
|
|
|
}
|
|
|
catch (Exception e) {
|
|
|
strConn = "";
|
|
|
}
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(strConn))
|
|
|
{
|
|
|
strConn = System.Configuration.ConfigurationManager.ConnectionStrings["DongShengDBServer"].ConnectionString;
|
|
|
var strlist = strConn.Split(';');
|
|
|
var serverStr = strlist[0];
|
|
|
int startIndex = serverStr.IndexOf("=");//开始位置
|
|
|
var IP = serverStr.Substring(startIndex + 1, serverStr.Length - startIndex - 1);//
|
|
|
if (IP.IndexOf(":") > 0) IP = IP.Substring(0, IP.IndexOf(":"));
|
|
|
if (string.IsNullOrEmpty(IP)) IP = "47.104.102.13";
|
|
|
strConn = "http://" + IP + ":8081";
|
|
|
}
|
|
|
|
|
|
var result = strConn + "/Dispatch/RegPort/";
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
protected void CheckBox2_CheckedChanged(object sender, EventArgs e)
|
|
|
{
|
|
|
if (!this.CheckBox2.Checked)
|
|
|
{
|
|
|
Session["PASSWORD"] = "";
|
|
|
bool chk = cookie.setCookie("PASSWORD", "");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
Session["PASSWORD"] = this.tbpassword.Value.Trim();
|
|
|
bool chk = cookie.setCookie("PASSWORD", Server.UrlEncode(this.tbpassword.Value.Trim()));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
protected void btLogin_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
string strCompanyCode = "";
|
|
|
string strCompanyName = "";
|
|
|
string strUserCodeName = "";
|
|
|
string strUserPassword = "";
|
|
|
string stripAddr = "";
|
|
|
|
|
|
|
|
|
strCompanyCode = this.list_subcompany.Text.Trim();
|
|
|
strCompanyName = this.lb_subcompany.Value.Trim();
|
|
|
strUserCodeName = this.list_CODENAME.Text.Trim();
|
|
|
strUserPassword = this.tbpassword.Value.Trim();
|
|
|
|
|
|
stripAddr = this.ipaddress.Text;
|
|
|
|
|
|
|
|
|
if (strCompanyCode.Equals("") || strUserCodeName.Equals("") || strUserPassword.Equals(""))
|
|
|
{
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key0",
|
|
|
"<script>alert('公司名称、用户名、密码不能为空,请重新登陆!');history.back();</script>");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if (strCompanyCode.IndexOf("'") >= 0)
|
|
|
strCompanyCode = strCompanyCode.Replace("'", " ");
|
|
|
if (strCompanyCode.IndexOf("'") >= 0)
|
|
|
strUserCodeName = strUserCodeName.Replace("'", " ");
|
|
|
if (strCompanyCode.IndexOf("'") >= 0)
|
|
|
strUserPassword = strUserPassword.Replace("'", " ");
|
|
|
|
|
|
|
|
|
UserEntity userEntity = new UserEntity();
|
|
|
UserDA userDA = new UserDA();
|
|
|
|
|
|
userEntity = userDA.GetSigleUserInfoBySignIn(strUserCodeName, strUserPassword, strCompanyCode);
|
|
|
|
|
|
CompanyEntity companyEntity = new CompanyEntity();
|
|
|
CompanyDA companyDA = new CompanyDA();
|
|
|
|
|
|
if (userEntity != null)
|
|
|
{
|
|
|
if (userEntity.Gid != null)
|
|
|
{
|
|
|
if (!userEntity.IsDeleted)
|
|
|
{
|
|
|
UserAttributeDA userAttributeDA = new UserAttributeDA();
|
|
|
UserAttributeEntity userAttributeEntity = new UserAttributeEntity();
|
|
|
|
|
|
userAttributeEntity =
|
|
|
userAttributeDA.GetUserAttributeByIdAndAttrName(userEntity.Gid, "isUseSystem");
|
|
|
|
|
|
if (userAttributeEntity != null)
|
|
|
{
|
|
|
if (userAttributeEntity.Gid != null)
|
|
|
{
|
|
|
var istrue = MsBaseInfoDAL.GetUserModuleEnable("HANDPHONEONLY", userEntity.Gid);
|
|
|
if (istrue) {
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key4",
|
|
|
"<script>alert('此账户仅支持手机登录!');history.back();</script>");
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
if (userAttributeEntity.RefEntity.AttributeValue.ToString().Trim().ToLower()
|
|
|
.Equals("true"))
|
|
|
{
|
|
|
Session["USERID"] = userEntity.Gid;
|
|
|
Session["CODENAME"] = userEntity.CodeName;
|
|
|
Session["SHOWNAME"] = userEntity.ShowName;
|
|
|
Session["PASS"] = userEntity.PassWord;
|
|
|
if (this.CheckBox2.Checked)
|
|
|
{
|
|
|
Session["PASSWORD"] = userEntity.PassWord;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
Session["PASSWORD"] = "";
|
|
|
}
|
|
|
if (this.selLan.SelectedValue == "Chinese")
|
|
|
{
|
|
|
Session["LANGUAGES"] = "zh-cn";
|
|
|
}
|
|
|
else if (this.selLan.SelectedValue == "English")
|
|
|
{
|
|
|
Session["LANGUAGES"] = "en-us";
|
|
|
}
|
|
|
|
|
|
if (!strCompanyCode.Trim().Equals(""))
|
|
|
{
|
|
|
companyEntity =
|
|
|
companyDA.GetCompanyByCodeNameNoLogoImg(strCompanyCode.ToUpper());
|
|
|
|
|
|
if (companyEntity != null)
|
|
|
{
|
|
|
if (companyEntity.GID != null)
|
|
|
{
|
|
|
Session["COMPANYID"] = companyEntity.GID;
|
|
|
Session["COMPANYNAME"] = companyEntity.NAME;
|
|
|
Session["LOCALCURR"] = companyEntity.LOCALCURR;
|
|
|
Session["WORKFLOWMSG"] = companyEntity.WORKFLOWMSG;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
Session["DEPTNAME"] = UserDA.GetUserDepartmentName(userEntity.Gid);
|
|
|
Session["DEPTGID"] = UserDA.GetDEPTGID(userEntity.Gid);
|
|
|
|
|
|
//Record User SignIn System
|
|
|
UserLoginStatusDA userLoginStatusDA = new UserLoginStatusDA();
|
|
|
UserLoginStatusEntity userLoginStatusEntity = new UserLoginStatusEntity();
|
|
|
|
|
|
//查看是否当前登录用户是否是时效内重新登录的用户
|
|
|
userLoginStatusEntity =
|
|
|
userLoginStatusDA.GetLoginStatusByUserID(Session["USERID"].ToString());
|
|
|
if (userLoginStatusEntity.GID != null)
|
|
|
{
|
|
|
DateTime signDateTime = userLoginStatusEntity.SignInTime;
|
|
|
DateTime serverDateTime = userLoginStatusEntity.ServerDateTime;
|
|
|
double expiresMinutes =
|
|
|
double.Parse(userLoginStatusEntity.ExpiresMinutes.ToString());
|
|
|
if (signDateTime.AddMinutes(expiresMinutes).CompareTo(serverDateTime) >= 0)
|
|
|
{
|
|
|
userLoginStatusDA.DeleteUserLoginStatus(userLoginStatusEntity.GID);
|
|
|
|
|
|
userLoginStatusEntity.GID = Guid.NewGuid().ToString();
|
|
|
userLoginStatusEntity.SessionID = "USERID";
|
|
|
userLoginStatusEntity.ExpiresMinutes = 200;
|
|
|
|
|
|
userLoginStatusDA.InsertLoginStatus(userLoginStatusEntity);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
userLoginStatusDA.UpdateLoginStatusForReSign(userLoginStatusEntity);
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
userLoginStatusEntity.GID = Guid.NewGuid().ToString();
|
|
|
userLoginStatusEntity.SessionID = Guid.NewGuid().ToString();
|
|
|
userLoginStatusEntity.UserID = Session["USERID"].ToString();
|
|
|
userLoginStatusEntity.ExpiresMinutes = 200;
|
|
|
|
|
|
userLoginStatusDA.InsertLoginStatus(userLoginStatusEntity);
|
|
|
}
|
|
|
|
|
|
//HomeService.HomeService.StoreMemcachedForLogin(userEntity.CodeName);
|
|
|
// HomeService.HomeService.StoreMemcachedForUser(userEntity.CodeName, userEntity.Gid, userEntity.ShowName, companyEntity.GID, strCompanyCode, companyEntity.NAME, companyEntity.LOCALCURR, companyEntity.WORKFLOWMSG, Session["DEPTGID"].ToString(), Session["DEPTNAME"].ToString());
|
|
|
|
|
|
bool ck0 = cookie.setCookie("DSUSERID", Server.UrlEncode(userEntity.Gid));
|
|
|
ck0 = cookie.setCookie("COMPANYCODENAME", Server.UrlEncode(strCompanyCode));
|
|
|
ck0 = cookie.setCookie("COMPANYNAME", Server.UrlEncode(companyEntity.NAME));
|
|
|
ck0 = cookie.setCookie("COMPANYID", Server.UrlEncode(companyEntity.GID));
|
|
|
ck0 = cookie.setCookie("LOCALCURR", Server.UrlEncode(companyEntity.LOCALCURR));
|
|
|
ck0 = cookie.setCookie("WORKFLOWMSG", Server.UrlEncode(companyEntity.WORKFLOWMSG));
|
|
|
ck0 = cookie.setCookie("CODENAME", Server.UrlEncode(userEntity.CodeName));
|
|
|
ck0 = cookie.setCookie("SHOWNAME", Server.UrlEncode(userEntity.ShowName));
|
|
|
T_ALL_DA T_ALL_DA = new T_ALL_DA();
|
|
|
var PARAMVALUE = T_ALL_DA.GetStrSQL("PARAMVALUE",
|
|
|
"select top 1 PARAMVALUE from sys_param_set where PARAMNAME='SALESUBMITFEE' ");
|
|
|
ck0 = cookie.setCookie("ISSALEWORK", Server.UrlEncode(PARAMVALUE));
|
|
|
PARAMVALUE = T_ALL_DA.GetStrSQL("PARAMVALUE", "select top 1 PARAMVALUE from sys_param_set where PARAMNAME='ISENABLECUSTRANGE' ");
|
|
|
ck0 = cookie.setCookie("ISENABLECUSTRANGE", Server.UrlEncode(PARAMVALUE));
|
|
|
PARAMVALUE = T_ALL_DA.GetStrSQL("PARAMVALUE", "select top 1 PARAMVALUE from sys_param_set where PARAMNAME='USEHOMEPAGE' ");
|
|
|
ck0 = cookie.setCookie("USEHOMEPAGE", Server.UrlEncode(PARAMVALUE));
|
|
|
|
|
|
|
|
|
if (this.CheckBox2.Checked)
|
|
|
{
|
|
|
ck0 = cookie.setCookie("PASSWORD", Server.UrlEncode(userEntity.PassWord));
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
ck0 = cookie.setCookie("PASSWORD", "");
|
|
|
}
|
|
|
|
|
|
if (this.CheckBox1.Checked)
|
|
|
{
|
|
|
ck0 = cookie.setCookie("isCheckBox", Server.UrlEncode("1"));
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
ck0 = cookie.setCookie("isCheckBox", Server.UrlEncode("0"));
|
|
|
}
|
|
|
|
|
|
#region 判断IP限制
|
|
|
|
|
|
string msg = iplimitDo(userEntity.Gid, stripAddr);
|
|
|
if (msg != "")
|
|
|
{
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key4",
|
|
|
"<script>alert('登录IP已被限制!');document.getElementById('lb_CODENAME').innerHTML = '';history.back();</script>");
|
|
|
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
Response.Redirect("~/Default.aspx");
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key4",
|
|
|
"<script>alert('账户已禁用,请联系管理员');history.back();</script>");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key4",
|
|
|
"<script>alert('用户名不存在,或用户名、密码错误,请重新登陆!');document.getElementById('lb_CODENAME').innerHTML = '';history.back();</script>");
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key4",
|
|
|
"<script>alert('用户名不存在,或用户名、密码错误,请重新登陆!');document.getElementById('lb_CODENAME').innerHTML = '';history.back();</script>");
|
|
|
}
|
|
|
|
|
|
|
|
|
protected void btLogin_Click2(object sender, EventArgs e)
|
|
|
{
|
|
|
string strCompanyCode = "";
|
|
|
string strCompanyName = "";
|
|
|
string strUserCodeName = "";
|
|
|
string strUserPassword = "";
|
|
|
string stripAddr = "";
|
|
|
string handphone = "";
|
|
|
string handcode = "";
|
|
|
handphone = this.lb_handphone2.Value.Trim();
|
|
|
handcode = this.tbyanzheng.Value.Trim();
|
|
|
if (handphone.Equals("") || handcode.Equals("") )
|
|
|
{
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key0",
|
|
|
"<script>alert('手机号、验证码为空,请重新登陆!');</script>");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
string key = $"VC_{handphone}";
|
|
|
if (!MemoryCache.Default.Contains(key))
|
|
|
{
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key0",
|
|
|
"<script>alert('验证码错误!');</script>");
|
|
|
return;
|
|
|
}
|
|
|
else if (MemoryCache.Default[key].ToString() != handcode)
|
|
|
{
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key0",
|
|
|
"<script>alert('验证码错误!');</script>");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
//strCompanyCode = this.list_subcompany.Text.Trim();
|
|
|
//strCompanyName = this.lb_subcompany.Value.Trim();
|
|
|
//strUserCodeName = this.list_CODENAME.Text.Trim();
|
|
|
//strUserPassword = this.tbpassword.Value.Trim();
|
|
|
|
|
|
stripAddr = this.ipaddress.Text;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (strCompanyCode.IndexOf("'") >= 0)
|
|
|
strCompanyCode = strCompanyCode.Replace("'", " ");
|
|
|
if (strCompanyCode.IndexOf("'") >= 0)
|
|
|
strUserCodeName = strUserCodeName.Replace("'", " ");
|
|
|
if (strCompanyCode.IndexOf("'") >= 0)
|
|
|
strUserPassword = strUserPassword.Replace("'", " ");
|
|
|
|
|
|
|
|
|
UserEntity userEntity = new UserEntity();
|
|
|
UserDA userDA = new UserDA();
|
|
|
|
|
|
userEntity = userDA.GetSigleUserInfoByMOBILE(handphone);
|
|
|
|
|
|
CompanyEntity companyEntity = new CompanyEntity();
|
|
|
CompanyDA companyDA = new CompanyDA();
|
|
|
|
|
|
if (userEntity != null)
|
|
|
{
|
|
|
if (userEntity.Gid != null)
|
|
|
{
|
|
|
if (!userEntity.IsDeleted)
|
|
|
{
|
|
|
UserAttributeDA userAttributeDA = new UserAttributeDA();
|
|
|
UserAttributeEntity userAttributeEntity = new UserAttributeEntity();
|
|
|
|
|
|
userAttributeEntity =
|
|
|
userAttributeDA.GetUserAttributeByIdAndAttrName(userEntity.Gid, "isUseSystem");
|
|
|
|
|
|
if (userAttributeEntity != null)
|
|
|
{
|
|
|
if (userAttributeEntity.Gid != null)
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (userAttributeEntity.RefEntity.AttributeValue.ToString().Trim().ToLower()
|
|
|
.Equals("true"))
|
|
|
{
|
|
|
Session["USERID"] = userEntity.Gid;
|
|
|
Session["CODENAME"] = userEntity.CodeName;
|
|
|
Session["SHOWNAME"] = userEntity.ShowName;
|
|
|
Session["PASS"] = userEntity.PassWord;
|
|
|
Session["PASSWORD"] = userEntity.PassWord;
|
|
|
if (this.selLan.SelectedValue == "Chinese")
|
|
|
{
|
|
|
Session["LANGUAGES"] = "zh-cn";
|
|
|
}
|
|
|
else if (this.selLan.SelectedValue == "English")
|
|
|
{
|
|
|
Session["LANGUAGES"] = "en-us";
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!userEntity.Gid.Trim().Equals(""))
|
|
|
{
|
|
|
companyEntity =
|
|
|
companyDA.GetCompanyByUserID(userEntity.Gid);
|
|
|
|
|
|
if (companyEntity != null)
|
|
|
{
|
|
|
if (companyEntity.GID != null)
|
|
|
{
|
|
|
Session["COMPANYID"] = companyEntity.GID;
|
|
|
Session["COMPANYNAME"] = companyEntity.NAME;
|
|
|
Session["LOCALCURR"] = companyEntity.LOCALCURR;
|
|
|
Session["WORKFLOWMSG"] = companyEntity.WORKFLOWMSG;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
Session["DEPTNAME"] = UserDA.GetUserDepartmentName(userEntity.Gid);
|
|
|
Session["DEPTGID"] = UserDA.GetDEPTGID(userEntity.Gid);
|
|
|
|
|
|
//Record User SignIn System
|
|
|
UserLoginStatusDA userLoginStatusDA = new UserLoginStatusDA();
|
|
|
UserLoginStatusEntity userLoginStatusEntity = new UserLoginStatusEntity();
|
|
|
|
|
|
//查看是否当前登录用户是否是时效内重新登录的用户
|
|
|
userLoginStatusEntity =
|
|
|
userLoginStatusDA.GetLoginStatusByUserID(Session["USERID"].ToString());
|
|
|
if (userLoginStatusEntity.GID != null)
|
|
|
{
|
|
|
DateTime signDateTime = userLoginStatusEntity.SignInTime;
|
|
|
DateTime serverDateTime = userLoginStatusEntity.ServerDateTime;
|
|
|
double expiresMinutes =
|
|
|
double.Parse(userLoginStatusEntity.ExpiresMinutes.ToString());
|
|
|
if (signDateTime.AddMinutes(expiresMinutes).CompareTo(serverDateTime) >= 0)
|
|
|
{
|
|
|
userLoginStatusDA.DeleteUserLoginStatus(userLoginStatusEntity.GID);
|
|
|
|
|
|
userLoginStatusEntity.GID = Guid.NewGuid().ToString();
|
|
|
userLoginStatusEntity.SessionID = "USERID";
|
|
|
userLoginStatusEntity.ExpiresMinutes = 200;
|
|
|
|
|
|
userLoginStatusDA.InsertLoginStatus(userLoginStatusEntity);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
userLoginStatusDA.UpdateLoginStatusForReSign(userLoginStatusEntity);
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
userLoginStatusEntity.GID = Guid.NewGuid().ToString();
|
|
|
userLoginStatusEntity.SessionID = Guid.NewGuid().ToString();
|
|
|
userLoginStatusEntity.UserID = Session["USERID"].ToString();
|
|
|
userLoginStatusEntity.ExpiresMinutes = 200;
|
|
|
|
|
|
userLoginStatusDA.InsertLoginStatus(userLoginStatusEntity);
|
|
|
}
|
|
|
|
|
|
//HomeService.HomeService.StoreMemcachedForLogin(userEntity.CodeName);
|
|
|
// HomeService.HomeService.StoreMemcachedForUser(userEntity.CodeName, userEntity.Gid, userEntity.ShowName, companyEntity.GID, strCompanyCode, companyEntity.NAME, companyEntity.LOCALCURR, companyEntity.WORKFLOWMSG, Session["DEPTGID"].ToString(), Session["DEPTNAME"].ToString());
|
|
|
|
|
|
bool ck0 = cookie.setCookie("DSUSERID", Server.UrlEncode(userEntity.Gid));
|
|
|
ck0 = cookie.setCookie("COMPANYCODENAME", Server.UrlEncode(strCompanyCode));
|
|
|
ck0 = cookie.setCookie("COMPANYNAME", Server.UrlEncode(companyEntity.NAME));
|
|
|
ck0 = cookie.setCookie("COMPANYID", Server.UrlEncode(companyEntity.GID));
|
|
|
ck0 = cookie.setCookie("LOCALCURR", Server.UrlEncode(companyEntity.LOCALCURR));
|
|
|
ck0 = cookie.setCookie("WORKFLOWMSG", Server.UrlEncode(companyEntity.WORKFLOWMSG));
|
|
|
ck0 = cookie.setCookie("CODENAME", Server.UrlEncode(userEntity.CodeName));
|
|
|
ck0 = cookie.setCookie("SHOWNAME", Server.UrlEncode(userEntity.ShowName));
|
|
|
T_ALL_DA T_ALL_DA = new T_ALL_DA();
|
|
|
var PARAMVALUE = T_ALL_DA.GetStrSQL("PARAMVALUE",
|
|
|
"select top 1 PARAMVALUE from sys_param_set where PARAMNAME='SALESUBMITFEE' ");
|
|
|
ck0 = cookie.setCookie("ISSALEWORK", Server.UrlEncode(PARAMVALUE));
|
|
|
PARAMVALUE = T_ALL_DA.GetStrSQL("PARAMVALUE", "select top 1 PARAMVALUE from sys_param_set where PARAMNAME='ISENABLECUSTRANGE' ");
|
|
|
ck0 = cookie.setCookie("ISENABLECUSTRANGE", Server.UrlEncode(PARAMVALUE));
|
|
|
PARAMVALUE = T_ALL_DA.GetStrSQL("PARAMVALUE", "select top 1 PARAMVALUE from sys_param_set where PARAMNAME='USEHOMEPAGE' ");
|
|
|
ck0 = cookie.setCookie("USEHOMEPAGE", Server.UrlEncode(PARAMVALUE));
|
|
|
|
|
|
|
|
|
|
|
|
#region 判断IP限制
|
|
|
|
|
|
string msg = iplimitDo(userEntity.Gid, stripAddr);
|
|
|
if (msg != "")
|
|
|
{
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key4",
|
|
|
"<script>alert('登录IP已被限制!');document.getElementById('lb_CODENAME').innerHTML = '';history.back();</script>");
|
|
|
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
Response.Redirect("~/Default.aspx");
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key4",
|
|
|
"<script>alert('账户已禁用,请联系管理员');history.back();</script>");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key4",
|
|
|
"<script>alert('用户名不存在,或用户名、密码错误,请重新登陆!');document.getElementById('lb_CODENAME').innerHTML = '';history.back();</script>");
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key4",
|
|
|
"<script>alert('用户名不存在,或用户名、密码错误,请重新登陆!');document.getElementById('lb_CODENAME').innerHTML = '';history.back();</script>");
|
|
|
}
|
|
|
|
|
|
protected void btGetCode_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key4",
|
|
|
"<script>alert('验证码已发送!');</script>");
|
|
|
|
|
|
}
|
|
|
|
|
|
protected void selLan_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
{
|
|
|
//Request.Cookies["Lan"].Value=this.selLan.SelectedItem.Value;
|
|
|
//Response.Cookies["Lan"].Value = this.selLan.SelectedItem.Value;
|
|
|
bool ck0 = cookie.setCookie("Lan", Server.UrlEncode(this.selLan.SelectedItem.Value));
|
|
|
|
|
|
}
|
|
|
|
|
|
private string iplimitDo(string userid,string ipaddr)
|
|
|
{
|
|
|
string message = "";
|
|
|
try
|
|
|
{
|
|
|
var IPLimit = MsSysParamSetDAL.GetData("PARAMNAME='IPLimit'");
|
|
|
//是否限制IP登录
|
|
|
if (IPLimit.PARAMVALUE == "1")
|
|
|
{
|
|
|
string clientIP = HttpContext.Current.Request.Url.ToString();
|
|
|
if (clientIP.IndexOf("192.168") > 0)
|
|
|
{
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
message = checkIp(userid, ipaddr);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
catch (Exception se)
|
|
|
{
|
|
|
|
|
|
}
|
|
|
return message;
|
|
|
}
|
|
|
|
|
|
private string checkIp(string userid, string ipaddr)
|
|
|
{
|
|
|
string message = "";
|
|
|
string sql = "select ip from sys_ipwhile where ip='"+ ipaddr + "'";
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
string ips = "";
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, sql))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
ips += reader["ip"].ToString() + ",";
|
|
|
}
|
|
|
}
|
|
|
if (string.IsNullOrEmpty(ips))
|
|
|
{
|
|
|
//message = "未获取到公司IP地址";
|
|
|
string sql2 = "select count(*) from sys_userwhile where USERID = '" + userid
|
|
|
+ "'";
|
|
|
int rst = Convert.ToInt32(db.ExecuteScalar(CommandType.Text, sql2));
|
|
|
if (rst > 0)
|
|
|
{
|
|
|
//验证ip
|
|
|
//DBLog.Log(clientIP);
|
|
|
//if (!ips.Contains(clientIP))
|
|
|
//{
|
|
|
// message = "IP已被限制!";
|
|
|
//}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
message = "IP已被限制!";
|
|
|
}
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//判断用户权限,是否需要ip登录验证
|
|
|
|
|
|
}
|
|
|
return message;
|
|
|
}
|
|
|
}
|
|
|
} |