Exemple #1
0
        /// <summary>
        /// Logs an Exception details.
        /// </summary>
        /// <param name="userID"></param>
        /// <param name="severityID"></param>
        /// <param name="className"></param>
        /// <param name="functionName"></param>
        /// <param name="message"></param>
        /// <param name="ex"></param>
        /// <returns></returns>
        public override bool LogException(string userID, Severity severityID, string className, string functionName, Exception ex)
        {
            //[2] -- ADD -- START Getting the class name and function name
            StackTrace stackTrace = new StackTrace();
            StackFrame stackFrame = stackTrace.GetFrame(1);
            MethodBase methodBase = stackFrame.GetMethod();

            className    = Convert.ToString(methodBase.DeclaringType);
            functionName = methodBase.Name;
            //[2] -- ADD -- END
            try
            {
                if (PrepCmmdForLog(userID, Severity.ProcessingError, className, functionName, PrepMsg(userID, ex)))
                {
                    if (!(UpdateDB()))
                    {
                        ILogger altLogger = LoggerFactory.createAlternateLogger();
                        return(altLogger.LogException(userID, severityID, className, functionName, ex));
                    }
                    else
                    {
                        return(true);
                    }
                }
                return(false);
            }
            catch (Exception exp)
            {
                ClassForProblemResolutionOnly obj = new ClassForProblemResolutionOnly();
                obj.WriteToEventLog(exp);
                return(false);
            }
        }
Exemple #2
0
 /// <summary>
 /// Writes the Warnings and Errors to the Log.
 /// </summary>
 /// <param name="userID"></param>
 /// <param name="severityID"></param>
 /// <param name="className"></param>
 /// <param name="functionName"></param>
 /// <param name="message"></param>
 /// <returns></returns>
 public override bool WriteToWarningLog(string userID, Severity severityID, string className, string functionName, string message)
 {
     try
     {
         if (PrepCmmdForLog(userID, severityID, className, functionName, PrepMsg(userID, severityID, message, State_Warn)))
         {
             if (!(UpdateDB()))
             {
                 ILogger altLogger = LoggerFactory.createAlternateLogger();
                 return(altLogger.WriteToWarningLog(userID, severityID, className, functionName, message));
             }
             else
             {
                 return(true);
             }
         }
         return(false);
     }
     catch (Exception ex)
     {
         ClassForProblemResolutionOnly obj = new ClassForProblemResolutionOnly();
         obj.WriteToEventLog(ex);
         return(false);
     }
 }
Exemple #3
0
        /// <summary>
        /// Writes The Information to the Log.
        /// </summary>
        /// <param name="userID"></param>
        /// <param name="severityID"></param>
        /// <param name="className"></param>
        /// <param name="functionName"></param>
        /// <param name="message"></param>
        /// <returns></returns>
        public override bool WriteToInfoLog(string userID, Severity severityID, string className, string functionName, string message)
        {
            //[2] -- ADD -- START Getting the class name and function name
            StackTrace stackTrace = new StackTrace();
            StackFrame stackFrame = stackTrace.GetFrame(1);
            MethodBase methodBase = stackFrame.GetMethod();

            className    = Convert.ToString(methodBase.DeclaringType);
            functionName = methodBase.Name;
            //[2] -- ADD -- END
            try
            {
                if (!(UpdateTrace(PrepMsg(userID, severityID, message, Level.INFO.ToString(), className, functionName))))
                {
                    ILogger altLogger = LoggerFactory.createAlternateLogger();
                    return(altLogger.WriteToInfoLog(userID, severityID, className, functionName, message));
                }
                return(true);
            }
            catch (Exception ex)
            {
                ClassForProblemResolutionOnly obj = new ClassForProblemResolutionOnly();
                obj.WriteToEventLog(ex);
                return(false);
            }
        }
Exemple #4
0
 /// <summary>
 /// Writes Informations, Warnings, Errors to the Log.
 /// </summary>
 /// <param name="userID"></param>
 /// <param name="severityID"></param>
 /// <param name="className"></param>
 /// <param name="functionName"></param>
 /// <param name="message"></param>
 /// <returns></returns>
 public override bool WriteToInfoLog(string userID, Severity severityID, string className, string functionName, string message)
 {
     try
     {
         if (!(UpdateFile(PrepMsg(userID, severityID, message, Level.INFO.ToString(), className, functionName))))
         {
             ILogger altLogger = LoggerFactory.createAlternateLogger();
             return(altLogger.WriteToInfoLog(userID, severityID, className, functionName, message));
         }
         return(true);
     }
     catch (Exception ex)
     {
         ClassForProblemResolutionOnly obj = new ClassForProblemResolutionOnly();
         obj.WriteToEventLog(ex);
         return(false);
     }
 }
Exemple #5
0
 /// <summary>
 /// Logs an Exception details.
 /// </summary>
 /// <param name="userID"></param>
 /// <param name="severityID"></param>
 /// <param name="className"></param>
 /// <param name="functionName"></param>
 /// <param name="message"></param>
 /// <param name="ex"></param>
 /// <returns></returns>
 public override bool LogException(string userID, Severity severityID, string className, string functionName, Exception ex)
 {
     try
     {
         if (!(UpdateFile(PrepMsg(userID, ex))))
         {
             ILogger altLogger = LoggerFactory.createAlternateLogger();
             return(altLogger.LogException(userID, severityID, className, functionName, ex));
         }
         return(true);
     }
     catch (Exception exp)
     {
         ClassForProblemResolutionOnly obj = new ClassForProblemResolutionOnly();
         obj.WriteToEventLog(exp);
         return(false);
     }
 }
Exemple #6
0
 /// <summary>
 /// Writes the warnings to the Log.
 /// </summary>
 /// <param name="userID"></param>
 /// <param name="severityID"></param>
 /// <param name="className"></param>
 /// <param name="functionName"></param>
 /// <param name="message"></param>
 /// <returns></returns>
 public override bool WriteToWarningLog(string userID, Severity severityID, string className, string functionName, string message)
 {
     try
     {
         if (CreateEventSource())
         {
             if (UpdateLog(userID, severityID, PrepMsg(userID, severityID, message, State_Warn, className, functionName), State_Warn, EventLogEntryType.Warning))
             {
                 return(true);
             }
         }
         ILogger altLogger = LoggerFactory.createAlternateLogger();
         return(altLogger.WriteToWarningLog(userID, severityID, className, functionName, message));
     }
     catch (Exception ex)
     {
         ClassForProblemResolutionOnly obj = new ClassForProblemResolutionOnly();
         obj.WriteToEventLog(ex);
         return(false);
     }
 }