Пример #1
0
        /// <summary>
        /// 获取用户信息
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        private MUserInfo ReadUserInfo(DbCommand cmd)
        {
            EyouSoft.Model.SSOStructure.MUserInfo model = null;
            using (IDataReader dr = DbHelper.ExecuteReader(cmd, SystemStore))
            {
                if (dr.Read())
                {
                    model               = new MUserInfo();
                    model.UserID        = dr.IsDBNull(dr.GetOrdinal("UserID")) ? "" : dr.GetString(dr.GetOrdinal("UserID"));
                    model.UserName      = dr.IsDBNull(dr.GetOrdinal("UserName")) ? "" : dr.GetString(dr.GetOrdinal("UserName"));
                    model.UserPwd       = dr.IsDBNull(dr.GetOrdinal("UserPwd")) ? "" : dr.GetString(dr.GetOrdinal("UserPwd"));
                    model.ContactName   = dr.IsDBNull(dr.GetOrdinal("ContactName")) ? "" : dr.GetString(dr.GetOrdinal("ContactName"));
                    model.ContactSex    = (Eyousoft_yhq.Model.sexType)dr.GetByte(dr.GetOrdinal("ContactSex"));
                    model.Remark        = dr.IsDBNull(dr.GetOrdinal("Remark")) ? "" : dr.GetString(dr.GetOrdinal("Remark"));
                    model.PromotionCode = dr.IsDBNull(dr.GetOrdinal("PromotionCode")) ? "" : dr.GetString(dr.GetOrdinal("PromotionCode"));
                    model.valiUser      = GetBoolean(dr.GetString(dr.GetOrdinal("valiUser")));
                    model.IsAdmin       = dr.GetString(dr.GetOrdinal("IsAgent"));
                    model.IsZZ          = GetBoolean(dr.GetString(dr.GetOrdinal("IsZZ")));

                    if (!dr.IsDBNull(dr.GetOrdinal("IssueTime")))
                    {
                        model.IssueTime = dr.GetDateTime(dr.GetOrdinal("IssueTime"));
                    }

                    model.MingPianId = dr["MingPianId"].ToString();
                }
            }

            if (model != null)
            {
                model.WeiDianId = GetWeiDianId(model.UserID);
            }

            return(model);
        }
Пример #2
0
        /// <summary>
        /// 用户是否登录
        /// </summary>
        /// <param name="info">登录用户信息</param>
        /// <returns></returns>
        public static bool IsLogin(out MUserInfo info)
        {
            info = GetUserInfo();

            if (info == null) return false;

            return true;
        }
Пример #3
0
        /// <summary>
        /// 自动登录,返回1成功,其它失败
        /// </summary>
        /// <param name="huiYuanId">会员编号</param>
        /// <param name="info">out</param>
        /// <returns></returns>
        public static int AutoLogin(string huiYuanId, out MUserInfo info)
        {
            var _dal = new Eyousoft_yhq.SQLServerDAL.DMemberLogin();
            info = null;

            info = _dal.LoginById(huiYuanId);
            if (info == null) return 0;

            SetCookies(info);

            return 1;
        }
