示例#1
0
        public static EnqueueResult[] TriggerSiteMailboxSync(IExchangePrincipal siteMailbox, string syncClientString, bool syncDocumentOnly)
        {
            List <EnqueueResult> list          = new List <EnqueueResult>();
            EnqueueResult        enqueueResult = RpcClientWrapper.EnqueueTeamMailboxSyncRequest(siteMailbox.MailboxInfo.Location.ServerFqdn, siteMailbox.MailboxInfo.MailboxGuid, QueueType.TeamMailboxDocumentSync, siteMailbox.MailboxInfo.OrganizationId, syncClientString, null, SyncOption.Default);

            enqueueResult.Type = QueueType.TeamMailboxDocumentSync;
            list.Add(enqueueResult);
            if (!syncDocumentOnly)
            {
                enqueueResult      = RpcClientWrapper.EnqueueTeamMailboxSyncRequest(siteMailbox.MailboxInfo.Location.ServerFqdn, siteMailbox.MailboxInfo.MailboxGuid, QueueType.TeamMailboxMembershipSync, siteMailbox.MailboxInfo.OrganizationId, syncClientString, null, SyncOption.Default);
                enqueueResult.Type = QueueType.TeamMailboxMembershipSync;
                list.Add(enqueueResult);
            }
            return(list.ToArray());
        }
        public static EnqueueResult EnqueueTeamMailboxSyncRequest(string targetServer, Guid mailboxGuid, QueueType queueType, OrganizationId orgId, string clientString, string domainController, SyncOption syncOption = SyncOption.Default)
        {
            if (mailboxGuid == Guid.Empty)
            {
                throw new ArgumentNullException("mailboxGuid");
            }
            if (orgId == null)
            {
                throw new ArgumentNullException("orgId");
            }
            if (queueType != QueueType.TeamMailboxDocumentSync && queueType != QueueType.TeamMailboxMembershipSync && queueType != QueueType.TeamMailboxMaintenanceSync)
            {
                throw new ArgumentException("queueType");
            }
            RpcClientWrapper.InitializeIfNeeded();
            if (!RpcClientWrapper.instance.initialized)
            {
                return(new EnqueueResult(EnqueueResultType.ClientInitError, ClientStrings.RpcClientInitError));
            }
            EnqueueResult result;

            try
            {
                using (JobQueueRpcClient jobQueueRpcClient = new JobQueueRpcClient(targetServer ?? RpcClientWrapper.instance.localServer.Fqdn))
                {
                    TeamMailboxSyncRpcInParameters teamMailboxSyncRpcInParameters = new TeamMailboxSyncRpcInParameters(mailboxGuid, orgId, clientString, syncOption, domainController);
                    byte[] data = jobQueueRpcClient.EnqueueRequest(1, (int)queueType, teamMailboxSyncRpcInParameters.Serialize());
                    EnqueueRequestRpcOutParameters enqueueRequestRpcOutParameters = new EnqueueRequestRpcOutParameters(data);
                    result = enqueueRequestRpcOutParameters.Result;
                }
            }
            catch (RpcException ex)
            {
                result = new EnqueueResult(EnqueueResultType.RpcError, ClientStrings.RpcClientRequestError(ex.Message));
            }
            return(result);
        }
        public override IAsyncResult BeginExecute(AsyncCallback executeCallback, object state)
        {
            this.executionAsyncResult = new LazyAsyncResult(null, state, executeCallback);
            this.performanceCounter.Start(OperationType.EndToEnd);
            try
            {
                this.InitializeSyncMetadata();
                base.UpdateSyncMetadataOnBeginSync();
            }
            catch (StorageTransientException ex)
            {
                ProtocolLog.LogError(this.loggingComponent, this.loggingContext, "MaintenanceSynchronizer.BeginExecute: failed with StorageTransientException", ex);
                this.executionAsyncResult.InvokeCallback(ex);
                return(this.executionAsyncResult);
            }
            catch (StoragePermanentException ex2)
            {
                ProtocolLog.LogError(this.loggingComponent, this.loggingContext, "MaintenanceSynchronizer.BeginExecute: failed with StoragePermanentException", ex2);
                this.executionAsyncResult.InvokeCallback(ex2);
                return(this.executionAsyncResult);
            }
            ProtocolLog.LogInformation(this.loggingComponent, this.loggingContext, "MaintenanceSynchronizer.BeginExecute");
            Exception value = null;
            Uri       uri;
            string    b;

            if (this.recordedSiteUrl != null && this.webCollectionUrl != null && this.TryGetSharePointSiteUrlAndTitle(this.webCollectionUrl, this.webId, out uri, out b, out value))
            {
                if (UriComparer.IsEqual(this.recordedSiteUrl, uri))
                {
                    if (string.Equals(this.displayName, b))
                    {
                        goto IL_286;
                    }
                }
                try
                {
                    IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(null, null, CultureInfo.InvariantCulture.LCID, false, ConsistencyMode.IgnoreInvalid, null, ADSessionSettings.FromOrganizationIdWithoutRbacScopesServiceOnly(this.orgId), 189, "BeginExecute", "f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\LinkedFolder\\MaintenanceSynchronizer.cs");
                    ADUser            aduser = tenantOrRootOrgRecipientSession.FindByExchangeGuid(this.TeamMailboxGuid) as ADUser;
                    if (aduser == null)
                    {
                        value = new ObjectNotFoundException(new LocalizedString("Cannot find the team mailbox by mailbox guid " + this.TeamMailboxGuid));
                    }
                    else
                    {
                        aduser.SharePointUrl = uri;
                        aduser.DisplayName   = b;
                        tenantOrRootOrgRecipientSession.Save(aduser);
                        ProtocolLog.LogInformation(this.loggingComponent, this.loggingContext, "MaintenanceSynchronizer.BeginExecute: updated new SharePoint site URL: " + uri);
                        if (!UriComparer.IsEqual(this.recordedSiteUrl, uri))
                        {
                            RpcClientWrapper.EnqueueTeamMailboxSyncRequest(this.mailboxSession.MailboxOwner.MailboxInfo.Location.ServerFqdn, this.mailboxSession.MailboxOwner.MailboxInfo.MailboxGuid, QueueType.TeamMailboxDocumentSync, this.mailboxSession.MailboxOwner.MailboxInfo.OrganizationId, "Maintenance Synchronizer", tenantOrRootOrgRecipientSession.LastUsedDc, SyncOption.Default);
                            RpcClientWrapper.EnqueueTeamMailboxSyncRequest(this.mailboxSession.MailboxOwner.MailboxInfo.Location.ServerFqdn, this.mailboxSession.MailboxOwner.MailboxInfo.MailboxGuid, QueueType.TeamMailboxMembershipSync, this.mailboxSession.MailboxOwner.MailboxInfo.OrganizationId, "Maintenance Synchronizer", tenantOrRootOrgRecipientSession.LastUsedDc, SyncOption.Default);
                        }
                    }
                }
                catch (DataSourceOperationException ex3)
                {
                    value = ex3;
                }
                catch (DataValidationException ex4)
                {
                    value = ex4;
                }
                catch (TransientException ex5)
                {
                    value = ex5;
                }
            }
IL_286:
            this.executionAsyncResult.InvokeCallback(value);
            return(this.executionAsyncResult);
        }