Пример #1
0
        /// <summary>
        /// 自动登录处理
        /// </summary>
        /// <param name="companyId">公司编号</param>
        /// <param name="userId">用户编号</param>
        /// <param name="username">用户账号</param>
        /// <param name="uInfo">登录用户信息</param>
        static void AutoLogin(string companyId, string huiYuanId, string username, out MYlHuiYuanInfo huiYuanInfo)
        {
            huiYuanInfo = null;
            IYlHuiYuanLogin dal        = new DYlHuiYuanLogin();
            var             yuMingInfo = GetYuMingInfo();

            if (yuMingInfo == null)
            {
                huiYuanInfo = null; return;
            }

            huiYuanInfo = dal.Login(huiYuanId);

            if (huiYuanInfo == null)
            {
                return;
            }
            if (huiYuanInfo.Username != username)
            {
                huiYuanInfo = null; return;
            }
            if (huiYuanInfo.CompanyId != companyId)
            {
                huiYuanInfo = null; return;
            }

            huiYuanInfo.LoginTime = huiYuanInfo.LatestLoginTime.HasValue ? huiYuanInfo.LatestLoginTime.Value : DateTime.Now;

            dal.LoginLogwr(huiYuanInfo, 1);

            SetHuiYuanCache(huiYuanInfo);
        }
Пример #2
0
        /// <summary>
        /// 用户登录,返回1登录成功
        /// </summary>
        /// <param name="companyId">系统公司编号</param>
        /// <param name="username">用户名</param>
        /// <param name="pwdInfo">登录密码</param>
        /// <param name="huiYuanInfo">登录会员信息</param>
        /// <param name="cookies_expires_lx">cookies过期类型 0:浏览器关闭,1:30天,2:30分钟</param>
        /// <returns></returns>
        public static int Login(string companyId, string username, MPasswordInfo pwdInfo, out MYlHuiYuanInfo huiYuanInfo, int cookies_expires_lx)
        {
            IYlHuiYuanLogin dal = new DYlHuiYuanLogin();

            huiYuanInfo = null;

            if (string.IsNullOrEmpty(companyId))
            {
                return(0);
            }
            if (string.IsNullOrEmpty(username))
            {
                return(-1);
            }
            if (pwdInfo == null || string.IsNullOrEmpty(pwdInfo.MD5Password))
            {
                return(-2);
            }
            var yuMingInfo = GetYuMingInfo();

            if (yuMingInfo == null)
            {
                return(-3);
            }

            huiYuanInfo = dal.Login(companyId, username, pwdInfo);

            if (huiYuanInfo == null)
            {
                return(-3);
            }
            if (huiYuanInfo.Status != EyouSoft.Model.EnumType.YlStructure.HuiYuanStatus.可用)
            {
                huiYuanInfo = null;
                return(-4);
            }

            huiYuanInfo.LoginTime = DateTime.Now;

            dal.LoginLogwr(huiYuanInfo, 0);

            SetHuiYuanCache(huiYuanInfo);
            SetHuiYuanCookies(huiYuanInfo, cookies_expires_lx);

            return(1);
        }