Exemplo n.º 1
0
 public void GetBuffer(out byte[] buffer, out uint steps, out uint progress, out FastTransferState state, out int residualCacheSize, out bool doneInCache)
 {
     if (this.cachedBuffer == null)
     {
         this.InternalGetBuffer(out buffer, out steps, out progress, out state, out residualCacheSize, out doneInCache);
     }
     else
     {
         buffer            = this.cachedBuffer;
         steps             = this.cachedSteps;
         progress          = this.cachedProgress;
         state             = this.cachedState;
         residualCacheSize = this.cachedResidualCacheSize;
         doneInCache       = this.cachedDoneInCache;
         this.cachedBuffer = null;
     }
     if (state == FastTransferState.Partial || state == FastTransferState.NoRoom)
     {
         this.InternalGetBuffer(out this.cachedBuffer, out this.cachedSteps, out this.cachedProgress, out this.cachedState, out this.cachedResidualCacheSize, out this.cachedDoneInCache);
         if ((this.cachedBuffer == null || this.cachedBuffer.Length == 0) && this.cachedState == FastTransferState.Done)
         {
             state             = this.cachedState;
             steps             = this.cachedSteps;
             progress          = this.cachedProgress;
             residualCacheSize = this.cachedResidualCacheSize;
             doneInCache       = this.cachedDoneInCache;
         }
     }
     if (buffer == null)
     {
         buffer = Array <byte> .Empty;
     }
     if (state == FastTransferState.Done)
     {
         this.allowGetFinalState = true;
     }
 }
Exemplo n.º 2
0
        private void InternalGetBuffer(out byte[] buffer, out uint steps, out uint progress, out FastTransferState state, out int residualCacheSize, out bool doneInCache)
        {
            StoreSession session = this.folder.Session;
            bool         flag    = false;

            try
            {
                if (session != null)
                {
                    session.BeginMapiCall();
                    session.BeginServerHealthCall();
                    flag = true;
                }
                if (StorageGlobals.MapiTestHookBeforeCall != null)
                {
                    StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod());
                }
                FastTransferBlock fastTransferBlock = this.MapiGetBuffer(out residualCacheSize, out doneInCache);
                buffer   = fastTransferBlock.Buffer;
                steps    = fastTransferBlock.Steps;
                progress = fastTransferBlock.Progress;
                state    = (FastTransferState)fastTransferBlock.State;
            }
            catch (MapiPermanentException ex)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.CannotGetSynchronizeBuffers(typeof(SynchronizerProviderBase)), ex, session, this, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("SynchronizerProviderBase.GetBuffer. Call to GetBuffer failed.", new object[0]),
                    ex
                });
            }
            catch (MapiRetryableException ex2)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.CannotGetSynchronizeBuffers(typeof(SynchronizerProviderBase)), ex2, session, this, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("SynchronizerProviderBase.GetBuffer. Call to GetBuffer failed.", new object[0]),
                    ex2
                });
            }
            finally
            {
                try
                {
                    if (session != null)
                    {
                        session.EndMapiCall();
                        if (flag)
                        {
                            session.EndServerHealthCall();
                        }
                    }
                }
                finally
                {
                    if (StorageGlobals.MapiTestHookAfterCall != null)
                    {
                        StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod());
                    }
                }
            }
        }