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;
        }
Пример #2
0
        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);
        }
        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();
        }