ChadSmiley Blog Things about family, life, coding, and more

31May/060

Template Build Class

Updated code to remove extra XML information

Chris suggested that a web service be made available for projects to check for updates at openNTF. Vince implemented this rather quickly so I started to testing it on my projects. Everything worked great, but what I noticed was that I now have to maintain this information in both the 'Check for Updates' agent and the $TemplateBuild shared field so that it shows in the database properties.

Remember Chris Doig's tool to set the build information using a notes database (Great Tool). There is duplicate information in these two tools causing me to maintain the build information in both places. Hopefully I have provided a class that can help reduce the duplicity. The Template Build class will allow the setting and getting of the Template Build, Template Build Name and Template Build Date of the $TemplateBuild shared field. This can be used by the web service to get the information, Chris's tool can use it to set the information, and anyone else can use it to set or get the information. Then everyone will be happy, at least I will be!!

Here are the methods available:

Public Sub new( )<br>
Public Function GetVersionField() As NotesDocument<br>
Public Function getTemplateBuildName( ) As String<br>
Public Function setTemplateBuildName( BuildName As String )<br>
Public Function getTemplateBuild( ) As String<br>
Public Function setTemplateBuild( Build As String )<br>
Public Function getTemplateBuildDate( ) As NotesDateTime<br>
Public Function hasTemplateBuild( ) As Boolean<br>
Public Sub delete( )<br>




Template Build Class

Option Public
Option Declare
 
'/**
' * Notes/Domino uses a shared field called $TemplateBuild to store the current 
' * build number, build name and build date this class will allow access to the shared field
' * both to read and update.  
' *
' * History
' *14 Apr 2005	Christopher J Doig	Initial version
' *30 May 2006	Chad Schelfhout ( http://www.chadsmiley.com )
' *		Converted function to class
' *		Setters and getters for Build information
' * 		Allow the creation of the shared field if it does not exist
' */
Class TemplateBuild
	SharedFieldTitleName As String
	SharedFieldName As String
	TemplateBuildNameField As String
	TemplateBuildField As String
	TemplateBuildDateField As String
 
	docTemplateBuild As NotesDocument
	session As NotesSession
	saveDocTemplateBuild As Boolean
	Public Sub New ()
		SharedFieldTitleName = "$Title"
		SharedFieldName = "$TemplateBuild" 
		TemplateBuildNameField = "$TemplateBuildName"
		TemplateBuildField = "$TemplateBuild"
		TemplateBuildDateField = "$TemplateBuildDate"
 
		Set session = New NotesSession
		saveDocTemplateBuild = False
		Call GetVersionField()
	End Sub
'/*
' * 	Attempt to load the Build information if it is not there then import the DXL to create
' * the shared field then try and load the Build information again.
' */
	Public Function GetVersionField () As NotesDocument
		Call attemptLoad()
		If docTemplateBuild Is Nothing Then
			Call createBuildTemplateField()
			Call attemptLoad()
		End If
		Set GetVersionField = docTemplateBuild
	End Function
 
'/*
' * Search for the shared field called $TemplateBuild
' */
	Private Sub attemptLoad() 
 
		Dim doc As NotesDocument
		Dim nc As NotesNoteCollection
		Dim item As NotesItem
		Dim strID As String
 
		Set nc = session.CurrentDatabase.CreateNoteCollection ( False )
		nc.SelectSharedFields = True
		Call nc.BuildCollection
		strID = nc.GetFirstNoteId
 
		Set docTemplateBuild = Nothing
		Do Until strID = ""
			Set doc = session.CurrentDatabase.GetDocumentByID ( strID )		
			Set item = doc.GetFirstItem ( SharedFieldTitleName )
			If item.Text = SharedFieldName Then
				Set docTemplateBuild = doc
				Exit Do
			End If
			strID = nc.GetNextNoteId ( strID )
		Loop
	End Sub
