mySobek Home   |   Help
Skip Navigation Links.
MISSING BANNER
Code Details >> Tools >> Logs >> LogFileXhtml

LogFileXhtml Class



This class establishes a rich XHTML log file. Then, lines can be added in three flavors ( error, nonerror, and complete).



Namespace: SobekCM.Tools.Logs
Assembly: SobekCM_Tools (in SobekCM_Tools.dll) Version: 4.10.0.0 (4.10.0)

Syntax

C#
public class LogFileXhtml

Remarks

There are two modes that can be used for this log file. You can specify Open()()()() and Close()()()(), which will leave the file stream (and associated resources) open during the period between the two calls. Alternatively, you can just call the Write routines directly. It will open the stream before the write and close right after writing and modifying the header information.

Object created by Mark V Sullivan (2003) for University of Florida's Digital Library Center.

Examples

The example below demonstrates using this object in the basic format, without adding new styles.
 Copy imageCopy
<SPAN class="lang">[C#]</SPAN> 
             using System;
             using System.IO;
             using GeneralTools.Logs;

             namespace GeneralTools
             {
                    public class LogFileXHTML_Example_1
                    {
                        static void Main() 
                        {
                            // Create a new XHTML Log File, setting the title and application at the same time
                            LogFileXHTML myLogger = new LogFileXHTML( "c:\\example.log.html", "Log File XHTML Example", "Class Library Example" );

                            // Make sure this is a fresh log file
                            myLogger.New();

                            // Open the file explicitly.  This will leave a connection open for 
                            // the next few lines of processing until Close() is called.
                            myLogger.Open();

                            // Go through and add each diretory name to this log file
                            int files = -1, folderNumber = 1;
                            foreach ( string thisDir in Directory.GetDirectories("C:\\") )
                            {
                                // Perform this in a try catch, as there may be a rights issue in system folders
                                try
                                {
                                    files =  Directory.GetFiles(thisDir).Length;
                                }
                                catch
                                {
                                    // Set the number of files in this directoty to a default of -1
                                    files = -1;
                                }

                                // If it could not detect the number of files, add the error
                                if ( files == -1 )
                                    myLogger.AddError( "ERROR! Unable to determine the number of files in folder " + thisDir );
                                else    
                                    myLogger.AddNonError( "Folder " + thisDir + " is the " + folderNumber + "th folder found had " + Directory.GetFiles(thisDir).Length + " files." );

                                // Increment the folder number
                                folderNumber++;
                            }    

                            // Add a final line
                            myLogger.AddComplete( folderNumber + " Total Folders Found and " + myLogger.ErrorCount + " Errors Found!" );

                            // Now, close the log file connection
                            myLogger.Close();

                            // Email the log file
                            myLogger.MailSMTP( "Example", "marsull@mail.uflib.ufl.edu" );
                        }
                    }
                }

Below is what the output file's text looks like. To see it in HTML, click here.
 Copy imageCopy
   <?xml version="1.0" encoding="UTF-8"?>
   <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
   <html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">

   <! Log file produced automatically by C# program LogFileXHTML.cs >
   <! Developed by Mark V Sullivan, November 2002 >

   <head>
   <title> Log File XHTML Example </title>   

   <! Values used by LogFileXHTML >
   <META NAME="Next_Position" CONTENT="3245">       
   <META NAME="Date_Created" CONTENT="11/12/2003 8:43:45 PM-">
   <META NAME="Row_Header" CONTENT="">                    
   <META NAME="Date_Stamping" CONTENT="True"> 
   <META NAME="Error_Count" CONTENT="1">   
   <META NAME="Application" CONTENT="Class Library Example">         

   <! Style Sheet Definitions >
   <style type="text/css">
       .logFileName { font-size: "x-large"; text-align: "center"; font-weight: "bold"; font-family: "Arial" }
       .logEntry { color: "black"; font-family: "Arial"; font-size: "15"; }
       .errorLogEntry { color: "red"; font-family: "Arial"; font-size: "15"; <!strong> }
       .completedLogEntry { color: "blue"; font-family: "Arial"; font-size: "15"; <!strong> }
   </style>
   </head>

   <body>

   <div class="logFileName">Log File XHTML Example</div>

   <br /><hr /><br />

   <div class="logEntry"> 11/12/2003 8:43:49 PM - Folder C:\adaptec is the 1th folder found had 1 files.</div>
   <div class="logEntry"> 11/12/2003 8:43:49 PM - Folder C:\ADOBEAPP is the 2th folder found had 0 files.</div>
   <div class="logEntry"> 11/12/2003 8:43:49 PM - Folder C:\Aerials is the 3th folder found had 0 files.</div>
   <div class="logEntry"> 11/12/2003 8:43:49 PM - Folder C:\comcheck is the 4th folder found had 0 files.</div>
   <div class="logEntry"> 11/12/2003 8:43:49 PM - Folder C:\Content SDK is the 5th folder found had 5 files.</div>
   <div class="logEntry"> 11/12/2003 8:43:49 PM - Folder C:\dell is the 6th folder found had 0 files.</div>
   <div class="logEntry"> 11/12/2003 8:43:49 PM - Folder C:\Documents and Settings is the 7th folder found had 0 files.</div>
   <div class="logEntry"> 11/12/2003 8:43:49 PM - Folder C:\Inetpub is the 8th folder found had 0 files.</div>
   <div class="logEntry"> 11/12/2003 8:43:49 PM - Folder C:\My Music is the 9th folder found had 0 files.</div>
   <div class="logEntry"> 11/12/2003 8:43:49 PM - Folder C:\OfficeScan NT is the 10th folder found had 95 files.</div>
   <div class="logEntry"> 11/12/2003 8:43:49 PM - Folder C:\Perl is the 11th folder found had 2 files.</div>
   <div class="logEntry"> 11/12/2003 8:43:49 PM - Folder C:\Processing is the 12th folder found had 0 files.</div>
   <div class="logEntry"> 11/12/2003 8:43:49 PM - Folder C:\Program Files is the 13th folder found had 2 files.</div>
   <div class="logEntry"> 11/12/2003 8:43:49 PM - Folder C:\RECYCLER is the 14th folder found had 0 files.</div>
   <div class="errorLogEntry"> 11/12/2003 8:43:49 PM - <strong>ERROR! Unable to determine the number of files in folder C:\System Volume Information</strong></div>
   <div class="logEntry"> 11/12/2003 8:43:49 PM - Folder C:\WINNT is the 16th folder found had 159 files.</div>
   <div class="completedLogEntry"> 11/12/2003 8:43:49 PM - <strong>17 Total Folders Found and 1 Errors Found!</strong></div>

<br /><hr /><br />

</body>

   </html>

Inheritance Hierarchy

System..::..Object
  SobekCM.Tools.Logs..::..LogFileXhtml

Constructors

  NameDescription
Public methodLogFileXhtml(String)
Constructor which builds a new LogFileXHTML object
Public methodLogFileXhtml(String, Boolean)
Constructor which builds a new LogFileXHTML object
Public methodLogFileXhtml(String, String)
Constructor which builds a new LogFileXHTML object
Public methodLogFileXhtml(String, String, Boolean)
Constructor which builds a new LogFileXHTML object
Public methodLogFileXhtml(String, String, String)
Constructor which builds a new LogFileXHTML object
Public methodLogFileXhtml(String, String, String, Boolean)
Constructor which builds a new LogFileXHTML object
Public methodLogFileXhtml(String, String, String, String)
Constructor which builds a new LogFileXHTML object
Public methodLogFileXhtml(String, String, String, String, Boolean)
Constructor which builds a new LogFileXHTML object

Methods

  NameDescription
Public methodAddComplete
Adds a line indicating completeness to the log file.
Public methodAddError
Adds an error line to the current log file.
Public methodAddNewStyle(String, String)
[NOT YET FULLY IMPLEMENTED]

Create a new style for this log file.
Public methodAddNewStyle(String, String, Boolean)
[NOT YET FULLY IMPLEMENTED]

Create a new style for this log file.
Public methodAddNewStyle(String, String, String)
[NOT YET FULLY IMPLEMENTED]

Create a new style for this log file.
Public methodAddNewStyle(String, String, String, Boolean)
[NOT YET FULLY IMPLEMENTED]

Create a new style for this log file.
Public methodAddNewStyle(String, String, String, Boolean, Boolean)
[NOT YET FULLY IMPLEMENTED]

Create a new style for this log file.
Public methodAddNonError
Adds a non-error line to the current log file.
Public methodClose
Saves and closes the log file.
Public methodDisableRowHeaders
Disable the additional information between the time/date and the log entry.
Public methodDisplay
Displays the XHTML log file in Internet Explorer.
Public methodEnableRowHeaders
Enables the additional information between the time/date and the log entry and sets this information to the string which is passed in.
Public methodExists
Returns true if the log file currently exists.
Public methodNew
Deletes the current log file, closing first if necessary.
Public methodOpen
Opens or creates a log file.

Properties

  NameDescription
Public propertyDateCreated
Gets the date and time the current log file was created.
Public propertyDateStampingEnabled
Gets and sets the flag which indicates if each line receives a date stamp.
Public propertyErrorCount
Gets the number of explicit calls to AddError(String) method were made.
Public propertyFileName
Returns the filename for this log file
Public propertyisOpen
Returns true if the log file is currently open.
Public propertySuppressExceptions
Gets and Sets the flag which indicates if all LogFile_Exceptions should be suppressed or not.

See Also



Version 4.10.0 ( last generated Monday, March 7, 2016 )