/// <summary>
        /// 用户登录接口
        /// </summary>
        /// <param name="username">登录用户名</param>
        /// <param name="password">登录密码</param>
        /// <returns></returns>
        public User Login(string username, string password)
        {
            try
            {
                User u = UserDal.Instance.GetUserBy(username);
                if (u != null)
                {
                    if (u.IsDisabled != 1)
                    {
                        bool flag;
                        if (u.IS_DOMAIN == 1)
                        {
                            string domainname = ConfigurationManager.AppSettings["DomainName"];
                            //采用域验证登陆
                            flag = ADLogin.Login(domainname, username, password);
                        }
                        else
                        {
                            flag = UserBll.Instance.UserLoginByClient(username, password);
                        }

                        if (flag)
                        {
                            return(u);
                        }
                    }
                }

                return(null);
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(ex);
                throw ex;
            }
        }
        public ActionResult Index(FormCollection collection)
        {
            string isVcodeSessionKey = Key.SessionKeys.IsValidateCode.ToString();
            string vcodeSessionKey   = Key.SessionKeys.ValidateCode.ToString();

            ViewBag.Forcescript       = "";
            ViewBag.IsVcodeSessionKey = isVcodeSessionKey;
            ViewBag.ErrMsg            = "";
            string account  = collection["Account"];
            string password = collection["Password"];
            string force    = collection["Force"];
            string vcode    = collection["VCode"];

            string domainname = ConfigurationManager.AppSettings["DomainName"];

            // LogHelper.WriteLog("domainname=" + domainname);

            //if (System.Web.HttpContext.Current.Session[isVcodeSessionKey] != null
            //    && "1" == System.Web.HttpContext.Current.Session[isVcodeSessionKey].ToString()
            //    && (System.Web.HttpContext.Current.Session[vcodeSessionKey] == null
            //    || string.Compare(System.Web.HttpContext.Current.Session[vcodeSessionKey].ToString(), vcode.Trim(), true) != 0))
            //{
            //    ViewBag.ErrMsg = "alert('验证码错误!');";
            //}
            //else
            {
                User u = UserDal.Instance.GetUserBy(account);
                if (u != null)
                {
                    if (u.IsDisabled != 1)
                    {
                        bool flag = false;
                        if (u.IS_DOMAIN == 1)
                        {
                            //LogHelper.WriteLog("启用域验证登陆,用户名:" + account + ",密码:" + password);
                            //采用域验证登陆
                            flag = ADLogin.Login(domainname, account, password);
                            //LogHelper.WriteLog("域验证返回值:" + flag);

                            SysVisitor.Instance.UserId      = u.FID;
                            SysVisitor.Instance.MOBILE      = u.Mobile;
                            SysVisitor.Instance.UserName    = u.UserName;
                            SysVisitor.Instance.IsAdmin     = (u.IsAdmin == 1);
                            SysVisitor.Instance.CurrentUser = u;
                            //SysVisitor.Instance.Departments = string.Join(",", GetDepIDs(u.FID, true));
                        }
                        else
                        {
                            flag = UserBll.Instance.UserLogin(account, password);
                        }

                        if (flag)
                        {
                            ViewBag.Forcescript = "top.location='" + Url.Content("~/Home") + "';";
                        }
                        else
                        {
                            System.Web.HttpContext.Current.Session[isVcodeSessionKey] = "1";
                            ViewBag.ErrMsg = "alert('亲,用户名或密码不正确哦。');";
                        }
                    }
                    else
                    {
                        ViewBag.ErrMsg = "alert('亲,您的帐号已被禁用,请联系管理员吧。');";
                    }
                }
                else
                {
                    ViewBag.ErrMsg = "alert('亲,用户名不存在哦!仔细猜一哈。');";
                }
            }
            return(View());
        }