protected override IConfigurable PrepareDataObject()
        {
            TaskLogger.LogEnter();
            DatabaseAvailabilityGroupConfiguration databaseAvailabilityGroupConfiguration = (DatabaseAvailabilityGroupConfiguration)base.PrepareDataObject();
            DagConfigurationHelper dagConfigurationHelper = DagConfigurationHelper.Deserialize(databaseAvailabilityGroupConfiguration.ConfigurationXML);

            if (dagConfigurationHelper.Version <= 1)
            {
                if (base.Fields["ServersPerDag"] != null)
                {
                    dagConfigurationHelper.ServersPerDag = this.ServersPerDag;
                }
                if (base.Fields["DatabasesPerServer"] != null)
                {
                    dagConfigurationHelper.DatabasesPerServer = this.DatabasesPerServer;
                }
                if (base.Fields["DatabasesPerVolume"] != null)
                {
                    dagConfigurationHelper.DatabasesPerVolume = this.DatabasesPerVolume;
                }
                if (base.Fields["CopiesPerDatabase"] != null)
                {
                    dagConfigurationHelper.CopiesPerDatabase = this.CopiesPerDatabase;
                }
                if (base.Fields["MinCopiesPerDatabaseForMonitoring"] != null)
                {
                    dagConfigurationHelper.MinCopiesPerDatabaseForMonitoring = this.MinCopiesPerDatabaseForMonitoring;
                }
                this.m_configXML = dagConfigurationHelper.Serialize();
                databaseAvailabilityGroupConfiguration.ConfigurationXML = this.m_configXML;
                TaskLogger.LogExit();
                return(databaseAvailabilityGroupConfiguration);
            }
            throw new DagConfigVersionConflictException(databaseAvailabilityGroupConfiguration.Name, 1, dagConfigurationHelper.Version);
        }
 protected override void InternalValidate()
 {
     TaskLogger.LogEnter();
     base.InternalValidate();
     if (this.preExistingDatabase != null)
     {
         TaskLogger.LogExit();
         return;
     }
     if (this.PublicFolderDatabase == null)
     {
         if (base.OwnerServerPublicFolderDatabases != null && base.OwnerServerPublicFolderDatabases.Length > 0)
         {
             this.DataObject.PublicFolderDatabase = (ADObjectId)base.OwnerServerPublicFolderDatabases[0].Identity;
         }
         else
         {
             base.WriteVerbose(Strings.VerboseFindClosestPublicFolderDatabaseFromServer(base.OwnerServer.Id.ToString()));
             this.DataObject.PublicFolderDatabase = Microsoft.Exchange.Data.Directory.SystemConfiguration.PublicFolderDatabase.FindClosestPublicFolderDatabase(base.DataSession, base.OwnerServer.Id);
         }
     }
     else
     {
         this.PublicFolderDatabase.AllowLegacy = true;
         IConfigurable dataObject = base.GetDataObject <PublicFolderDatabase>(this.PublicFolderDatabase, base.DataSession, null, new LocalizedString?(Strings.ErrorPublicFolderDatabaseNotFound(this.PublicFolderDatabase.ToString())), new LocalizedString?(Strings.ErrorPublicFolderDatabaseNotUnique(this.PublicFolderDatabase.ToString())));
         this.DataObject.PublicFolderDatabase = (ADObjectId)dataObject.Identity;
     }
     if (this.OfflineAddressBook != null)
     {
         IConfigurable dataObject2 = base.GetDataObject <OfflineAddressBook>(this.OfflineAddressBook, base.DataSession, null, new LocalizedString?(Strings.ErrorOfflineAddressBookNotFound(this.OfflineAddressBook.ToString())), new LocalizedString?(Strings.ErrorOfflineAddressBookNotUnique(this.OfflineAddressBook.ToString())));
         this.DataObject.OfflineAddressBook = (ADObjectId)dataObject2.Identity;
     }
     base.ValidateFilePaths(base.ParameterSetName == "Recovery");
     if (base.Fields.IsModified("AutoDagExcludeFromMonitoring"))
     {
         this.DataObject.AutoDagExcludeFromMonitoring = this.AutoDagExcludeFromMonitoring;
     }
     else
     {
         DatabaseAvailabilityGroup databaseAvailabilityGroup = DagTaskHelper.ReadDag(this.DataObject.MasterServerOrAvailabilityGroup, this.ConfigurationSession);
         if (databaseAvailabilityGroup != null)
         {
             DatabaseAvailabilityGroupConfiguration databaseAvailabilityGroupConfiguration = DagConfigurationHelper.ReadDagConfig(databaseAvailabilityGroup.DatabaseAvailabilityGroupConfiguration, this.ConfigurationSession);
             if (databaseAvailabilityGroupConfiguration != null)
             {
                 DagConfigurationHelper dagConfigurationHelper = DagConfigurationHelper.Deserialize(databaseAvailabilityGroupConfiguration.ConfigurationXML);
                 if (dagConfigurationHelper.MinCopiesPerDatabaseForMonitoring > 1)
                 {
                     this.DataObject.AutoDagExcludeFromMonitoring = true;
                 }
             }
         }
     }
     TaskLogger.LogExit();
 }
        private DagConfigurationEntry ConstructNewDagConfigEntry(DatabaseAvailabilityGroupConfiguration dagConfig)
        {
            DagConfigurationHelper dagConfigurationHelper = DagConfigurationHelper.Deserialize(dagConfig.ConfigurationXML);

            if (dagConfigurationHelper.Version <= 1)
            {
                return(new DagConfigurationEntry
                {
                    Name = dagConfig.Name,
                    Identity = dagConfig.Identity,
                    ServersPerDag = dagConfigurationHelper.ServersPerDag,
                    DatabasesPerServer = dagConfigurationHelper.DatabasesPerServer,
                    DatabasesPerVolume = dagConfigurationHelper.DatabasesPerVolume,
                    CopiesPerDatabase = dagConfigurationHelper.CopiesPerDatabase,
                    MinCopiesPerDatabaseForMonitoring = dagConfigurationHelper.MinCopiesPerDatabaseForMonitoring
                });
            }
            throw new DagConfigVersionConflictException(dagConfig.Name, 1, dagConfigurationHelper.Version);
        }