Exemplo n.º 1
0
 private bool ShouldSkipSync(TeamMailboxSyncId id, TeamMailboxSyncInfo info, out EnqueueResult result)
 {
     result = EnqueueResult.Success;
     if (info == null)
     {
         result = new EnqueueResult(EnqueueResultType.NonexistentTeamMailbox, ServerStrings.RpcServerIgnoreNotFoundTeamMailbox(id.MailboxGuid.ToString()));
         return(true);
     }
     if (info.IsPending)
     {
         result = new EnqueueResult(EnqueueResultType.AlreadyPending, ServerStrings.RpcServerRequestAlreadyPending(info.MailboxGuid.ToString(), info.PendingClientString, info.PendingClientRequestTime.ToString()));
         return(true);
     }
     if (info.LifeCycleState == TeamMailboxLifecycleState.PendingDelete)
     {
         result = new EnqueueResult(EnqueueResultType.PendingDeleteTeamMailbox, ServerStrings.RpcServerIgnorePendingDeleteTeamMailbox(id.MailboxGuid.ToString()));
         return(true);
     }
     if (info.LifeCycleState == TeamMailboxLifecycleState.Unlinked)
     {
         result = new EnqueueResult(EnqueueResultType.UnlinkedTeamMailbox, ServerStrings.RpcServerIgnoreUnlinkedTeamMailbox(id.MailboxGuid.ToString()));
         return(true);
     }
     return(false);
 }
Exemplo n.º 2
0
 private void CleanupSyncInfo(TeamMailboxSyncInfo info)
 {
     if (info != null)
     {
         if (info.Logger != null)
         {
             info.Logger.Dispose();
         }
         if (info.MailboxSession != null && !info.MailboxSession.IsDisposed)
         {
             info.MailboxSession.Dispose();
         }
     }
 }
Exemplo n.º 3
0
 public TeamMailboxSyncJob(JobQueue queue, Configuration config, TeamMailboxSyncInfo syncInfoEntry, string clientString, SyncOption syncOption) : base(queue, config, clientString)
 {
     this.SyncInfoEntry = syncInfoEntry;
     this.SyncOption    = syncOption;
     if (((TeamMailboxSyncConfiguration)config).UseOAuth)
     {
         this.credentials = ((TeamMailboxSyncJobQueue)queue).OAuthCredentialFactory.Get(syncInfoEntry.MailboxPrincipal.MailboxInfo.OrganizationId);
     }
     else
     {
         this.credentials = CredentialCache.DefaultCredentials;
     }
     this.loggingContext = new LoggingContext(this.SyncInfoEntry.MailboxGuid, this.SyncInfoEntry.SiteUrl, base.ClientString, null);
 }
Exemplo n.º 4
0
 protected override Job InternalCreateJob(TeamMailboxSyncInfo info, string clientString, SyncOption syncOption)
 {
     return(new MaintenanceSyncJob(this, this.config, info, clientString, syncOption));
 }
Exemplo n.º 5
0
 public MaintenanceSyncJob(JobQueue queue, Configuration config, TeamMailboxSyncInfo syncInfoEntry, string clientString, SyncOption syncOption) : base(queue, config, syncInfoEntry, clientString, syncOption)
 {
 }
 protected override Job InternalCreateJob(TeamMailboxSyncInfo info, string clientString, SyncOption syncOption)
 {
     return(new MembershipSyncJob(this, this.config, this.teamMailboxSecurityRefresher, info, clientString, syncOption));
 }
