Monday, April 29, 2013

Lotus Notes C API's for fetching Agent properties

Hi All,

I have created a tool for monitoring the scheduled agents. I have found an API's which help us to fetch the agent properties. This is not my own code, i found this API's in IBM website. Please refer the below code.
Note : 
1. While running, you have to check target and source database should have full acess, otherwise your server or lotus notes client will crash.
2. Dont Schedule it, try to run this API manually.

Call this API as with paramenter - GetAssistInfo db, a$, info


Sub GetAssistInfo(db As NotesDatabase, agent As String, info As AssistInfo)
np$ = Space(1024)
OSPathNetConstruct 0, db.Server, db.FilePath, np$

Dim hDB As Long
NSFDbOpen np$, hDB
If hDB = 0 Then
Messagebox "Can't open database", 16
Exit Sub
End If

pt& = Instr(agent, "|")
If pt& = 0 Then ti$ = Trim$(agent) Else ti$ = Trim$(Left$(agent, pt& - 1))

Dim nID As Long
NIFFindDesignNote hDB, ti$, NOTE_CLASS_FILTER, nID
If nID = 0 Then
Messagebox "Can't find agent " & ti$, 16
Exit Sub
End If

If Instr(db.GetDocumentByID(Hex$(nID)).~$Flags(0), "f") = 0 Then
Messagebox ti$ & " is not an agent", 16
Exit Sub
End If

Dim hNT As Long
NSFNoteOpen hDB, nID, 0, hNT

Dim iB As BlockID, vB As BlockID
NSFItemInfo hNT&, "$AssistInfo", 11, iB, dt%, vB, nv&
If Not vB.hPool = 0 Then
p& = OSLockObject(vB.hPool) + vB.Block
Peek info.Version, p& + 2, 2
Peek info.TriggerType, p& + 4, 2
Peek info.SearchType, p& + 6, 2
Peek info.IntervalType, p& + 8, 2
Peek info.Interval, p& + 10, 2
Peek v&, p& + 12, 4
If v& <= 31 Then info.Time1 = v& Else info.Time1 = Cdat(v&/100/60/60/24)
Peek v&, p& + 16, 4
If v& <= 31 Then info.Time2 = v& Else info.Time2 = Cdat(v&/100/60/60/24)
t$ = Space(81)
ConvertTIMEDATEToText 0, 0, p& + 20, t$, 80, nt%
If Not nt% = 0 Then info.StartTime = Cdat(Left$(t$, nt%))
t$ = Space(81)
ConvertTIMEDATEToText 0, 0, p& + 28, t$, 80, nt%
If Not nt% = 0 Then info.EndTime = Cdat(Left$(t$, nt%))
Peek info.Flags, p& + 36, 4
OSUnlockObject vB.hPool
End If

NSFNoteClose hNT
NSFDbClose hDB
End Sub



No comments:

Post a Comment