Exemple #1
0
        public void LoginUserSQLselect()
        {
            LoginUserBLL     bus   = new LoginUserBLL();
            List <LoginUser> users = bus.ForSQLT();

            Assert.AreEqual(2, users.Count);
        }
Exemple #2
0
        static void Main(string[] args)
        {
            ILoginUserBLL bLL       = new LoginUserBLL();
            LoginUser     loginUser = bLL.GetLoginUserByUsername("tjsanshao");

            Console.WriteLine(loginUser.Password);
            Console.ReadKey();
        }
Exemple #3
0
        public void DbSelect()
        {
            LoginUserBLL     bus   = new LoginUserBLL();
            List <LoginUser> users = bus.GetEntities(bs => bs.Del == false);
            int count = users.Count;

            Assert.AreEqual(2, count);
        }
Exemple #4
0
        protected void ImageButtonLogin_Click(object sender, ImageClickEventArgs e)
        {
            LoginUserBLL loginUserBLL = new LoginUserBLL();
            LoginUser    loginUser    = loginUserBLL.GetLoginUser(txtUserName.Text, txtPassword.Text, 0);

            if (loginUser == null)
            {
                SessionSet.PageMessage = "您输入的用户名或密码不正确!";
                return;
            }

            PrjPub.CurrentLoginUser     = loginUser;
            PrjPub.WelcomeInfo          = loginUser.OrgName + ":" + loginUser.EmployeeName + ",您好!";
            SessionSet.UserID           = loginUser.UserID;
            SessionSet.EmployeeID       = loginUser.EmployeeID;
            SessionSet.EmployeeName     = loginUser.EmployeeName;
            SessionSet.OrganizationID   = loginUser.OrgID;
            SessionSet.OrganizationName = loginUser.OrgName;

            //判断用户数



            //ApplicationSet.UserCount ++;
            //if (ApplicationSet.UserCount > ApplicationSet.AllowUserCount)
            //{
            //    SessionSet.PageMessage = "系统已达最大用户数,请稍候登录!";
            //    ApplicationSet.UserCount --;
            //    return;
            //}

            ////控件显示
            //lblUserName.Text = "使用部门:";
            //lblPassword.Text = "登录用户:";
            //lblDepartment.Text = loginUser.OrgName;
            //lblEmployee.Text = loginUser.EmployeeName;
            //lblUserCount.Text = "用户许可数:&nbsp;&nbsp;" + ApplicationSet.AllowUserCount.ToString();

            //txtUserName.Visible = false;
            //txtPassword.Visible = false;
            //ImageButtonLogin.Visible = false;
            //lblDepartment.Visible = true;
            //lblEmployee.Visible = true;
            //lblUserCount.Visible = true;

            ////将登录用户添加到在线用户数组
            //ApplicationSet.UserOnline.Add(loginUser.UserID);

            ////登录成功标志
            //SessionSet.Login = true;

            //设置Form许可
            FormsAuthentication.SetAuthCookie(loginUser.UserID, false);

            Response.Redirect("Main/Main.aspx");
        }
Exemple #5
0
        public void DbDelete()
        {
            LoginUserBLL bus = new LoginUserBLL();
            LoginUser    bu  = new LoginUser()
            {
                Id = 2
            };
            int count = bus.Del(bu) ? 1 : 0;

            Assert.AreEqual(1, count);
        }
Exemple #6
0
        public void DbInsert()
        {
            LoginUserBLL bus       = new LoginUserBLL();
            MD5Helper    mD5Helper = new MD5Helper();
            LoginUser    bu        = new LoginUser()
            {
                UserName = "******", UserCode = "test", LogPWD = mD5Helper.CreateMD5Hash("test"), Del = false
            };
            int nbu = bus.Add(bu);

            Assert.AreEqual(2, nbu);
        }
Exemple #7
0
 public async Task <string> Login(LoginUserBLL loginUser)
 {
     try
     {
         var user = _mapper.Map <LoginUser>(loginUser);
         return(await _userUnitOfWork.AuthorizationAsync(user));
     }
     catch (Exception)
     {
         return(null);
     }
 }