Exemplo n.º 7
0
        protected override bool TryCreateJob(byte[] data, out Job job, out EnqueueResult result)
        {
            result = EnqueueResult.Success;
            job    = null;
            string server = null;
            TeamMailboxSyncRpcInParameters teamMailboxSyncRpcInParameters = null;
            TeamMailboxSyncInfo            teamMailboxSyncInfo            = null;

            try
            {
                teamMailboxSyncRpcInParameters = new TeamMailboxSyncRpcInParameters(data);
            }
            catch (SerializationException ex)
            {
                result = new EnqueueResult(EnqueueResultType.InvalidData, ServerStrings.RpcServerParameterSerializationError(ex.Message));
                return(false);
            }
            catch (ArgumentNullException ex2)
            {
                result = new EnqueueResult(EnqueueResultType.InvalidData, ServerStrings.RpcServerParameterInvalidError(ex2.Message));
                return(false);
            }
            OrganizationId    orgId             = teamMailboxSyncRpcInParameters.OrgId.Equals(OrganizationId.ForestWideOrgId) ? OrganizationId.ForestWideOrgId : teamMailboxSyncRpcInParameters.OrgId;
            TeamMailboxSyncId teamMailboxSyncId = new TeamMailboxSyncId(teamMailboxSyncRpcInParameters.MailboxGuid, orgId, teamMailboxSyncRpcInParameters.DomainController);
            bool flag = (teamMailboxSyncRpcInParameters.SyncOption & SyncOption.RefreshTeamMailboxCacheEntry) == SyncOption.RefreshTeamMailboxCacheEntry || !string.IsNullOrEmpty(teamMailboxSyncRpcInParameters.DomainController);

            try
            {
                bool flag2 = this.teamMailboxSyncInfoCache.Contains(teamMailboxSyncId);
                teamMailboxSyncInfo = this.teamMailboxSyncInfoCache.Get(teamMailboxSyncId);
                if (this.ShouldSkipSync(teamMailboxSyncId, teamMailboxSyncInfo, out result))
                {
                    return(false);
                }
                if ((teamMailboxSyncInfo.MailboxSession != null && (teamMailboxSyncInfo.MailboxSession.IsDisposed || teamMailboxSyncInfo.MailboxSession.IsDead)) || ExDateTime.UtcNow - teamMailboxSyncInfo.WhenCreatedUtcTime > ((TeamMailboxSyncConfiguration)base.Configuration).CacheAbsoluteExpiry || (flag && flag2))
                {
                    TeamMailboxSyncInfo info = this.teamMailboxSyncInfoCache.Remove(teamMailboxSyncId);
                    this.CleanupSyncInfo(info);
                    teamMailboxSyncInfo = this.teamMailboxSyncInfoCache.Get(teamMailboxSyncId);
                    if (this.ShouldSkipSync(teamMailboxSyncId, teamMailboxSyncInfo, out result))
                    {
                        return(false);
                    }
                }
                server = TeamMailboxSyncInfoCache.LocalServerFqdn;
            }
            catch (ADTransientException ex3)
            {
                result = new EnqueueResult(EnqueueResultType.DirectoryError, ServerStrings.RpcServerDirectoryError(teamMailboxSyncId.MailboxGuid.ToString(), ex3.Message));
                return(false);
            }
            catch (DataSourceOperationException ex4)
            {
                result = new EnqueueResult(EnqueueResultType.DirectoryError, ServerStrings.RpcServerDirectoryError(teamMailboxSyncId.MailboxGuid.ToString(), ex4.Message));
                return(false);
            }
            catch (DataValidationException ex5)
            {
                result = new EnqueueResult(EnqueueResultType.DirectoryError, ServerStrings.RpcServerDirectoryError(teamMailboxSyncId.MailboxGuid.ToString(), ex5.Message));
                return(false);
            }
            catch (StorageTransientException ex6)
            {
                result = new EnqueueResult(EnqueueResultType.StorageError, ServerStrings.RpcServerStorageError(teamMailboxSyncId.MailboxGuid.ToString(), ex6.Message));
                return(false);
            }
            catch (WrongServerException ex7)
            {
                result = new EnqueueResult(EnqueueResultType.WrongServer, ServerStrings.RpcServerWrongRequestServer(teamMailboxSyncId.MailboxGuid.ToString(), ex7.Message));
                return(false);
            }
            catch (StoragePermanentException ex8)
            {
                result = new EnqueueResult(EnqueueResultType.StorageError, ServerStrings.RpcServerStorageError(teamMailboxSyncId.MailboxGuid.ToString(), ex8.Message));
                return(false);
            }
            if ((teamMailboxSyncRpcInParameters.SyncOption & SyncOption.IgnoreNextAllowedSyncTimeRestriction) == SyncOption.Default && teamMailboxSyncInfo.NextAllowedSyncUtcTime > ExDateTime.UtcNow)
            {
                result = new EnqueueResult(EnqueueResultType.RequestThrottled, ServerStrings.RpcServerRequestThrottled(teamMailboxSyncId.MailboxGuid.ToString(), teamMailboxSyncInfo.NextAllowedSyncUtcTime.ToString()));
                return(false);
            }
            teamMailboxSyncInfo.IsPending                = true;
            teamMailboxSyncInfo.PendingClientString      = teamMailboxSyncRpcInParameters.ClientString;
            teamMailboxSyncInfo.PendingClientRequestTime = ExDateTime.UtcNow;
            job = this.InternalCreateJob(teamMailboxSyncInfo, teamMailboxSyncRpcInParameters.ClientString, teamMailboxSyncRpcInParameters.SyncOption);
            result.ResultDetail = ServerStrings.RpcServerRequestSuccess(server);
            return(true);
        }
Exemplo n.º 8
0
 protected abstract Job InternalCreateJob(TeamMailboxSyncInfo info, string clientString, SyncOption syncOption);
Exemplo n.º 9
0
 public MembershipSyncJob(JobQueue queue, Configuration config, ITeamMailboxSecurityRefresher teamMailboxSecurityRefresher, TeamMailboxSyncInfo syncInfoEntry, string clientString, SyncOption syncOption) : base(queue, config, syncInfoEntry, clientString, syncOption)
 {
     if (teamMailboxSecurityRefresher == null)
     {
         throw new ArgumentNullException("teamMailboxSecurityRefresher");
     }
     this.teamMailboxSecurityRefresher = teamMailboxSecurityRefresher;
     this.loggingComponent             = ProtocolLog.Component.MembershipSync;
 }
Exemplo n.º 10
0
 public DocumentSyncJob(JobQueue queue, Configuration config, TeamMailboxSyncInfo syncInfoEntry, string clientString, SyncOption syncOption) : base(queue, config, syncInfoEntry, clientString, syncOption)
 {
     this.loggingComponent = ProtocolLog.Component.DocumentSync;
 }