Beispiel #1
0
 public Organization GetOrganization()
 {
     if (_Organization == null)
     {
         _Organization = Organization.GetOrganizationById(this.OrganizationId);
     }
     return _Organization;
 }
Beispiel #2
0
 /// <summary>
 /// 获得当前组织子节点
 /// </summary>
 /// <param name="orgCode"></param>
 /// <returns></returns>
 private List<Organization> GetDeepChildren(Organization organization)
 {
     //返回数据
     List<Organization> list = new List<Organization>();
     //获得下级部门
     List<Organization> childrenOrganization = organization.Children;
     if (childrenOrganization != null)
     {
         foreach (Organization childOrganization in childrenOrganization)
         {
             list.Add(childOrganization);
             list.AddRange(GetDeepChildren(childOrganization));
         }
     }
     return list;
 }
Beispiel #3
0
 private List<Organization> GetDeepParentList(Organization organization)
 {
     List<Organization> organizationList = new List<Organization>();
     if (organization != null && organization.GetParent() != null)
     {
         organizationList.AddRange(GetDeepParentList(organization.GetParent()));
         organizationList.Add(organization.GetParent());
     }
     return organizationList;
 }
Beispiel #4
0
 public Organization SetParent(Organization parent)
 {
     parent.AddChild(this);
     _Parent = parent;
     return parent;
 }
Beispiel #5
0
 public Organization RemoveChild(Organization organization)
 {
     if (organization.ParentId == this.Id)
     {
         organization.Delete();
     }
     return organization;
 }
Beispiel #6
0
 /// <summary>
 /// 上级部门
 /// </summary>
 public Organization GetParent()
 {
     if (_Parent == null)
     {
         _Parent = GetOrganizationById(this.ParentId);
     }
     return _Parent;
 }
Beispiel #7
0
 /// <summary>
 /// 新增子节点
 /// </summary>
 /// <param name="organization"></param>
 public Organization AddChild(Organization organization)
 {
     //设置上级id
     if (organization.ParentId != this.Id)
     {
         //检查互斥
         List<Role> roleList1 = this.LinkRoleList;
         List<Role> roleList2 = organization.LinkRoleList;
         foreach (Role role1 in roleList1)
         {
             foreach (Role role2 in roleList1)
             {
                 if (RoleMutex.CheckMutex(role1, role2, RoleMutexType.Static))
                 {
                     throw new Exception("当前组织或其父级或其子级的角色存在静态互斥关系");
                 }
             }
         }
         organization.ParentId = this.Id;
         organization.Save();
     }
     return organization;
 }
Beispiel #8
0
 /// <summary>
 /// 构造函数
 /// </summary>
 public static Organization Create()
 {
     Organization organization = new Organization();
     return organization;
 }