Example #1
0
        internal static BadMessageRec Item(MessageRec msgData, FolderRec folderRec, Exception exception)
        {
            BadMessageRec badMessageRec = new BadMessageRec();

            if (exception == null)
            {
                badMessageRec.Kind = BadItemKind.MissingItem;
            }
            else if (CommonUtils.ExceptionIs(exception, new WellKnownException[]
            {
                WellKnownException.MapiMaxSubmissionExceeded
            }))
            {
                badMessageRec.Kind = BadItemKind.LargeItem;
            }
            else
            {
                badMessageRec.Kind = BadItemKind.CorruptItem;
            }
            badMessageRec.EntryId      = msgData.EntryId;
            badMessageRec.Sender       = (msgData[PropTag.SenderName] as string);
            badMessageRec.Recipient    = (msgData[PropTag.ReceivedByName] as string);
            badMessageRec.Subject      = (msgData[PropTag.Subject] as string);
            badMessageRec.MessageClass = (msgData[PropTag.MessageClass] as string);
            badMessageRec.MessageSize  = (int?)msgData[PropTag.MessageSize];
            badMessageRec.DateSent     = (DateTime?)msgData[PropTag.ClientSubmitTime];
            badMessageRec.DateReceived = (DateTime?)msgData[PropTag.MessageDeliveryTime];
            badMessageRec.FolderId     = msgData.FolderId;
            badMessageRec.FolderName   = folderRec.FolderName;
            badMessageRec.Failure      = FailureRec.Create(exception);
            badMessageRec.RawFailure   = exception;
            return(badMessageRec);
        }
Example #2
0
 public void Append(LocalizedString msg, Exception failure, ReportEntryFlags flags)
 {
     this.Append(new ReportEntry(msg, ReportEntryType.Error)
     {
         Failure = FailureRec.Create(failure),
         Flags   = (flags | ReportEntryFlags.Failure)
     });
 }
Example #3
0
        public IDictionary <Guid, FailureRec> GetQuarantinedJobs()
        {
            IRegistryReader instance  = RegistryReader.Instance;
            IRegistryWriter instance2 = RegistryWriter.Instance;

            string[] array = null;
            try
            {
                array = instance.GetSubKeyNames(Registry.LocalMachine, JobQuarantineProvider.KeyNameFormatQuarantinedJobRoot);
            }
            catch (ArgumentException)
            {
            }
            if (array == null)
            {
                return(new Dictionary <Guid, FailureRec>());
            }
            Dictionary <Guid, FailureRec> dictionary = new Dictionary <Guid, FailureRec>(array.Length);

            string[] array2 = array;
            int      i      = 0;

            while (i < array2.Length)
            {
                string text       = array2[i];
                Guid   key        = Guid.Empty;
                string subkeyName = Path.Combine(JobQuarantineProvider.KeyNameFormatQuarantinedJobRoot, text);
                try
                {
                    key = new Guid(text);
                }
                catch (FormatException)
                {
                    try
                    {
                        instance2.DeleteSubKeyTree(Registry.LocalMachine, subkeyName);
                    }
                    catch (ArgumentException)
                    {
                    }
                    goto IL_118;
                }
                goto IL_80;
IL_118:
                i++;
                continue;
IL_80:
                string value = instance.GetValue <string>(Registry.LocalMachine, subkeyName, "FailureType", string.Empty);
                string     value2 = instance.GetValue <string>(Registry.LocalMachine, subkeyName, "Message", string.Empty);
                string     value3 = instance.GetValue <string>(Registry.LocalMachine, subkeyName, "StackTrace", string.Empty);
                string     value4 = instance.GetValue <string>(Registry.LocalMachine, subkeyName, "DataContext", string.Empty);
                string     value5 = instance.GetValue <string>(Registry.LocalMachine, subkeyName, "InnerException", string.Empty);
                FailureRec value6 = FailureRec.Create(value, value2, value3, value4, value5);
                dictionary.Add(key, value6);
                goto IL_118;
            }
            return(dictionary);
        }
Example #4
0
 internal static BadMessageRec MissingItem(Exception ex)
 {
     return(new BadMessageRec
     {
         Kind = BadItemKind.MissingItem,
         Failure = FailureRec.Create(ex),
         EntryId = BadMessageRec.ComputeKey(BitConverter.GetBytes(ex.GetHashCode()), BadItemKind.MissingItem)
     });
 }
Example #5
0
 internal static BadMessageRec InferenceData(Exception failure, byte[] entryId)
 {
     return(new BadMessageRec
     {
         Kind = BadItemKind.CorruptInferenceProperties,
         Failure = FailureRec.Create(failure),
         EntryId = entryId,
         RawFailure = failure
     });
 }
Example #6
0
 internal static BadMessageRec MailboxSetting(Exception failure, ItemPropertiesBase item)
 {
     return(new BadMessageRec
     {
         Kind = BadItemKind.CorruptMailboxSetting,
         Failure = FailureRec.Create(failure),
         RawFailure = failure,
         MessageClass = item.GetType().ToString(),
         EntryId = item.GetId()
     });
 }
Example #7
0
 internal static BadMessageRec Folder(FolderRec folderRec, BadItemKind kind, Exception failure)
 {
     return(new BadMessageRec
     {
         Kind = kind,
         EntryId = BadMessageRec.ComputeKey(folderRec.EntryId, kind),
         FolderId = folderRec.EntryId,
         FolderName = folderRec.FolderName,
         Failure = FailureRec.Create(failure),
         RawFailure = failure
     });
 }
