/// <summary> /// Translates the severity. /// </summary> /// <param name="errors">The errors.</param> /// <returns></returns> private static ParallelExecutionEventStatus TranslateSeverity( SqlErrorCollection errors) { ParallelExecutionEventStatus status = ParallelExecutionEventStatus.Information; if ((errors != null) && (errors.Count > 0)) { byte highest = errors .OfType <SqlError>() .Max(t => t.Class); if (highest <= 10) { status = ParallelExecutionEventStatus.Information; } else if (highest <= 16) { status = ParallelExecutionEventStatus.Warning; } else if (highest <= 19) { status = ParallelExecutionEventStatus.Error; } else { status = ParallelExecutionEventStatus.Critical; } } return(status); }
/// <summary> /// Tries the and report exception. /// </summary> /// <param name="e">The e.</param> private static void TryAndReportException( Exception e) { Guid?session = (currentConfiguration != null ? (Guid?)currentConfiguration.SessionId : null); ParallelExecutionEventStatus status = ParallelExecutionEventStatus.Error; if (e is SqlException) { status = TranslateSeverity((e as SqlException).Errors); } DataHelpers.usp_LogParallelExecutionEvent( null, session, null, status, e.Message, e.ToString()); }
/// <summary> /// Logs a parallel execution event. /// </summary> /// <param name="connection">The connection.</param> /// <param name="sessionID">The session identifier.</param> /// <param name="partitionID">The partition identifier.</param> /// <param name="logStatus">The log status.</param> /// <param name="title">The title.</param> /// <param name="comments">The comments.</param> public static void usp_LogParallelExecutionEvent( SqlConnection connection, Guid?sessionID, Guid?partitionID, ParallelExecutionEventStatus logStatus, string title, string comments) { Dictionary <string, object> parameters = new Dictionary <string, object>(); parameters.Add("@SessionId", ConvertForParameter(sessionID)); parameters.Add("@PartitionId", ConvertForParameter(partitionID)); parameters.Add("@LogStatus", (int)logStatus); parameters.Add("@LogDate", ConvertForParameter(null)); parameters.Add("@Title", ConvertForParameter(title)); parameters.Add("@Comments", ConvertForParameter(comments)); Execute_Procedure_NonQuery( connection, "parallel.usp_LogParallelExecutionEvent", parameters); }