Esempio n. 1
0
 private void ModifyEventSinkList(EventPump.ModifyEventSinkListType modificationType, EventSink eventSink)
 {
     lock (this.sinkListLock)
     {
         this.isModifyingEventSinkList = true;
         try
         {
             Dictionary <Guid, List <EventSink> > dictionary = this.eventSinks;
             if (modificationType == EventPump.ModifyEventSinkListType.AddEventSink)
             {
                 List <EventSink> collection = null;
                 List <EventSink> list;
                 if (dictionary.TryGetValue(eventSink.MailboxGuid, out collection))
                 {
                     list = new List <EventSink>(collection);
                 }
                 else
                 {
                     list = new List <EventSink>();
                 }
                 list.Add(eventSink);
                 Dictionary <Guid, List <EventSink> > dictionary2 = dictionary.ShallowCopy <Guid, List <EventSink> >();
                 dictionary2[eventSink.MailboxGuid] = list;
                 this.eventSinks = dictionary2;
                 if (this.exception != null)
                 {
                     eventSink.HandleException(this.exception);
                 }
             }
             else
             {
                 List <EventSink> collection2 = dictionary[eventSink.MailboxGuid];
                 List <EventSink> list2       = new List <EventSink>(collection2);
                 list2.Remove(eventSink);
                 Dictionary <Guid, List <EventSink> > dictionary3 = dictionary.ShallowCopy <Guid, List <EventSink> >();
                 if (list2.Count == 0)
                 {
                     dictionary3.Remove(eventSink.MailboxGuid);
                 }
                 else
                 {
                     dictionary3[eventSink.MailboxGuid] = list2;
                 }
                 this.eventSinks = dictionary3;
             }
         }
         finally
         {
             this.isModifyingEventSinkList = false;
         }
     }
 }
Esempio n. 2
0
        internal void ExecuteRecovery(EventSink eventSink)
        {
            ExTraceGlobals.EventTracer.TraceDebug <EventPump, EventSink>((long)this.GetHashCode(), "EventPump::ExecuteRecovery. {0}. Starting Recovery. EventSink = {1}.", this, eventSink);
            try
            {
                IRecoveryEventSink recoveryEventSink = null;
                EventWatermark     eventWatermark    = null;
                long num = 0L;
                Guid mailboxGuid;
                try
                {
                    mailboxGuid       = eventSink.MailboxGuid;
                    recoveryEventSink = eventSink.StartRecovery();
                    eventWatermark    = recoveryEventSink.FirstMissedEventWatermark;
                    num = recoveryEventSink.LastMissedEventWatermark;
                }
                catch (ObjectDisposedException)
                {
                    ExTraceGlobals.EventTracer.TraceDebug <EventPump, EventSink>((long)this.GetHashCode(), "EventPump::ExecuteRecovery. {0}. Executing recovery in a disposed sink. Aborting recovery. EventSink = {1}.", this, eventSink);
                    return;
                }
                Restriction restriction = null;
                if (!eventSink.IsPublicFolderDatabase)
                {
                    restriction = Restriction.EQ(PropTag.EventMailboxGuid, mailboxGuid.ToByteArray());
                }
                long num2 = eventWatermark.WasEventProcessed ? (eventWatermark.MapiWatermark + 1L) : eventWatermark.MapiWatermark;
                long num3 = num2;
                bool flag = true;
                while (flag)
                {
                    int eventCountToCheck = EventPump.GetEventCountToCheck(num3, eventWatermark, num2, num);
                    if (eventCountToCheck > 0)
                    {
                        MapiEvent[] array = null;
                        long        num4  = 0L;
                        try
                        {
                            this.disposeLock.EnterReadLock();
                            if (this.IsDisposed)
                            {
                                return;
                            }
                            array = EventPump.ReadEvents(this.mapiEventManager, this.mapiEventManagerLock, num3, eventCountToCheck, eventCountToCheck, restriction, out num4);
                        }
                        finally
                        {
                            try
                            {
                                this.disposeLock.ExitReadLock();
                            }
                            catch (SynchronizationLockException)
                            {
                            }
                        }
                        int num5 = 0;
                        while (num5 < array.Length && flag)
                        {
                            MapiEvent mapiEvent = array[num5];
                            if (EventPump.IsEventBetweenCounters(num3, num, mapiEvent.Watermark.EventCounter))
                            {
                                try
                                {
                                    flag = recoveryEventSink.RecoveryConsume(mapiEvent);
                                    goto IL_179;
                                }
                                catch (ObjectDisposedException)
                                {
                                    ExTraceGlobals.EventTracer.TraceDebug <EventPump, EventSink>((long)this.GetHashCode(), "EventPump::ExecuteRecovery. {0}. Executing recovery in a disposed sink. Aborting recovery. EventSink = {1}.", this, eventSink);
                                    return;
                                }
                                goto Block_9;
                            }
                            goto IL_150;
IL_179:
                            num5++;
                            continue;
Block_9:
                            try
                            {
IL_150:
                                recoveryEventSink.EndRecovery();
                            }
                            catch (ObjectDisposedException)
                            {
                                ExTraceGlobals.EventTracer.TraceDebug <EventPump, EventSink>((long)this.GetHashCode(), "EventPump::ExecuteRecovery. {0}. Executing recovery in a disposed sink. Aborting recovery. EventSink = {1}.", this, eventSink);
                                return;
                            }
                            flag = false;
                            goto IL_179;
                        }
                        num3 = num4 + 1L;
                    }
                    else
                    {
                        try
                        {
                            recoveryEventSink.EndRecovery();
                        }
                        catch (ObjectDisposedException)
                        {
                            ExTraceGlobals.EventTracer.TraceDebug <EventPump, EventSink>((long)this.GetHashCode(), "EventPump::ExecuteRecovery. {0}. Executing recovery in a disposed sink. Aborting recovery. EventSink = {1}.", this, eventSink);
                            return;
                        }
                        flag = false;
                    }
                }
            }
            catch (StoragePermanentException ex)
            {
                eventSink.HandleException(ex);
            }
            catch (StorageTransientException ex2)
            {
                eventSink.HandleException(ex2);
            }
            ExTraceGlobals.EventTracer.TraceDebug <EventPump, EventSink>((long)this.GetHashCode(), "EventPump::ExecuteRecovery. {0}. Exiting Recovery. EventSink = {1}.", this, eventSink);
        }