Beispiel #1
0
 private void ProcessClassificationDocumentForComparisonModel(MdbDocument comparisonDocument, InferencePropertyBag comparisonDiagnostics, int comparisonVersion, MdbDocument classificationDocument, InferencePropertyBag classificationDiagnostics, Dictionary <OrderedFeatureSet, FeatureValues> cachedFeatureValues, DocumentProcessingContext processingContext, MdbInferenceRecipient ownerAsInferenceRecipient, ModelVersionBreadCrumb breadCrumb, VariantConfigurationSnapshot flightFeatures, object uniqueBodyWords, bool?conversationLoadRequired)
 {
     try
     {
         object obj;
         if (classificationDiagnostics.TryGetValue(InferenceSchema.MessageClassificationTime, out obj))
         {
             comparisonDiagnostics.Add(InferenceSchema.MessageClassificationTime, obj);
         }
         if (classificationDiagnostics.TryGetValue(DocumentSchema.MailboxId, out obj))
         {
             comparisonDiagnostics.Add(DocumentSchema.MailboxId, obj);
         }
         if (classificationDiagnostics.TryGetValue(InferenceSchema.InternetMessageId, out obj))
         {
             comparisonDiagnostics.Add(InferenceSchema.InternetMessageId, obj);
         }
         if (classificationDiagnostics.TryGetValue(InferenceSchema.MessageIdentifier, out obj))
         {
             comparisonDiagnostics.Add(InferenceSchema.MessageIdentifier, obj);
         }
         if (classificationDocument.TryGetProperty(InferenceSchema.IsNewConversation, out obj))
         {
             comparisonDocument.SetProperty(InferenceSchema.IsNewConversation, obj);
         }
         if (classificationDocument.TryGetProperty(InferenceSchema.ConversationClutterInformation, out obj))
         {
             comparisonDocument.SetProperty(InferenceSchema.ConversationClutterInformation, obj);
         }
         if (classificationDocument.TryGetProperty(InferenceSchema.ConversationImportanceProperties, out obj))
         {
             comparisonDocument.SetProperty(InferenceSchema.ConversationImportanceProperties, obj);
         }
         comparisonDocument.SetProperty(InferenceSchema.SkipConversationExtraction, true);
         bool flag = false;
         OrderedFeatureSet featureSet = ModelConfiguration.GetModelVersionConfiguration(comparisonVersion).FeatureSet;
         if (cachedFeatureValues.ContainsKey(featureSet))
         {
             comparisonDocument.SetProperty(InferenceSchema.ImportanceFeatureValues, cachedFeatureValues[featureSet]);
             comparisonDocument.SetProperty(InferenceSchema.SkipFeatureVectorCalculation, true);
             flag = true;
         }
         comparisonDocument.SetProperty(InferenceSchema.SkipFeatureVectorPersistance, true);
         comparisonDocument.SetProperty(InferenceSchema.SkipPredictedActionsPersistance, true);
         this.ProcessClassificationDocument(comparisonDocument, comparisonDiagnostics, new ModelVersionSelector.ModelVersionInfo(comparisonVersion, false), processingContext, ownerAsInferenceRecipient, breadCrumb, flightFeatures, uniqueBodyWords, conversationLoadRequired);
         if (!flag && comparisonDocument.TryGetProperty(InferenceSchema.ImportanceFeatureValues, out obj))
         {
             cachedFeatureValues[featureSet] = (FeatureValues)obj;
         }
     }
     catch (Exception ex)
     {
         if (ex is OutOfMemoryException || ex is StackOverflowException || ex is ThreadAbortException)
         {
             throw;
         }
         comparisonDiagnostics.Add(InferenceSchema.ClassificationAgentException, ex);
     }
 }