Пример #4
0
        /// <summary>
        /// 获取用户信息
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        private MUserInfo ReadUserInfo(DbCommand cmd)
        {
            EyouSoft.Model.SSOStructure.MUserInfo model = null;
            using (IDataReader dr = DbHelper.ExecuteReader(cmd, SystemStore))
            {
                if (dr.Read())
                {
                    model = new MUserInfo();
                    model.UserID = dr.IsDBNull(dr.GetOrdinal("UserID")) ? "" : dr.GetString(dr.GetOrdinal("UserID"));
                    model.UserName = dr.IsDBNull(dr.GetOrdinal("UserName")) ? "" : dr.GetString(dr.GetOrdinal("UserName"));
                    model.UserPwd = dr.IsDBNull(dr.GetOrdinal("UserPwd")) ? "" : dr.GetString(dr.GetOrdinal("UserPwd"));
                    model.ContactName = dr.IsDBNull(dr.GetOrdinal("ContactName")) ? "" : dr.GetString(dr.GetOrdinal("ContactName"));
                    model.ContactSex = (Eyousoft_yhq.Model.sexType)dr.GetByte(dr.GetOrdinal("ContactSex"));
                    model.Remark = dr.IsDBNull(dr.GetOrdinal("Remark")) ? "" : dr.GetString(dr.GetOrdinal("Remark"));
                    model.PromotionCode = dr.IsDBNull(dr.GetOrdinal("PromotionCode")) ? "" : dr.GetString(dr.GetOrdinal("PromotionCode"));
                    model.valiUser = GetBoolean(dr.GetString(dr.GetOrdinal("valiUser")));
                    model.IsAdmin = dr.GetString(dr.GetOrdinal("IsAgent"));
                    model.IsZZ = GetBoolean(dr.GetString(dr.GetOrdinal("IsZZ")));

                    if (!dr.IsDBNull(dr.GetOrdinal("IssueTime")))
                    {
                        model.IssueTime = dr.GetDateTime(dr.GetOrdinal("IssueTime"));
                    }

                    model.MingPianId = dr["MingPianId"].ToString();
                }
            }

            if (model != null)
            {
                model.WeiDianId = GetWeiDianId(model.UserID);
            }

            return model;
        }
Пример #5
0
        /// <summary>
        /// 设置登录Cookies
        /// </summary>
        /// <param name="info">登录用户信息</param>
        private static void SetCookies(MUserInfo info)
        {
            //Cookies生存周期为浏览器进程
            HttpResponse response = HttpContext.Current.Response;

            RemoveCookies();

            var cookie = new HttpCookie(LoginCookieUserId);
            cookie.Value = info.UserID.ToString();
            cookie.HttpOnly = true;
            response.AppendCookie(cookie);

            cookie = new HttpCookie(LoginCookieUsername);
            cookie.Value = HttpContext.Current.Server.UrlEncode(info.UserName);
            cookie.HttpOnly = true;
            response.AppendCookie(cookie);

            cookie = new HttpCookie(LoginCookieLastLogTime);
            cookie.Value = DateTime.Now.ToString("yyyy-M-d-H-m-s");
            //cookie.HttpOnly = true;
            response.AppendCookie(cookie);
        }
Пример #6
0
 public void autoLogin(string userId, string username, out MUserInfo uInfo)
 {
     uInfo = null;
     uInfo = dal.LoginById(userId);
     if (uInfo == null) return;
     if (uInfo.UserName != username) { uInfo = null; return; }
 }
Пример #7
0
        /// <summary>
        /// 会员登录,返回1成功,其它失败
        /// </summary>
        /// <param name="u">用户名</param>
        /// <param name="p">密码</param>
        /// <param name="info">OUT 会员信息</param>
        /// <returns></returns>
        public static int Login(string u, string p, out MUserInfo info)
        {
            info = null;
            if (string.IsNullOrEmpty(u) || string.IsNullOrEmpty(p)) return 0;

            var _dal = new Eyousoft_yhq.SQLServerDAL.DMemberLogin();

            info = _dal.Login(u, p);

            if (info == null) return -1;

            SetCookies(info);

            return 1;
        }
Пример #8
0
        /// <summary>
        /// OnInit
        /// </summary>
        /// <param name="e"></param>
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            MUserInfo m = null;
            bool isLogin = IsLogin(out m);

            if (!isLogin)
            {
                string URL = Server.UrlEncode(Request.Url.ToString());
                if (URL.Contains("AppPage"))
                { Response.Redirect("/AppPage/App_login.aspx?rurl=" + URL); }
                else
                {
                    Response.Redirect("/login.aspx?rurl=" + URL);
                }
            }

            HuiYuanInfo = m;
        }