private static void UpdateSubmissionExceptionCallstackRecords(MessageStatus messageStatus, int callstacksPerBucket, StoreDriverSubmission.SubmissionOccurrenceRecord occurrenceRecord) { if (callstacksPerBucket > 0) { string key = messageStatus.Exception.ToString(); lock (StoreDriverSubmission.exceptionSubmissionCallstackRecords) { Dictionary <string, StoreDriverSubmission.SubmissionOccurrenceRecord> dictionary; if (!StoreDriverSubmission.exceptionSubmissionCallstackRecords.TryGetValue(messageStatus.Action, out dictionary)) { dictionary = new Dictionary <string, StoreDriverSubmission.SubmissionOccurrenceRecord>(callstacksPerBucket); StoreDriverSubmission.exceptionSubmissionCallstackRecords[messageStatus.Action] = dictionary; } StoreDriverSubmission.SubmissionOccurrenceRecord submissionOccurrenceRecord; if (!dictionary.TryGetValue(key, out submissionOccurrenceRecord) && dictionary.Count == callstacksPerBucket) { DateTime t = DateTime.MaxValue; string key2 = null; foreach (KeyValuePair <string, StoreDriverSubmission.SubmissionOccurrenceRecord> keyValuePair in dictionary) { if (keyValuePair.Value.Timestamp < t) { t = keyValuePair.Value.Timestamp; key2 = keyValuePair.Key; } } dictionary.Remove(key2); } dictionary[key] = occurrenceRecord; } } }
internal static void UpdateSubmissionExceptionStatisticRecords(MessageStatus messageStatus, int lastOccurrencesPerException, int callstacksPerBucket, MailItemSubmitter mailItemSubmitter) { MapiSubmissionInfo mapiSubmissionInfo = mailItemSubmitter.SubmissionInfo as MapiSubmissionInfo; StoreDriverSubmission.SubmissionOccurrenceRecord submissionOccurrenceRecord = new StoreDriverSubmission.SubmissionOccurrenceRecord(DateTime.UtcNow, mailItemSubmitter.StartTime, mailItemSubmitter.SubmissionInfo.MdbGuid, (mapiSubmissionInfo == null) ? Guid.Empty : mapiSubmissionInfo.MailboxGuid, (mapiSubmissionInfo == null) ? null : mapiSubmissionInfo.EntryId, (mapiSubmissionInfo == null) ? null : mapiSubmissionInfo.ParentEntryId, (mapiSubmissionInfo == null) ? 0L : mapiSubmissionInfo.EventCounter, mailItemSubmitter.OrganizationId, mailItemSubmitter.ErrorCode, mailItemSubmitter.SubmissionInfo.MailboxFqdn, mailItemSubmitter.Item.HasMessageItem ? mailItemSubmitter.Item.Item.InternetMessageId : null, mailItemSubmitter.SubmissionConnectionId, mailItemSubmitter.MessageSize, mailItemSubmitter.RecipientCount, mailItemSubmitter.Result.Sender, mailItemSubmitter.Stage); if (lastOccurrencesPerException > 0) { string key = StoreDriverSubmission.GenerateExceptionKey(messageStatus); lock (StoreDriverSubmission.submissionExceptionStatisticRecords) { StoreDriverSubmission.ExceptionStatisticRecord <StoreDriverSubmission.SubmissionOccurrenceRecord> value; if (!StoreDriverSubmission.submissionExceptionStatisticRecords.TryGetValue(key, out value)) { value = default(StoreDriverSubmission.ExceptionStatisticRecord <StoreDriverSubmission.SubmissionOccurrenceRecord>); value.LastOccurrences = new Queue <StoreDriverSubmission.SubmissionOccurrenceRecord>(lastOccurrencesPerException); } if (value.LastOccurrences.Count == lastOccurrencesPerException) { value.LastOccurrences.Dequeue(); } value.LastOccurrences.Enqueue(submissionOccurrenceRecord); value.CountSinceServiceStart++; StoreDriverSubmission.submissionExceptionStatisticRecords[key] = value; } } StoreDriverSubmission.UpdateSubmissionExceptionCallstackRecords(messageStatus, callstacksPerBucket, submissionOccurrenceRecord); }