Ejemplo n.º 1
0
        private bool HISLogin()
        {
            string userName = string.Empty;
            string password = string.Empty;

            if (Request.QueryString["la"] != null && !string.IsNullOrWhiteSpace(Request.QueryString["la"].ToString()))
            {
                userName = Request.QueryString["la"].ToString();
                Huserid  = userName;
            }
            else
            {
                return(false);
            }
            if (Request.QueryString["pw"] != null && !string.IsNullOrWhiteSpace(Request.QueryString["pw"].ToString()))
            {
                password = Request.QueryString["pw"].ToString();
            }
            else
            {
                return(false);
            }
            if (Request.QueryString["operator_no"] != null && !string.IsNullOrWhiteSpace(Request.QueryString["operator_no"].ToString()))
            {
                Hoperid = Request.QueryString["operator_no"].ToString();
            }
            else
            {
                return(false);
            }
            if (Request.QueryString["PERFORMED_BY"] != null && !string.IsNullOrWhiteSpace(Request.QueryString["PERFORMED_BY"].ToString()))
            {
                Hdept = Request.QueryString["PERFORMED_BY"].ToString();
            }
            else
            {
                return(false);
            }
            //if (Request.QueryString["Hdeptname"] != null && !string.IsNullOrWhiteSpace(Request.QueryString["Hdeptname"].ToString()))
            //{
            //    Hdeptname = Request.QueryString["Hdeptname"].ToString();
            //}
            //else
            //{
            //    return false;
            //}
            if (Request.QueryString["patient_id"] != null && !string.IsNullOrWhiteSpace(Request.QueryString["patient_id"].ToString()))
            {
                Hpatient = Request.QueryString["patient_id"].ToString();
            }
            else
            {
                return(false);
            }
            if (Request.QueryString["visit_id"] != null && !string.IsNullOrWhiteSpace(Request.QueryString["visit_id"].ToString()))
            {
                Hvisit = Request.QueryString["visit_id"].ToString();
            }
            else
            {
                return(false);
            }
            if (Request.QueryString["doctor_user"] != null && !string.IsNullOrWhiteSpace(Request.QueryString["doctor_user"].ToString()))
            {
                Hdoctor = Request.QueryString["doctor_user"].ToString();
            }
            else
            {
                return(false);
            }
            if (Request.QueryString["order_doctor"] != null && !string.IsNullOrWhiteSpace(Request.QueryString["order_doctor"].ToString()))
            {
                Hdoctorname = Request.QueryString["order_doctor"].ToString();
            }
            else
            {
                return(false);
            }
            LoginInfo login = UserLogin(userName);

            if (login != null)
            {
                bool isEncrypt = EncryptionUtil.ComparePasswords(login.UserPwd, password);
                if (isEncrypt)
                {
                    if (!login.Enabled)
                    {
                        return(false);
                    }
                    else if (login.UserStatus != "01")
                    {
                        return(false);
                    }
                    else
                    {
                        // 登录成功
                        HttpCookie myCookie = new HttpCookie("YUAN_" + Request.Url.Authority, userName + "@" + password + "@N@N");
                        myCookie.Expires = System.DateTime.Now.AddMinutes(600);
                        Response.Cookies.Add(myCookie);

                        UserInfo user = new UserInfo()
                        {
                            UserDept = login.UserDept,
                            UserID   = login.UserID,
                            UserName = login.UserName,
                            UserPwd  = login.UserPwd,
                            UserRole = login.UserRole,
                            Enabled  = login.Enabled
                        };

                        DateTime expiration = DateTime.Now.AddMinutes(120);
                        CreateFormsAuthenticationTicket(user.UserID, JsonConvert.SerializeObject(user), false, expiration);

                        return(true);
                    }
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }