using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using Maticsoft.BLL; using System.Data; using System.Data.SqlClient; using System.Diagnostics; using System.Collections; using System.Management; using Ajax; public partial class index : System.Web.UI.Page { Maticsoft.BLL.nr_sys_rizhi rizhibll = new nr_sys_rizhi(); Maticsoft.Model.nr_sys_rizhi rizhi = new Maticsoft.Model.nr_sys_rizhi(); protected void Page_Load(object sender, EventArgs e) { Utility.RegisterTypeForAjax(typeof(index)); if (Request.QueryString["sions"] != null && Request.QueryString["sions"].ToString() == "no") { Session.Abandon(); } DataTable dtuserinfo = DBHlper.Execute("select * from nr_sysuserinfo").Tables[0]; if (dtuserinfo.Rows.Count > 0) { //gsmctitle.InnerText = dtuserinfo.Rows[0]["mingcheng"].ToString(); //img_logo.Src = "UseFile/" + dtuserinfo.Rows[0]["logourl"].ToString(); dlbdtitle.InnerText = "欢迎登陆-Flycan_ERP-管理平台"; } } protected void bt_tj_Click(object sender, EventArgs e) { try { //用户角色查询判定 if (getjs.PanDing) { if (DBHlper.getjscount() > getjs.JsCount) { //nelson //rx_error.Text = "请您购买足够的角色!"; //return; } if (DBHlper.getyhcount() > getjs.UserCount) { //nelson //rx_error.Text = "请您购买足够的用户!"; //return; } } nr_z_yhzh yh = new nr_z_yhzh(); string zhanghao = dlzhanghao.Value; string mima = DBHlper.getmima(dlmima.Value); Maticsoft.Model.nr_z_yhzh zhdt = yh.Selectbyzm(zhanghao, mima); if (zhdt != null) { //查询账号禁用状态 if (zhdt.yangshi == 0) { rx_error.Text = "账号已被封存!"; return; } Session["user"] = zhdt; Session.Timeout = 1440; //单点登录 Hashtable hOnline = (Hashtable)Application["Online"]; if (hOnline != null) { int i = 0; while (i < hOnline.Count) //强制查询到底 { IDictionaryEnumerator idE = hOnline.GetEnumerator(); string strKey = ""; while (idE.MoveNext()) { if (idE.Value != null && idE.Value.ToString().Equals(zhanghao)) { //already login strKey = idE.Key.ToString(); hOnline[strKey] = "alreadyLogin"; break; } } i = i + 1; } } else { hOnline = new Hashtable(); } hOnline[Session.SessionID] = zhanghao; Application.Lock(); Application["Online"] = hOnline; Application.UnLock(); //用户登录的时候将登录用户名放在一个全局变量Online,Online为Hashtable结构, // DBHlper.SETOperation(); //Key为SessionID,Value为用户名。每次用户登录时均判断以下要登录的用户名在Online中是不是已经存在, //如果存在该用户名已经被登录,将第一个人登录的SessionID对应的用户名强制变更为XXXXXX,表示该登录将被强制注销 rizhi.yonghuming = dlzhanghao.Value; //拼接字符串插入日志 rizhi.jilu = dlzhanghao.Value + "成功登录了系统,账号为:" + dlzhanghao.Value; rizhi.leixing = "系统登录"; rizhi.riqi = DateTime.Now; rizhibll.Add(rizhi); Response.Redirect("Framework_File/FrameMain.aspx"); } else { rx_error.Text = "账号或密码错误!"; return; } } catch { rx_error.Text = "数据连接异常!"; return; } } }