Exemplo n.º 1
0
 public ActionResult ActionSave(B_ACTION entity)
 {
     BLL.Organize.Action Action = new BLL.Organize.Action();
     if (ModelState.IsValid)
     {
         bool save;
         try
         {
             save = Action.Save(entity);
         }
         catch (Exception)
         {
             save = false;
         }
         if (save)
         {
             return(Json(new { IsSuccess = true, Message = "保存成功" }, "text/html", JsonRequestBehavior.AllowGet));
         }
         else
         {
             return(Json(new { IsSuccess = false, Message = "保存失败" }, "text/html", JsonRequestBehavior.AllowGet));
         }
     }
     return(View());
 }
Exemplo n.º 2
0
        public ActionResult ActionLoad(int page, int rows, string order, string sort)
        {
            BLL.Organize.Action Action = new BLL.Organize.Action();

            var result = Action.LoadAllActionByPage(page, rows, order, sort);

            return(Json(result));
        }
Exemplo n.º 3
0
        public ActionResult ActionEdit(int?id)
        {
            BLL.Organize.Action Action = new BLL.Organize.Action();
            B_ACTION            cot    = Action.Edit(id) as B_ACTION;

            this.ViewData["entity"] = cot;
            ViewData["action"]      = cot.ParentID == null ? 1000 : cot.ParentID;
            return(View());
        }
Exemplo n.º 4
0
 public ActionResult GetMenu()
 {
     try
     {
         BLL.Organize.Action action = new BLL.Organize.Action();
         string userId = User.Identity.Name.Split('|')[0];
         Dictionary <string, object> dicts = new Dictionary <string, object>();
         dicts.Add("menus", action.GetMenu("0", userId));
         return(this.Json(dicts));
     }
     catch (Exception e)
     {
         Dictionary <string, string> dict = new Dictionary <string, string>();
         dict.Add("InfoID", "0");
         dict.Add("InfoMessage", e.Message);
         return(this.Json(dict));
     }
 }
Exemplo n.º 5
0
        public ActionResult ActionDelete(IList <int> idList)
        {
            BLL.Organize.Action Action = new BLL.Organize.Action();
            bool delete;

            try
            {
                delete = Action.Delete(idList);
            }
            catch (Exception)
            {
                delete = false;
            }

            if (delete)
            {
                return(Json(new { IsSuccess = true, Message = "删除成功" }));
            }
            else
            {
                return(Json(new { IsSuccess = false, Message = "删除失败" }));
            }
        }
Exemplo n.º 6
0
        public ActionResult Login(string userName, string passWord, string validateCode)
        {
            BLL.Organize.Worker bllWorker = new BLL.Organize.Worker();
            BLL.Organize.Action action    = new BLL.Organize.Action();

            if (ModelState.IsValid)
            {
                //检查登录失败次数
                if (FailCount >= FailedLogin)
                {
                    return(Json(new { IsSuccess = false, Message = string.Format("您登录失败{0}次,{1}分钟内不能再登陆!",
                                                                                 FailedLogin,
                                                                                 NoLoginTime) },
                                "text/html", JsonRequestBehavior.AllowGet));
                }

                //检查验证码
                if (Session["ValidateCode"] != null && validateCode != Session["ValidateCode"].ToString())
                {
                    FailCount++;
                    return(Json(new { IsSuccess = false, Message = "验证码错误!" }, "text/html", JsonRequestBehavior.AllowGet));
                }

                //B_WORKER worker = bllWorker.Login(HttpUtility.UrlDecode(userName), HttpUtility.UrlDecode(passWord));
                B_WORKER worker = bllWorker.Login(userName, passWord);

                if (worker != null)
                {
                    if (FailCount > 0)
                    {
                        FailCount = 0;
                    }

                    //判断登陆者有无权限
                    List <C_MENU_TREE> isAuth = action.GetMenu("0", worker.ID.ToString());
                    if (isAuth == null)
                    {
                        return(Json(new { IsSuccess = false, Message = "您没有任何权限,请联系管理员!" }));
                    }

                    //判断是否是Internet访问并且允许此人Internet访问
                    //bool isInternetAccess = Convert.ToBoolean(ConfigurationManager.AppSettings["IsInternetAccess"]);

                    //if (isInternetAccess && worker.IsAllowInternetAccess.ToUpper() == "N")
                    //{
                    //    return Json(new { IsSuccess = false, Message = "您没有Internet访问权限,请联系管理员!" }, "text/html", JsonRequestBehavior.AllowGet);
                    //}

                    //写登录日志
                    BLL.Organize.Worker w = new BLL.Organize.Worker();

                    B_LOGIN_LOG log = new B_LOGIN_LOG();
                    log.Name      = userName;
                    log.IP        = Request.UserHostAddress;
                    log.LoginTime = DateTime.Now;

                    w.LoginLog(log);

                    //登录成功,写cookie
                    FormsAuthentication.SetAuthCookie(worker.ID.ToString() + "|" + worker.Name + "|" + userName, true);

                    Session.Remove("ValidateCode");

                    return(Json(new { IsSuccess = true, Message = "登录成功" }, "text/html", JsonRequestBehavior.AllowGet));
                }
                else
                {
                    FailCount++;
                    return(Json(new { IsSuccess = false, Message = "账号或密码错误,请联系管理员!" }, "text/html", JsonRequestBehavior.AllowGet));
                }
            }

            return(View());
        }