Brocade Virtual ADX XML API Programmer’s Guide (Supporting ADX v03.1.00) User Manual

Page 839

Advertising
background image

Brocade Virtual ADX XML API Programmer’s Guide

829

53-1003248-01

Example: Adding and binding a real server and a VIP

B

/////////////////////////////////////////////////////////////////////////////

public bool OpenRCloseLog(bool bOpen)

{

string sLogPath = "";

//get the full location of the assembly with DaoTests in it

string sfullPath =

System.Reflection.Assembly.GetAssembly(typeof(Utils)).Location;

//get the folder that's in

string sDirectory = Path.GetDirectoryName(sfullPath);

sLogPath = String.Format("{0}\\ConfigureSLB.txt", sDirectory);

//check whether m_StreamWriter object is null before opening the log

file

if (bOpen == true && m_StreamWriter == null)

{

m_FileStream = new FileStream(sLogPath, FileMode.OpenOrCreate |

FileMode.Append, FileAccess.Write);

m_StreamWriter = new StreamWriter(m_FileStream);

if (m_StreamWriter == null)

{

return false;

}

return true;

}

else

{

//Check the validity of the streamwriter before calling close

command

if (m_StreamWriter != null)

{

//Close the log file

m_StreamWriter.Close();

m_FileStream.Close();

m_FileStream = null;

m_StreamWriter = null;

}

}

return true;

}

/////////////////////////////////////////////////////////////////////////////

// Name: WL

//

// Description: This function to write the log message to the file.

//

// Parameters: sLogMessage - the log message to be written to the log file.

//

/////////////////////////////////////////////////////////////////////////////

public void WL(string sLogMessage, string sLogMessage1)

{

if (m_StreamWriter == null)

{

//Do not write the log if the log file is not opened

if (false == OpenRCloseLog(true))

return;

}

m_StreamWriter.Write("\r\n");

m_StreamWriter.WriteLine("{0}: --{1} {2}--", DateTime.Now,

sLogMessage, sLogMessage1);

Advertising