private void ResolveParameters() { if (this.CommandType == MoveActiveMailboxDatabase.CommandTypes.MoveAwayFromServer) { this.m_sourceServer = (Server)base.GetDataObject <Server>(this.Server, base.DataSession, null, new LocalizedString?(Strings.ErrorMailboxServerNotFound(this.Server.ToString())), new LocalizedString?(Strings.ErrorMailboxServerNotUnique(this.Server.ToString()))); if (this.m_sourceServer == null) { base.WriteError(new InvalidOperationException(Strings.ServerNotFound(this.Server.ToString())), ErrorCategory.InvalidData, this.Server.ToString()); } this.m_sourceAmServer = new AmServerName(this.m_sourceServer); } MailboxServerIdParameter mailboxServerIdParameter = null; if (this.TargetServerSpecified) { mailboxServerIdParameter = this.ActivateOnServer; } else if (this.CommandType == MoveActiveMailboxDatabase.CommandTypes.MoveBackToServer) { mailboxServerIdParameter = this.ActivatePreferredOnServer; } if (mailboxServerIdParameter != null) { this.m_targetServer = (Server)base.GetDataObject <Server>(mailboxServerIdParameter, base.DataSession, null, new LocalizedString?(Strings.ErrorMailboxServerNotFound(mailboxServerIdParameter.ToString())), new LocalizedString?(Strings.ErrorMailboxServerNotUnique(mailboxServerIdParameter.ToString()))); if (this.m_targetServer == null) { base.WriteError(new InvalidOperationException(Strings.ServerNotFound(mailboxServerIdParameter.ToString())), ErrorCategory.InvalidData, mailboxServerIdParameter); } this.m_targetAmServer = new AmServerName(this.m_targetServer); } }
protected override void InternalValidate() { base.InternalValidate(); if (this.Identity == null && this.Server == null) { this.Server = MailboxServerIdParameter.Parse(Environment.MachineName); } MailboxServerIdParameter mailboxServerIdParameter = null; if (this.Server != null) { mailboxServerIdParameter = this.Server; } else if (this.Local) { mailboxServerIdParameter = MailboxServerIdParameter.Parse(Environment.MachineName); } if (mailboxServerIdParameter != null) { this.m_server = (Server)base.GetDataObject <Server>(mailboxServerIdParameter, base.DataSession, null, new LocalizedString?(Strings.ErrorMailboxServerNotFound(mailboxServerIdParameter.ToString())), new LocalizedString?(Strings.ErrorMailboxServerNotUnique(mailboxServerIdParameter.ToString()))); if (base.HasErrors || this.m_server == null) { base.WriteError(new CouldNotFindServerObject(mailboxServerIdParameter.ToString()), ErrorCategory.InvalidOperation, mailboxServerIdParameter); return; } if (!this.m_server.IsE14OrLater) { base.WriteError(new InvalidOperationException(Strings.ErrorServerNotE14OrLater(mailboxServerIdParameter.ToString())), ErrorCategory.InvalidOperation, mailboxServerIdParameter); } if (!this.m_server.IsMailboxServer) { base.WriteError(this.m_server.GetServerRoleError(ServerRole.Mailbox), ErrorCategory.InvalidOperation, mailboxServerIdParameter); return; } string arg = (this.Identity == null) ? "*" : this.Identity.DatabaseName; string text = string.Format("{0}{1}{2}", arg, '\\', this.m_server.Name); if (this.Identity != null && !string.IsNullOrEmpty(this.Identity.ServerName) && this.Identity.ServerName != "*") { this.WriteWarning(Strings.GetDbcsOverridingServer(this.Identity.ServerName, this.m_server.Name, text)); } this.Identity = DatabaseCopyIdParameter.Parse(text); } this.rootId = new DatabasesContainer().Id; QueryFilter queryFilter = new OrFilter(new QueryFilter[] { new NotFilter(new ExistsFilter(DatabaseCopySchema.ParentObjectClass)), new TextFilter(DatabaseCopySchema.ParentObjectClass, MailboxDatabase.MostDerivedClass, MatchOptions.FullString, MatchFlags.IgnoreCase) }); if (Datacenter.IsMicrosoftHostedOnly(true)) { queryFilter = QueryFilter.OrTogether(new QueryFilter[] { queryFilter, new TextFilter(DatabaseCopySchema.ParentObjectClass, PublicFolderDatabase.MostDerivedClass, MatchOptions.FullString, MatchFlags.IgnoreCase) }); } this.Identity.SetAdditionalQueryFilter(queryFilter); this.Identity.AllowInvalid = true; }
protected override void WriteResult(IConfigurable dataObject) { MailboxDatabase mailboxDatabase = (MailboxDatabase)dataObject; if (this.DumpsterStatistics) { Server server = this.m_ServerObject; if (server == null) { MailboxServerIdParameter id = MailboxServerIdParameter.Parse(mailboxDatabase.ServerName); server = (Server)base.GetDataObject <Server>(id, base.DataSession, null, new LocalizedString?(Strings.ErrorServerNotFound(mailboxDatabase.ServerName)), new LocalizedString?(Strings.ErrorServerNotUnique(mailboxDatabase.ServerName))); } this.QueryDumpsterStats(server, mailboxDatabase.DistinguishedName, ref mailboxDatabase); } base.WriteResult(dataObject); }
public static void ValidateDatabaseCopyActionTask(DatabaseCopy databaseCopy, bool allowInvalidDbCopy, bool fCheckDbReplicated, IConfigDataProvider session, ObjectId rootId, Task.TaskErrorLoggingDelegate writeError, LocalizedString mdbNotUniqueError, LocalizedString?singleDbCopyError, out Server server) { string databaseName = databaseCopy.DatabaseName; server = null; Database database = databaseCopy.GetDatabase <Database>(); DatabaseTasksHelper.CheckDatabaseForCopyTaskImpl(database, fCheckDbReplicated, writeError, singleDbCopyError); if (database.Recovery) { writeError(new InvalidOperationException(Strings.ErrorInvalidOperationOnRecoveryMailboxDatabase(database.Name)), ErrorCategory.InvalidOperation, database.Identity); } if (databaseCopy.HostServer != null) { MailboxServerIdParameter serverIdParam = new MailboxServerIdParameter(databaseCopy.HostServer); server = databaseCopy.Session.Read <Server>(databaseCopy.HostServer); DatabaseTasksHelper.CheckServerObjectForCopyTask(serverIdParam, writeError, server); return; } if (!allowInvalidDbCopy && !databaseCopy.IsHostServerValid) { writeError(new InvalidOperationException(Strings.ErrorDbCopyHostServerInvalid(databaseCopy.Name)), ErrorCategory.InvalidData, databaseCopy); } }
protected override void WriteResult <T>(IEnumerable <T> dataObjects) { TaskLogger.LogEnter(new object[] { dataObjects }); Dictionary <string, Collection <DatabaseCopy> > dictionary = new Dictionary <string, Collection <DatabaseCopy> >(); foreach (T t in dataObjects) { IConfigurable configurable = t; DatabaseCopy databaseCopy = configurable as DatabaseCopy; string key; if (this.m_server != null) { key = this.m_server.Name; } else { key = databaseCopy.HostServerName; } Collection <DatabaseCopy> collection; if (!dictionary.TryGetValue(key, out collection)) { collection = new Collection <DatabaseCopy>(); dictionary.Add(key, collection); } collection.Add(databaseCopy); } using (Dictionary <string, Collection <DatabaseCopy> > .KeyCollection.Enumerator enumerator2 = dictionary.Keys.GetEnumerator()) { while (enumerator2.MoveNext()) { string dbCopyServerName = enumerator2.Current; Collection <DatabaseCopy> collection2 = dictionary[dbCopyServerName]; Server server2; if (this.m_server != null) { server2 = this.m_server; } else { MailboxServerIdParameter mailboxServerIdParameter = MailboxServerIdParameter.Parse(dbCopyServerName); IEnumerable <Server> objects = mailboxServerIdParameter.GetObjects <Server>(this.RootId, this.ConfigurationSession); server2 = objects.FirstOrDefault((Server server) => server.Name.Equals(dbCopyServerName, StringComparison.OrdinalIgnoreCase)); } if (server2 != null) { if (ReplayRpcVersionControl.IsGetCopyStatusEx2RpcSupported(server2.AdminDisplayVersion)) { DatabaseCopyStatusEntry[] array = this.PrepareStatusEntryFromRpc(server2, collection2); for (int i = 0; i < array.Length; i++) { this.WriteCopyStatusResultIfAppropriate(array[i]); } } else { this.WriteError(new InvalidOperationException(Strings.GetDbcsRpcNotSupported(server2.Name, server2.AdminDisplayVersion.ToString(), ReplayRpcVersionControl.GetCopyStatusEx2SupportVersion.ToString())), ErrorCategory.InvalidOperation, server2.Identity, false); } } else { foreach (DatabaseCopy databaseCopy2 in collection2) { DatabaseCopyStatusEntry databaseCopyStatusEntry = this.ConstructNewSatusEntry(databaseCopy2); this.UpdateMisconfiguredCopyStatusEntry(databaseCopyStatusEntry, databaseCopy2); this.WriteCopyStatusResultIfAppropriate(databaseCopyStatusEntry); } } } } TaskLogger.LogExit(); }