using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Web.SessionState;
///
/// Summary description for ErrorClass
///
public static class ErrorClass
{
public class ErrorHandler
{
///
/// protected string - file path to errorlog xml file
///
protected string _errorlogfilepath;
///
/// Parameterised Constructor - N.B. No default constructor !
/// Instantiates the class and sets the error log file path for useage
///
/// string errorlog file path
public ErrorHandler(string errorlogfilepath)
{
_errorlogfilepath = errorlogfilepath;
if (!System.IO.File.Exists(errorlogfilepath))
{
CreateLogFile(errorlogfilepath);
}
}
///
/// Creates the necessary log file in the correct format if it doesn't already exist
///
/// string errorlog file path
public void CreateLogFile(string errorlogfilepath)
{
System.Data.DataSet ds = new System.Data.DataSet();
System.Data.DataTable dt = new System.Data.DataTable();
System.Data.DataColumn dc0 = new System.Data.DataColumn("Error_Type", System.Type.GetType("System.String"));
System.Data.DataColumn dc1 = new System.Data.DataColumn("Error_DateTime", System.Type.GetType("System.DateTime"));
System.Data.DataColumn dc2 = new System.Data.DataColumn("Error_Description", System.Type.GetType("System.String"));
System.Data.DataColumn dc3 = new System.Data.DataColumn("Error_Source", System.Type.GetType("System.String"));
System.Data.DataColumn dc4 = new System.Data.DataColumn("Error_Stack_Trace", System.Type.GetType("System.String"));
System.Data.DataColumn dc5 = new System.Data.DataColumn("Error_Caused_By_Method", System.Type.GetType("System.String"));
System.Data.DataColumn dc6 = new System.Data.DataColumn("Help_Link", System.Type.GetType("System.String"));
System.Data.DataColumn dc7 = new System.Data.DataColumn("Optional_Text_1", System.Type.GetType("System.String"));
System.Data.DataColumn dc8 = new System.Data.DataColumn("Optional_Text_2", System.Type.GetType("System.String"));
dt.Columns.Add(dc0);
dt.Columns.Add(dc1);
dt.Columns.Add(dc2);
dt.Columns.Add(dc3);
dt.Columns.Add(dc4);
dt.Columns.Add(dc5);
dt.Columns.Add(dc6);
dt.Columns.Add(dc7);
dt.Columns.Add(dc8);
ds.Tables.Add(dt);
ds.WriteXml(errorlogfilepath, System.Data.XmlWriteMode.WriteSchema);
}
///
/// Saves System.Exception Information to Log file
///
/// System.Exception
/// optional string for free form data to be logged with entry
/// optional string 2 for free form data to be logged with entry
public void SaveExceptionToLog(System.Exception ex, string optitem1, string optitem2)
{
System.Data.DataSet ds = new System.Data.DataSet();
ds.ReadXml(_errorlogfilepath);
System.Data.DataRow drow = ds.Tables[0].NewRow();
drow[0] = "System.Exception";
drow[1] = System.DateTime.Now.ToString();
drow[2] = ex.Message;
drow[3] = ex.Source;
drow[4] = ex.StackTrace;
drow[5] = ex.TargetSite;
drow[6] = ex.HelpLink;
drow[7] = optitem1;
drow[8] = optitem2;
ds.Tables[0].Rows.Add(drow);
ds.AcceptChanges();
ds.WriteXml(_errorlogfilepath, System.Data.XmlWriteMode.WriteSchema);
}
///
/// Saves System.ApplicationException to Log file
///
/// System.ApplicationException
/// optional string for free form data to be logged with entry
/// optional string 2 for free form data to be logged with entry
public void SaveExceptionToLog(System.ApplicationException appex, string optitem1, string optitem2)
{
System.Data.DataSet ds = new System.Data.DataSet();
ds.ReadXml(_errorlogfilepath);
System.Data.DataRow drow = ds.Tables[0].NewRow();
drow[0] = "System.ApplicationException";
drow[1] = System.DateTime.Now.ToString();
drow[2] = appex.Message;
drow[3] = appex.Source;
drow[4] = appex.StackTrace;
drow[5] = appex.TargetSite;
drow[6] = appex.HelpLink;
drow[7] = optitem1;
drow[8] = optitem2;
ds.Tables[0].Rows.Add(drow);
ds.AcceptChanges();
ds.WriteXml(_errorlogfilepath, System.Data.XmlWriteMode.WriteSchema);
}
///
/// Saves System.ArgumentException to Log file
///
/// System.ArgumentException
/// optional string for free form data to be logged with entry
/// optional string 2 for free form data to be logged with entry
public void SaveExceptionToLog(System.ArgumentException argex, string optitem1, string optitem2)
{
System.Data.DataSet ds = new System.Data.DataSet();
ds.ReadXml(_errorlogfilepath);
System.Data.DataRow drow = ds.Tables[0].NewRow();
drow[0] = "System.ArgumentException";
drow[1] = System.DateTime.Now.ToString();
drow[2] = argex.Message;
drow[3] = argex.Source;
drow[4] = argex.StackTrace;
drow[5] = argex.TargetSite;
drow[6] = argex.HelpLink;
drow[7] = optitem1;
drow[8] = optitem2;
ds.Tables[0].Rows.Add(drow);
ds.AcceptChanges();
ds.WriteXml(_errorlogfilepath, System.Data.XmlWriteMode.WriteSchema);
}
///
/// Saves System.ArgumentNullException to Log file
///
/// System.ArgumentNullException
/// optional string for free form data to be logged with entry
/// optional string 2 for free form data to be logged with entry
public void SaveExceptionToLog(System.ArgumentNullException arnex, string optitem1, string optitem2)
{
System.Data.DataSet ds = new System.Data.DataSet();
ds.ReadXml(_errorlogfilepath);
System.Data.DataRow drow = ds.Tables[0].NewRow();
drow[0] = "System.ArgumentNullException";
drow[1] = System.DateTime.Now.ToString();
drow[2] = arnex.Message;
drow[3] = arnex.Source;
drow[4] = arnex.StackTrace;
drow[5] = arnex.TargetSite;
drow[6] = arnex.HelpLink;
drow[7] = optitem1;
drow[8] = optitem2;
ds.Tables[0].Rows.Add(drow);
ds.AcceptChanges();
ds.WriteXml(_errorlogfilepath, System.Data.XmlWriteMode.WriteSchema);
}
///
/// Saves System.ArgumentOutOfRangeException to Log File
///
/// System.ArgumentOutOfRangeException
/// optional string for free form data to be logged with entry
/// optional string 2 for free form data to be logged with entry
public void SaveExceptionToLog(System.ArgumentOutOfRangeException aorex, string optitem1, string optitem2)
{
System.Data.DataSet ds = new System.Data.DataSet();
ds.ReadXml(_errorlogfilepath);
System.Data.DataRow drow = ds.Tables[0].NewRow();
drow[0] = "System.ArgumentOutOfRangeException";
drow[1] = System.DateTime.Now.ToString();
drow[2] = aorex.Message;
drow[3] = aorex.Source;
drow[4] = aorex.StackTrace;
drow[5] = aorex.TargetSite;
drow[6] = aorex.HelpLink;
drow[7] = optitem1;
drow[8] = optitem2;
ds.Tables[0].Rows.Add(drow);
ds.AcceptChanges();
ds.WriteXml(_errorlogfilepath, System.Data.XmlWriteMode.WriteSchema);
}
///
/// Saves System.ArithmeticException to Log File
///
/// System.ArithmeticException
/// optional string for free form data to be logged with entry
/// optional string 2 for free form data to be logged with entry
public void SaveExceptionToLog(System.ArithmeticException arrex, string optitem1, string optitem2)
{
System.Data.DataSet ds = new System.Data.DataSet();
ds.ReadXml(_errorlogfilepath);
System.Data.DataRow drow = ds.Tables[0].NewRow();
drow[0] = "System.ArithmeticException";
drow[1] = System.DateTime.Now.ToString();
drow[2] = arrex.Message;
drow[3] = arrex.Source;
drow[4] = arrex.StackTrace;
drow[5] = arrex.TargetSite;
drow[6] = arrex.HelpLink;
drow[7] = optitem1;
drow[8] = optitem2;
ds.Tables[0].Rows.Add(drow);
ds.AcceptChanges();
ds.WriteXml(_errorlogfilepath, System.Data.XmlWriteMode.WriteSchema);
}
///
/// Saves System.ArrayTypeMismatchException to Log File
///
/// System.ArrayTypeMismatchException
/// optional string for free form data to be logged with entry
/// optional string 2 for free form data to be logged with entry
public void SaveExceptionToLog(System.ArrayTypeMismatchException atmex, string optitem1, string optitem2)
{
System.Data.DataSet ds = new System.Data.DataSet();
ds.ReadXml(_errorlogfilepath);
System.Data.DataRow drow = ds.Tables[0].NewRow();
drow[0] = "System.ArrayTypeMismatchException";
drow[1] = System.DateTime.Now.ToString();
drow[2] = atmex.Message;
drow[3] = atmex.Source;
drow[4] = atmex.StackTrace;
drow[5] = atmex.TargetSite;
drow[6] = atmex.HelpLink;
drow[7] = optitem1;
drow[8] = optitem2;
ds.Tables[0].Rows.Add(drow);
ds.AcceptChanges();
ds.WriteXml(_errorlogfilepath, System.Data.XmlWriteMode.WriteSchema);
}
///
/// Saves System.DivideByZeroException to Log File
///
/// System.DivideByZeroException
/// optional string for free form data to be logged with entry
/// optional string 2 for free form data to be logged with entry
public void SaveExceptionToLog(System.DivideByZeroException dbzex, string optitem1, string optitem2)
{
System.Data.DataSet ds = new System.Data.DataSet();
ds.ReadXml(_errorlogfilepath);
System.Data.DataRow drow = ds.Tables[0].NewRow();
drow[0] = "System.DivideByZeroException";
drow[1] = System.DateTime.Now.ToString();
drow[2] = dbzex.Message;
drow[3] = dbzex.Source;
drow[4] = dbzex.StackTrace;
drow[5] = dbzex.TargetSite;
drow[6] = dbzex.HelpLink;
drow[7] = optitem1;
drow[8] = optitem2;
ds.Tables[0].Rows.Add(drow);
ds.AcceptChanges();
ds.WriteXml(_errorlogfilepath, System.Data.XmlWriteMode.WriteSchema);
}
///
/// Saves System.DllNotFoundException to Log File
///
/// System.DllNotFoundException
/// optional string for free form data to be logged with entry
/// optional string 2 for free form data to be logged with entry
public void SaveExceptionToLog(System.DllNotFoundException dllnfex, string optitem1, string optitem2)
{
System.Data.DataSet ds = new System.Data.DataSet();
ds.ReadXml(_errorlogfilepath);
System.Data.DataRow drow = ds.Tables[0].NewRow();
drow[0] = "System.DllNotFoundException";
drow[1] = System.DateTime.Now.ToString();
drow[2] = dllnfex.Message;
drow[3] = dllnfex.Source;
drow[4] = dllnfex.StackTrace;
drow[5] = dllnfex.TargetSite;
drow[6] = dllnfex.HelpLink;
drow[7] = optitem1;
drow[8] = optitem2;
ds.Tables[0].Rows.Add(drow);
ds.AcceptChanges();
ds.WriteXml(_errorlogfilepath, System.Data.XmlWriteMode.WriteSchema);
}
///
/// Saves System.FieldAccessException to Log File
///
/// System.FieldAccessException
/// optional string for free form data to be logged with entry
/// optional string 2 for free form data to be logged with entry
public void SaveExceptionToLog(System.FieldAccessException faex, string optitem1, string optitem2)
{
System.Data.DataSet ds = new System.Data.DataSet();
ds.ReadXml(_errorlogfilepath);
System.Data.DataRow drow = ds.Tables[0].NewRow();
drow[0] = "System.FieldAccessException";
drow[1] = System.DateTime.Now.ToString();
drow[2] = faex.Message;
drow[3] = faex.Source;
drow[4] = faex.StackTrace;
drow[5] = faex.TargetSite;
drow[6] = faex.HelpLink;
drow[7] = optitem1;
drow[8] = optitem2;
ds.Tables[0].Rows.Add(drow);
ds.AcceptChanges();
ds.WriteXml(_errorlogfilepath, System.Data.XmlWriteMode.WriteSchema);
}
///
/// Saves System.FormatException to Log File
///
/// System.FormatException
/// optional string for free form data to be logged with entry
/// optional string 2 for free form data to be logged with entry
public void SaveExceptionToLog(System.FormatException forex, string optitem1, string optitem2)
{
System.Data.DataSet ds = new System.Data.DataSet();
ds.ReadXml(_errorlogfilepath);
System.Data.DataRow drow = ds.Tables[0].NewRow();
drow[0] = "System.FormatException";
drow[1] = System.DateTime.Now.ToString();
drow[2] = forex.Message;
drow[3] = forex.Source;
drow[4] = forex.StackTrace;
drow[5] = forex.TargetSite;
drow[6] = forex.HelpLink;
drow[7] = optitem1;
drow[8] = optitem2;
ds.Tables[0].Rows.Add(drow);
ds.AcceptChanges();
ds.WriteXml(_errorlogfilepath, System.Data.XmlWriteMode.WriteSchema);
}
///
/// Saves System.IndexOutOfRangeException to Log File
///
/// System.IndexOutOfRangeException
/// optional string for free form data to be logged with entry
/// optional string 2 for free form data to be logged with entry
public void SaveExceptionToLog(System.IndexOutOfRangeException iorex, string optitem1, string optitem2)
{
System.Data.DataSet ds = new System.Data.DataSet();
ds.ReadXml(_errorlogfilepath);
System.Data.DataRow drow = ds.Tables[0].NewRow();
drow[0] = "System.IndexOutOfRangeException";
drow[1] = System.DateTime.Now.ToString();
drow[2] = iorex.Message;
drow[3] = iorex.Source;
drow[4] = iorex.StackTrace;
drow[5] = iorex.TargetSite;
drow[6] = iorex.HelpLink;
drow[7] = optitem1;
drow[8] = optitem2;
ds.Tables[0].Rows.Add(drow);
ds.AcceptChanges();
ds.WriteXml(_errorlogfilepath, System.Data.XmlWriteMode.WriteSchema);
}
///
/// Saves System.InvalidOperationException to Log File
///
/// System.InvalidOperationException
/// optional string for free form data to be logged with entry
/// optional string 2 for free form data to be logged with entry
public void SaveExceptionToLog(System.InvalidOperationException iopex, string optitem1, string optitem2)
{
System.Data.DataSet ds = new System.Data.DataSet();
ds.ReadXml(_errorlogfilepath);
System.Data.DataRow drow = ds.Tables[0].NewRow();
drow[0] = "System.InvalidOperationException";
drow[1] = System.DateTime.Now.ToString();
drow[2] = iopex.Message;
drow[3] = iopex.Source;
drow[4] = iopex.StackTrace;
drow[5] = iopex.TargetSite;
drow[6] = iopex.HelpLink;
drow[7] = optitem1;
drow[8] = optitem2;
ds.Tables[0].Rows.Add(drow);
ds.AcceptChanges();
ds.WriteXml(_errorlogfilepath, System.Data.XmlWriteMode.WriteSchema);
}
///
/// Saves System.InvalidProgramException to Log File
///
/// System.InvalidProgramException
/// optional string for free form data to be logged with entry
/// optional string 2 for free form data to be logged with entry
public void SaveExceptionToLog(System.InvalidProgramException ipex, string optitem1, string optitem2)
{
System.Data.DataSet ds = new System.Data.DataSet();
ds.ReadXml(_errorlogfilepath);
System.Data.DataRow drow = ds.Tables[0].NewRow();
drow[0] = "System.InvalidProgramException";
drow[1] = System.DateTime.Now.ToString();
drow[2] = ipex.Message;
drow[3] = ipex.Source;
drow[4] = ipex.StackTrace;
drow[5] = ipex.TargetSite;
drow[6] = ipex.HelpLink;
drow[7] = optitem1;
drow[8] = optitem2;
ds.Tables[0].Rows.Add(drow);
ds.AcceptChanges();
ds.WriteXml(_errorlogfilepath, System.Data.XmlWriteMode.WriteSchema);
}
///
/// Saves System.MemberAccessException to Log File
///
/// System.MemberAccessException
/// optional string for free form data to be logged with entry
/// optional string 2 for free form data to be logged with entry
public void SaveExceptionToLog(System.MemberAccessException maex, string optitem1, string optitem2)
{
System.Data.DataSet ds = new System.Data.DataSet();
ds.ReadXml(_errorlogfilepath);
System.Data.DataRow drow = ds.Tables[0].NewRow();
drow[0] = "System.MemberAccessException";
drow[1] = System.DateTime.Now.ToString();
drow[2] = maex.Message;
drow[3] = maex.Source;
drow[4] = maex.StackTrace;
drow[5] = maex.TargetSite;
drow[6] = maex.HelpLink;
drow[7] = optitem1;
drow[8] = optitem2;
ds.Tables[0].Rows.Add(drow);
ds.AcceptChanges();
ds.WriteXml(_errorlogfilepath, System.Data.XmlWriteMode.WriteSchema);
}
///
/// Saves System.MethodAccessException to Log File
///
/// System.MethodAccessException
/// optional string for free form data to be logged with entry
/// optional string 2 for free form data to be logged with entry
public void SaveExceptionToLog(System.MethodAccessException macex, string optitem1, string optitem2)
{
System.Data.DataSet ds = new System.Data.DataSet();
ds.ReadXml(_errorlogfilepath);
System.Data.DataRow drow = ds.Tables[0].NewRow();
drow[0] = "System.MethodAccessException";
drow[1] = System.DateTime.Now.ToString();
drow[2] = macex.Message;
drow[3] = macex.Source;
drow[4] = macex.StackTrace;
drow[5] = macex.TargetSite;
drow[6] = macex.HelpLink;
drow[7] = optitem1;
drow[8] = optitem2;
ds.Tables[0].Rows.Add(drow);
ds.AcceptChanges();
ds.WriteXml(_errorlogfilepath, System.Data.XmlWriteMode.WriteSchema);
}
///
/// Saves System.MissingFieldException to Log File
///
/// System.MissingFieldException
/// optional string for free form data to be logged with entry
/// optional string 2 for free form data to be logged with entry
public void SaveExceptionToLog(System.MissingFieldException mfex, string optitem1, string optitem2)
{
System.Data.DataSet ds = new System.Data.DataSet();
ds.ReadXml(_errorlogfilepath);
System.Data.DataRow drow = ds.Tables[0].NewRow();
drow[0] = "System.MissingFieldException";
drow[1] = System.DateTime.Now.ToString();
drow[2] = mfex.Message;
drow[3] = mfex.Source;
drow[4] = mfex.StackTrace;
drow[5] = mfex.TargetSite;
drow[6] = mfex.HelpLink;
drow[7] = optitem1;
drow[8] = optitem2;
ds.Tables[0].Rows.Add(drow);
ds.AcceptChanges();
ds.WriteXml(_errorlogfilepath, System.Data.XmlWriteMode.WriteSchema);
}
///
/// Saves System.MissingMemberException to Log File
///
/// System.MissingMemberException
/// optional string for free form data to be logged with entry
/// optional string 2 for free form data to be logged with entry
public void SaveExceptionToLog(System.MissingMemberException mmex, string optitem1, string optitem2)
{
System.Data.DataSet ds = new System.Data.DataSet();
ds.ReadXml(_errorlogfilepath);
System.Data.DataRow drow = ds.Tables[0].NewRow();
drow[0] = "System.MissingMemberException";
drow[1] = System.DateTime.Now.ToString();
drow[2] = mmex.Message;
drow[3] = mmex.Source;
drow[4] = mmex.StackTrace;
drow[5] = mmex.TargetSite;
drow[6] = mmex.HelpLink;
drow[7] = optitem1;
drow[8] = optitem2;
ds.Tables[0].Rows.Add(drow);
ds.AcceptChanges();
ds.WriteXml(_errorlogfilepath, System.Data.XmlWriteMode.WriteSchema);
}
///
/// Saves System.MissingMethodException to Log File
///
/// System.MissingMethodException
/// optional string for free form data to be logged with entry
/// optional string 2 for free form data to be logged with entry
public void SaveExceptionToLog(System.MissingMethodException mmeex, string optitem1, string optitem2)
{
System.Data.DataSet ds = new System.Data.DataSet();
ds.ReadXml(_errorlogfilepath);
System.Data.DataRow drow = ds.Tables[0].NewRow();
drow[0] = "System.MissingMethodException";
drow[1] = System.DateTime.Now.ToString();
drow[2] = mmeex.Message;
drow[3] = mmeex.Source;
drow[4] = mmeex.StackTrace;
drow[5] = mmeex.TargetSite;
drow[6] = mmeex.HelpLink;
drow[7] = optitem1;
drow[8] = optitem2;
ds.Tables[0].Rows.Add(drow);
ds.AcceptChanges();
ds.WriteXml(_errorlogfilepath, System.Data.XmlWriteMode.WriteSchema);
}
///
/// Saves System.NotFiniteNumberException to Log File
///
/// System.NotFiniteNumberException
/// optional string for free form data to be logged with entry
/// optional string 2 for free form data to be logged with entry
public void SaveExceptionToLog(System.NotFiniteNumberException nfnex, string optitem1, string optitem2)
{
System.Data.DataSet ds = new System.Data.DataSet();
ds.ReadXml(_errorlogfilepath);
System.Data.DataRow drow = ds.Tables[0].NewRow();
drow[0] = "System.NotFiniteNumberException";
drow[1] = System.DateTime.Now.ToString();
drow[2] = nfnex.Message;
drow[3] = nfnex.Source;
drow[4] = nfnex.StackTrace;
drow[5] = nfnex.TargetSite;
drow[6] = nfnex.HelpLink;
drow[7] = optitem1;
drow[8] = optitem2;
ds.Tables[0].Rows.Add(drow);
ds.AcceptChanges();
ds.WriteXml(_errorlogfilepath, System.Data.XmlWriteMode.WriteSchema);
}
///
/// Saves System.NotImplementedException to Log File
///
/// System.NotImplementedException
/// optional string for free form data to be logged with entry
/// optional string 2 for free form data to be logged with entry
public void SaveExceptionToLog(System.NotImplementedException niex, string optitem1, string optitem2)
{
System.Data.DataSet ds = new System.Data.DataSet();
ds.ReadXml(_errorlogfilepath);
System.Data.DataRow drow = ds.Tables[0].NewRow();
drow[0] = "System.NotImplementedException";
drow[1] = System.DateTime.Now.ToString();
drow[2] = niex.Message;
drow[3] = niex.Source;
drow[4] = niex.StackTrace;
drow[5] = niex.TargetSite;
drow[6] = niex.HelpLink;
drow[7] = optitem1;
drow[8] = optitem2;
ds.Tables[0].Rows.Add(drow);
ds.AcceptChanges();
ds.WriteXml(_errorlogfilepath, System.Data.XmlWriteMode.WriteSchema);
}
///
/// Saves System.NotSupportedException to Log File
///
/// System.NotSupportedException
/// optional string for free form data to be logged with entry
/// optional string 2 for free form data to be logged with entry
public void SaveExceptionToLog(System.NotSupportedException nsex, string optitem1, string optitem2)
{
System.Data.DataSet ds = new System.Data.DataSet();
ds.ReadXml(_errorlogfilepath);
System.Data.DataRow drow = ds.Tables[0].NewRow();
drow[0] = "System.NotSupportedException";
drow[1] = System.DateTime.Now.ToString();
drow[2] = nsex.Message;
drow[3] = nsex.Source;
drow[4] = nsex.StackTrace;
drow[5] = nsex.TargetSite;
drow[6] = nsex.HelpLink;
drow[7] = optitem1;
drow[8] = optitem2;
ds.Tables[0].Rows.Add(drow);
ds.AcceptChanges();
ds.WriteXml(_errorlogfilepath, System.Data.XmlWriteMode.WriteSchema);
}
///
/// Saves System.NullReferenceException to Log File
///
/// System.NullReferenceException
/// optional string for free form data to be logged with entry
/// optional string 2 for free form data to be logged with entry
public void SaveExceptionToLog(System.NullReferenceException nrex, string optitem1, string optitem2)
{
System.Data.DataSet ds = new System.Data.DataSet();
ds.ReadXml(_errorlogfilepath);
System.Data.DataRow drow = ds.Tables[0].NewRow();
drow[0] = "System.NullReferenceException";
drow[1] = System.DateTime.Now.ToString();
drow[2] = nrex.Message;
drow[3] = nrex.Source;
drow[4] = nrex.StackTrace;
drow[5] = nrex.TargetSite;
drow[6] = nrex.HelpLink;
drow[7] = optitem1;
drow[8] = optitem2;
ds.Tables[0].Rows.Add(drow);
ds.AcceptChanges();
ds.WriteXml(_errorlogfilepath, System.Data.XmlWriteMode.WriteSchema);
}
///
/// Saves System.OutOfMemoryException to Log File
///
/// System.OutOfMemoryException
/// optional string for free form data to be logged with entry
/// optional string 2 for free form data to be logged with entry
public void SaveExceptionToLog(System.OutOfMemoryException oomex, string optitem1, string optitem2)
{
System.Data.DataSet ds = new System.Data.DataSet();
ds.ReadXml(_errorlogfilepath);
System.Data.DataRow drow = ds.Tables[0].NewRow();
drow[0] = "System.OutOfMemoryException";
drow[1] = System.DateTime.Now.ToString();
drow[2] = oomex.Message;
drow[3] = oomex.Source;
drow[4] = oomex.StackTrace;
drow[5] = oomex.TargetSite;
drow[6] = oomex.HelpLink;
drow[7] = optitem1;
drow[8] = optitem2;
ds.Tables[0].Rows.Add(drow);
ds.AcceptChanges();
ds.WriteXml(_errorlogfilepath, System.Data.XmlWriteMode.WriteSchema);
}
///
/// Saves System.OverflowException to Log File
///
/// System.OverflowException
/// optional string for free form data to be logged with entry
/// optional string 2 for free form data to be logged with entry
public void SaveExceptionToLog(System.OverflowException ofex, string optitem1, string optitem2)
{
System.Data.DataSet ds = new System.Data.DataSet();
ds.ReadXml(_errorlogfilepath);
System.Data.DataRow drow = ds.Tables[0].NewRow();
drow[0] = "System.OverflowException";
drow[1] = System.DateTime.Now.ToString();
drow[2] = ofex.Message;
drow[3] = ofex.Source;
drow[4] = ofex.StackTrace;
drow[5] = ofex.TargetSite;
drow[6] = ofex.HelpLink;
drow[7] = optitem1;
drow[8] = optitem2;
ds.Tables[0].Rows.Add(drow);
ds.AcceptChanges();
ds.WriteXml(_errorlogfilepath, System.Data.XmlWriteMode.WriteSchema);
}
///
/// Saves System.RankException to Log File
///
/// System.RankException
/// optional string for free form data to be logged with entry
/// optional string 2 for free form data to be logged with entry
public void SaveExceptionToLog(System.RankException rex, string optitem1, string optitem2)
{
System.Data.DataSet ds = new System.Data.DataSet();
ds.ReadXml(_errorlogfilepath);
System.Data.DataRow drow = ds.Tables[0].NewRow();
drow[0] = "System.RankException";
drow[1] = System.DateTime.Now.ToString();
drow[2] = rex.Message;
drow[3] = rex.Source;
drow[4] = rex.StackTrace;
drow[5] = rex.TargetSite;
drow[6] = rex.HelpLink;
drow[7] = optitem1;
drow[8] = optitem2;
ds.Tables[0].Rows.Add(drow);
ds.AcceptChanges();
ds.WriteXml(_errorlogfilepath, System.Data.XmlWriteMode.WriteSchema);
}
///
/// Saves System.StackOverflowException to Log File
///
/// System.StackOverflowException
/// optional string for free form data to be logged with entry
/// optional string 2 for free form data to be logged with entry
public void SaveExceptionToLog(System.StackOverflowException soex, string optitem1, string optitem2)
{
System.Data.DataSet ds = new System.Data.DataSet();
ds.ReadXml(_errorlogfilepath);
System.Data.DataRow drow = ds.Tables[0].NewRow();
drow[0] = "System.StackOverflowException";
drow[1] = System.DateTime.Now.ToString();
drow[2] = soex.Message;
drow[3] = soex.Source;
drow[4] = soex.StackTrace;
drow[5] = soex.TargetSite;
drow[6] = soex.HelpLink;
drow[7] = optitem1;
drow[8] = optitem2;
ds.Tables[0].Rows.Add(drow);
ds.AcceptChanges();
ds.WriteXml(_errorlogfilepath, System.Data.XmlWriteMode.WriteSchema);
}
///
/// Saves System.SystemException to Log File
///
/// System.SystemException
/// optional string for free form data to be logged with entry
/// optional string 2 for free form data to be logged with entry
public void SaveExceptionToLog(System.SystemException sex, string optitem1, string optitem2)
{
System.Data.DataSet ds = new System.Data.DataSet();
ds.ReadXml(_errorlogfilepath);
System.Data.DataRow drow = ds.Tables[0].NewRow();
drow[0] = "System.SystemException";
drow[1] = System.DateTime.Now.ToString();
drow[2] = sex.Message;
drow[3] = sex.Source;
drow[4] = sex.StackTrace;
drow[5] = sex.TargetSite;
drow[6] = sex.HelpLink;
drow[7] = optitem1;
drow[8] = optitem2;
ds.Tables[0].Rows.Add(drow);
ds.AcceptChanges();
ds.WriteXml(_errorlogfilepath, System.Data.XmlWriteMode.WriteSchema);
}
///
/// Saves System.TypeInitializationException to Log File
///
/// System.TypeInitializationException
/// optional string for free form data to be logged with entry
/// optional string 2 for free form data to be logged with entry
public void SaveExceptionToLog(System.TypeInitializationException tiex, string optitem1, string optitem2)
{
System.Data.DataSet ds = new System.Data.DataSet();
ds.ReadXml(_errorlogfilepath);
System.Data.DataRow drow = ds.Tables[0].NewRow();
drow[0] = "System.TypeInitializationException";
drow[1] = System.DateTime.Now.ToString();
drow[2] = tiex.Message;
drow[3] = tiex.Source;
drow[4] = tiex.StackTrace;
drow[5] = tiex.TargetSite;
drow[6] = tiex.HelpLink;
drow[7] = optitem1;
drow[8] = optitem2;
ds.Tables[0].Rows.Add(drow);
ds.AcceptChanges();
ds.WriteXml(_errorlogfilepath, System.Data.XmlWriteMode.WriteSchema);
}
///
/// Saves System.TypeLoadException to Log File
///
/// System.TypeLoadException
/// optional string for free form data to be logged with entry
/// optional string 2 for free form data to be logged with entry
public void SaveExceptionToLog(System.TypeLoadException tlex, string optitem1, string optitem2)
{
System.Data.DataSet ds = new System.Data.DataSet();
ds.ReadXml(_errorlogfilepath);
System.Data.DataRow drow = ds.Tables[0].NewRow();
drow[0] = "System.TypeLoadException";
drow[1] = System.DateTime.Now.ToString();
drow[2] = tlex.Message;
drow[3] = tlex.Source;
drow[4] = tlex.StackTrace;
drow[5] = tlex.TargetSite;
drow[6] = tlex.HelpLink;
drow[7] = optitem1;
drow[8] = optitem2;
ds.Tables[0].Rows.Add(drow);
ds.AcceptChanges();
ds.WriteXml(_errorlogfilepath, System.Data.XmlWriteMode.WriteSchema);
}
///
/// Saves System.TypeUnloadedException to Log File
///
/// System.TypeUnloadedException
/// optional string for free form data to be logged with entry
/// optional string 2 for free form data to be logged with entry
public void SaveExceptionToLog(System.TypeUnloadedException tuex, string optitem1, string optitem2)
{
System.Data.DataSet ds = new System.Data.DataSet();
ds.ReadXml(_errorlogfilepath);
System.Data.DataRow drow = ds.Tables[0].NewRow();
drow[0] = "System.TypeUnloadedException";
drow[1] = System.DateTime.Now.ToString();
drow[2] = tuex.Message;
drow[3] = tuex.Source;
drow[4] = tuex.StackTrace;
drow[5] = tuex.TargetSite;
drow[6] = tuex.HelpLink;
drow[7] = optitem1;
drow[8] = optitem2;
ds.Tables[0].Rows.Add(drow);
ds.AcceptChanges();
ds.WriteXml(_errorlogfilepath, System.Data.XmlWriteMode.WriteSchema);
}
///
/// Saves System.UnauthorizedAccessException to Log File
///
/// System.UnauthorizedAccessException
/// optional string for free form data to be logged with entry
/// optional string 2 for free form data to be logged with entry
public void SaveExceptionToLog(System.UnauthorizedAccessException uaex, string optitem1, string optitem2)
{
System.Data.DataSet ds = new System.Data.DataSet();
ds.ReadXml(_errorlogfilepath);
System.Data.DataRow drow = ds.Tables[0].NewRow();
drow[0] = "System.UnauthorizedAccessException";
drow[1] = System.DateTime.Now.ToString();
drow[2] = uaex.Message;
drow[3] = uaex.Source;
drow[4] = uaex.StackTrace;
drow[5] = uaex.TargetSite;
drow[6] = uaex.HelpLink;
drow[7] = optitem1;
drow[8] = optitem2;
ds.Tables[0].Rows.Add(drow);
ds.AcceptChanges();
ds.WriteXml(_errorlogfilepath, System.Data.XmlWriteMode.WriteSchema);
}
///
/// Saves System.UriFormatException to Log File
///
/// System.UriFormatException
/// optional string for free form data to be logged with entry
/// optional string 2 for free form data to be logged with entry
public void SaveExceptionToLog(System.UriFormatException ufex, string optitem1, string optitem2)
{
System.Data.DataSet ds = new System.Data.DataSet();
ds.ReadXml(_errorlogfilepath);
System.Data.DataRow drow = ds.Tables[0].NewRow();
drow[0] = "System.UriFormatException";
drow[1] = System.DateTime.Now.ToString();
drow[2] = ufex.Message;
drow[3] = ufex.Source;
drow[4] = ufex.StackTrace;
drow[5] = ufex.TargetSite;
drow[6] = ufex.HelpLink;
drow[7] = optitem1;
drow[8] = optitem2;
ds.Tables[0].Rows.Add(drow);
ds.AcceptChanges();
ds.WriteXml(_errorlogfilepath, System.Data.XmlWriteMode.WriteSchema);
}
///
/// Saves System.Data.SqlClient.SqlException to Log File
///
/// System.Data.SqlClient.SqlException
/// optional string for free form data to be logged with entry
/// optional string 2 for free form data to be logged with entry
public void SaveExceptionToLog(System.Data.SqlClient.SqlException Sqlex, string optitem1, string optitem2)
{
System.Data.DataSet ds = new System.Data.DataSet();
ds.ReadXml(_errorlogfilepath);
// iterate the errors collection
// please note optitem1 & optitem2 will be applied to each of the Sqlex.Errors rows !
for (int i = 0; i < Sqlex.Errors.Count; i++)
{
System.Data.DataRow drow = ds.Tables[0].NewRow();
drow[0] = "System.Data.SqlClient.SqlException Error";
drow[1] = System.DateTime.Now.ToString();
drow[2] = Sqlex.Errors[i].Message;
drow[3] = "Line No: " + Sqlex.Errors[i].LineNumber.ToString();
drow[4] = Sqlex.Errors[i].Procedure;
drow[5] = Sqlex.Errors[i].Server;
drow[6] = Sqlex.Errors[i].State.ToString();
drow[7] = optitem1;
drow[8] = optitem2;
ds.Tables[0].Rows.Add(drow);
}
ds.AcceptChanges();
ds.WriteXml(_errorlogfilepath, System.Data.XmlWriteMode.WriteSchema);
}
}
}
No comments:
Post a Comment