'/*
' * Import a shared field called $TemplateBuild
' */
	Private Sub createBuildTemplateField()
 
		Dim importer As NotesDXLImporter
		Set importer = session.CreateDXLImporter
 
		importer.DesignImportOption = DXLIMPORTOPTION_CREATE
		Call importer.Import( |<?xml version='1.0' encoding='utf-8'?><!DOCTYPE sharedfield>
		<sharedfield name='$TemplateBuild' xmlns='http://www.lotus.com/dxl' language='en'>
	<field type='text' kind='editable' name='$TemplateBuild'/>
	<item name='$TemplateBuildName' sign='true'>
		<textlist>
			<text>Application Name</text>
		</textlist>
	</item>
	<item name='$TemplateBuild' sign='true'>
		<textlist>
			<text>0.0.0</text>
		</textlist>
	</item>
	<item name='$TemplateBuildDate' sign='true'>
		<datetimelist>
			<datetime dst='true'>19010101T000000,00-07</datetime>
		</datetimelist>
	</item>
</sharedfield>| , Session.CurrentDatabase )
		saveDocTemplateBuild = True
	End Sub
'/*
' * Get, Set Template Build Name
' */	
	Public Function getTemplateBuildName As String
		getTemplateBuildName = ""
		If hasTemplateBuild Then
			If docTemplateBuild.HasItem( TemplateBuildNameField ) Then
				getTemplateBuildName = docTemplateBuild.getFirstItem( TemplateBuildNameField ).text
			End If
		End If
	End Function
	Public Sub setTemplateBuildName ( BuildName As String )
		If hasTemplateBuild Then
			Call docTemplateBuild.ReplaceItemValue( TemplateBuildNameField ,  BuildName )
			saveDocTemplateBuild = True
		End If
	End Sub
 
'/*
' * Get, Set Template Build
' */	
	Public Function getTemplateBuild	As String
		getTemplateBuild = ""
		If hasTemplateBuild Then
			If docTemplateBuild.HasItem( TemplateBuildField ) Then
				getTemplateBuild = docTemplateBuild.getFirstItem( TemplateBuildField ).text
			End If
		End If
	End Function
	Public Sub setTemplateBuild ( Build As String )
		If hasTemplateBuild Then
			Call docTemplateBuild.ReplaceItemValue( TemplateBuildField ,  Build )
			saveDocTemplateBuild = True
		End If
	End Sub
 
'/*
' * Get, Set Template Build Date
' */	
	Public Function getTemplateBuildDate As NotesDateTime
		Set getTemplateBuildDate = New NotesDateTime( "0/0/0" )
		If hasTemplateBuild Then
			If ( docTemplateBuild.HasItem( TemplateBuildDateField ) ) Then
				Set getTemplateBuildDate = docTemplateBuild.getFirstItem( TemplateBuildDateField ).dateTimeValue
			End If
		End If
	End Function
	Public Sub setTemplateBuildDate ( BuildDate As NotesDateTime )
		If hasTemplateBuild Then
			Call docTemplateBuild.ReplaceItemValue( TemplateBuildDateField ,  BuildDate )
			saveDocTemplateBuild = True
		End If
	End Sub
 
	Public Function hasTemplateBuild As Boolean
		hasTemplateBuild = Not ( docTemplateBuild Is Nothing)
	End Function
 
	Public Sub delete 
		If saveDocTemplateBuild Then
			Call docTemplateBuild.Save( True , False )
			saveDocTemplateBuild = False
		End If
	End Sub
End Class
Tagged as: , , No Comments
25May/060

Open Audit 1.0.0 Beta 1

Collage of configuration options I have created my second openNTF project which will allow developers to create audit documents when field changes.  All configuration will be controlled through a configuration document for a given form.  Open Audit is currently in beta, I am looking for some feed back to see if this will be useful for developers before I continue to develop the rest of the tool.  Currently on the Notes UI has been implemented, which is the toughest part (just my opinion).

Here is where Open Audit is at as of 1.0.0 Beta 1
New Features

  • Configurable audit key
  • Field filter and field exclusion filter, with wildcards
  • Field descriptions to assign more meaningful names
  • Retention based on days or number of versions
  • External audit database or current database

