Ejemplo n.º 1
0
        // Token: 0x0600017E RID: 382 RVA: 0x0000A5F4 File Offset: 0x000087F4
        private AssistantTaskContext DoWork(AssistantTaskContext context)
        {
            ELCAssistant.Tracer.TraceDebug((long)this.GetHashCode(), "ElcAssistant.InitialStep");
            MailboxSession     mailboxSession     = context.Args.StoreSession as MailboxSession;
            ElcDataTaskContext elcDataTaskContext = context as ElcDataTaskContext;

            ExAssert.RetailAssert(mailboxSession != null, "Collection step invoked with an invalid session. {0}", new object[]
            {
                (context.Args.StoreSession == null) ? "null" : context.Args.StoreSession.GetType().FullName
            });
            ExAssert.RetailAssert(elcDataTaskContext != null, "Collection step invoked with an invalid task context. {0}", new object[]
            {
                context.GetType().FullName
            });
            elcDataTaskContext.RetriesAttempted++;
            bool flag = this.InvokeInternalAssistant(mailboxSession, context.Args, context.CustomDataToLog, elcDataTaskContext.RetriesAttempted);

            if (flag)
            {
                ELCAssistant.Tracer.TraceDebug <IExchangePrincipal, int>((long)this.GetHashCode(), "ELCAssistant is not done processing, this mailbox will be retried, mailbox {0} , Total attempts {1}", mailboxSession.MailboxOwner, elcDataTaskContext.RetriesAttempted);
                return(new ElcDataTaskContext(context.MailboxData, context.Job, new AssistantStep(this.DoWork), elcDataTaskContext.RetriesAttempted));
            }
            ELCAssistant.Tracer.TraceDebug <IExchangePrincipal, int>((long)this.GetHashCode(), "ELCAssistant is done processing mailbox {0} , Total attempts {1}", mailboxSession.MailboxOwner, elcDataTaskContext.RetriesAttempted);
            return(null);
        }
        // Token: 0x0600145A RID: 5210 RVA: 0x0007583C File Offset: 0x00073A3C
        private AssistantTaskContext CollectionStep(AssistantTaskContext context)
        {
            this.tracer.TraceFunction((long)this.GetHashCode(), "InferenceDataCollectionAssistant.CollectionStep");
            ExAssert.RetailAssert(context != null, "Collection step invoked with a null task context");
            StoreSession storeSession = context.Args.StoreSession;
            InferenceDataCollectionTaskContext inferenceDataCollectionTaskContext = context as InferenceDataCollectionTaskContext;

            ExAssert.RetailAssert(inferenceDataCollectionTaskContext != null, "Collection step invoked with an invalid task context. {0}", new object[]
            {
                context.GetType().FullName
            });
            this.diagnosticLogger.LogInformation("Starting collection task. CollectionGuid={0}, Init={1}, Watermark={2}, MailboxGuid={3}, Name={4}", new object[]
            {
                inferenceDataCollectionTaskContext.MailboxProcessingState.CollectionGuid,
                inferenceDataCollectionTaskContext.MailboxProcessingState.IsInitialized,
                (inferenceDataCollectionTaskContext.MailboxProcessingState.Watermark == null) ? "None" : inferenceDataCollectionTaskContext.MailboxProcessingState.Watermark.DocumentId.ToString(),
                storeSession.MailboxGuid,
                storeSession.MailboxOwner.MailboxInfo.DisplayName
            });
            Exception exception = null;

            MailboxProcessor.ProcessingResult processingResult;
            try
            {
                MailboxProcessor mailboxProcessor = new MailboxProcessor(this.collectionContext, storeSession, inferenceDataCollectionTaskContext.MailboxProcessingState);
                processingResult = mailboxProcessor.Process();
            }
            catch (NonUniqueRecipientException ex)
            {
                processingResult = 1;
                exception        = ex;
            }
            AssistantTaskContext result;

            if (processingResult == 2)
            {
                this.diagnosticLogger.LogInformation("Yielding collection task. CollectionGuid={0}, Init={1}, Watermark={2}, MailboxGuid={3}, Name={4}", new object[]
                {
                    inferenceDataCollectionTaskContext.MailboxProcessingState.CollectionGuid,
                    inferenceDataCollectionTaskContext.MailboxProcessingState.IsInitialized,
                    (inferenceDataCollectionTaskContext.MailboxProcessingState.Watermark == null) ? "None" : inferenceDataCollectionTaskContext.MailboxProcessingState.Watermark.DocumentId.ToString(),
                    storeSession.MailboxGuid,
                    storeSession.MailboxOwner.MailboxInfo.DisplayName
                });
                result = new InferenceDataCollectionTaskContext(context.MailboxData, context.Job, new AssistantStep(this.CollectionStep), inferenceDataCollectionTaskContext.MailboxProcessingState);
            }
            else
            {
                storeSession.Mailbox[MailboxSchema.InferenceDataCollectionProcessingState] = new byte[]
                {
                    1
                };
                storeSession.Mailbox.Save();
                if (processingResult == 1)
                {
                    this.diagnosticLogger.LogError("Failed collection task. CollectionGuid={0}, Init={1}, Watermark={2}, MailboxGuid={3}, Name={4}, Exception={5}", new object[]
                    {
                        inferenceDataCollectionTaskContext.MailboxProcessingState.CollectionGuid,
                        inferenceDataCollectionTaskContext.MailboxProcessingState.IsInitialized,
                        (inferenceDataCollectionTaskContext.MailboxProcessingState.Watermark == null) ? "None" : inferenceDataCollectionTaskContext.MailboxProcessingState.Watermark.DocumentId.ToString(),
                        storeSession.MailboxGuid,
                        storeSession.MailboxOwner.MailboxInfo.DisplayName,
                        Util.StringizeException(exception)
                    });
                }
                else
                {
                    this.diagnosticLogger.LogInformation("Finished collection task. CollectionGuid={0}, Init={1}, Watermark={2}, MailboxGuid={3}, Name={4}", new object[]
                    {
                        inferenceDataCollectionTaskContext.MailboxProcessingState.CollectionGuid,
                        inferenceDataCollectionTaskContext.MailboxProcessingState.IsInitialized,
                        (inferenceDataCollectionTaskContext.MailboxProcessingState.Watermark == null) ? "None" : inferenceDataCollectionTaskContext.MailboxProcessingState.Watermark.DocumentId.ToString(),
                        storeSession.MailboxGuid,
                        storeSession.MailboxOwner.MailboxInfo.DisplayName
                    });
                }
                result = null;
            }
            InferenceDataCollectionAssistant.PostInferenceDataCollectionProgressNotification(storeSession.MailboxGuid, processingResult.ToString());
            if (processingResult == null)
            {
                InferenceDataCollectionAssistant.PostInferenceDataCollectionSuccessNotification(storeSession.MailboxGuid);
            }
            return(result);
        }