// Token: 0x06000134 RID: 308 RVA: 0x00007C84 File Offset: 0x00005E84
        private static void HandleImplicitMarkAsNotClutter(MapiEvent mapiEvent, MailboxSession session, MessageItem message, List <KeyValuePair <string, object> > customDataToLog)
        {
            ConversationId valueOrDefault = message.GetValueOrDefault <ConversationId>(ItemSchema.ConversationId, null);

            if (valueOrDefault == null)
            {
                customDataToLog.Add(new KeyValuePair <string, object>("InferenceDiagnostics", "ConversationIdNull"));
                return;
            }
            message.Load(new PropertyDefinition[]
            {
                ItemSchema.ConversationFamilyId
            });
            ConversationId valueOrDefault2 = message.GetValueOrDefault <ConversationId>(ItemSchema.ConversationFamilyId, null);

            if (valueOrDefault2 == null)
            {
                customDataToLog.Add(new KeyValuePair <string, object>("InferenceDiagnostics", "ConversationFamilyIdNull"));
                return;
            }
            VariantConfigurationSnapshot flightFeatures = FlightModule.GetFlightFeatures(session);

            StoreObjectId[] folderIds = new StoreObjectId[]
            {
                session.GetDefaultFolderId(DefaultFolderType.Drafts)
            };
            ICoreConversation coreConversation;

            if (flightFeatures != null && flightFeatures.DataStorage.ModernMailInfra.Enabled && !flightFeatures.DataStorage.ThreadedConversation.Enabled)
            {
                ConversationFamilyFactory conversationFamilyFactory = new ConversationFamilyFactory(session, valueOrDefault2);
                coreConversation = conversationFamilyFactory.CreateConversation(valueOrDefault, folderIds, true, false, InferenceProcessor.ConversationMessagePropertiesToLoad);
            }
            else
            {
                coreConversation = Conversation.Load(session, valueOrDefault, folderIds, true, false, InferenceProcessor.ConversationMessagePropertiesToLoad);
            }
            ConversationClutterInformation conversationClutterInformation = MdbConversationClutterInformationFactory.GetConversationClutterInformation(null, session, flightFeatures, coreConversation);

            if (conversationClutterInformation != null)
            {
                conversationClutterInformation.MarkItemsAsNotClutter(true);
            }
        }
Exemplo n.º 2
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;
                }
            }
        }