Beispiel #2
0
 private void ProcessClassificationDocument(MdbDocument document, InferencePropertyBag classificationDiagnostics, ModelVersionSelector.ModelVersionInfo versionInfo, DocumentProcessingContext processingContext, MdbInferenceRecipient ownerAsInferenceRecipient, ModelVersionBreadCrumb breadCrumb, VariantConfigurationSnapshot flightFeatures, object uniqueBodyWords, bool?conversationLoadRequired)
 {
     document.SetProperty(InferenceSchema.MailboxOwner, ownerAsInferenceRecipient);
     document.SetProperty(InferenceSchema.ClassificationDiagnostics, classificationDiagnostics);
     document.SetProperty(InferenceSchema.ModelVersionToLoad, versionInfo);
     document.SetProperty(InferenceSchema.ModelVersionBreadCrumb, breadCrumb);
     if (conversationLoadRequired != null)
     {
         document.SetProperty(InferenceSchema.ConversationLoadRequired, conversationLoadRequired);
     }
     if (flightFeatures != null)
     {
         document.SetProperty(InferenceSchema.UserFlightFeatures, flightFeatures);
     }
     if (uniqueBodyWords != null)
     {
         document.SetProperty(InferenceSchema.UniqueBodyWords, uniqueBodyWords);
     }
     this.pipeline.ProcessDocument(document, processingContext);
 }
Beispiel #3
0
 public void LogModelComparisonData(MdbDocument document, InferencePropertyBag classificationDiagnostics)
 {
     if (document != null && classificationDiagnostics != null)
     {
         object    obj;
         object    item  = classificationDiagnostics.TryGetValue(DocumentSchema.MailboxId, out obj) ? obj : null;
         object    item2 = classificationDiagnostics.TryGetValue(InferenceSchema.MessageIdentifier, out obj) ? obj : null;
         object    item3 = classificationDiagnostics.TryGetValue(InferenceSchema.InternetMessageId, out obj) ? obj : null;
         object    item4 = classificationDiagnostics.TryGetValue(InferenceSchema.MessageClassificationTime, out obj) ? obj : null;
         Exception ex    = classificationDiagnostics.TryGetValue(InferenceSchema.ClassificationAgentException, out obj) ? ((Exception)obj) : null;
         ModelVersionSelector.ModelVersionInfo modelVersionInfo = document.TryGetProperty(InferenceSchema.ModelVersionToLoad, out obj) ? ((ModelVersionSelector.ModelVersionInfo)obj) : null;
         object item5 = -1;
         object item6 = -1;
         object item7 = null;
         UserConfigurationOverride            userConfigurationOverride     = document.TryGetProperty(InferenceSchema.UserConfigurationOverride, out obj) ? ((UserConfigurationOverride)obj) : null;
         PredictedActionAndProbability        predictedActionAndProbability = null;
         List <PredictedActionAndProbability> list = classificationDiagnostics.TryGetValue(InferenceSchema.PredictedActionsAll, out obj) ? ((List <PredictedActionAndProbability>)obj) : null;
         if (list != null)
         {
             predictedActionAndProbability = list.FirstOrDefault((PredictedActionAndProbability entry) => entry.Action == PredictedMessageAction.Clutter);
         }
         IList <object> list2 = new List <object>(InferenceClassificationComparisonLogger.Columns.Count);
         list2.Add(DateTime.UtcNow);
         list2.Add(InferenceCommonUtility.ServerVersion);
         list2.Add(item);
         list2.Add(item2);
         list2.Add((modelVersionInfo == null) ? string.Empty : modelVersionInfo.Version.ToString());
         list2.Add(item5);
         list2.Add(item6);
         list2.Add(item4);
         list2.Add((predictedActionAndProbability == null) ? string.Empty : predictedActionAndProbability.Probability.ToString());
         list2.Add((userConfigurationOverride == null) ? string.Empty : userConfigurationOverride.ClutterThreshold.ToString());
         list2.Add(item3);
         list2.Add((ex == null) ? string.Empty : InferenceCommonUtility.StringizeException(ex));
         list2.Add(item7);
         this.dataLogger.Log(list2);
     }
 }