Exemple #8
0
        public void DbUpdate()
        {
            LoginUserBLL bus       = new LoginUserBLL();
            MD5Helper    mD5Helper = new MD5Helper();
            LoginUser    bu        = new LoginUser()
            {
                Id = 1, UserName = "******", UserCode = "sad", LogPWD = mD5Helper.CreateMD5Hash("sad"), Del = false
            };

            int count = bus.Update(bu) ? 1 : 0;

            Assert.AreEqual(1, count);
        }
Exemple #9
0
        public void DbUpdateRange()
        {
            LoginUserBLL     bus  = new LoginUserBLL();
            List <LoginUser> buls = bus.GetPageEntityes(bu => bu.Del == false, bu => bu.Id, 10, 1, true);

            buls[0].UserCode = "sadmin";
            buls[0].UserName = "******";

            buls[1].UserCode = "systest";
            buls[1].UserName = "******";

            bus.UpdateRange(buls, e => e.UserCode.Length > 0);

            Assert.AreEqual(2, buls.Count);
        }
Exemple #10
0
        public ActionResult UrlLogin(string loginname, string urllogin)
        {
            LoginUserBLL bll = new LoginUserBLL();

            if (bll.Login(loginname))
            {
                //登录成功,跳转到主页面
                return(Redirect("~/Home/Index?urllogin="******"alert('业务系统未找到[" + loginname + "]登录人!')";
                return(js);
            }
        }
Exemple #11
0
        public ActionResult UserLoginByInfo(LoginInfo info)
        {
            //首先检查用户名密码
            LoginUserBLL bll = new LoginUserBLL();

            if (bll.Login(info.LoginName, info.PassWord))
            {
                //登录成功,跳转到主页面
                return(this.JsonResult(E_JsonResult.OK, "", null, "~/Home/Index"));
            }
            else
            {
                //登录失败,发送错误错误给用户
                return(this.JsonResult(E_JsonResult.Error, "登录失败!用户名密码错误!", null, null));
            }
        }
Exemple #12
0
        //
        // GET: /BM/Login/

        public ActionResult Index()
        {
            string name = Request.Form["username"].ToString();
            string pw   = Request.Form["passWord"].ToString();

            //首先检查用户名密码
            LoginUserBLL bll = new LoginUserBLL();

            if (bll.Login(name, pw))
            {
                string username = UserOperateContext.Current.Session_UsrInfo.Name;
                string workCode = UserOperateContext.Current.Session_UsrInfo.WorkCode;
                //登录成功,跳转到主页面
                return(Json(new { msg = "OK", UName = username, WorkCode = workCode }, "appliction/json", JsonRequestBehavior.AllowGet));
            }
            else
            {
                //登录失败,发送错误错误给用户
                return(Json(new { msg = "Error" }, "appliction/json", JsonRequestBehavior.AllowGet));
            }
        }
Exemple #13
0
        public ActionResult Login(FormCollection formCollection)
        {
            string username = formCollection["username"];
            string password = formCollection["password"];

            TempData["usernameInput"] = username;
            TempData["passwordInput"] = password;

            ILoginUserBLL bLL       = new LoginUserBLL();
            LoginUser     loginUser = bLL.GetLoginUserByUsername(username);



            if (loginUser == null)
            {
                TempData["error"] = "Username Error";
                return(RedirectToAction("Index"));
            }
            else
            {
                Models.LoginUser viewLoginUser = new Models.LoginUser()
                {
                    Id        = loginUser.Id,
                    Username  = loginUser.Username,
                    Password  = loginUser.Password,
                    RoleLevel = loginUser.RoleLevel
                };

                if (loginUser.Password == password)
                {
                    Session["loginUser"] = viewLoginUser;
                    return(RedirectToAction("Index", "Main"));
                }
                else
                {
                    TempData["error"] = "Password Error";
                    return(RedirectToAction("Index"));
                }
            }
        }
Exemple #14
0
        private void pictureBox3_Click(object sender, EventArgs e)
        {
            LoginUser u = new LoginUser();

            u.UserName = txtUname.Text;
            u.PassWord = txtPwd.Text;

            if (txtUname.Text == "")
            {
                lblUname.Visible = true;
                lblUname.Text    = "用户名不能为空";
                return;
            }
            else if (txtPwd.Text == "")
            {
                lblPwd.Visible = true;
                lblPwd.Text    = "密码不能为空";
                return;
            }
            else
            {
                Boolean isValid = new LoginUserBLL().Check(u);
                if (isValid)
                {
                    zhufrom zhu = new zhufrom();
                    zhu.Tag = txtUname.Text;
                    zhu.Show();
                    this.Hide();
                }
                else
                {
                    lblPwd.Visible = true;
                    lblPwd.Text    = "用户名或密码不正确,登录失败";
                }
            }
        }
        protected void ImageButtonLogin_Click(object sender, EventArgs e)
        {
            #region 验证服务器端狗信息
            ET99FullClass et99   = new ET99FullClass();
            Random        random = new Random((int)(DateTime.Now.Ticks >> 32));
            string        strServerRandomData   = string.Empty;
            string        strServerRandomResult = string.Empty;
            string        strServerPid          = string.Empty;
            string        strServerUserpin      = string.Empty;
            //string strServerSn = string.Empty;
            string strServerKey = string.Empty;

            for (int i = 0; i < 20; i++)
            {
                strServerRandomData += random.Next(9).ToString();
            }

            try
            {
                strServerPid = ConfigurationManager.AppSettings["PID"];
                et99.FindToken(strServerPid);
            }
            catch
            {
                SessionSet.PageMessage = "服务器端未检测到加密锁!";
                return;
            }
            try
            {
                et99.OpenToken(strServerPid, 1);
            }
            catch
            {
                SessionSet.PageMessage = "服务器端打开加密锁失败!";
                et99.CloseToken();
                return;
            }
            try
            {
                strServerUserpin = ConfigurationManager.AppSettings["USERPIN"];
                et99.VerifyPIN(0, strServerUserpin);
            }
            catch
            {
                SessionSet.PageMessage = "服务器端加密锁USERPIN不正确!";
                et99.CloseToken();
                return;
            }

            try
            {
                strServerKey          = ConfigurationManager.AppSettings["KEY1"];
                strServerRandomResult = et99.MD5HMAC(1, strServerRandomData, 20).ToString();
                if (strServerRandomResult != et99.Soft_MD5HMAC(1, strServerRandomData, strServerKey).ToString())
                {
                    SessionSet.PageMessage = "服务器端加密锁密钥不正确!";
                    return;
                }
            }
            catch
            {
                SessionSet.PageMessage = "服务器端验证加密锁密钥出错!";
                return;
            }
            #endregion

            if (ddlOrg.SelectedValue == "0")
            {
                SessionSet.PageMessage = "请选择单位!";
                return;
            }

            LoginUserBLL loginUserBLL = new LoginUserBLL();
            LoginUser    loginUser;

            if (PrjPub.IsServerCenter)
            {
                loginUser = loginUserBLL.GetLoginUserByOrgID(Convert.ToInt32(ddlOrg.SelectedValue), txtUserName.Text, txtPassword.Text, 0);
            }
            else
            {
                loginUser = loginUserBLL.GetLoginUserByOrgID(Convert.ToInt32(ddlOrg.SelectedValue), txtUserName.Text, txtPassword.Text, 1);
            }

            if (loginUser == null)
            {
                SessionSet.PageMessage = "您输入的用户名或密码不正确!";
                return;
            }

            string strUser     = string.Empty;
            string strCacheKey = loginUser.EmployeeID.ToString();

            strUser = Convert.ToString(Cache[strCacheKey]);

            SystemUserLoginBLL      objloginBll = new SystemUserLoginBLL();
            IList <SystemUserLogin> objList     = objloginBll.GetSystemUserLogin(loginUser.EmployeeID);

            if (strUser == string.Empty || objList.Count == 0)
            {
                TimeSpan SessTimeOut = new TimeSpan(0, 0, System.Web.HttpContext.Current.Session.Timeout, 0, 0);

                Cache.Insert(strCacheKey, strCacheKey, null, DateTime.MaxValue, SessTimeOut, CacheItemPriority.NotRemovable, null);
                Session["User"] = strCacheKey;

                if (objList.Count == 0)
                {
                    SystemUserLogin objLogin = new SystemUserLogin();
                    objLogin.EmployeeID = loginUser.EmployeeID;
                    objLogin.IPAddress  = Pub.GetRealIP();
                    objloginBll.DeleteSystemUserLogin(loginUser.EmployeeID);
                    objloginBll.AddSystemUserLogin(objLogin);
                }
            }
            else
            {
                SessionSet.PageMessage = "该用户已经登录,不能重复登录!";
                return;
            }

            PrjPub.CurrentLoginUser     = loginUser;
            PrjPub.CurrentStudent       = loginUser;
            PrjPub.WelcomeInfo          = loginUser.OrgName + ":" + loginUser.EmployeeName + ",您好!";
            PrjPub.StudentID            = loginUser.EmployeeID.ToString();
            hfEmployeeID.Value          = loginUser.EmployeeID.ToString();
            Session["StudentOrdID"]     = loginUser.OrgID;
            SessionSet.UserID           = loginUser.UserID;
            SessionSet.EmployeeID       = loginUser.EmployeeID;
            SessionSet.EmployeeName     = loginUser.EmployeeName;
            SessionSet.OrganizationID   = loginUser.OrgID;
            SessionSet.OrganizationName = loginUser.OrgName;
            SessionSet.StationOrgID     = loginUser.StationOrgID;

            EmployeeBLL     objEmployeeBll = new EmployeeBLL();
            OrganizationBLL objOrgBll      = new OrganizationBLL();
            //控件显示
            lblUserName.Text = "姓&nbsp;&nbsp;&nbsp;&nbsp;名:";
            lblOrgName.Text  = objOrgBll.GetOrganization(loginUser.StationOrgID).ShortName;

            lblPassword.Text     = "工资编号:";
            lblOrg.Text          = objEmployeeBll.GetEmployee(loginUser.EmployeeID).WorkNo;
            lblEmployeeName.Text = loginUser.EmployeeName;

            lbl.Visible     = true;
            lblPost.Visible = true;
            lblPost.Text    = loginUser.PostName;

            if (Request.QueryString.Get("Type") == "middle")
            {
                ddlOrg.Visible           = false;
                lblOrgName.Visible       = true;
                txtUserName.Visible      = false;
                txtPassword.Visible      = false;
                ImageButtonLogin.Visible = false;
                btnExit.Visible          = true;
                lblOrg.Visible           = true;
                lblEmployeeName.Visible  = true;
                btnModifyPsw.Visible     = true;
                btnExam.Visible          = true;

                //ClientScript.RegisterStartupScript(GetType(),
                //        "jsSelectFirstNode",
                //        @"ShowExamList();",
                //        true);

                //ClientScript.RegisterStartupScript(GetType(), "import", "inputCallback.callback('middle');", true);
            }
            else if (Request.QueryString.Get("Type") == "right")
            {
                ddlOrg.Visible           = false;
                lblOrgName.Visible       = true;
                txtUserName.Visible      = false;
                txtPassword.Visible      = false;
                ImageButtonLogin.Visible = false;
                btnExit.Visible          = true;
                lblOrg.Visible           = true;
                lblEmployeeName.Visible  = true;
                btnModifyPsw.Visible     = true;
                btnResult.Visible        = true;

                //ClientScript.RegisterStartupScript(GetType(),
                //    "jsSelectFirstNode",
                //    @"ShowResultList();",
                //    true);

                //ClientScript.RegisterStartupScript(GetType(), "import", "inputCallback.callback('right');", true);
            }
            else if (Request.QueryString.Get("Type") == "left")
            {
                //将此人的登录次数+1
                EmployeeBLL objEmpBll = new EmployeeBLL();
                Employee    employee  = objEmpBll.GetEmployee(loginUser.EmployeeID);

                employee.LoginCount = employee.LoginCount + 1;
                if (PrjPub.IsServerCenter)
                {
                    objEmpBll.UpdateEmployee(employee);
                }
                else
                {
                    objEmpBll.UpdateEmployeeInStation(employee);
                }

                ddlOrg.Visible           = false;
                lblOrgName.Visible       = true;
                txtUserName.Visible      = false;
                txtPassword.Visible      = false;
                ImageButtonLogin.Visible = false;
                btnExit.Visible          = true;
                lblOrg.Visible           = true;
                lblEmployeeName.Visible  = true;
                btnModifyPsw.Visible     = true;
                btnExam.Visible          = false;
                btnStudy.Visible         = true;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            string type = Request.QueryString.Get("type1");

            if (type == "StudySelected")
            {
                this.btnStudy.Visible = false;
            }
            else
            {
                if (Request.QueryString.Get("Type") == "middle" && Request.QueryString.Get("IsFinger") == "1")//!PrjPub.IsServerCenter &&
                {
                    string errorMessage = "";
                    string mac_dest     = "";
                    try
                    {
                        mac_dest = GetCustomerMac(GetClientIP());
                    }
                    catch
                    {
                        errorMessage = "无法获取客户端MAC地址!";
                        mac_dest     = "";
                    }

                    //errorMessage = mac_dest;
                    //mac_dest = "";

                    string employeeId = "";
                    string examId     = "";
                    lblMAC.Text = mac_dest;
                    if (!string.IsNullOrEmpty(mac_dest))
                    {
                        string strSql = "select * from Computer_Room_Detail"
                                        + " where MAC_Address='" + mac_dest + "'";

                        OracleAccess db = new OracleAccess();

                        DataSet ds = db.RunSqlDataSet(strSql);

                        if (ds.Tables[0].Rows.Count > 0)
                        {
                            string computerId   = ds.Tables[0].Rows[0]["Computer_Room_ID"].ToString();
                            string computerSeat = ds.Tables[0].Rows[0]["Computer_Room_Seat"].ToString();

                            strSql = "select * from Random_Exam_Result_Detail_Temp "
                                     + " where Computer_Room_ID=" + computerId
                                     + " and Computer_Room_Seat=" + computerSeat
                                     + " and FingerPrint is not null and Is_Remove=0";

                            DataSet dsResult = db.RunSqlDataSet(strSql);

                            if (dsResult.Tables[0].Rows.Count > 0)
                            {
                                employeeId = dsResult.Tables[0].Rows[0]["Employee_ID"].ToString();
                                examId     = dsResult.Tables[0].Rows[0]["Random_Exam_ID"].ToString();

                                strSql = "select a.* from System_User a "
                                         + " inner join Employee b on a.Employee_ID=b.Employee_ID "
                                         + " where a.Employee_ID=" + employeeId;

                                DataSet dsSystem = db.RunSqlDataSet(strSql);

                                LoginUserBLL loginUserBLL = new LoginUserBLL();
                                LoginUser    loginUser;
                                if (dsSystem.Tables[0].Rows.Count > 0)
                                {
                                    loginUser = loginUserBLL.GetLoginUser(dsSystem.Tables[0].Rows[0]["User_ID"].ToString(), dsSystem.Tables[0].Rows[0]["Password"].ToString(), 1);
                                }
                                else
                                {
                                    strSql = "select * from  Employee  "
                                             + " where Employee_ID=" + employeeId;
                                    DataRow dr = db.RunSqlDataSet(strSql).Tables[0].Rows[0];

                                    string strUserId;
                                    if (dr["Work_No"] == DBNull.Value)
                                    {
                                        strUserId = dr["Identity_CardNo"].ToString();
                                    }
                                    else
                                    {
                                        strUserId = dr["Work_No"].ToString();
                                    }

                                    strSql = "insert into System_User values("
                                             + "'" + strUserId + "','111111',"
                                             + employeeId + ",0,null)";
                                    db.ExecuteNonQuery(strSql);

                                    //strSql = "begin dbms_mview.refresh('System_User','?'); end;";
                                    //db.ExecuteNonQuery(strSql);

                                    loginUser = loginUserBLL.GetLoginUser(strUserId, "111111", 1);
                                }

                                if (string.IsNullOrEmpty(Request.QueryString.Get("type1")))
                                {
                                    string strUser     = string.Empty;
                                    string strCacheKey = loginUser.EmployeeID.ToString();

                                    strUser = Convert.ToString(Cache[strCacheKey]);

                                    SystemUserLoginBLL      objloginBll = new SystemUserLoginBLL();
                                    IList <SystemUserLogin> objList     = objloginBll.GetSystemUserLogin(loginUser.EmployeeID);

                                    if (strUser == string.Empty || objList.Count == 0)
                                    {
                                        TimeSpan SessTimeOut = new TimeSpan(0, 0, System.Web.HttpContext.Current.Session.Timeout, 0, 0);

                                        Cache.Insert(strCacheKey, strCacheKey, null, DateTime.MaxValue, SessTimeOut,
                                                     CacheItemPriority.NotRemovable, null);
                                        Session["User"] = strCacheKey;

                                        if (objList.Count == 0)
                                        {
                                            SystemUserLogin objLogin = new SystemUserLogin();
                                            objLogin.EmployeeID = loginUser.EmployeeID;
                                            objLogin.IPAddress  = Pub.GetRealIP();
                                            objloginBll.DeleteSystemUserLogin(loginUser.EmployeeID);
                                            objloginBll.AddSystemUserLogin(objLogin);
                                        }
                                    }
                                }

                                PrjPub.CurrentStudent       = loginUser;
                                PrjPub.WelcomeInfo          = loginUser.OrgName + ":" + loginUser.EmployeeName + ",您好!";
                                PrjPub.StudentID            = loginUser.EmployeeID.ToString();
                                hfEmployeeID.Value          = loginUser.EmployeeID.ToString();
                                Session["StudentOrdID"]     = loginUser.OrgID;
                                SessionSet.UserID           = loginUser.UserID;
                                SessionSet.EmployeeID       = loginUser.EmployeeID;
                                SessionSet.EmployeeName     = loginUser.EmployeeName;
                                SessionSet.OrganizationID   = loginUser.OrgID;
                                SessionSet.OrganizationName = loginUser.OrgName;
                                SessionSet.StationOrgID     = loginUser.StationOrgID;

                                OrganizationBLL objOrgBll = new OrganizationBLL();
                                //控件显示
                                lblUserName.Text = "姓&nbsp;名:" + DateTime.Now;
                                lblOrg.Text      = objOrgBll.GetOrganization(loginUser.StationOrgID).ShortName;

                                lblPassword.Text     = "单&nbsp;位:";
                                lblEmployeeName.Text = loginUser.EmployeeName;

                                trCard.Visible  = false;
                                lbl.Visible     = true;
                                lblPost.Visible = true;
                                lblPost.Text    = loginUser.PostName;


                                txtUserName.Visible      = false;
                                txtPassword.Visible      = false;
                                ImageButtonLogin.Visible = false;
                                btnExit.Visible          = true;
                                lblOrg.Visible           = true;
                                lblEmployeeName.Visible  = true;
                                //btnModifyPsw.Visible = true;
                                btnExam.Visible = true;
                            }
                        }
                        //else
                        //{
                        //    errorMessage = "系统中不存在当前客户端的MAC地址!";
                        //}
                    }

                    ClientScript.RegisterStartupScript(GetType(),
                                                       "jsSelectFirstNode",
                                                       @"ShowStudentExam('" + errorMessage + "','" + employeeId + "','" + examId + "');",
                                                       true);
                }
            }

            lbl1.Text = "员工编码:";
        }
Exemple #17
0
        protected void ImageButtonLogin_Click(object sender, ImageClickEventArgs e)
        {
            LoginUserBLL loginUserBLL = new LoginUserBLL();
            LoginUser    loginUser;

            if (PrjPub.IsServerCenter)
            {
                loginUser = loginUserBLL.GetLoginUser(txtUserID.Text, txtPassword.Text, 0);
            }
            else
            {
                loginUser = loginUserBLL.GetLoginUser(txtUserID.Text, txtPassword.Text, 1);
            }

            if (loginUser == null)
            {
                SessionSet.PageMessage = "您输入的用户名或密码不正确!";
                return;
            }

            PrjPub.CurrentStudent   = loginUser;
            PrjPub.WelcomeInfo      = loginUser.OrgName + ":" + loginUser.EmployeeName + ",您好!";
            PrjPub.StudentID        = loginUser.EmployeeID.ToString();
            Session["StudentOrdID"] = loginUser.OrgID;

            //控件显示
            lblUserName.Text = "单&nbsp;&nbsp;位:";
            lblOrg.Text      = loginUser.OrgName;

            lblPassword.Text     = "姓&nbsp;&nbsp;名:";
            lblEmployeeName.Text = loginUser.EmployeeName;

            lblWorkNo1.Visible = true;
            lblWorkNo2.Visible = true;
            EmployeeBLL objEmployeeBll = new EmployeeBLL();

            lblWorkNo2.Text = objEmployeeBll.GetEmployee(loginUser.EmployeeID).WorkNo;

            string strPost = loginUser.PostName;

            PostBLL objPostBll    = new PostBLL();
            Post    objPost       = objPostBll.GetPost(loginUser.PostID);
            Post    objPostType   = objPostBll.GetPost(objPost.ParentId);
            string  strType       = objPostType.PostName;
            Post    objPostSystem = objPostBll.GetPost(objPostType.ParentId);
            string  strSystem     = objPostSystem.PostName;

            lblFullName.Text = strSystem + "-" + strType + "-" + strPost;

            txtUserID.Visible       = false;
            lblOrg.Visible          = true;
            txtPassword.Visible     = false;
            lblEmployeeName.Visible = true;
            lblPostName.Visible     = true;
            lblFullName.Visible     = true;

            ImageButtonLogin.Visible  = false;
            ImageButtonLogout.Visible = true;

            btnStudyBook.Visible       = false;
            btnStudyCourse.Visible     = false;
            btnSelectTrainType.Visible = true;
            btnStudy.Visible           = true;

            BindGrid();
        }
Exemple #18
0
        protected void ImageButtonLogin_Click(object sender, ImageClickEventArgs e)
        {
            #region 验证服务器端狗信息

            if (!string.IsNullOrEmpty(ConfigurationManager.AppSettings["PID"]))
            {
                ET99FullClass et99 = new ET99FullClass();

                Random random = new Random((int)(DateTime.Now.Ticks >> 32));
                string strServerRandomData   = string.Empty;
                string strServerRandomResult = string.Empty;
                string strServerPid          = string.Empty;
                string strServerUserpin      = string.Empty;
                //string strServerSn = string.Empty;
                string strServerKey = string.Empty;

                for (int i = 0; i < 20; i++)
                {
                    strServerRandomData += random.Next(9).ToString();
                }

                try
                {
                    strServerPid = ConfigurationManager.AppSettings["PID"];
                    et99.FindToken(strServerPid);
                }
                catch
                {
                    SessionSet.PageMessage = "服务器端未检测到加密锁!";
                    return;
                }
                try
                {
                    et99.OpenToken(strServerPid, 1);
                }
                catch
                {
                    SessionSet.PageMessage = "服务器端打开加密锁失败!";
                    et99.CloseToken();
                    return;
                }
                try
                {
                    strServerUserpin = ConfigurationManager.AppSettings["USERPIN"];
                    et99.VerifyPIN(0, strServerUserpin);
                }
                catch
                {
                    SessionSet.PageMessage = "服务器端加密锁USERPIN不正确!";
                    et99.CloseToken();
                    return;
                }
                //try
                //{
                //    strServerSn = ConfigurationManager.AppSettings["SN"];
                //    if (et99.GetSN().ToString() != strServerSn)
                //    {
                //        SessionSet.PageMessage = "服务器端加密锁SN不正确!";
                //        return;
                //    }
                //}
                //catch
                //{
                //    SessionSet.PageMessage = "服务器端获取加密锁SN出错!";
                //}
                try
                {
                    strServerKey          = ConfigurationManager.AppSettings["KEY1"];
                    strServerRandomResult = et99.MD5HMAC(1, strServerRandomData, 20).ToString();
                    if (strServerRandomResult != et99.Soft_MD5HMAC(1, strServerRandomData, strServerKey).ToString())
                    {
                        SessionSet.PageMessage = "服务器端加密锁密钥不正确!";
                        return;
                    }
                }
                catch
                {
                    SessionSet.PageMessage = "服务器端验证加密锁密钥出错!";
                    return;
                }
            }

            #endregion

            LoginUserBLL loginUserBLL = new LoginUserBLL();
            LoginUser    loginUser;


            if (PrjPub.IsServerCenter)
            {
                loginUser = loginUserBLL.GetLoginUser(txtUserName.Text, txtPassword.Text, 0);
            }
            else
            {
                loginUser = loginUserBLL.GetLoginUser(txtUserName.Text, txtPassword.Text, 1);
            }


            if (loginUser == null)
            {
                SessionSet.PageMessage = "您输入的用户名或密码不正确!";
                return;
            }

            if (loginUser.RoleID == 0)
            {
                PrjPub.CurrentStudent   = loginUser;
                PrjPub.WelcomeInfo      = loginUser.OrgName + ":" + loginUser.EmployeeName + ",您好!";
                PrjPub.StudentID        = loginUser.EmployeeID.ToString();
                Session["StudentOrdID"] = loginUser.OrgID;
                Response.Redirect("Online/AccountManage.aspx");
            }

            PrjPub.CurrentLoginUser     = loginUser;
            PrjPub.WelcomeInfo          = loginUser.OrgName + ":" + loginUser.EmployeeName + ",您好!";
            SessionSet.UserID           = loginUser.UserID;
            SessionSet.EmployeeID       = loginUser.EmployeeID;
            SessionSet.EmployeeName     = loginUser.EmployeeName;
            SessionSet.OrganizationID   = loginUser.OrgID;
            SessionSet.OrganizationName = loginUser.OrgName;
            SessionSet.StationOrgID     = loginUser.StationOrgID;


            //if (!PrjPub.IsWuhan() && loginUser.EmployeeID != 1 && loginUser.EmployeeID != 2 && !(loginUser.RoleID==2 && !PrjPub.IsServerCenter))
            //{
            //    string strUser = string.Empty;
            //    string strCacheKey = loginUser.EmployeeID.ToString();

            //    strUser = Convert.ToString(Cache[strCacheKey]);

            //    SystemUserLoginBLL objloginBll = new SystemUserLoginBLL();
            //    IList<SystemUserLogin> objList = objloginBll.GetSystemUserLogin(loginUser.EmployeeID);

            //    if (strUser == string.Empty || objList.Count == 0)
            //    {
            //        TimeSpan SessTimeOut = new TimeSpan(0, 0, System.Web.HttpContext.Current.Session.Timeout, 0, 0);

            //        Cache.Insert(strCacheKey, strCacheKey, null, DateTime.MaxValue, SessTimeOut, CacheItemPriority.NotRemovable, null);
            //        Session["User"] = strCacheKey;

            //        if(objList.Count == 0)
            //        {
            //            SystemUserLogin objLogin = new SystemUserLogin();
            //            objLogin.EmployeeID = loginUser.EmployeeID;
            //            objLogin.IPAddress = Pub.GetRealIP();
            //            objloginBll.DeleteSystemUserLogin(loginUser.EmployeeID);
            //            objloginBll.AddSystemUserLogin(objLogin);
            //        }
            //    }
            //    else
            //    {
            //        SessionSet.PageMessage = "该用户已经登录,不能重复登录!";
            //        return;
            //    }
            //}

            //判断用户数

            //ApplicationSet.UserCount ++;
            //if (ApplicationSet.UserCount > ApplicationSet.AllowUserCount)
            //{
            //    SessionSet.PageMessage = "系统已达最大用户数,请稍候登录!";
            //    ApplicationSet.UserCount --;
            //    return;
            //}

            ////控件显示
            //lblUserName.Text = "使用部门:";
            //lblPassword.Text = "登录用户:";
            //lblDepartment.Text = loginUser.OrgName;
            //lblEmployee.Text = loginUser.EmployeeName;
            //lblUserCount.Text = "用户许可数:&nbsp;&nbsp;" + ApplicationSet.AllowUserCount.ToString();

            //txtUserName.Visible = false;
            //txtPassword.Visible = false;
            //ImageButtonLogin.Visible = false;
            //lblDepartment.Visible = true;
            //lblEmployee.Visible = true;
            //lblUserCount.Visible = true;

            ////将登录用户添加到在线用户数组
            //ApplicationSet.UserOnline.Add(loginUser.UserID);

            ////登录成功标志
            //SessionSet.Login = true;

            //设置Form许可
            FormsAuthentication.SetAuthCookie(loginUser.UserID, false);

            //HttpBrowserCapabilities brObject = Request.Browser;
            //SessionSet.PageMessage = brObject.Type;

            if (string.IsNullOrEmpty(Request.QueryString.Get("type")))
            {
                loginUser.IsDangan = false;
                Response.Redirect("Main/Admin_Index.aspx");
            }
            else
            {
                loginUser.IsDangan = true;
                Response.Redirect("Main/Admin_Index_Dangan.aspx");
            }
        }