private void OnEntryChanged(ExSearchResultEntry entry)
        {
            List <RecipientSyncOperation> recipientSyncOperation = this.GetRecipientSyncOperation(entry);
            List <RecipientSyncOperation> results = null;

            try
            {
                results = this.mserveService.Synchronize(recipientSyncOperation);
            }
            catch (MserveException e)
            {
                throw new ExDirectoryException("Mserve synchronization failed", e);
            }
            MserveTargetConnection.ProcessSyncResult processSyncResult = this.ProcessSyncResults(results);
            if (processSyncResult != MserveTargetConnection.ProcessSyncResult.Success)
            {
                throw new ExDirectoryException("OnEntryChanged failed with ProcessSyncResults " + processSyncResult, null);
            }
        }
 private MserveTargetConnection.ProcessSyncResult ProcessSyncResults(List <RecipientSyncOperation> results)
 {
     MserveTargetConnection.ProcessSyncResult processSyncResult = MserveTargetConnection.ProcessSyncResult.Success;
     foreach (RecipientSyncOperation recipientSyncOperation in results)
     {
         if (recipientSyncOperation.HasNonRetryableErrors)
         {
             this.LogFailedAddresses(recipientSyncOperation.NonRetryableEntries);
         }
         if (recipientSyncOperation.HasRetryableErrors)
         {
             this.LogFailedAddresses(recipientSyncOperation.RetryableEntries);
             processSyncResult |= MserveTargetConnection.ProcessSyncResult.FailedMServ;
         }
         if (recipientSyncOperation.DuplicatedAddEntries.Count > 0 && this.operationsWithDuplicatedAddEntries.Count <= this.duplicatedAddEntriesCacheSize)
         {
             this.operationsWithDuplicatedAddEntries.Add(recipientSyncOperation);
         }
         if (!recipientSyncOperation.SuppressSyncStateUpdate && recipientSyncOperation.TotalPendingSyncStateCommitEntries != 0)
         {
             this.UpdateRecipientSyncStateValue(recipientSyncOperation);
             try
             {
                 this.UpdateRecipientSyncStateValueInAD(recipientSyncOperation);
                 foreach (OperationType key in recipientSyncOperation.PendingSyncStateCommitEntries.Keys)
                 {
                     recipientSyncOperation.PendingSyncStateCommitEntries[key].Clear();
                 }
             }
             catch (ExDirectoryException exception)
             {
                 base.LogSession.LogException(EdgeSyncLoggingLevel.Low, EdgeSyncEvent.TargetConnection, exception, "Failed to update SyncState for " + recipientSyncOperation.DistinguishedName);
                 processSyncResult |= MserveTargetConnection.ProcessSyncResult.FailedUpdateSyncState;
             }
             if (this.testShutdownAndLease())
             {
                 processSyncResult |= MserveTargetConnection.ProcessSyncResult.ShutdownOrLostLease;
                 return(processSyncResult);
             }
         }
     }
     return(processSyncResult);
 }
        public override bool OnSynchronized()
        {
            List <RecipientSyncOperation> results = null;

            try
            {
                results = this.mserveService.Synchronize();
            }
            catch (MserveException ex)
            {
                ExTraceGlobals.TargetConnectionTracer.TraceError <string>((long)this.GetHashCode(), "MserveWebService failed to flush operations because of {0}", ex.Message);
                base.LogSession.LogException(EdgeSyncLoggingLevel.Low, EdgeSyncEvent.TargetConnection, ex, "MserveWebService failed to flush");
                return(false);
            }
            MserveTargetConnection.ProcessSyncResult processSyncResult = this.ProcessSyncResults(results);
            if (processSyncResult != MserveTargetConnection.ProcessSyncResult.Success)
            {
                base.LogSession.LogException(EdgeSyncLoggingLevel.Low, EdgeSyncEvent.TargetConnection, new ExDirectoryException("ProcessSyncResults " + processSyncResult, null), "Failed OnSynchronized");
            }
            return(processSyncResult == MserveTargetConnection.ProcessSyncResult.Success && this.ResolveDuplicateAddedEntries());
        }