[LotusScript] 簽認資料庫

withwangzhen發表於2011-06-21

1  代理   DB簽認
Sub Initialize
 
 
 On Error Goto ErrHandler
 Dim systemview As NotesView
 Dim systemdoc As NotesDocument
 Set s = New NotesSession
 Set db=s.CurrentDatabase
 Dim SearchFormula As String
 
 totalnum=0
 RefreshInfo=""
 theInstantV = Now
 Set EmpDB=s.getdatabase(db.Server,"SYSTEM\\UGOP.nsf")
 Set EmpOldView= EmpDB.GetView("(ByOldEName)")
 
 Set DBView = db.getView("Vw_APList")
 Set DBDC = DBView.AllEntries
 Set DBDE= DBDC.GetFirstEntry( )
 While Not(DBDE Is Nothing)
  Set DBDoc = DBDE.Document
  Set refreshDB = s.GetDatabase(DBDoc.ServerIp(0),DBDoc.ApPath(0))
  serverName = DBDoc.ServerName(0)
  apNames = apNames +serverName
  Call refreshDB.sign(DBSIGN_DOC_ALL)
  Call DBDoc.replaceitemvalue("phase2","Y")
  Call DBDoc.Save(True,False) 
  Set DBDE= DBDC.GetNextEntry(DBDE)
  Print totalnum
  totalnum = totalnum + 1
 Wend
 Messagebox Cstr(totalnum)
 '錯誤處理
 
 Set mdoc=db.createdocument
 Set rtitem=New notesrichtextitem(mdoc,"Body")
 mdoc.Form="memo"
 Dim adminmail(0)
 adminmail(0) ="With Wang/CN/CMINL@CMINL"
 mdoc.sendto=adminmail
 mdoc.subject=Cstr(Today)+" Domain Change Phase(SignACL)"+"For ALL"
 ErrorMsg = apNames +" OK !"+ ErrorMsg
 ErrorMsg="執行時間 From:"+ theInstantV+Chr(13)+ErrorMsg
 ErrorMsg="執行時間 To:"+ Cstr(Now)+Chr(13)+ErrorMsg
 ErrorMsg="已更新DB :"+Chr(13)+ErrorMsg
 ErrorMsg="已處理"+Cstr(totalnum)+"筆資料"+Chr(13)+ErrorMsg
 Call rtitem.AppendText( ErrorMsg )
 Call rtitem.AddNewline(3)
 Call rtitem.AppendText(RefreshInfo)
 mdoc.send(True)
 
 Print "更新Acl結束~!"
 Exit Sub
 
ErrHandler:
 ErrorMsg=ErrorMsg+Chr(13)+serverName+ "[Error #" & Cstr(Err) & "]: " + Error$ + Cstr(Erl())
 Resume Next
End Sub

2  Function UserNames
Function UserNames (Action As String, Username As Variant) As String
 Dim InputName As New NotesNAME(Username) 
 Action=Ucase(Action)
 Select Case Action
 Case "[CANONICAL]"
  UserNames=InputName.Canonical
 Case "[ABBREVIATE]"
  UserNames=InputName.Abbreviated
 Case "[CN]"
  UserNames=InputName.Common
 Case "[C]"
  UserNames=InputName.Country
 Case "[OU1]"
  UserNames=InputName.OrgUnit1
 Case "[OU2]"
  UserNames=InputName.OrgUnit2
 Case "[OU3]"
  UserNames=InputName.OrgUnit3
 Case "[O]"
  UserNames=InputName.Organization
 Case Else
  UserNames=InputName.Canonical
 End Select   
End Function

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/24998103/viewspace-700381/,如需轉載,請註明出處,否則將追究法律責任。

相關文章