示例#1
0
 public void LogException(ExceptionMessage ExceptionMsg, string sMediaKey, Exception exception)
 {
     try
     {
         if (sMediaKey.ToUpper().Trim().Equals("TXT"))
         {
             WriteLogFile(exception, ExceptionMsg);
         }
         else if (sMediaKey.ToUpper().Trim().Equals("EV"))
         {
             MachineLog(exception);
         }
         else if (sMediaKey.ToUpper().Trim().Equals("DB"))
         {
         }
     }
     catch
     {
         throw;
     }
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="message">This Indicates the custom message which developer use to pass</param>
 /// <param name="MediaKey">This indicates the media in which form exception logs eg: TXT for text file,DB for database table.,EV: for System Event Viewer.CSV: for Comma seperated file</param>
 /// <param name="exception">This Indicates the default exception which is generated by application</param>
 /// <param name="ExceptionMsg">This is a AdInsight Custom message wich is used to maintain all the function execution cycle</param>
 public ExceptionApp(string message, string MediaKey, Exception exception, ExceptionMessage ExceptionMsg)
     : base("No Messgae Given", exception)
 {
     _ExceptionMessage = new ExceptionMessage(exception.Message);
     ExceptionWriteLog.Instance.LogException(_ExceptionMessage, MediaKey, exception);
 }
 /// <summary>
 ///Method for ExceptionMessage
 /// </summary>
 /// <param name="message">This Indicates the custom message which developer use to pass</param>
 /// <param name="MediaKey">This indicates the media in which form exception logs eg: TXT for text file,DB for database table.,EV: for System Event Viewer.CSV: for Comma seperated file</param>
 /// <param name="exception">This Indicates the default exception which is generated by application</param>
 public ExceptionApp(string message, string MediaKey, Exception exception)
     : base(message)
 {
     _ExceptionMessage = new ExceptionMessage(message);
     ExceptionWriteLog.Instance.LogException(_ExceptionMessage, MediaKey, exception);
 }
示例#4
0
        private StringBuilder CreateExceptionMessage(Exception ex, ExceptionMessage ExceptionMsg)
        {
            StringBuilder objStr = null;

            StringBuilder objStrMessage = null;
            StringBuilder objStrIExp    = null;
            StringBuilder objStrSTrace  = null;
            StringBuilder objStrSource  = null;
            StringBuilder objStrTSite   = null;
            StringBuilder objStrTMsg    = null;
            string        strLineNo     = string.Empty;

            try
            {
                ExtractExceptionInformation(ex);

                objStr = new StringBuilder();

                objStrMessage = new StringBuilder();
                objStrIExp    = new StringBuilder();
                objStrSTrace  = new StringBuilder();
                objStrSource  = new StringBuilder();
                objStrTSite   = new StringBuilder();
                objStrTMsg    = new StringBuilder();

                string errorDateTime = DateTime.Now.ToString("MM-dd-yyyy hh:mm:ss");
                objStrMessage.AppendLine("=========================   ERROR LOG AT Date(MM-dd-yyyy hh:mm:ss) :-  " + errorDateTime + "   =========================");

                objStrIExp.AppendLine("--------------------------------");
                objStrMessage.AppendLine("PARIS Message ==> ");
                objStrMessage.AppendLine(Convert.ToString(ExceptionMsg.LastMessage));
                objStrMessage.AppendLine("--------------------------------");

                objStrIExp.AppendLine("File Name ==> ");
                objStrIExp.AppendLine(Convert.ToString(Error_FileName));
                objStrIExp.AppendLine("--------------------------------");

                objStrIExp.AppendLine("--------------------------------");
                objStrIExp.AppendLine("Method Name ==> ");
                objStrIExp.AppendLine(Convert.ToString(ex.TargetSite.Name.ToString()));
                objStrIExp.AppendLine("--------------------------------");

                objStrIExp.AppendLine("--------------------------------");
                objStrIExp.AppendLine("Line No ==> ");
                objStrIExp.AppendLine(Convert.ToString(Error_LineNo));
                objStrIExp.AppendLine("--------------------------------");

                objStrIExp.AppendLine("--------------------------------");
                objStrMessage.AppendLine("Message ==> ");
                objStrMessage.AppendLine(Convert.ToString(ex.Message));
                objStrMessage.AppendLine("--------------------------------");

                objStrIExp.AppendLine("--------------------------------");
                objStrIExp.AppendLine("Inner Exception ==> ");
                objStrIExp.AppendLine(Convert.ToString(ex.InnerException));
                objStrIExp.AppendLine("--------------------------------");

                objStrSTrace.AppendLine("--------------------------------");
                objStrSTrace.AppendLine("Stack Trace ==> ");
                objStrSTrace.AppendLine(Convert.ToString(ex.StackTrace));
                objStrSTrace.AppendLine("--------------------------------");

                objStrSource.AppendLine("--------------------------------");
                objStrSource.AppendLine("Source ==> ");
                objStrSource.AppendLine(Convert.ToString(ex.Source));

                objStrTSite.AppendLine("==============================================================");

                objStrTMsg.AppendLine("--------------------------------");
                objStrTMsg.AppendLine("PARIS Message History ==>");
                foreach (var item in ExceptionMsg.Messages)
                {
                    objStrTMsg.AppendLine(item);
                }
                objStrTMsg.AppendLine("--------------------------------");
            }
            catch
            {
                throw new Exception(ERR_MESSAGE_CREATION);
            }
            finally
            {
                objStr.Append(objStrMessage);
                objStr.Append(objStrIExp);
                objStr.Append(objStrSTrace);
                objStr.Append(objStrSource);
                objStr.Append(objStrTMsg);
                objStr.Append(objStrTSite);
            }

            return(objStr);
        }