Beispiel #4
0
        protected override void InternalProcessDocument(DocumentContext data)
        {
            object obj = null;

            if (data.Document.TryGetProperty(PeopleRelevanceSchema.IsBasedOnRecipientInfoData, out obj) && (bool)obj)
            {
                this.DiagnosticsSession.TraceDebug("RecipientInfo-based relevance is enabled. Skip processing SentItems", new object[0]);
                return;
            }
            DocumentProcessingContext documentProcessingContext = data.AsyncResult.AsyncState as DocumentProcessingContext;

            Util.ThrowOnConditionFailed(documentProcessingContext != null, "Context object passed in async call is not of type DocumentProcessingContext");
            Util.ThrowOnMismatchType <Document>(data.Document, "data.Document");
            Document document = data.Document as Document;

            this.DiagnosticsSession.TraceDebug <IIdentity>("Processing document - {0}", document.Identity);
            IList <IDocument> list     = null;
            IDocument         property = document.GetProperty <IDocument>(PeopleRelevanceSchema.SentItemsTrainingSubDocument);

            this.DiagnosticsSession.TraceDebug <int>("Count of nested documents in the training set - {0}", property.NestedDocuments.Count);
            if (document.TryGetProperty(PeopleRelevanceSchema.CurrentTimeWindowNumber, out obj))
            {
                document.SetProperty(PeopleRelevanceSchema.TimeWindowNumberAtLastRun, (long)obj);
            }
            bool flag = false;

            foreach (IDocument document2 in property.NestedDocuments)
            {
                if (base.PipelineContext != null && InferencePipelineUtil.IsAbortOnProcessingRequested((PipelineContext)base.PipelineContext))
                {
                    flag = true;
                    break;
                }
                this.DiagnosticsSession.TraceDebug <IIdentity>("Processing mini document - {0}", document2.Identity);
                using (MdbDocument mdbDocument = MdbInferenceFactory.Current.CreateFullDocument(document2, documentProcessingContext, MdbPeoplePropertyMap.Instance, PeopleRelevanceDocumentFactory.SentItemsFullDocumentProperties))
                {
                    this.DiagnosticsSession.TraceDebug <IIdentity>("Creating full document succeeded - {0}", mdbDocument.Identity);
                    if (document.TryGetProperty(PeopleRelevanceSchema.ContactList, out obj))
                    {
                        mdbDocument.SetProperty(PeopleRelevanceSchema.ContactList, obj);
                    }
                    if (document.TryGetProperty(PeopleRelevanceSchema.CurrentTimeWindowStartTime, out obj))
                    {
                        mdbDocument.SetProperty(PeopleRelevanceSchema.CurrentTimeWindowStartTime, obj);
                        mdbDocument.SetProperty(PeopleRelevanceSchema.CurrentTimeWindowNumber, document.GetProperty <long>(PeopleRelevanceSchema.CurrentTimeWindowNumber));
                    }
                    if (document.TryGetProperty(PeopleRelevanceSchema.MailboxOwner, out obj))
                    {
                        mdbDocument.SetProperty(PeopleRelevanceSchema.MailboxOwner, obj);
                    }
                    this.DiagnosticsSession.TraceDebug <IIdentity>("Pushing full document to the nested pipeline - {0}", mdbDocument.Identity);
                    try
                    {
                        this.NestedPipeline.ProcessDocument(mdbDocument, documentProcessingContext);
                        this.DiagnosticsSession.TraceDebug <IIdentity>("Processing full document in the nested pipeline completed without exceptions - {0}", mdbDocument.Identity);
                        if (mdbDocument.TryGetProperty(PeopleRelevanceSchema.SentTime, out obj))
                        {
                            document2.SetProperty(PeopleRelevanceSchema.SentTime, obj);
                        }
                        else
                        {
                            this.DiagnosticsSession.TraceDebug <IIdentity>("Missing sent time property in full document after completing nested pipeline - {0}", mdbDocument.Identity);
                        }
                        IDictionary <string, IInferenceRecipient> property2 = mdbDocument.GetProperty <IDictionary <string, IInferenceRecipient> >(PeopleRelevanceSchema.ContactList);
                        document.SetProperty(PeopleRelevanceSchema.ContactList, property2);
                        ExDateTime property3 = mdbDocument.GetProperty <ExDateTime>(PeopleRelevanceSchema.CurrentTimeWindowStartTime);
                        document.SetProperty(PeopleRelevanceSchema.CurrentTimeWindowStartTime, property3);
                        long property4 = mdbDocument.GetProperty <long>(PeopleRelevanceSchema.CurrentTimeWindowNumber);
                        document.SetProperty(PeopleRelevanceSchema.CurrentTimeWindowNumber, property4);
                    }
                    catch (ComponentException ex)
                    {
                        if (list == null)
                        {
                            list = new List <IDocument>(property.NestedDocuments.Count);
                        }
                        this.DiagnosticsSession.TraceError <IIdentity, string>("Received an operation failed exception while processing mini document - {0} message- {1}", document2.Identity, ex.Message);
                        this.DiagnosticsSession.TraceDebug <IIdentity>("Adding the mini document - {0} to the failed Documents collection", document2.Identity);
                        this.DiagnosticsSession.LogDiagnosticsInfo(DiagnosticsLoggingTag.Warnings, string.Format("U={0} - Received an operation failed exception while processing mini document - {1} message- {2}", documentProcessingContext.Session.MailboxOwner.MailboxInfo.PrimarySmtpAddress, document2.Identity, ex.Message), new object[0]);
                        list.Add(document2);
                    }
                }
            }
            if (flag)
            {
                throw new AbortOnProcessingRequestedException();
            }
            int num = 0;

            if (list != null && list.Count > 0)
            {
                num = list.Count;
                this.DiagnosticsSession.TraceDebug <int>("Count of failed Documents - {0}", num);
                property.RemoveDocuments(list);
                if (property.NestedDocuments.Count == 0)
                {
                    throw new NestedDocumentCountZeroException();
                }
            }
            this.DiagnosticsSession.LogDiagnosticsInfo(DiagnosticsLoggingTag.Informational, string.Format("U={0} - NestedSentItemsPipeline: {1} messages processed successfully, {2} messages failed", documentProcessingContext.Session.MailboxOwner.MailboxInfo.PrimarySmtpAddress, property.NestedDocuments.Count, num), new object[0]);
        }
