// Token: 0x06000250 RID: 592 RVA: 0x0000CB98 File Offset: 0x0000AD98
 private void HandleEventHelper(EmergencyKit kit, MailboxSession itemStore, StoreObject item)
 {
     kit.SetContext(this.Assistant.Instance, this);
     try
     {
         base.CatchMeIfYouCan(delegate
         {
             this.Assistant.Instance.HandleEvent(kit.MapiEvent, itemStore, item);
         }, (this.Assistant != null) ? this.Assistant.Name : "<null>");
         ExTraceGlobals.EventDispatcherTracer.TraceDebug <EventDispatcher, MapiEvent>((long)this.GetHashCode(), "{0}: Event handled successfully: {1}", this, kit.MapiEvent);
     }
     catch (SkipException ex)
     {
         this.Assistant.PerformanceCounters.HandledExceptions.Increment();
         ExTraceGlobals.EventDispatcherTracer.TraceError <EventDispatcher, MapiEvent, SkipException>((long)this.GetHashCode(), "{0}: Assistant has instructed us to skip event {1} with exception {2}", this, kit.MapiEvent, ex);
         base.LogEvent(AssistantsEventLogConstants.Tuple_AssistantSkippingEvent, null, new object[]
         {
             this.Assistant.Name,
             kit.MapiEvent,
             this.MailboxDisplayName,
             ex
         });
         IEventSkipNotification eventSkipNotification = this.Assistant.Instance as IEventSkipNotification;
         if (eventSkipNotification != null)
         {
             eventSkipNotification.OnSkipEvent(kit.MapiEvent, ex);
         }
     }
     catch (AIException ex2)
     {
         this.Assistant.PerformanceCounters.HandledExceptions.Increment();
         ExTraceGlobals.EventDispatcherTracer.TraceError <EventDispatcher, MapiEvent, AIException>((long)this.GetHashCode(), "{0}: Failed to handle event {1} with exception {2}", this, kit.MapiEvent, ex2);
         string periodicKey = string.Format("{0}: Assistant {1} failed to handle event {2} with exception {3} on mailbox {4}", new object[]
         {
             this,
             this.Assistant.Name,
             kit.MapiEvent,
             ex2,
             this.MailboxDisplayName
         });
         base.LogEvent(AssistantsEventLogConstants.Tuple_AssistantFailedToProcessEvent, periodicKey, new object[]
         {
             this.Assistant.Name,
             kit.MapiEvent,
             this.MailboxDisplayName,
             ex2
         });
         kit.UnsetContext();
         throw;
     }
     kit.UnsetContext();
 }
        private AssistantTaskContext ProcessAdminRpcMailboxUnderPoisonControl(AssistantTaskContext context, EmergencyKit kit)
        {
            TimeBasedDatabaseJob.processMailboxTestHook.Value();
            AssistantTaskContext result = null;
            Guid activityId             = (ActivityContext.ActivityId != null) ? ActivityContext.ActivityId.Value : Guid.Empty;

            if (context.Args == null)
            {
                context.Args = InvokeArgs.Create(null, this.Driver.TimePerTask, context.MailboxData);
            }
            AssistantsLog.LogStartProcessingMailboxEvent(activityId, this.Assistant as AssistantBase, context.MailboxData.MailboxGuid, context.MailboxData.DisplayName, this);
            try
            {
                kit.SetContext(this.Assistant, context.MailboxData);
                result = context.Step(context);
            }
            finally
            {
                kit.UnsetContext();
            }
            AssistantsLog.LogEndProcessingMailboxEvent(activityId, this.Assistant as AssistantBase, context.CustomDataToLog, context.MailboxData.MailboxGuid, context.MailboxData.DisplayName, this);
            return(result);
        }
        private AssistantTaskContext ProcessStoreMailbox(AssistantTaskContext context, EmergencyKit kit)
        {
            TimeBasedDatabaseJob.processMailboxTestHook.Value();
            StoreMailboxData     storeMailboxData = context.MailboxData as StoreMailboxData;
            AssistantTaskContext assistantTaskContext;

            using (StoreSession storeSession = this.OpenMailboxSession(storeMailboxData))
            {
                Stopwatch stopwatch = Stopwatch.StartNew();
                try
                {
                    if (context.Args == null)
                    {
                        context.Args = InvokeArgs.Create(storeSession, this.Driver.TimePerTask, storeMailboxData);
                    }
                    kit.SetContext(this.Assistant, storeMailboxData);
                    assistantTaskContext = context.Step(context);
                }
                finally
                {
                    kit.UnsetContext();
                    if (this.Driver.AssistantType.ControlDataPropertyDefinition != null && context.Args != null)
                    {
                        context.Args.StoreSession.Mailbox[this.Driver.AssistantType.ControlDataPropertyDefinition] = ControlData.Create(DateTime.UtcNow).ToByteArray();
                        context.Args.StoreSession.Mailbox.Save();
                    }
                }
                stopwatch.Stop();
                this.performanceCounters.AverageMailboxProcessingTime.IncrementBy(stopwatch.ElapsedTicks);
                this.performanceCounters.AverageMailboxProcessingTimeBase.Increment();
                if (assistantTaskContext == null)
                {
                    this.performanceCounters.MailboxesProcessed.Increment();
                }
            }
            return(assistantTaskContext);
        }