private List <DatabaseAvailabilityGroupNetwork> Find(QueryFilter queryFilter, ObjectId rootId, bool deepSearch, SortBy sortBy)
        {
            List <DatabaseAvailabilityGroupNetwork> list = new List <DatabaseAvailabilityGroupNetwork>();
            DagNetworkQueryFilter dagNetworkQueryFilter  = null;

            if (queryFilter != null)
            {
                dagNetworkQueryFilter = (queryFilter as DagNetworkQueryFilter);
            }
            IEnumerable <DatabaseAvailabilityGroup> enumerable;

            if (this.TargetDag != null)
            {
                enumerable = new DatabaseAvailabilityGroup[]
                {
                    this.TargetDag
                };
            }
            else
            {
                string identity = "*";
                if (dagNetworkQueryFilter != null && dagNetworkQueryFilter.NamesToMatch != null && dagNetworkQueryFilter.NamesToMatch.DagName != null)
                {
                    identity = dagNetworkQueryFilter.NamesToMatch.DagName;
                }
                DatabaseAvailabilityGroupIdParameter databaseAvailabilityGroupIdParameter = DatabaseAvailabilityGroupIdParameter.Parse(identity);
                enumerable = databaseAvailabilityGroupIdParameter.GetObjects <DatabaseAvailabilityGroup>(null, this.m_adSession);
            }
            if (enumerable != null)
            {
                Regex regex = null;
                if (dagNetworkQueryFilter != null && dagNetworkQueryFilter.NamesToMatch != null && dagNetworkQueryFilter.NamesToMatch.NetName != null)
                {
                    string pattern = Wildcard.ConvertToRegexPattern(dagNetworkQueryFilter.NamesToMatch.NetName);
                    regex = new Regex(pattern, RegexOptions.IgnoreCase);
                }
                foreach (DatabaseAvailabilityGroup databaseAvailabilityGroup in enumerable)
                {
                    DagNetworkConfiguration dagNetworkConfiguration = (this.m_targetServer == null) ? DagNetworkRpc.GetDagNetworkConfig(databaseAvailabilityGroup) : DagNetworkRpc.GetDagNetworkConfig(this.m_targetServer);
                    if (dagNetworkConfiguration != null && dagNetworkConfiguration.Networks != null)
                    {
                        this.m_netConfig = dagNetworkConfiguration;
                        foreach (DatabaseAvailabilityGroupNetwork databaseAvailabilityGroupNetwork in dagNetworkConfiguration.Networks)
                        {
                            if (regex == null || regex.IsMatch(databaseAvailabilityGroupNetwork.Name))
                            {
                                DagNetworkObjectId identity2 = new DagNetworkObjectId(databaseAvailabilityGroup.Name, databaseAvailabilityGroupNetwork.Name);
                                databaseAvailabilityGroupNetwork.SetIdentity(identity2);
                                databaseAvailabilityGroupNetwork.ResetChangeTracking();
                                list.Add(databaseAvailabilityGroupNetwork);
                            }
                        }
                    }
                }
            }
            return(list);
        }
Example #2
0
        protected DatabaseAvailabilityGroup LookupDag(DatabaseAvailabilityGroupIdParameter dagParam)
        {
            ADObjectId id = new DatabaseAvailabilityGroupContainer().Id;

            return((DatabaseAvailabilityGroup)base.GetDataObject <DatabaseAvailabilityGroup>(dagParam, base.GlobalConfigSession, id, new LocalizedString?(Strings.ErrorDagNotFound(dagParam.ToString())), new LocalizedString?(Strings.ErrorDagNotUnique(dagParam.ToString()))));
        }