Advertisement
gunawantw

Missing person

Nov 27th, 2018
3,396
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. %REM
  2.     Agent Run
  3.     Created Nov 27, 2018 by Admin/Universe
  4.     Description: Comments for Agent
  5. %END REM
  6. Option Public
  7. Option Declare
  8.  
  9. Const ServerName = "Domino/Universe"
  10. Const NabFileName = "names.nsf"
  11. Const UserLicName = "userlicenses.nsf"
  12.  
  13. Sub Initialize
  14.     Dim ses As New NotesSession
  15.     Dim db As NotesDatabase
  16.     Dim NABDb As NotesDatabase
  17.     Dim LicDb As NotesDatabase
  18.      
  19.     Set NABDb = New NotesDatabase(ServerName,NABFileName)
  20.    
  21.     If Nabdb Is Nothing Then
  22.         MsgBox "Could not open your NAB database " + NABFilename + " at server " + ServerName
  23.         GoTo selesai
  24.     End If
  25.    
  26.     Set LicDb = New NotesDatabase(ServerName,UserLicName)
  27.  
  28.     If LicDb Is Nothing Then
  29.         MsgBox "Could not open your License database " + UserLicName + " at server " + ServerName      
  30.         GoTo selesai
  31.     End If
  32.    
  33.     Dim NABView As NotesView
  34.     Set NABView = NABdb.Getview("($VIMPeople)")
  35.    
  36.     Dim NABPeopleDoc As NotesDocument
  37.     Set NABPeopleDoc = NABView.Getfirstdocument()
  38.    
  39.     Dim LicDoc As NotesDocument
  40.     Dim strMissingPerson As String
  41.     Dim strPerson as string
  42.     Dim NNPerson As NotesName
  43.    
  44.     While Not NABPeopleDoc Is Nothing
  45.         'Print NABPeopleDoc.FullName(0)
  46.         strPerson = NABPeopleDoc.FullName(0)
  47.        
  48.         Set NNPerson = New NotesName(strPerson)
  49.        
  50.         Set LicDoc = getDocumentByKey(NNPerson.canonical,"($LicUsers)",LicDb)
  51.         If LicDoc Is Nothing Then
  52.             strMissingPerson = strMissingPerson + NNPerson.abbreviated + "; "
  53.         End If
  54.        
  55.         Set NABPeopleDoc = NABView.Getnextdocument(NABPeopleDoc)
  56.     Wend
  57.    
  58.     msgbox "Missing Person are " + strMissingPerson
  59.    
  60. selesai:
  61.     Exit sub
  62.    
  63. End Sub
  64. Sub Terminate
  65.    
  66. End Sub
  67.  
  68. Function getDocumentByKey(strKey As String,strView As String, lookupdb As NotesDatabase) As NotesDocument
  69.     Set getDocumentByKey = Nothing
  70.    
  71.     Dim act As String
  72.     Dim errstr As String
  73.    
  74.     On Error GoTo errhandler
  75.    
  76.    
  77.     Dim viewLookup As NotesView
  78.     Dim viewLookupName As String
  79.     viewLookupName = strView
  80.     Set viewLookup = lookupdb.Getview(viewLookupName)
  81.    
  82.     If viewLookup Is Nothing Then
  83.         MsgBox "view " + strView + " not found!"
  84.         GoTo keluar
  85.     End If
  86.    
  87.     Dim lookupDoc As NotesDocument
  88.     Set lookupDoc = viewLookup.Getdocumentbykey(strKey,True)
  89.    
  90.     If lookupDoc Is Nothing Then
  91.         'is okay!
  92.         GoTo keluar
  93.     End If
  94.    
  95.     Set getDocumentByKey = lookupdoc
  96.        
  97. keluar:
  98.     Exit Function
  99.    
  100. errhandler:
  101.     errstr = "function getDocumentByKey error found ...."  & Str(Err) & ": " & Error$ + " at line " + CStr(Erl)
  102.    
  103.     Print errstr$
  104.     Resume Next
  105.    
  106.    
  107. End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement