Esempio n. 1
0
 private void ProcessRecipients(IList <IMessageRecipient> recipients, IDictionary <string, IInferenceRecipient> contactList, ExDateTime sentTime, bool isReply, long currentTimeWindowNumber)
 {
     foreach (IMessageRecipient recipient in recipients)
     {
         IInferenceRecipient inferenceRecipient = new InferenceRecipient(recipient);
         string key = inferenceRecipient.SmtpAddress.ToLower(CultureInfo.InvariantCulture);
         if (!contactList.ContainsKey(key))
         {
             contactList.Add(key, inferenceRecipient);
         }
         else
         {
             contactList[key].UpdateFromRecipient(inferenceRecipient);
             inferenceRecipient = contactList[key];
         }
         if (inferenceRecipient.TotalSentCount == 0L)
         {
             int num = isReply ? 2 : 6;
             inferenceRecipient.FirstSentTime      = sentTime.UniversalTime;
             inferenceRecipient.RawRecipientWeight = (double)(num - 1);
             inferenceRecipient.RecipientRank      = int.MaxValue;
         }
         inferenceRecipient.TotalSentCount      += 1L;
         inferenceRecipient.LastSentTime         = sentTime.UniversalTime;
         inferenceRecipient.LastUsedInTimeWindow = currentTimeWindowNumber;
         inferenceRecipient.RawRecipientWeight  += 1.0;
     }
 }
Esempio n. 2
0
        private void BuildRecipientList(DocumentContext data, IEnumerable <IRecipientInfo> recipientList, IDictionary <string, IInferenceRecipient> contactList)
        {
            if (recipientList == null || !recipientList.Any <IRecipientInfo>())
            {
                return;
            }
            ExDateTime property = data.Document.GetProperty <ExDateTime>(PeopleRelevanceSchema.LastProcessedMessageSentTime);

            foreach (IRecipientInfo recipientInfo in recipientList)
            {
                if (recipientInfo.SentCount != 0U)
                {
                    if (string.IsNullOrEmpty(recipientInfo.Address))
                    {
                        this.DiagnosticsSession.TraceDebug <IIdentity>("{0}: missing Address", data.Document.Identity);
                    }
                    else if (recipientInfo.FirstSentTimeUtc == null || recipientInfo.LastSentTimeUtc == null)
                    {
                        this.DiagnosticsSession.TraceDebug <IIdentity, string>("{0}: {1}: empty FirstSentTime or LastSentTime", data.Document.Identity, recipientInfo.Address);
                    }
                    else if (recipientInfo.LastSentTimeUtc < recipientInfo.FirstSentTimeUtc)
                    {
                        this.DiagnosticsSession.TraceDebug("{0}: {1}: LastSentTime {2} < FirstSentTime {3}", new object[]
                        {
                            data.Document.Identity,
                            recipientInfo.Address,
                            recipientInfo.LastSentTimeUtc.Value,
                            recipientInfo.FirstSentTimeUtc.Value
                        });
                    }
                    else if (!(recipientInfo.LastSentTimeUtc.Value.UniversalTime < property.UniversalTime))
                    {
                        object obj;
                        long   num;
                        if (!data.Document.TryGetProperty(PeopleRelevanceSchema.CurrentTimeWindowNumber, out obj))
                        {
                            num = 1L;
                            data.Document.SetProperty(PeopleRelevanceSchema.CurrentTimeWindowStartTime, recipientInfo.LastSentTimeUtc);
                            data.Document.SetProperty(PeopleRelevanceSchema.CurrentTimeWindowNumber, num);
                        }
                        else
                        {
                            num = (long)obj;
                            TimeSpan t = recipientInfo.LastSentTimeUtc.Value.UniversalTime - data.Document.GetProperty <ExDateTime>(PeopleRelevanceSchema.CurrentTimeWindowStartTime).UniversalTime;
                            if (t >= PicwContactExtractor.TimeWindowLength)
                            {
                                num += 1L;
                                data.Document.SetProperty(PeopleRelevanceSchema.CurrentTimeWindowStartTime, recipientInfo.LastSentTimeUtc);
                                data.Document.SetProperty(PeopleRelevanceSchema.CurrentTimeWindowNumber, num);
                            }
                        }
                        string text = recipientInfo.Address.ToLower(CultureInfo.InvariantCulture);
                        IInferenceRecipient inferenceRecipient;
                        if (!contactList.ContainsKey(text))
                        {
                            inferenceRecipient = new InferenceRecipient(new MdbRecipient(text, text, string.Empty));
                            inferenceRecipient.RawRecipientWeight = 5.0;
                            inferenceRecipient.RecipientRank      = int.MaxValue;
                            contactList.Add(text, inferenceRecipient);
                        }
                        else
                        {
                            inferenceRecipient = contactList[text];
                        }
                        if (inferenceRecipient.TotalSentCount != (long)((ulong)recipientInfo.SentCount))
                        {
                            inferenceRecipient.FirstSentTime        = recipientInfo.FirstSentTimeUtc.Value.UniversalTime;
                            inferenceRecipient.LastSentTime         = recipientInfo.LastSentTimeUtc.Value.UniversalTime;
                            inferenceRecipient.LastUsedInTimeWindow = num;
                            inferenceRecipient.RawRecipientWeight  += (double)((ulong)recipientInfo.SentCount - (ulong)inferenceRecipient.TotalSentCount);
                            inferenceRecipient.TotalSentCount       = (long)((ulong)recipientInfo.SentCount);
                        }
                    }
                }
            }
        }
 internal static int GetRelevanceCategoryForRecipient(IInferenceRecipient recipient)
 {
     return(InferenceRecipient.GetRelevanceCategoryForRank(recipient.RecipientRank));
 }