Anda di halaman 1dari 5

Function isOffDay(ndtDate As NotesDateTime,strOffDay As String) As Boolean

%REM
Purpose: To check if the given date is the off day
Author:Atin
Date: 20-Nov 2007
Version: 1.0
%END REM
On Error Goto errorHandler
'Set error flag to false assuming there is no error
objErr.errFlag=False
Dim docProfile As NotesDocument
Dim varNonWrkDays As Variant
Set docProfile=dbCurrent.GetProfileDocument("Profile")
isOffDay=False
If Not docProfile Is Nothing Then
varNonWrkDays= docProfile.fldNonWrkDays
Forall tmpNonWrkDay In varNonWrkDays
Dim strWeekDay As String
strWeekDay = Weekday(ndtDate.DateOnly)
If lstWeekDays(strWeekDay)=tmpNonWrkDay Then
strOffDay=lstWeekDays(strWeekDay)
isOffDay=True
Exit Forall
End If
End Forall
End If
cleanExit:
Exit Function
errorHandler:
Call objErr.PostError (Err, Erl, "Common :: Script Library ", "",docSetu
p,objErr.CreateLogDoc)
Resume cleanExit
End Function

--------------------------------------------------------------------------------
---------------------

Function DaysDiff(strDate1,strDate2) As Long


'Purpose: Time of On-Job effectivity
'Author: Rinkal Keswani
'Dated: Sep 25, 2008
'Version: 1.0
On Error Goto errorHandler
Dim ndtDate1 As notesdatetime
Dim ndtDate2 As notesdatetime
Dim lngDiff As Long
Dim intDiffReturn As Integer
Set ndtDate1 = New NotesDateTime( strDate1 )
Set ndtDate2 = New NotesDateTime( strDate2 )
lngDiff=ndtDate2.TimeDifference( ndtDate1)
intDiffReturn=lngDiff/86400
Call UpdateStatusLog(docStatusLog,"intDiffReturn is " + Cstr(intDiffRetu
rn))
DaysDiff=intDiffReturn
cleanExit:
Exit Function
errorHandler:
Call objErr.PostError (Err, Erl, getAgentName + ":: Agent", "",Nothing,
objErr.CreateLogDoc)
Resume cleanExit
End Function
--------------------------------------------------------------------------------
--------------------
Function isOffDay(ndtDate As NotesDateTime,strOffDay As String) As Boolean
%REM
Purpose: To check if the given date is the off day
Author:Atin
Date: 20-Nov 2007
Version: 1.0
%END REM
On Error Goto errorHandler
'Set error flag to false assuming there is no error
objErr.errFlag=False
Dim docProfile As NotesDocument
Dim varNonWrkDays As Variant
Set docProfile=dbCurrent.GetProfileDocument("Profile")
isOffDay=False
If Not docProfile Is Nothing Then
varNonWrkDays= docProfile.fldNonWrkDays
Forall tmpNonWrkDay In varNonWrkDays
Dim strWeekDay As String
strWeekDay = Weekday(ndtDate.DateOnly)
If lstWeekDays(strWeekDay)=tmpNonWrkDay Then
strOffDay=lstWeekDays(strWeekDay)
isOffDay=True
Exit Forall
End If
End Forall
End If
cleanExit:
Exit Function
errorHandler:
Call objErr.PostError (Err, Erl, "Common :: Script Library ", "",docSetu
p,objErr.CreateLogDoc)
Resume cleanExit
End Function
--------------------------------------------------------------------------------
--------------------
Public Function AppendValues(docTemp As NotesDocument, strFieldName As String, v
arNewValue As Variant, intItems As Integer, ItemTYPE As Integer) _
As Integer
%REM
Purpose: This function is used to append text/non text values to the any given
fieldName
Author:Atin
Date: 18-Aug 2006
Version: 1.0
%END REM
On Error Goto errorHandler
'Set error flag to false assuming there is no error
objErr.errFlag=False
Dim arrNewValue As Variant
Dim itmNew As NotesItem
Dim varNewArrValues As Variant
Dim intKtr As Integer
'Set flag to falso to indicate that no value is appended
AppendValues = False
If intItems<=0 Then intItems=1
If Isarray(varNewValue)=True Then
arrNewValue=varNewValue
intItems=Ubound(varNewValue)
If intItems<=0 Then intItems=1
Redim Preserve varNewArrValue(0 To intItems) As String
intKtr=0
Forall tmpVal In arrNewValue
varNewArrValue(intKtr)=Cstr(tmpVal)
intKtr=intKtr+1
End Forall
Else
Redim varNewArrValue(0 To intItems-1) As String
varNewArrValue(0)= Cstr(varNewValue)
End If
If Not docTemp.HasItem( strFieldName ) Then
Set itmNew = docTemp.ReplaceItemValue( strFieldName, varNewArrVa
lue)
itmNew.Type=itemType
If itemType=READERS Then itmNew.IsReaders=True
Else
If Cstr(docTemp.GetItemValue( strFieldName ) ( 0 )) = "" Then
Set itmNew = docTemp.ReplaceItemValue( strFieldName, var
NewArrValue)
itmNew.Type=itemType
If itemType=READERS Then itmNew.IsReaders=True
Else
Call TrimArray(varNewArrValue)
Call docTemp.ReplaceItemValue( strFieldName, Arrayappend
( docTemp.GetItemValue( strFieldName ), varNewArrValue ) )
End If
AppendValues = True
End If

cleanExit:
Exit Function
errorHandler:
Call objErr.PostError (Err, Erl, "Common :: Script Library ", "",docTemp
,objErr.CreateLogDoc)
Resume cleanExit
End Function
--------------------------------------------------------------------------------
--------------------------

Public Function getAgentOwner As String


%REM
Purpose: to get the name of the user with which ID the agent is running
Author:Atin
Date: 28-Aug 2006
Version: 1.0
%END REM
On Error Goto errorHandler
'Set error flag to false assuming there is no error
objErr.errFlag=False
Dim currAgent As NotesAgent
'Set the current running agent
Set currAgent=currSession.CurrentAgent
'Set the name of user if run on behalf of property is set
getAgentOwner =Trim(currAgent.OnBehalfOf)
'if run on behalf of properry in the agent is not set then
'then owner is the last signer of the agent
If getAgentOwner ="" Then
getAgentOwner =currAgent.Owner
End If

cleanExit:
Exit Function
errorHandler:
Call objErr.PostError (Err, Erl, "Common :: Script Library ", "",Nothing
,objErr.CreateLogDoc)
Resume cleanExit
End Function
--------------------------------------------------------------------------------
-----------------------
Public Function getAgentName As String
%REM
Purpose: to get the name of the Agent
Author:Atin
Date: 18-Sep 2006
Version: 1.0
%END REM
On Error Goto errorHandler
'Set error flag to false assuming there is no error
objErr.errFlag=False
Dim currAgent As NotesAgent
'Set the current running agent
Set currAgent=currSession.CurrentAgent
'Set the name of agent
getAgentName =Trim(currAgent.Name)
cleanExit:
Exit Function
errorHandler:
Call objErr.PostError (Err, Erl, "Common :: Script Library ", "",Nothing
,objErr.CreateLogDoc)
Resume cleanExit
End Function
--------------------------------------------------------------------------------
----------------------

Anda mungkin juga menyukai