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);
        }