Exemple #1
0
        public bool Invoke(string command, IAssociationAdaptor masterAdaptor, params MailboxAssociation[] associations)
        {
            ArgumentValidator.ThrowIfNull("masterAdaptor", masterAdaptor);
            ADUser masterMailbox       = masterAdaptor.MasterLocator.FindAdUser();
            bool   isRpcCallSuccessful = false;

            GrayException.MapAndReportGrayExceptions(delegate()
            {
                try
                {
                    MailboxLocator[] array = associations.Select(new Func <MailboxAssociation, MailboxLocator>(masterAdaptor.GetSlaveMailboxLocator)).ToArray <MailboxLocator>();
                    this.logger.LogEvent(new SchemaBasedLogEvent <MailboxAssociationLogSchema.CommandExecution>
                    {
                        {
                            MailboxAssociationLogSchema.CommandExecution.Command,
                            command
                        },
                        {
                            MailboxAssociationLogSchema.CommandExecution.GroupMailbox,
                            masterAdaptor.MasterLocator
                        },
                        {
                            MailboxAssociationLogSchema.CommandExecution.UserMailboxes,
                            array
                        }
                    });
                    RpcAssociationReplicatorRunNowParameters rpcAssociationReplicatorRunNowParameters = new RpcAssociationReplicatorRunNowParameters
                    {
                        SlaveMailboxes = array
                    };
                    ReplicationAssistantInvoker.Tracer.TraceDebug <string, RpcAssociationReplicatorRunNowParameters>((long)this.GetHashCode(), "ReplicationAssistantInvoker::ReplicateAssociations. Calling RpcAssociationReplicator in '{0}' with parameter: '{1}'", this.targetServerFqdn, rpcAssociationReplicatorRunNowParameters);
                    using (AssistantsRpcClient assistantsRpcClient = new AssistantsRpcClient(this.targetServerFqdn))
                    {
                        assistantsRpcClient.StartWithParams("MailboxAssociationReplicationAssistant", masterMailbox.ExchangeGuid, masterMailbox.Database.ObjectGuid, rpcAssociationReplicatorRunNowParameters.ToString());
                    }
                    isRpcCallSuccessful = true;
                }
                catch (RpcException ex)
                {
                    this.LogError(Strings.RpcReplicationCallFailed(ex.ErrorCode));
                    masterAdaptor.AssociationStore.SaveMailboxAsOutOfSync();
                }
            });
            return(isRpcCallSuccessful);
        }