Exemple #1
0
        public JsonResult Authentication(FormCollection form)
        {
            JsonReturnMessages msg = new JsonReturnMessages();
            try
            {
                string userid = form["UserID"];
                string pwd = form["Password"];

                bool IsSuccess = _SysManageService.Authentication(userid, pwd);
                if (IsSuccess)
                {
                    FormsAuthentication.SetAuthCookie(userid, false);
                    msg.IsSuccess = true;
                    msg.Msg = "操作成功";
                }
                else
                {
                    msg.IsSuccess = false;
                    msg.Msg = "用户名或密码错误";
                }
            }
            catch (BizException bizex)
            {
                msg.IsSuccess = false;
                msg.Msg = bizex.Message;
            }
            catch (Exception ex)
            {
                msg.IsSuccess = false;
                msg.Msg = "登录失败:" + ex.Message;
            }
            return Json(msg);
        }
        public JsonResult AddRoleUser(FormCollection form)
        {
            JsonReturnMessages msg = new JsonReturnMessages();
            try
            {
                int roleid = Convert.ToInt32(form["RoleID"]);
                //TODO:验证是否能管理这个角色
                string userids = form["userids"];
                sysManageService.AddRoleUser(roleid, userids, base.UserId, base.CurrentUser.FullName);

                msg.IsSuccess = true;
                msg.Msg = "操作成功";
            }
            catch (BizException bizex)
            {
                msg.IsSuccess = false;
                msg.Msg = bizex.Message;
            }
            catch (Exception ex)
            {
                msg.IsSuccess = false;
                msg.Msg = "操作失败:" + ex.Message;
            }
            return Json(msg);
        }
        public JsonResult DeleteDictInfo(int id)
        {
            JsonReturnMessages msg = new JsonReturnMessages();

            try
            {
                int ret = sysManageService.DeleteDictInfo(id);
                if (ret > 0)
                {
                    msg.IsSuccess = true;
                    msg.Msg = "操作成功";
                }
                else
                {
                    msg.IsSuccess = false;
                    msg.Msg = "操作失败:操作完成了,但是莫有效果";
                }
            }
            catch (Exception ex)
            {
                msg.IsSuccess = false;
                msg.Msg = "操作失败:" + ex.Message;
            }

            return Json(msg);
        }
 public JsonResult DeleteOrgInfo(string id)
 {
     JsonReturnMessages msg = new JsonReturnMessages();
     if (!string.IsNullOrEmpty(id))
     {
         try
         {
             int ret = sysManageService.DeleteOrgInfo(id);
             if (ret > 0)
             {
                 msg.IsSuccess = true;
                 msg.Msg = "操作成功";
             }
             else
             {
                 msg.IsSuccess = false;
                 msg.Msg = "操作失败:操作完成了,但是莫有效果";
             }
         }
         catch (BizException bizex)
         {
             msg.IsSuccess = false;
             msg.Msg = bizex.Message;
         }
         catch //(Exception ex)
         {
             msg.IsSuccess = false;
             msg.Msg = "操作失败,请稍后重试!";
         }
     }
     else
     {
         msg.IsSuccess = false;
         msg.Msg = "参数错误";
     }
     return Json(msg);
 }
        public JsonResult SaveDictInfo(int? id, DictInfo di)
        {
            JsonReturnMessages msg = new JsonReturnMessages();
            try
            {
                if (id.HasValue && id.Value > 0)
                {
                    di.IsNew = false;
                    di.DictID = id.Value;
                }
                else
                {
                    di.IsNew = true;
                }
                di.IsSystem = false;

                sysManageService.SaveDictInfo(di);
                msg.IsSuccess = true;
                msg.Msg = "操作成功";
            }
            catch (BizException ex)
            {
                msg.IsSuccess = false;
                msg.Msg = ex.Message;
            }
            catch (Exception ex)
            {
                msg.IsSuccess = false;
                msg.Msg = "操作失败:" + ex.Message;
            }
            return Json(msg);
        }
        public JsonResult SetRolePrivilege(FormCollection form)
        {
            JsonReturnMessages msg = new JsonReturnMessages();

            try
            {

                int roleid = Convert.ToInt32(form["RoleID"]);
                string addids = form["AddIDS"];
                string minusids = form["MinusIDS"];
                if (string.IsNullOrEmpty(addids) && string.IsNullOrEmpty(minusids))
                {
                    msg.IsSuccess = false;
                    msg.Msg = "没有要操作的项";
                }
                else
                {
                    sysManageService.SetRolePrivilege(roleid, addids, minusids, base.UserId, base.CurrentUser.FullName);
                    msg.IsSuccess = true;
                    msg.Msg = "操作成功";
                }

            }
            catch (BizException bizex)
            {
                msg.IsSuccess = false;
                msg.Msg = bizex.Message;
            }
            catch (Exception ex)
            {
                msg.IsSuccess = false;
                msg.Msg = "操作失败:" + ex.Message;
            }
            return Json(msg);
        }
        public JsonResult SaveUserInfo(string id, UserInfo user)
        {
            JsonReturnMessages msg = new JsonReturnMessages();
            try
            {
                user.IsNew = string.IsNullOrEmpty(id);

                if (user.IsNew && string.IsNullOrEmpty(user.Password))
                {
                    throw new BizException("新用户密码不能为空");
                }
                user.LastUpdateUserUID = base.UserId;
                user.LastUpdateUserName = base.CurrentUser.FullName;
                user.LastUpdateTime = DateTime.Now;

                sysManageService.SaveUserInfo(user);
                msg.IsSuccess = true;
                msg.Msg = "操作成功";
            }
            catch (BizException ex)
            {
                msg.IsSuccess = false;
                msg.Msg = ex.Message;
            }
            catch
            {
                msg.IsSuccess = false;
                msg.Msg = "操作失败,请稍后重试!";
            }
            return Json(msg);
        }
        public JsonResult SaveRoleInfo(int? id, RoleInfo ri)
        {
            JsonReturnMessages msg = new JsonReturnMessages();
            try
            {
                if (id.HasValue && id.Value > 0)
                {
                    ri.IsNew = false;
                    ri.RoleID = id.Value;
                }
                else
                {
                    ri.IsNew = true;
                }

                ri.LastUpdateUserUID = base.UserId;
                ri.LastUpdateUserName = base.CurrentUser.FullName;
                ri.LastUpdateTime = DateTime.Now;
                ri.IsSystem = false;
                sysManageService.SaveRoleInfo(ri);
                msg.IsSuccess = true;
                msg.Msg = "操作成功";
            }
            catch (BizException ex)
            {
                msg.IsSuccess = false;
                msg.Msg = ex.Message;
            }
            catch (Exception ex)
            {
                msg.IsSuccess = false;
                msg.Msg = "操作失败:" + ex.Message;
            }
            return Json(msg);
        }
        public JsonResult SavePrivilegeInfo(string id, Privilege p)
        {
            JsonReturnMessages msg = new JsonReturnMessages();
            try
            {
                if (string.IsNullOrEmpty(id))
                {
                    p.IsNew = true;
                }
                else
                {
                    p.IsNew = false;
                }

                //在根下新建权限
                if (p.PrivilegeCode == "")
                {
                    p.PrivilegeCode = null;
                }
                p.LastUpdateUserUID = base.UserId;
                p.LastUpdateUserName = base.CurrentUser.FullName;
                p.LastUpdateTime = DateTime.Now;

                sysManageService.SavePrivilege(p);

                msg.IsSuccess = true;
                msg.Msg = "操作成功";
            }
            catch (BizException bizex)
            {
                msg.IsSuccess = false;
                msg.Msg = bizex.Message;
            }
            catch
            {
                msg.IsSuccess = false;
                msg.Msg = "操作失败,请稍后重试";
            }
            return Json(msg);
        }
        public JsonResult SaveOrgInfo(string id, Organization Organization)
        {
            JsonReturnMessages msg = new JsonReturnMessages();
            try
            {
                if (string.IsNullOrEmpty(id))
                {
                    Organization.IsNew = true;
                }
                else
                {
                    Organization.IsNew = false;
                }

                Organization.LastUpdateUserUID = base.UserId;
                Organization.LastUpdateUserName = base.CurrentUser.FullName;
                Organization.LastUpdateTime = DateTime.Now;

                sysManageService.SaveOrgInfo(Organization);

                msg.IsSuccess = true;
                msg.Msg = "操作成功";
            }
            catch (BizException bizex)
            {
                msg.IsSuccess = false;
                msg.Msg = bizex.Message;
            }
            catch (Exception ex)
            {
                msg.IsSuccess = false;
                msg.Msg = "操作失败:" + ex.Message;
            }
            return Json(msg);
        }