The following is configured with a class to configure the publisher, such as obtaining the position of the above three files and setting the relevant configuration:
///
/// ExceptionSetting summary description.
/// summary>
Public class exceptionSetting
{
///
/// Get folder for exception processing
/// summary>
Public Static String FilePath
{
get
{
String fullpath;
IF (Appconfig.GetAppSetting ("ExceptionPath")! = NULL)
{
FullPath = Appconfig.getAppSetting ("ExceptionPath");
While (fullpath.startswith ("//"))
{
Fullpath = FullPath.Remove (0, 1);
}
}
Else
{
Fullpath = path.getdirectoryName (path.getfullpath ("temp.xml"));
}
Fullpath = path.getFullPath (Fullpath);
Fullpath = FullPath "//";
IF (! Directory.exists (Path.GetDirectoryName (Fullpath)))
{
Directory.createdIRectory (path.getdirectoryName);
}
Return Fullpath;
}
}
///
/// Get or set the string of folders for exception processing
/// summary>
Public Static String FilePathSettingString
{
get
{
Return Appconfig.GetAppSetting ("ExceptionPath");
}
set
{
Appconfig.saveAppSetting ("ExceptionPath", Value;
}
}
///
/// Get or set the system exception record type, default to use XML file record
/// summary>
Public Static CanuseExceptionLogType ExceptionLogType
{
get
{
String exceptionLogType = Appconfig.GetAppSetting ("exceptionLogType";
IF (ExceptionLogType.Tolower (). Trim () == canuseExceptionLogType.systemlog.toString (). TOLOWER ())
{
Return canuseExceptionLogType.systemlog;
}
ELSE IF (ExceptionLogType.tolower (). Trim () == canuseExceptionLogType.all.tostring (). TOLOWER ())
{
Return canuseExceptionLogType.all;
}
Else
Return canuseExceptionLogType.xmlfile;
}
set
{
Appconfig.saveAppSetting ("ExceptionLogType", value.tostring ());
}
}
}
The following category is to read and write three files used in the abnormal publisher:
///
A summary description of /// logaccess.
/// summary>
Public Class logaccess
{
///
/// Write an exception handling log
/// summary>
/// param>
Public Static Void WriteLogfile (ExceptionLogdata DS)
{
DS.WRITEXML (ExceptionSetting.FilePath "ExceptionLog.xml");
}
///
/// read out an exception handling log
/// summary>
///
Public Static ExceptionLogdata Readlogfile ()
{
ExceptionLogData DS = New ExceptionLogdata ();
IF (! file.exists (exceptionsetting.filepath "exceptionlog.xml"))
{
DS.WRITEXML (ExceptionSetting.FilePath "ExceptionLog.xml");
}
Ds.clear ();
DS.Readxml (ExceptionSetting.FilePath "ExceptionLog.xml");
Return DS;
}
///
/// read the custom universal information
/// summary>
///
Public Static CustomOutMestageData getCustomOutmessage ()
{
CustomOutMessageData DS = New CustomOutMessageData ();
IF (! file.exists (exceptionSetting.filepath "customoutmessage.xml")))))
{
DS.WriteXML (ExceptionSetting.FilePath "CustomoutMessage.xml");
}
Ds.clear ();
DS.Readxml (ExceptionSetting.FilePath "CustomoutMessage.xml");
Return DS;
}
///
/// Write custom universal information
/// summary>
/// param>
Public Static Void Savecustomoutmessage (CustomoutMessageData DS)
{
DS.WriteXML (ExceptionSetting.FilePath "CustomoutMessage.xml");
}
///
/// Get an exception handling definition information
/// summary>
///
Public Static ExceptionDetAildata getExceptionDetail ()
{
ExceptionDetAildata ExceptionDetAilds = New ExceptionDetAildata ();
IF (! file.exists (exceptionSetting.filepath "exceptionList.xml"))
{
ExceptionDetAilds.writexml (ExceptionSetting.FilePath "ExceptionList.xml");
FileStream Fs = New FileStream (ExceptionSetting.FilePath "ExceptionList.xml", FileMode.Openorcreate, FileAccess.Readwrite;
Streamwriter W = New StreamWriter (FS);
W.BaseStream.seek (0, seekorigin.end);
w.write ("/ n / n ");
w.flush ();
W. close ();
}
ExceptionDetAilds.clear ();
ExceptionDetAilds.Readxml (ExceptionSetting.FilePath "ExceptionList.xml");
Return EXCEPTIONDETAILDS;
}
///
// / save an exception handling definition information
/// summary>
/// Abnormal processing definition information to be saved param>
Public Static Void SaveExceptionDetail (ExceptionDetAildata ExceptionDetAilds)
{
ExceptionDetAilds.writexml (ExceptionSetting.FilePath "ExceptionList.xml");
FileStream Fs = New FileStream (ExceptionSetting.FilePath "ExceptionList.xml", FileMode.Openorcreate, FileAccess.Readwrite;
Streamwriter W = New StreamWriter (FS);
W.BaseStream.seek (0, seekorigin.end);
w.write ("/ n / n "); w.flush ();
W. close ();
}
}
(Endlessly)