Exemplo n.º 1
0
        public ActionResult GetRoleCode()
        {
            //判断是否是管理员
            if (HomeBusiness.IsAdmin(LoginUser.UserId))
            {
                return(Json("isadmin", JsonRequestBehavior.AllowGet));
            }
            var list = JurisdictionBusiness.GetAllRoleCodeByUserid(LoginUser);

            if (list != null)
            {
                return(Json(list, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json(string.Empty, JsonRequestBehavior.AllowGet));
            }
        }
Exemplo n.º 2
0
        public ActionResult Login(string account, string password, string dbtype)
        {
            var msg     = string.Empty;
            var success = false;

            try
            {
                if (!string.IsNullOrEmpty(dbtype))
                {
                    Session.Timeout = 1440;
                    Session[SessionKey.SESSION_KEY_DBINFO] = dbtype;
                }
                else
                {
                    return(RedirectToAction("LoginPage"));
                }
                var result = HomeBusiness.Login(account, password);

                //写入cookie
                string key  = CommonHelper.Md5(CookieKey.COOKIE_KEY_USERINFO);
                string data = JsonHelper.Serializer <UserLoginInfo>(result);
                CookieHelper.SetCookie(
                    key,
                    CommonHelper.DesEncrypt(data, HomeContent.CookieKeyEncrypt),
                    DateTime.Now.AddDays(1).Date,
                    ServerInfo.GetTopDomain);

                //写入权限信息
                var    list     = JurisdictionBusiness.GetAllRoleCodeByUserid(LoginUser);
                string roleKey  = CommonHelper.Md5(CookieKey.COOKIE_KEY_ROLEINFO);
                string roleData = JsonHelper.Serializer <List <string> >(list);
                CookieHelper.SetCookie(roleKey, CommonHelper.DesEncrypt(roleData, CookieKey.COOKIE_KEY_ENCRYPT),
                                       DateTime.Now.AddDays(1).Date, ServerInfo.GetTopDomain);

                success = true;
            }
            catch (Exception ex)
            {
                msg = ex.Message;
            }
            return(Json(new { Success = success, Message = msg }));
        }