public void Reset() { Activity[] activities = new Activity[] { AppendOnlyActivityLog.CreateResetActivity() }; this.Append(activities); }
public IEnumerable <Activity> Query() { MapiFastTransferStream fxStream = null; StoreSession storeSession = this.mailboxSession; bool flag = false; try { if (storeSession != null) { storeSession.BeginMapiCall(); storeSession.BeginServerHealthCall(); flag = true; } if (StorageGlobals.MapiTestHookBeforeCall != null) { StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod()); } fxStream = (MapiFastTransferStream)this.mailboxSession.Mailbox.MapiStore.OpenProperty(PropTag.FastTransfer, InterfaceIds.IFastTransferStream, 1, OpenPropertyFlags.None); } catch (MapiPermanentException ex) { throw StorageGlobals.TranslateMapiException(ServerStrings.FailedToReadActivityLog, ex, storeSession, this, "{0}. MapiException = {1}.", new object[] { string.Format("Query", new object[0]), ex }); } catch (MapiRetryableException ex2) { throw StorageGlobals.TranslateMapiException(ServerStrings.FailedToReadActivityLog, ex2, storeSession, this, "{0}. MapiException = {1}.", new object[] { string.Format("Query", new object[0]), ex2 }); } finally { try { if (storeSession != null) { storeSession.EndMapiCall(); if (flag) { storeSession.EndServerHealthCall(); } } } finally { if (StorageGlobals.MapiTestHookAfterCall != null) { StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod()); } } } using (fxStream) { StoreSession storeSession2 = this.mailboxSession; bool flag2 = false; try { if (storeSession2 != null) { storeSession2.BeginMapiCall(); storeSession2.BeginServerHealthCall(); flag2 = true; } if (StorageGlobals.MapiTestHookBeforeCall != null) { StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod()); } fxStream.Configure(AppendOnlyActivityLog.FxConfigurationProps); } catch (MapiPermanentException ex3) { throw StorageGlobals.TranslateMapiException(ServerStrings.FailedToReadActivityLog, ex3, storeSession2, this, "{0}. MapiException = {1}.", new object[] { string.Format("Query", new object[0]), ex3 }); } catch (MapiRetryableException ex4) { throw StorageGlobals.TranslateMapiException(ServerStrings.FailedToReadActivityLog, ex4, storeSession2, this, "{0}. MapiException = {1}.", new object[] { string.Format("Query", new object[0]), ex4 }); } finally { try { if (storeSession2 != null) { storeSession2.EndMapiCall(); if (flag2) { storeSession2.EndServerHealthCall(); } } } finally { if (StorageGlobals.MapiTestHookAfterCall != null) { StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod()); } } } Queue <Activity> activityBuffer = new Queue <Activity>(); bool resetActivityFound = false; Action <Activity> desearializationDelegate = delegate(Activity activity) { if (AppendOnlyActivityLog.IsResetActivity(activity)) { resetActivityFound = true; } if (!resetActivityFound) { activityBuffer.Enqueue(activity); } }; using (IFastTransferProcessor <FastTransferUploadContext> processor = new FastTransferMessageIterator(new ActivityMessageIteratorClient(desearializationDelegate), true)) { using (FastTransferUploadContext context = new FastTransferUploadContext(CTSGlobals.AsciiEncoding, NullResourceTracker.Instance, IncludeAllPropertyFilterFactory.Instance, false)) { context.PushInitial(processor); byte[] buffer = null; while (!resetActivityFound) { StoreSession storeSession3 = this.mailboxSession; bool flag3 = false; try { if (storeSession3 != null) { storeSession3.BeginMapiCall(); storeSession3.BeginServerHealthCall(); flag3 = true; } if (StorageGlobals.MapiTestHookBeforeCall != null) { StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod()); } buffer = fxStream.Download(); } catch (MapiPermanentException ex5) { throw StorageGlobals.TranslateMapiException(ServerStrings.FailedToReadActivityLog, ex5, storeSession3, this, "{0}. MapiException = {1}.", new object[] { string.Format("Query", new object[0]), ex5 }); } catch (MapiRetryableException ex6) { throw StorageGlobals.TranslateMapiException(ServerStrings.FailedToReadActivityLog, ex6, storeSession3, this, "{0}. MapiException = {1}.", new object[] { string.Format("Query", new object[0]), ex6 }); } finally { try { if (storeSession3 != null) { storeSession3.EndMapiCall(); if (flag3) { storeSession3.EndServerHealthCall(); } } } finally { if (StorageGlobals.MapiTestHookAfterCall != null) { StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod()); } } } if (buffer == null) { break; } context.PutNextBuffer(new ArraySegment <byte>(buffer)); if (context.State == FastTransferState.Error) { new CorruptDataException(ServerStrings.FailedToReadActivityLog); } while (activityBuffer.Count > 0) { yield return(activityBuffer.Dequeue()); } } context.Flush(); if (context.State == FastTransferState.Error) { new CorruptDataException(ServerStrings.FailedToReadActivityLog); } while (activityBuffer.Count > 0) { yield return(activityBuffer.Dequeue()); } } } } yield break; }