/// <summary>
        /// 用户登录
        /// </summary>
        /// <param name="loginName"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public WebResult <bool> Login(string loginName, string password)
        {
            try
            {
                if (loginName.IsNullOrEmpty() || password.IsNullOrEmpty())
                {
                    return(Result(false, ErrorCode.sys_param_format_error));
                }
                using (var db = new DbRepository())
                {
                    string md5Password = CryptoHelper.MD5_Encrypt(password);
                    var    user        = db.User.Where(x => x.Password.Equals(md5Password) && x.Account.Equals(loginName)).FirstOrDefault();
                    if (user == null)
                    {
                        return(Result(false, ErrorCode.user_login_error));
                    }
                    else if (user.ExpireTime < DateTime.Now)
                    {
                        user.Flag = user.Flag & (long)GlobalFlag.Unabled;
                        db.SaveChanges();
                        return(Result(false, ErrorCode.user_expire));
                    }
                    else if ((user.Flag & (long)GlobalFlag.Unabled) != 0)
                    {
                        return(Result(false, ErrorCode.user_disabled));
                    }
                    else if ((user.Flag & (long)GlobalFlag.Removed) != 0)
                    {
                        return(Result(false, ErrorCode.user_not_exit));
                    }

                    else
                    {
                        var company = db.User.Where(x => x.CompanyId.Equals(user.CompanyId) && x.MenuFlag == -1).FirstOrDefault();
                        if (company == null)
                        {
                            return(Result(false, ErrorCode.user_not_exit));
                        }
                        else if (company.ExpireTime < DateTime.Now)
                        {
                            user.Flag = user.Flag & (long)GlobalFlag.Unabled;
                            db.SaveChanges();
                            return(Result(false, ErrorCode.user_expire));
                        }
                        else if ((company.Flag & (long)GlobalFlag.Unabled) != 0)
                        {
                            return(Result(false, ErrorCode.user_disabled));
                        }
                        else if ((company.Flag & (long)GlobalFlag.Removed) != 0)
                        {
                            return(Result(false, ErrorCode.user_not_exit));
                        }
                        else
                        {
                            CookieHelper.CreateCookie(user);
                            return(Result(true));
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LogHelper.WriteException(ex);
                return(Result(false, ErrorCode.sys_fail));
            }
        }