Ejemplo n.º 1
0
        /// <summary>
        /// Report a message through the Debug Manager. Time stamps and other
        /// info is addded automatically.
        /// </summary>
        /// <param name="Source">An identifier of the source of the message. Method name, parameter or sim.</param>
        /// <param name="Title">Title of the message.</param>
        /// <param name="Body">Message body.</param>
        internal static void Report(string Source, string Title, string Body)
        {
            string TimeStamp = DateTimeStringBuilder.GetDateTimeString();

            try
            {
                switch (dManagerEJP._debugMode)
                {
                case DebugModeEJP.None:
                    break;

                case DebugModeEJP.File:
                    dManagerEJP.ReportToFile(TimeStamp, Source, Title, Body);
                    break;

                case DebugModeEJP.Email:
                    dManagerEJP.ReportToEmail(TimeStamp, Source, Title, Body);
                    break;

                case DebugModeEJP.Console:
                    dManagerEJP.ReportToConsole(TimeStamp, Source, Title, Body);
                    break;

                case DebugModeEJP.Output:
                    dManagerEJP.ReportToOutput(TimeStamp, Source, Title, Body);
                    break;

                default:
                    break;
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException(TimeStamp + dManagerEJP._name +
                                               "Debug Manager Excpetion:\n" + ex.Message);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Writes the report to the designated receiver.
        /// </summary>
        private static void WriteReport(MessageType DebugMessageType, string Title, string Body)
        {
            //Test for the current Filter.
            bool shouldReport = false;

            //We always report internal messages...
            if (DebugMessageType == MessageType.Internal)
            {
                shouldReport = true;
            }
            else
            {
                switch (DebugMessageType)
                {
                case MessageType.Information:
                    if ((DebugLevels.Information & DebugReporter._outPutFilter) > 0)
                    {
                        shouldReport = true;
                    }
                    break;

                case MessageType.Warning:
                    if ((DebugLevels.Warning & DebugReporter._outPutFilter) > 0)
                    {
                        shouldReport = true;
                    }
                    break;

                case MessageType.Error:
                    if ((DebugLevels.Error & DebugReporter._outPutFilter) > 0)
                    {
                        shouldReport = true;
                    }
                    break;

                default:
                    break;
                }
            }

            if (!shouldReport)
            {
                return;
            }

            if (DebugReporter._dManagerStatus != ReporterStatus.OK)
            {
                throw new ApplicationException(DebugReporter.Name +
                                               " - The Debug Reporter is no longer alive. Cannot Write Report.");
            }

            //Get some additional data on the current stack frame.
            StackFrame frame    = new StackFrame(2, true);
            string     method   = frame.GetMethod().Name;
            string     file     = frame.GetFileName();
            string     line     = frame.GetFileLineNumber().ToString();
            string     typename = frame.GetMethod().DeclaringType.FullName;

            string TimeStamp = DateTimeStringBuilder.GetDateTimeString();

            try
            {
                switch (DebugReporter._debugMode)
                {
                case DebugMode.None:
                    break;

                case DebugMode.File:
                    DebugReporter.ReportToFile(DebugMessageType, TimeStamp, file, method, line, typename, Title, Body);
                    break;

                case DebugMode.Email:
                    DebugReporter.ReportToEmail(DebugMessageType, TimeStamp, file, method, line, typename, Title, Body);
                    break;

                case DebugMode.Console:
                    DebugReporter.ReportToConsole(DebugMessageType, TimeStamp, file, method, line, typename, Title, Body);
                    break;

                case DebugMode.Output:
                    DebugReporter.ReportToOutput(DebugMessageType, TimeStamp, file, method, line, typename, Title, Body);
                    break;

                case DebugMode.Wreq_v1:
                    DebugReporter.ReportToWreq_v1(DebugMessageType, TimeStamp, file, method, line, typename, Title, Body);
                    break;

                default:
                    break;
                }
            }
            catch (Exception ex)
            {
                DebugReporter.KillDebugReporter("Failed to Write Report.\nException:\n" + ex.Message);

                throw new ApplicationException(TimeStamp + DebugReporter.Name +
                                               "Unhandled Excpetion:\n" + ex.Message);
            }
        }