Ejemplo n.º 1
0
        public static void LogException(SmartException exc)
        {
            try
            {
                Assembly assembly = Assembly.GetExecutingAssembly();
                string   filename = assembly.Location + ".log";

                using (var log = new StreamWriter(filename, true))
                {
                    StringBuilder builder = new StringBuilder();
                    builder.Append(DateTime.Now.ToString("MM/dd HH:mm:ss"));
                    builder.Append(" EXCEPTION: ");
                    builder.Append(exc.Message);

                    log.WriteLine(new String('=', 80));
                    log.WriteLine(builder.ToString());
                    log.WriteLine(new String('-', 80));
                    log.WriteLine(exc.XmlMessage);

                    log.Close();
                }
            }
            catch
            {
                // no-op
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="exc"></param>
        /// <param name="scope"></param>
        public ExceptionDialog(SmartException exc, string scope)
            : this()
        {
            titleBlock.Text = String.Format(
                "{0} {1} Exception", Properties.Resources.ApplicationTitle, scope);

            detailBlock.Text = exc.XmlMessage;
        }
Ejemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="exc"></param>
        /// <param name="scope"></param>

        public ExceptionDialog(SmartException exc, string scope)
            : this()
        {
            titleBlock.Text = String.Format(
                "{0} {1} Exception", Properties.Resources.I_ApplicationTitle, scope);

            detailBlock.Text = exc.XmlMessage;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Write a formatted exception to the log.
        /// </summary>
        /// <param name="category"></param>
        /// <param name="exc"></param>

        public static void WriteLine(string category, Exception exc)
        {
            if (Trace.Listeners.Count > 0)
            {
                SmartException smart = new SmartException(exc);
                WriteLine(Level.Error, category, new string('=', 80));
                WriteLine(Level.Error, category, smart.Message);
                WriteLine(Level.Error, category, new string('-', 80));
                WriteLine(Level.Error, category, smart.XmlMessage);
            }
        }
Ejemplo n.º 5
0
        public static void HandleException(Exception exc, string scope)
        {
            if (!excepted)
            {
                // set excepted to true before we do anything furthe or we may fall into
                // an infinite loop of thrown exceptions!
                excepted = true;
                SmartException smartExc = new SmartException(exc);
                LogException(smartExc);

                ExceptionDialog dialog = new ExceptionDialog(smartExc, scope);
                dialog.ShowDialog();
                dialog = null;
            }
        }
Ejemplo n.º 6
0
        public static void LogException(SmartException exc)
        {
            try
            {
                Assembly assembly = Assembly.GetExecutingAssembly();
                string filename = assembly.Location + ".log";

                StreamWriter log = new StreamWriter(filename, true);

                StringBuilder builder = new StringBuilder();
                builder.Append(DateTime.Now.ToString("MM/dd HH:mm:ss"));
                builder.Append(" EXCEPTION: ");
                builder.Append(exc.Message);

                log.WriteLine(new String('=', 80));
                log.WriteLine(builder.ToString());
                log.WriteLine(new String('-', 80));
                log.WriteLine(exc.XmlMessage);

                log.Close();
                log.Dispose();
                log = null;
            }
            catch
            {
                // no-op
            }
        }
Ejemplo n.º 7
0
        public static void HandleException(Exception exc, string scope)
        {
            if (!excepted)
            {
                // set excepted to true before we do anything furthe or we may fall into
                // an infinite loop of thrown exceptions!
                excepted = true;
                SmartException smartExc = new SmartException(exc);
                LogException(smartExc);

                ExceptionDialog dialog = new ExceptionDialog(smartExc, scope);
                dialog.ShowDialog();
                dialog = null;
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Write a message and formatted exception to the log.
        /// </summary>
        /// <param name="category"></param>
        /// <param name="message"></param>
        /// <param name="exc"></param>
        public static void WriteLine(string category, string message, Exception exc)
        {
            if (Trace.Listeners.Count > 0)
            {
                WriteLine(Level.Error, category, message);

                SmartException smart = new SmartException(exc);
                WriteLine(Level.Error, category, new String('=', 80));
                WriteLine(Level.Error, category, smart.Message);
                WriteLine(Level.Error, category, new String('-', 80));
                WriteLine(Level.Error, category, smart.XmlMessage);
            }
        }