Not Implemented

  • Backend audit class
  • Java audit class
  • Retention agent
23May/060

Line Break Class

Simple class to get the necessary characters to create a line break. The line break is needed for prompts, input, and others. There is not much to explain once you see the available methods:

Public   Sub  new  (   )  As  String 
Public   Function  getLineBreakSession (  Session As  NotesSession   )  As  String
Public   Function  getLineBreak (   )  As  String 
Public   Function  getWindows (   )  As  String
Public   Function  getMacintosh (   )  As  String
Public   Function  getUnix (   )  As String
Public   Function  getLinux (   )  As  String

The first code block is the traditional LotusScript coding where you will need to create an instance of LineBreak in order to use it. The second follows the concept of simulating an abstract concept. This allows LineBreak.getLineBreak() to be called from anywhere at any time as long as the class is included.

Line Break

 Option Declare
 
'/**
' *	Determines what line break to use base on the platform.
' *	
' *	@author	Chad Schelfhout ( http:///www.chadsmiley.com)
' * @since		1.0.0
' */
Class LineBreak
	Private pSession As notesSession
'/**
' *	Constructor
' */
	Public Sub new ( )
		Set pSession = New NotesSession
	End Sub
'/**
' *	Get the type of line break based off the current session
' */
	Public Function getLineBreakSession( Session As NotesSession )As String
		Set pSession = Session
		getLineBreakSession = getLineBreak()
	End Function
'/**
' * determines the current line break based off the current platform
' */
	Public Function getLineBreak() As String
		If pSession Is Nothing Then
			Set pSession = New NotesSession()
		End If
		Select Case pSession.Platform()
		Case "Windows/32":
			getLineBreak = getWindows()
		Case "Macintosh":
			getLineBreak = getMacintosh()
		Case "Unix":
			getLineBreak = getUnix()
		Case "Linux":
			getLineBreak = getLinux()
		End Select
	End Function
'/**
' *	Returns the Windows line break
' */
	Public Function getWindows() As String
		getWindows = Chr$(13) & Chr$(10)
	End Function
'/**
' *	Returns the Mac line break
' */
	Public Function getMacintosh() As String
		getMacintosh = Chr$(13)
	End Function
'/**
' *	Returns the Unix line break
' */
	Public Function getUnix() As String
		getUnix = Chr$(10)
	End Function
'/**
' *	Returns the Linx line break
' */
	Public Function getLinux() As String
		getLinux = Chr$(10)
	End Function
End Class

Line Break simulate abstract class

Option Declare
 
'/**
' * Global variable to simulate an abstract class that is why it is named
' * the same as the class.
' */
Dim LineBreak As LineBreak
 
'/**
' *	Determines what line break to use base on the platform.
' *	
' * @author	Chad Schelfhout ( http:///www.chadsmiley.com)
' * @since		1.0.0
' */
Class LineBreak
	Private pSession As notesSession
'/**
' *	Constructor
' */
	Public Sub new ( )
		Set pSession = New NotesSession
	End Sub
'/**
' *	Get the type of line break based off the current session
' */
	Public Function getLineBreakSession( Session As NotesSession )As String
		Set pSession = Session
		getLineBreakSession = getLineBreak()
	End Function
'/**
' * determines the current line break based off the current platform
' */
	Public Function getLineBreak() As String
		If pSession Is Nothing Then
			Set pSession = New NotesSession()
		End If
		Select Case pSession.Platform()
		Case "Windows/32":
			getLineBreak = getWindows()
		Case "Macintosh":
			getLineBreak = getMacintosh()
		Case "Unix":
			getLineBreak = getUnix()
		Case "Linux":
			getLineBreak = getLinux()
		End Select
	End Function
'/**
' *	Returns the Windows line break
' */
	Public Function getWindows() As String
		getWindows = Chr$(13) & Chr$(10)
	End Function
