예제 #1
0
        protected static MapiMessage GetDeliveryReceipt(MapiFolder folder, string subject, bool dsnOnly)
        {
            string    value = DsnHumanReadableWriter.GetLocalizedSubjectPrefix(DsnFlags.Relay).ToString();
            MapiTable contentsTable;
            MapiTable mapiTable = contentsTable = folder.GetContentsTable();

            try
            {
                mapiTable.SetColumns(new PropTag[]
                {
                    PropTag.EntryId,
                    PropTag.Subject,
                    PropTag.MessageClass
                });
                PropValue[][] array = mapiTable.QueryRows(1000, QueryRowsFlags.None);
                for (int i = 0; i <= array.GetUpperBound(0); i++)
                {
                    if (!dsnOnly || ObjectClass.IsDsnPositive(array[i][2].Value.ToString()))
                    {
                        string text = array[i][1].Value.ToString();
                        if ((!text.StartsWith(value, StringComparison.OrdinalIgnoreCase) || subject.StartsWith(value, StringComparison.OrdinalIgnoreCase)) && text.EndsWith(subject, StringComparison.OrdinalIgnoreCase))
                        {
                            byte[] bytes = array[i][0].GetBytes();
                            return((MapiMessage)folder.OpenEntry(bytes));
                        }
                    }
                }
            }
            finally
            {
                if (contentsTable != null)
                {
                    ((IDisposable)contentsTable).Dispose();
                }
            }
            return(null);
        }
 private void MatchCrossPremiseMessages(MapiFolder responseFolder, MapiFolder probeFolder, SmtpAddress source, List <SmtpAddress> targets)
 {
     using (MapiTable contentsTable = responseFolder.GetContentsTable())
     {
         using (MapiTable contentsTable2 = probeFolder.GetContentsTable())
         {
             contentsTable.SetColumns(new PropTag[]
             {
                 PropTag.EntryId,
                 PropTag.Subject,
                 PropTag.ClientSubmitTime
             });
             contentsTable2.SetColumns(new PropTag[]
             {
                 PropTag.EntryId,
                 PropTag.Subject,
                 PropTag.ClientSubmitTime
             });
             PropValue[][] array  = contentsTable.QueryRows(1000, QueryRowsFlags.None);
             PropValue[][] array2 = contentsTable2.QueryRows(1000, QueryRowsFlags.None);
             List <byte[]> list   = new List <byte[]>();
             List <byte[]> list2  = new List <byte[]>();
             Dictionary <SmtpAddress, CrossPremiseTestMailFlowHelper.HealthData> dictionary = new Dictionary <SmtpAddress, CrossPremiseTestMailFlowHelper.HealthData>(targets.Count);
             for (int i = 0; i <= array2.GetUpperBound(0); i++)
             {
                 if (TestMailFlowHelper.IsValidPropData(array2, i, 3))
                 {
                     string text = (string)array2[i][1].Value;
                     if (text.StartsWith("CrossPremiseMailFlowMonitoring-", StringComparison.OrdinalIgnoreCase))
                     {
                         byte[] bytes = array2[i][0].GetBytes();
                         using (MapiMessage mapiMessage = (MapiMessage)probeFolder.OpenEntry(bytes))
                         {
                             SmtpAddress key = SmtpAddress.Parse((string)mapiMessage.GetProp(PropTag.ReceivedByEmailAddress).Value);
                             if (!dictionary.ContainsKey(key))
                             {
                                 dictionary.Add(key, new CrossPremiseTestMailFlowHelper.HealthData(EnhancedTimeSpan.Zero, EnhancedTimeSpan.Zero, 0, 0, 0, 0));
                             }
                             ExDateTime exDateTime = (ExDateTime)array2[i][2].GetDateTime();
                             if (exDateTime.Add(base.Task.CrossPremisesExpirationTimeout) < ExDateTime.UtcNow)
                             {
                                 dictionary[key].ExpiredNumber++;
                                 list.Add(bytes);
                             }
                             else
                             {
                                 for (int j = 0; j <= array.GetUpperBound(0); j++)
                                 {
                                     if (TestMailFlowHelper.IsValidPropData(array, j, 3))
                                     {
                                         string text2 = (string)array[j][1].Value;
                                         if (text2.EndsWith(text, StringComparison.OrdinalIgnoreCase))
                                         {
                                             byte[] bytes2 = array[j][0].GetBytes();
                                             if (((ExDateTime)array[j][2].GetDateTime()).Add(base.Task.CrossPremisesExpirationTimeout) < ExDateTime.UtcNow)
                                             {
                                                 list2.Add(bytes2);
                                             }
                                             else
                                             {
                                                 using (MapiMessage mapiMessage2 = (MapiMessage)responseFolder.OpenEntry(bytes2))
                                                 {
                                                     EnhancedTimeSpan t;
                                                     EnhancedTimeSpan t2;
                                                     if (this.ProcessCrossPremiseMessagePair(mapiMessage, mapiMessage2, source.ToString(), key.ToString(), out t, out t2))
                                                     {
                                                         dictionary[key].ProbeLatency    += t;
                                                         dictionary[key].ResponseLatency += t2;
                                                         dictionary[key].SuccessNumber++;
                                                     }
                                                     else
                                                     {
                                                         dictionary[key].FailedNumber++;
                                                     }
                                                 }
                                                 list2.Add(bytes2);
                                                 list.Add(bytes);
                                             }
                                         }
                                     }
                                 }
                                 if (!list.Contains(bytes) && exDateTime.AddMinutes(10.0) < ExDateTime.UtcNow)
                                 {
                                     dictionary[key].PendingNumber++;
                                 }
                             }
                         }
                     }
                 }
             }
             this.SaveHealthData(source, dictionary);
             if (list2.Count > 0)
             {
                 responseFolder.DeleteMessages(DeleteMessagesFlags.ForceHardDelete, list2.ToArray());
             }
             if (list.Count > 0)
             {
                 probeFolder.DeleteMessages(DeleteMessagesFlags.ForceHardDelete, list.ToArray());
             }
         }
     }
 }