private static void WriteInternal(Guid requestGuid, Exception failure, bool isFatal, RequestState requestState, SyncStage syncStage, string folderName, string operationType, Guid failureGuid, int failureLevel) { FailureData objectToLog = default(FailureData); objectToLog.FailureGuid = failureGuid; objectToLog.RequestGuid = requestGuid; objectToLog.Failure = failure; objectToLog.FailureLevel = failureLevel; objectToLog.IsFatal = isFatal; objectToLog.RequestState = requestState; objectToLog.SyncStage = syncStage; objectToLog.FolderName = folderName; objectToLog.OperationType = operationType; if (objectToLog.OperationType == null && objectToLog.Failure != null) { string dataContext = ExecutionContext.GetDataContext(failure); objectToLog.OperationType = FailureLog.GetDataContextToPersist(dataContext); } GenericSettingsContext genericSettingsContext = new GenericSettingsContext("FailureType", CommonUtils.GetFailureType(failure), null); using (genericSettingsContext.Activate()) { if (ConfigBase <MRSConfigSchema> .GetConfig <bool>("SendGenericWatson")) { string watsonHash; CommonUtils.SendGenericWatson(failure, CommonUtils.FullFailureMessageWithCallStack(failure, 5), out watsonHash); objectToLog.WatsonHash = watsonHash; } else { objectToLog.WatsonHash = CommonUtils.ComputeCallStackHash(failure, 5); } } FailureLog.instance.LogObject(objectToLog); if (failure.InnerException != null) { FailureLog.WriteInternal(requestGuid, failure.InnerException, isFatal, requestState, syncStage, folderName, operationType, failureGuid, failureLevel + 1); } }
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) { } }