|
using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using BusinessAppMVVM.Web.Services;
namespace BusinessAppMVVM.Helpers
{
public class LoggerManager
{
/// <summary>
/// Writing the Error and Activity logs in the log files.
/// </summary>
/// <param name="errorCommentOrType">Error Comment or Error Type or in case of event enter Event Name</param>
/// <param name="errorDetails">Error Details</param>
/// <returns>bool</returns>
public static bool WriteLog(string errorCommentOrType, string errorDetails)
{
try
{
MessageBox.Show("Some error is occured in application. Please try again after refresh. " + errorDetails);
if (((App)Application.Current).IsEventLogOn)
{
LoggingContext logErrorServiceClient = new LoggingContext();
logErrorServiceClient.LogException(errorCommentOrType, errorDetails,
invokeOperation =>
{
if (invokeOperation.HasError)
{
MessageBox.Show("Some error is occurred while error logging!");
}
else
MessageBox.Show(@"Error is logged in BusinessAppMVVM\BusinessAppMVVM.Web\logs\.");
}, null);
}
return true;
}
catch (Exception ex)
{
return false;
}
}
}
/// <summary>
/// Log Type
/// </summary>
public enum LogType
{
DEBUG,
ERROR,
FATAL,
INFO,
WARN
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.