private OrganizationList GetOrganizationByOperation(List <ResourceOperation> list, Organization organization) { OrganizationList orgList = new OrganizationList(); orgList.AutoTreeIndexEnabled = false; DataConstraintRule constraintRule = DataConstraintRule.All; if (null != list) { foreach (var operation in list) { DataConstraintRule currentConstraintRule; currentConstraintRule = System.Enum.TryParse(operation.OperationName, out currentConstraintRule) ? currentConstraintRule : DataConstraintRule.Own; var value = constraintRule.CompareTo(currentConstraintRule); if (value < 0) { constraintRule = currentConstraintRule; } } } if (constraintRule == DataConstraintRule.OwnCompany) { orgList.Add(organization); } else if (constraintRule == DataConstraintRule.Lower) { orgList.AddRange(HierarchicalStructureDataCache.OrganizationList.Where(o => o.TreeIndex.StartsWith(organization.TreeIndex))); } else if (constraintRule == DataConstraintRule.All) { orgList.AddRange(HierarchicalStructureDataCache.OrganizationList); } return(orgList); }