Пример #1
0
 protected internal override void InternalExecute()
 {
     Profile p = new Profile();
     p.Id = Guid.NewGuid().ToString();
     foreach (ProfileData d in data)
     {
         p.AddPermission(d.Path, d.Name, d.Actions, d.Type);
     }
     Factorys.DaoFactory.GetDAO<IAccessDao>().CreateProfile(p);
 }
Пример #2
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 });
            }
        }
Пример #3
0
 /// <summary>
 /// 保存新增的权限信息
 /// </summary>
 /// <param name="profile"></param>
 /// <param name="success"></param>
 /// <returns></returns>
 private ChangeProfileCmd SaveAdded(Profile profile, out bool success)
 {
     success = true;
     try
     {
         if (this.HasArg(ChangeProfileCmd.ARGS_RES_ADDED))
         {
             IList<PermissionArg> pargs = this.Args.ResAdded is PermissionArg[]
                                          ? ((PermissionArg[])this.Args.ResAdded).ToList()
                                          : this.Args.ResAdded as IList<PermissionArg>;
             FilePermissionInfo[] ps = new FilePermissionInfo[pargs.Count];
             for (int i = 0; i < pargs.Count; i++)
             {
                 ps[i] = new FilePermissionInfo(pargs[i].Path);
                 ps[i].RealAction |= pargs[i].Action;
             }
             Factorys.DaoFactory.GetDAO<IAccessDao>().AddPermission(profile.Id, ps);
             for (int i = 0; i < ps.Length; i++)
             {
                 profile.AddResourcePermission(ps[i], pargs[i].Name);
             }
         }
     }
     catch (Exception e)
     {
         Logger.Error("新增资源权限时发生错误!", e);
         success = false;
     }
     try
     {
         if (this.HasArg(ChangeProfileCmd.ARGS_ORG_ADDED))
         {
             IList<PermissionArg> pargs = this.Args.OrgAdded is PermissionArg[]
                                          ? ((PermissionArg[])this.Args.OrgAdded).ToList()
                                          : this.Args.OrgAdded as IList<PermissionArg>;
             OrgPermission[] ps = new OrgPermission[pargs.Count];
             for (int i = 0; i < pargs.Count; i++)
             {
                 ps[i] = new OrgPermission(pargs[i].Path);
                 ps[i].RealAction |= pargs[i].Action;
             }
             Factorys.DaoFactory.GetDAO<IAccessDao>().AddPermission(profile.Id, ps);
             for (int i = 0; i < ps.Length; i++)
             {
                 profile.AddOrgPermission(ps[i], pargs[i].Name);
             }
         }
     }
     catch (Exception e)
     {
         Logger.Error("新增机构权限时发生错误!", e);
         success = false;
     }
     return this;
 }
Пример #4
0
 /// <summary>
 /// 保存删除的权限信息
 /// </summary>
 /// <param name="profile"></param>
 /// <param name="success"></param>
 /// <returns></returns>
 private ChangeProfileCmd SaveRemoved(Profile profile, out bool success)
 {
     success = true;
     try
     {
         if (this.HasArg(ChangeProfileCmd.ARGS_RES_REMOVED))
         {
             IList<PermissionArg> pargs = this.Args.ResRemoved is PermissionArg[]
                                          ? ((PermissionArg[])this.Args.ResRemoved).ToList()
                                          : this.Args.ResRemoved as IList<PermissionArg>;
             string[] removed = new string[pargs.Count];
             for (int i = 0; i < pargs.Count; i++)
             {
                 removed[i] = pargs[i].Name;
             }
             Factorys.DaoFactory.GetDAO<IAccessDao>().RmPermission(this.id, false, removed);
             for (int i = 0; i < removed.Length; i++)
             {
                 profile.Remove(removed[i]);
             }
         }
     }
     catch (Exception e)
     {
         Logger.Error("删除资源权限时发生错误");
         success = false;
     }
     try
     {
         if (this.HasArg(ChangeProfileCmd.ARGS_ORG_REMOVED))
         {
             IList<PermissionArg> pargs = this.Args.OrgRemoved is PermissionArg[]
                                          ? ((PermissionArg[])this.Args.OrgRemoved).ToList()
                                          : this.Args.OrgRemoved as IList<PermissionArg>;
             string[] removed = new string[pargs.Count];
             for (int i = 0; i < pargs.Count; i++)
             {
                 removed[i] = string.IsNullOrWhiteSpace(pargs[i].Id) ? pargs[i].Name : pargs[i].Id;
             }
             Factorys.DaoFactory.GetDAO<IAccessDao>().RmPermission(this.id, true, removed);
             for (int i = 0; i < removed.Length; i++)
             {
                 profile.Remove(removed[i], true);
             }
         }
     }
     catch (Exception e)
     {
         Logger.Error("删除机构权限时发生错误");
         success = false;
     }
     return this;
 }
Пример #5
0
 /// <summary>
 /// 保存更新的权限信息
 /// </summary>
 /// <param name="profile"></param>
 /// <param name="success"></param>
 /// <returns></returns>
 private ChangeProfileCmd SaveEdited(Profile profile, out bool success)
 {
     success = true;
     try
     {
         if (this.HasArg(ChangeProfileCmd.ARGS_RES_EDITED))
         {
             IList<PermissionArg> pargs = this.Args.ResEdited is PermissionArg[]
                                          ? ((PermissionArg[])this.Args.ResEdited).ToList()
                                          : this.Args.ResEdited as IList<PermissionArg>;
             string[] edit = new string[pargs.Count];
             for (int i = 0; i < pargs.Count; i++)
             {
                 edit[i] = string.IsNullOrWhiteSpace(pargs[i].Id) ? pargs[i].Name : pargs[i].Id;
             }
             Factorys.DaoFactory.GetDAO<IAccessDao>().UpdatePermission(this.id, false, edit);
             for (int i = 0; i < pargs.Count; i++)
             {
                 profile.UpdatePermission(pargs[i].Path, pargs[i].Name, pargs[i].Action);
             }
         }
     }
     catch (Exception e)
     {
         Logger.Error("保存资源权限时发生错误");
         success = false;
     }
     try
     {
         if (this.HasArg(ChangeProfileCmd.ARGS_ORG_EDITED))
         {
             IList<PermissionArg> pargs = this.Args.OrgEdited is PermissionArg[]
                                          ? ((PermissionArg[])this.Args.OrgEdited).ToList()
                                          : this.Args.OrgEdited as IList<PermissionArg>;
             string[] edit = new string[pargs.Count];
             for (int i = 0; i < pargs.Count; i++)
             {
                 edit[i] = string.IsNullOrWhiteSpace(pargs[i].Id) ? pargs[i].Name : pargs[i].Id;
             }
             Factorys.DaoFactory.GetDAO<IAccessDao>().UpdatePermission(this.id, true, edit);
             for (int i = 0; i < pargs.Count; i++)
             {
                 profile.UpdatePermission(pargs[i].Path, pargs[i].Name, pargs[i].Action, true);
             }
         }
     }
     catch (Exception e)
     {
         Logger.Error("保存机构权限时发生错误");
         success = false;
     }
     return this;
 }
Пример #6
0
 public void AddProfile(Profile profile)
 {
     profiles.Add(profile);
 }