예제 #1
0
        public ActionResult Save(string profileId, string name, PInfo[] pinfo, string description = "")
        {
            if (pinfo == null)
                pinfo = new PInfo[0];

            Profile p = new Profile();
            p.Id = profileId;
            p.Name = name;
            p.Description = description;
            try
            {
                //TODO:调用DAO持久层保存profile信息 RolePermissionDatabase.SaveProfile(p, pinfo);
                return Json(new { msg = "修改成功!" });
            }
            catch (CommandException e)
            {//TODO:根据具体异常中的信息处理错误内容
                logger.Error("修改profile出错!", e);
                string cause = "";
                if (!string.IsNullOrWhiteSpace(e.Cause))
                    cause = "错误原因:" + e.Cause;
                return Json(new { msg = "修改profile失败!" + cause });
            }
        }
예제 #2
0
        /// <summary>
        /// Profile编辑页面
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult Edit(string id)
        {
            try
            {
                InitOrgTree();
                InitResPermission();

                Profile profile = null;//TODO获取指定id的profile对象:RolePermissionDatabase.GetProfile(id);
                var clientProfile = new { Name = profile.Name, Desc = profile.Description, Id = id, PInfos = new List<PInfo>() };

                foreach (var org in profile.AllOrgPermission)
                {
                    PInfo p = new PInfo();
                    p.Path = org.Name;
                    p.Actions = org.RealAction;
                    p.Type = 1;
                    clientProfile.PInfos.Add(p);
                }
                foreach (var res in profile.AllResourcePermission)
                {
                    PInfo p = new PInfo();
                    p.Path = res.Name;
                    p.Actions = res.RealAction;
                    p.Type = 0;
                    clientProfile.PInfos.Add(p);
                }

                ViewBag.Profile = JsonConvert.SerializeObject(clientProfile);
                return View();
            }
            catch (Exception e)
            {
                logger.Error(e);
                return Json(new { msg = "读取Profile信息失败" });
            }
        }