'/**
' *	Returns the Mac line break
' */
	Public Function getMacintosh() As String
		getMacintosh = Chr$(13)
	End Function
'/**
' *	Returns the Unix line break
' */
	Public Function getUnix() As String
		getUnix = Chr$(10)
	End Function
'/**
' *	Returns the Linx line break
' */
	Public Function getLinux() As String
		getLinux = Chr$(10)
	End Function
End Class
'/**
' * Instanciate the global variable that will act like an abstract class
' */
Sub Initialize
	Set LineBreak = New LineBreak()
End Sub
Tagged as: , No Comments
17May/062

Lotus Notes Error Notification – Cancel

My Notes has not crashed lately but when it happens I select cancel on the dialog like this:
lotus-notes-error-notification-cancel-1
What I did not know was that there was a second screen cleverly hidden behind with another message to see if I really wanted to cancel and to never show it again.  I never noticed this before, I always kept pressing cancel.  Now I know it is there and so do you!!!
lotus-notes-error-notification-cancel-2
So I selected 'Do not show this message again' and selected Cancel.  The next time Notes crashed and I selected cancel and this time I clicked the check box and selected OK.  I am thinking I will never have to see this confirmation screen again, but the third time Notes crashed there it was again.  Please make this go away.

Tagged as: 2 Comments
16May/060

Fighting comment spam


If you have not noticed Captain Oblivious posted a way to combat the comment spam that has been hitting the users of BlogSphere, including me.  To be different, I came up with my own way of combating it.  I have added  a new field to my comments that requires some additional characters to be entered, or copy and pasted.  
I have been using this for about a week and it has been working very nice.  So let me know your thoughts.  I realize that this not that bullet proof but would like to know if other people are interested if the codes where encrypted more.  Eventually, I would like to implement Captcha but only if there is an interest.

Update:  Now that spam is under control I have enabled referrers again.

11May/060

SnT Thursday – Military Time

Ever wanted to categories information based on date\time.The sorting was not whate I expected becase 10:44 AM is after 09:08 AM. Military time was the first thing that came to mind and I found just what I was looking for at Lotus Notes FAQ - How do you convert a time field to display as military time? from Key Yee. I did add the date to the string, the only chnage is contacting the hour, minute and seconds into an array and then imploding it using a colon, which is quicker than h + ":" + m +":" + s.

REM {From Jason Collier (jcollier@sd.synetics.com)}; 
DateTime := @Created; 
time := @Time(dateTime); 
t:= @Text(@Time(time)); 
t2:=@Left(@Text(@ReplaceSubstring(@Text(@Time(time)); ":" ;"")); 6); 
h:=@Left(t2;2); 
s:=@Right(t2;2); 
m:=@Middle(t2;2;2); 
AM:=@ReplaceSubstring(@Left(t2;2) ; "12" ;"00"); 
 PM:=@ReplaceSubstring(@Left(t2;2) ; "12" ;"12"); 
 PM2:=@Text(@TextToNumber(h)+12); 
 timecheck:= @If(@Contains(t;"AM"); AM ; @If(@Contains(t;"PM") &amp; @Contains(@Left(t2;2);"12") ; PM ; PM2)); 
 MilTime := timecheck : m : s ; 
   @Text( @Date( DateTime ) ) + "\\" + @Implode( MilTime ; ":" )
2May/060

Proverbs 2:1-9

1-My son, if you receive my words,
And treasure my commands within you,
2-So that you incline your ear to wisdom,
And apply your heart to understanding;
3-Yes, if you cry out for discernment,
And lift up your voice for understanding,
4-If you seek her as silver,
And search for her as for hidden treasures;
5-Then you will understand the fear of the LORD,
And find the knowledge of God.
6-For the LORD gives wisdom;
From His mouth come knowledge and understanding;
7-He stores up sound wisdom for the upright;
He is a shield to those who walk uprightly;
8-He guards the paths of justice,
And preserves the way of His saints.
9-Then you will understand righteousness and justice,
Equity and every good path.
Tagged as: No Comments