Beispiel #5
0
        public void OnPromotedMessageHandler(StoreDriverEventSource source, StoreDriverDeliveryEventArgs args)
        {
            this.wasMessageDelivered = false;
            this.logValues           = null;
            StoreDriverDeliveryEventArgsImpl storeDriverDeliveryEventArgsImpl = (StoreDriverDeliveryEventArgsImpl)args;
            Stopwatch                    stopwatch                    = Stopwatch.StartNew();
            InferencePropertyBag         inferencePropertyBag         = new InferencePropertyBag();
            MdbDocument                  mdbDocument                  = null;
            VariantConfigurationSnapshot variantConfigurationSnapshot = null;

            try
            {
                InferenceClassificationAgent.tracer.TraceDebug(0L, "Called InferenceClassificationAgent.OnPromotedMessageHandler");
                inferencePropertyBag.Add(InferenceSchema.MessageClassificationTime, ExDateTime.UtcNow);
                inferencePropertyBag.Add(InferenceSchema.ServerName, this.server.Name);
                if (storeDriverDeliveryEventArgsImpl.MailboxSession != null)
                {
                    inferencePropertyBag.Add(DocumentSchema.MailboxId, storeDriverDeliveryEventArgsImpl.MailboxSession.MailboxGuid.ToString());
                    inferencePropertyBag.Add(InferenceSchema.ClutterEnabled, storeDriverDeliveryEventArgsImpl.MailboxSession.Mailbox.GetValueOrDefault <bool>(MailboxSchema.InferenceClutterEnabled, false));
                    inferencePropertyBag.Add(InferenceSchema.ClassificationEnabled, storeDriverDeliveryEventArgsImpl.MailboxSession.Mailbox.GetValueOrDefault <bool>(MailboxSchema.InferenceClassificationEnabled, false));
                    inferencePropertyBag.Add(InferenceSchema.HasBeenClutterInvited, storeDriverDeliveryEventArgsImpl.MailboxSession.Mailbox.GetValueOrDefault <bool>(MailboxSchema.InferenceHasBeenClutterInvited, false));
                }
                inferencePropertyBag.Add(InferenceSchema.InternetMessageId, storeDriverDeliveryEventArgsImpl.ReplayItem.InternetMessageId);
                inferencePropertyBag.Add(InferenceSchema.Locale, InferenceClassificationAgent.GetLocale(storeDriverDeliveryEventArgsImpl));
                if (storeDriverDeliveryEventArgsImpl.MailboxOwner != null && storeDriverDeliveryEventArgsImpl.MailboxOwner.OrganizationId != null && storeDriverDeliveryEventArgsImpl.MailboxOwner.OrganizationId.OrganizationalUnit != null)
                {
                    inferencePropertyBag.Add(InferenceSchema.TenantName, storeDriverDeliveryEventArgsImpl.MailboxOwner.OrganizationId.OrganizationalUnit.Name);
                }
                if (!InferenceClassificationAgent.IsMailboxInteresting(storeDriverDeliveryEventArgsImpl))
                {
                    inferencePropertyBag.Add(InferenceSchema.ClassificationStatus, InferenceClassificationAgentLogger.Status.Skipped);
                    inferencePropertyBag.Add(InferenceSchema.ClassificationStatusMessage, "MailboxNotInteresting");
                }
                else if (!InferenceClassificationAgent.IsMessageInteresting(storeDriverDeliveryEventArgsImpl))
                {
                    inferencePropertyBag.Add(InferenceSchema.ClassificationStatus, InferenceClassificationAgentLogger.Status.Skipped);
                    inferencePropertyBag.Add(InferenceSchema.ClassificationStatusMessage, "MessageNotInteresting");
                }
                else
                {
                    storeDriverDeliveryEventArgsImpl.PropertiesForAllMessageCopies = (storeDriverDeliveryEventArgsImpl.PropertiesForAllMessageCopies ?? new Dictionary <PropertyDefinition, object>());
                    Guid guid = Guid.NewGuid();
                    storeDriverDeliveryEventArgsImpl.PropertiesForAllMessageCopies[MessageItemSchema.InferenceMessageIdentifier] = guid;
                    inferencePropertyBag.Add(InferenceSchema.MessageIdentifier, guid);
                    variantConfigurationSnapshot = FlightModule.GetFlightFeatures(storeDriverDeliveryEventArgsImpl.MailboxOwner);
                    if (variantConfigurationSnapshot != null)
                    {
                        inferencePropertyBag.Add(InferenceSchema.UserFlightFeatures, variantConfigurationSnapshot);
                    }
                    IDeliveryClassificationStrategy deliveryClassificationStrategy = ClassificationStrategyFactory.Create(storeDriverDeliveryEventArgsImpl.MailboxSession, variantConfigurationSnapshot);
                    inferencePropertyBag.Add(InferenceSchema.IsUiEnabled, deliveryClassificationStrategy != null);
                    OriginalDeliveryFolderInfo originalDeliveryFolderInfo = InferenceClassificationAgent.GetOriginalDeliveryFolderInfo(storeDriverDeliveryEventArgsImpl);
                    storeDriverDeliveryEventArgsImpl.PropertiesForAllMessageCopies[ItemSchema.OriginalDeliveryFolderInfo] = originalDeliveryFolderInfo.Serialize();
                    inferencePropertyBag.Add(InferenceSchema.OriginalDeliveryFolder, originalDeliveryFolderInfo);
                    if (!InferenceClassificationAgent.IsDeliveryFolderInteresting(originalDeliveryFolderInfo))
                    {
                        inferencePropertyBag.Add(InferenceSchema.ClassificationStatus, InferenceClassificationAgentLogger.Status.Skipped);
                        inferencePropertyBag.Add(InferenceSchema.ClassificationStatusMessage, "DeliveryFolderNotInteresting");
                    }
                    else if (!this.isPipelineEnabled)
                    {
                        inferencePropertyBag.Add(InferenceSchema.ClassificationStatus, InferenceClassificationAgentLogger.Status.Failed);
                        inferencePropertyBag.Add(InferenceSchema.ClassificationStatusMessage, "PipelineDisabled");
                        InferenceClassificationProcessing.NumberOfItemsSkippedDueToDisabledPipeline.Increment();
                    }
                    else
                    {
                        ConversationClutterInformation conversationClutterInformation = null;
                        bool flag = false;
                        InferenceClassificationResult inferenceClassificationResult = InferenceClassificationResult.None;
                        if (this.RunClassificationPipeline(storeDriverDeliveryEventArgsImpl, inferencePropertyBag, variantConfigurationSnapshot, out mdbDocument, out flag, out conversationClutterInformation))
                        {
                            if (flag)
                            {
                                inferenceClassificationResult |= InferenceClassificationResult.IsClutterModel;
                            }
                            string value = string.Empty;
                            bool   flag2 = false;
                            bool   flag3;
                            InferenceClassificationResult inferenceClassificationResult2;
                            string text;
                            bool   flag4;
                            if (InferenceClassificationAgent.CheckForRuleAndConversationOverrides(storeDriverDeliveryEventArgsImpl.SharedPropertiesBetweenAgents, originalDeliveryFolderInfo, out flag3, out inferenceClassificationResult2, out text, out flag4))
                            {
                                flag  = flag3;
                                value = text;
                            }
                            inferenceClassificationResult |= inferenceClassificationResult2;
                            if (flag4 && conversationClutterInformation != null)
                            {
                                flag = conversationClutterInformation.IsNewMessageClutter(flag, out flag2);
                            }
                            inferencePropertyBag.Add(InferenceSchema.IsClutter, flag);
                            if (flag)
                            {
                                inferenceClassificationResult |= InferenceClassificationResult.IsClutterFinal;
                            }
                            if (deliveryClassificationStrategy != null)
                            {
                                deliveryClassificationStrategy.ApplyClassification(storeDriverDeliveryEventArgsImpl, inferenceClassificationResult);
                                if (flag2 && conversationClutterInformation != null)
                                {
                                    conversationClutterInformation.MarkItemsAsNotClutter();
                                }
                            }
                            storeDriverDeliveryEventArgsImpl.PropertiesForAllMessageCopies[ItemSchema.InferenceClassificationResult] = inferenceClassificationResult;
                            inferencePropertyBag.Add(InferenceSchema.InferenceClassificationResult, inferenceClassificationResult);
                            inferencePropertyBag.Add(InferenceSchema.ClassificationStatus, InferenceClassificationAgentLogger.Status.Succeeded);
                            inferencePropertyBag.Add(InferenceSchema.ClassificationStatusMessage, value);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                if (ex is OutOfMemoryException || ex is StackOverflowException || ex is ThreadAbortException)
                {
                    throw;
                }
                Exception innerException = ex.InnerException;
                if (innerException is StorageTransientException)
                {
                    InferenceClassificationProcessing.NumberOfTransientExceptions.Increment();
                }
                else if (innerException is QuotaExceededException)
                {
                    InferenceClassificationProcessing.NumberOfQuotaExceededExceptions.Increment();
                }
                this.diagnosticsSession.LogDiagnosticsInfo(DiagnosticsLoggingTag.Failures, "Received exception {0}", new object[]
                {
                    ex
                });
                inferencePropertyBag.Add(InferenceSchema.ClassificationStatus, InferenceClassificationAgentLogger.Status.Failed);
                inferencePropertyBag.Add(InferenceSchema.ClassificationStatusMessage, "Exception");
                inferencePropertyBag.Add(InferenceSchema.ClassificationAgentException, ex);
            }
            finally
            {
                stopwatch.Stop();
                InferenceClassificationAgent.tracer.TraceDebug <long>((long)this.GetHashCode(), "InferenceClassification agent took {0} ms to process the item.", stopwatch.ElapsedMilliseconds);
                inferencePropertyBag.Add(InferenceSchema.TimeTakenToClassify, stopwatch.ElapsedMilliseconds);
                if (storeDriverDeliveryEventArgsImpl.MailboxSession != null)
                {
                    InferenceClassificationAgent.RecordPerformanceCounter(storeDriverDeliveryEventArgsImpl.MailboxSession.MdbGuid.ToString(), stopwatch.ElapsedMilliseconds);
                }
                InferenceClassificationTracking inferenceClassificationTracking = InferenceClassificationTracking.Create();
                this.logValues = this.classificationAgentLogger.ExtractClassificationProperties(inferencePropertyBag, mdbDocument, inferenceClassificationTracking);
                if (variantConfigurationSnapshot != null && variantConfigurationSnapshot.Inference.InferenceStampTracking.Enabled)
                {
                    storeDriverDeliveryEventArgsImpl.PropertiesForAllMessageCopies[MessageItemSchema.InferenceClassificationTrackingEx] = inferenceClassificationTracking.ToString();
                }
                if (mdbDocument != null)
                {
                    mdbDocument.Dispose();
                    mdbDocument = null;
                }
            }
        }
Beispiel #6
0
        internal bool RunClassificationPipeline(StoreDriverDeliveryEventArgsImpl argsImpl, InferencePropertyBag classificationDiagnostics, VariantConfigurationSnapshot flightFeatures, out MdbDocument document, out bool isClutter, out ConversationClutterInformation conversationClutterInformation)
        {
            document  = null;
            isClutter = false;
            conversationClutterInformation = null;
            InferenceClassificationAgent.tracer.TraceDebug((long)this.GetHashCode(), "Processing incoming message");
            ModelVersionBreadCrumb breadCrumb      = ClutterUtilities.GetModelVersionBreadCrumb(argsImpl.MailboxSession);
            ModelVersionSelector   versionSelector = new ModelVersionSelector(this.modelConfiguration, breadCrumb, delegate(string str)
            {
                this.diagnosticsSession.TraceDebug(str, new object[0]);
            });

            if (versionSelector.ClassificationModelVersion.Version == -2147483648)
            {
                classificationDiagnostics.Add(InferenceSchema.ClassificationStatus, InferenceClassificationAgentLogger.Status.Skipped);
                classificationDiagnostics.Add(InferenceSchema.ClassificationStatusMessage, "ClassificationModelNotFound");
                return(false);
            }
            MdbInferenceRecipient ownerAsInferenceRecipient;

            if (string.Equals(argsImpl.MailboxSession.MailboxOwner.MailboxInfo.DisplayName, argsImpl.MailboxSession.MailboxOwner.LegacyDn, StringComparison.OrdinalIgnoreCase))
            {
                ownerAsInferenceRecipient = new MdbInferenceRecipient(argsImpl.MailboxSession.MailboxOwner, argsImpl.MailboxSession.Culture, argsImpl.MailboxOwner.DisplayName);
            }
            else
            {
                ownerAsInferenceRecipient = new MdbInferenceRecipient(argsImpl.MailboxSession.MailboxOwner, argsImpl.MailboxSession.Culture, null);
            }
            bool?conversationLoadRequired = null;

            if (argsImpl.SharedPropertiesBetweenAgents != null && argsImpl.SharedPropertiesBetweenAgents.ContainsKey(ItemSchema.ConversationLoadRequiredByInference))
            {
                conversationLoadRequired = new bool?((bool)argsImpl.SharedPropertiesBetweenAgents[ItemSchema.ConversationLoadRequiredByInference]);
            }
            DocumentProcessingContext  processingContext          = new DocumentProcessingContext(argsImpl.MailboxSession);
            MdbCompositeItemIdentity   mdbCompositeItemIdentity   = new MdbCompositeItemIdentity(argsImpl.MailboxSession.MdbGuid, argsImpl.MailboxSession.MailboxGuid, StoreObjectId.DummyId, 1);
            MdbInMemoryDocumentAdapter mdbInMemoryDocumentAdapter = new MdbInMemoryDocumentAdapter(mdbCompositeItemIdentity, argsImpl.ReplayItem, MdbInferencePropertyMap.Instance);

            document = new MdbDocument(mdbCompositeItemIdentity, DocumentOperation.Insert, mdbInMemoryDocumentAdapter);
            object uniqueBodyWords;

            document.TryGetProperty(InferenceSchema.UniqueBodyWordsFromProvider, out uniqueBodyWords);
            this.ProcessClassificationDocument(document, classificationDiagnostics, versionSelector.ClassificationModelVersion, processingContext, ownerAsInferenceRecipient, breadCrumb, flightFeatures, uniqueBodyWords, conversationLoadRequired);
            IItem inMemoryItem = mdbInMemoryDocumentAdapter.InMemoryItem;

            if (inMemoryItem == null)
            {
                InferenceClassificationAgent.tracer.TraceError((long)this.GetHashCode(), "The InMemoryItem of the inMemDocAdapter was null");
                classificationDiagnostics.Add(InferenceSchema.ClassificationStatus, InferenceClassificationAgentLogger.Status.Skipped);
                classificationDiagnostics.Add(InferenceSchema.ClassificationStatusMessage, "InMemoryItemNull");
                return(false);
            }
            object obj;

            if (document.TryGetProperty(InferenceSchema.ConversationClutterInformation, out obj))
            {
                conversationClutterInformation = (obj as ConversationClutterInformation);
            }
            classificationDiagnostics.Add(InferenceSchema.ConversationClutterInformation, conversationClutterInformation);
            classificationDiagnostics.Add(InferenceSchema.MarkedAsBulk, InferenceClassificationAgent.IsBulkMail(argsImpl, argsImpl.MailboxOwner));
            isClutter = document.GetProperty <bool>(InferenceSchema.ComputedClutterValue);
            foreach (StorePropertyDefinition propertyDefinition in InferenceClassificationAgent.PropertiesToReplicate)
            {
                InferenceClassificationAgent.CopyIfValid(propertyDefinition, inMemoryItem, argsImpl.PropertiesForAllMessageCopies);
            }
            if (this.classificationComparisonLogger != null && flightFeatures != null && flightFeatures.Inference.InferenceModelComparison.Enabled)
            {
                IEnumerable <int> enumerable = from entry in versionSelector.TrainingModelVersions
                                               where entry.Version != versionSelector.ClassificationModelVersion.Version && (breadCrumb.Contains((short)entry.Version, ModelVersionBreadCrumb.VersionType.Ready) || breadCrumb.Contains((short)entry.Version, ModelVersionBreadCrumb.VersionType.NotReady))
                                               select entry.Version;
                if (enumerable != null && enumerable.Any <int>())
                {
                    Dictionary <OrderedFeatureSet, FeatureValues> dictionary = new Dictionary <OrderedFeatureSet, FeatureValues>();
                    dictionary.Add(ModelConfiguration.GetModelVersionConfiguration(versionSelector.ClassificationModelVersion.Version).FeatureSet, document.GetProperty <FeatureValues>(InferenceSchema.ImportanceFeatureValues));
                    this.classificationComparisonLogger.LogModelComparisonData(document, classificationDiagnostics);
                    foreach (int comparisonVersion in enumerable)
                    {
                        MdbDocument          mdbDocument          = new MdbDocument(mdbCompositeItemIdentity, DocumentOperation.Insert, mdbInMemoryDocumentAdapter);
                        InferencePropertyBag inferencePropertyBag = new InferencePropertyBag();
                        this.ProcessClassificationDocumentForComparisonModel(mdbDocument, inferencePropertyBag, comparisonVersion, document, classificationDiagnostics, dictionary, processingContext, ownerAsInferenceRecipient, breadCrumb, flightFeatures, uniqueBodyWords, conversationLoadRequired);
                        this.classificationComparisonLogger.LogModelComparisonData(mdbDocument, inferencePropertyBag);
                    }
                }
            }
            return(true);
        }