Example #8
0
 public static void Add(Guid requestGuid, Exception ex)
 {
     if (!QuarantinedJobs.Enabled)
     {
         return;
     }
     JobQuarantineProvider.Instance.QuarantineJob(requestGuid, ex);
     lock (QuarantinedJobs.syncRoot)
     {
         QuarantinedJobs.Jobs.Add(requestGuid, FailureRec.Create(ex));
     }
 }
Example #9
0
 public ReportEntry(LocalizedString message, ReportEntryType type, Exception failure, ReportEntryFlags flags)
 {
     this.Message      = message;
     this.CreationTime = (DateTime)ExDateTime.UtcNow;
     this.ServerName   = CommonUtils.LocalShortComputerName;
     this.Type         = type;
     this.Flags        = flags;
     if (failure != null)
     {
         this.Failure = FailureRec.Create(failure);
         this.Flags  |= ReportEntryFlags.Failure;
     }
 }
Example #10
0
 private FailureRec(Exception ex)
 {
     this.Timestamp         = DateTime.UtcNow;
     this.FailureType       = CommonUtils.GetFailureType(ex);
     this.FailureCode       = CommonUtils.HrFromException(ex);
     this.MapiLowLevelError = CommonUtils.GetMapiLowLevelError(ex);
     this.FailureSide       = CommonUtils.GetExceptionSide(ex);
     this.ExceptionTypes    = CommonUtils.ClassifyException(ex);
     this.Message           = CommonUtils.FullExceptionMessage(ex).ToString();
     this.DataContext       = ExecutionContext.GetDataContext(ex);
     this.StackTrace        = CommonUtils.GetStackTrace(ex);
     this.InnerException    = FailureRec.Create(ex.InnerException);
 }
Example #11
0
        internal static BadMessageRec FolderProperty(FolderRec folderRec, PropTag propTag, string sourceValue, string destValue)
        {
            BadMessageRec badMessageRec = new BadMessageRec();

            badMessageRec.FolderId   = folderRec.EntryId;
            badMessageRec.FolderName = folderRec.FolderName;
            badMessageRec.Kind       = BadItemKind.FolderPropertyMismatch;
            badMessageRec.EntryId    = BadMessageRec.ComputeKey(folderRec.EntryId, badMessageRec.Kind, propTag);
            PropertyMismatchException ex = new PropertyMismatchException((uint)propTag, sourceValue, destValue);

            badMessageRec.Failure    = FailureRec.Create(ex);
            badMessageRec.RawFailure = ex;
            return(badMessageRec);
        }
Example #12
0
        void IDataImport.SendMessage(IDataMessage message)
        {
            MessageExportResultsMessage messageExportResultsMessage = message as MessageExportResultsMessage;

            if (messageExportResultsMessage == null)
            {
                base.WrappedObject.SendMessage(message);
                return;
            }
            this.MissingMessages = messageExportResultsMessage.MissingMessages;
            this.BadMessages     = messageExportResultsMessage.BadMessages;
            foreach (BadMessageRec badMessageRec in this.BadMessages)
            {
                badMessageRec.Failure = FailureRec.Create(new RemotePermanentException(new LocalizedString(badMessageRec.XmlData), null));
            }
        }
Example #13
0
 public void QuarantineJob(Guid requestGuid, Exception ex)
 {
     try
     {
         FailureRec failureRec = FailureRec.Create(ex);
         string     subkeyName = string.Format(JobQuarantineProvider.KeyNameFormatQuarantinedJob, requestGuid);
         RegistryWriter.Instance.CreateSubKey(Registry.LocalMachine, subkeyName);
         RegistryWriter.Instance.SetValue(Registry.LocalMachine, subkeyName, "FailureType", failureRec.FailureType ?? string.Empty, RegistryValueKind.String);
         RegistryWriter.Instance.SetValue(Registry.LocalMachine, subkeyName, "Message", failureRec.Message ?? string.Empty, RegistryValueKind.String);
         RegistryWriter.Instance.SetValue(Registry.LocalMachine, subkeyName, "StackTrace", failureRec.StackTrace ?? string.Empty, RegistryValueKind.String);
         string dataContext = failureRec.DataContext ?? string.Empty;
         RegistryWriter.Instance.SetValue(Registry.LocalMachine, subkeyName, "DataContext", FailureLog.GetDataContextToPersist(dataContext), RegistryValueKind.String);
         string text = string.Empty;
         if (failureRec.InnerException != null)
         {
             text = failureRec.InnerException.StackTrace;
         }
         RegistryWriter.Instance.SetValue(Registry.LocalMachine, subkeyName, "InnerException", text ?? string.Empty, RegistryValueKind.String);
     }
     catch (ArgumentException)
     {
     }
 }
Example #14
0
        public static FailureRec Create(string failureType, string message, string stackTrace, string dataContext, string innerException)
        {
            FailureRec innerFailure = string.IsNullOrEmpty(innerException) ? null : FailureRec.Create(string.Empty, string.Empty, innerException, string.Empty, string.Empty);

            return(new FailureRec(failureType, message, stackTrace, dataContext, innerFailure));
        }