我有一个从文本文件导入文档的代理。所以用户要求我在一个文件中记录导入,包括导入的时间、导入的文件数量、失败和原因。我有点明白它的逻辑的一部分,但我不知道使用什么方法。我使用了 NotesLog 类,但它不足以获取所需的信息。
这是我的代理的一部分:
Sub LoadAPMSSUBdoc(Rname As Variant, directory As Variant, Datef As Variant)
Dim session As New NotesSession
Dim Tdoc As NotesDocumentCollection
Dim dateTime As New NotesDateTime ("01/01/2000")
Dim GDate As Variant
Dim LocView As notesview
Dim LocDoc As notesdocument
Dim subsidiary As String
Print "Loading APMSSUB - Other Staff Information"
Set session = New NotesSession
Set cdb = session.CurrentDatabase
Set LocView = cdb.GetView("LsvLocationProfile")
Set LocDoc = LocView.getfirstdocument
StaffServerName = LocDoc.Z_ExtServer(0)
'SearchFormula$ = "Select Form = ""dfOther"" & @Date(s_Created) != @Date(@Today) "
If (upj = True) And (upg = True) Then
SearchFormula$ = "Select Form = ""dfOther"" "
ElseIf (ibmmy = True) Then
SearchFormula$ = "Select Form = ""dfOther"" & L_Employee = ""UPJ"" "
Else
SearchFormula$ = "Select Form = ""dfOther"" & L_Employee = ""UPG"" "
End If
Set Tdoc = cdb.Search( SearchFormula$, DateTime, 0 )
If Tdoc.Count <> 0 Then
Call Tdoc.RemoveAll(True)
End If
'Get an unused file number
file_no% = Freefile()
Open (Trim(directory + "apmssub.txt")) For Input As file_no%
Set db = Session.CurrentDatabase
Select Case Datef
Case "DMY" : Cdatf = "dd/mm/yyyy"
Case "MDY" : Cdatf = "mm/dd/yyyy"
Case "YMD" : Cdatf = "yyyy/mm/dd"
Case Else :
Print "LoadAPMSSUBdoc - Unknown system date format"
Exit Sub
End Select
Do While Not Eof(file_no%)
Line Input #file_no%, tmp
SerialNo = Trim$(Mid$(tmp,1,6))
Initial = Trim$(Mid$(tmp,239,3))
HQualification = Strconv(Trim$(Mid$(tmp,8,30)),3)
Major = Strconv(Trim$(Mid$(tmp,38,40)),3)
Inst = Strconv(Trim$(Mid$(tmp,78,50)),3)
If Trim$(Mid$(tmp,128,8)) = "" Then
GDate = Null
Else
GD1 = Setdate(Trim$(Mid$(tmp,128,8)), "mm/dd/yy", Datef)
GDate = Cdat(Format(GD1, Cdatf))
'Datenumber ( Val(Trim$(Mid$(tmp,134,2))) , Val(Trim$(Mid$(tmp,131,2))) , Val(Trim$(Mid$(tmp,128,2))) ))
'Print GDate
End If
OB = 0
For i = 4 To 0 Step -1
x1 = 137 + (i * 12)
x2 = 139 + (i * 12)
temp = Trim$(Mid$(tmp,x1,1))
If temp <> "" Then
Redim Preserve Prate(OB)
Redim Preserve Pdate(OB)
Prate(OB) = temp
PD1 = Setdate(Trim$(Mid$(tmp,x2,8)), "mm/dd/yy", Datef)
Pdate(OB) = Cdat(Format(PD1, Cdatf))
'Datenumber ( Val(Trim$(Mid$(tmp,x2+6,2))) , Val(Trim$(Mid$(tmp,x2+3,2))) , Val(Trim$(Mid$(tmp,x2,2))) ))
OB = OB + 1
End If
Next
If OB = 0 And Trim$(Mid$(tmp,185,1)) = "" Then
Redim Preserve Prate(OB)
Redim Preserve Pdate(OB)
Prate(0) = ""
Pdate(0) = Null
End If
AB = 0
For i = 0 To 3
x1 = 198 + (i * 10)
temp = Trim$(Mid$(tmp,x1,10))
If temp <> "" Then
Redim Preserve AAmt(AB)
AAmt(AB) = Val(temp)
AB = AB + 1
End If
Next
If AB = 0 And Trim$(Mid$(tmp,198,10)) = "" Then
Redim Preserve AAmt(AB)
AAmt(0) = Null
End If
subsidiary = Filter(CStr(SerialNo))
If (subsidiary = "UPJ" And upj = True) Or (subsidiary = "UPG" And upg = True) Then
Set doc = New NotesDocument(db)
doc.Form = "dfOther"
doc.L_Employee = subsidiary
doc.E_StaffSerialNo_1 = SerialNo
doc.E_PBCRating = Prate
doc.E_PBCDate = Pdate
doc.E_AdjAmt = AAmt
doc.E_HQualification = HQualification
doc.E_MajorSubject = Major
doc.E_InstituteName = Inst
doc.E_GraduateDate = GDate
doc.E_Initial = Initial
doc.s_created = Now
'doc.G_AuthorDisp = "Management SGP"
doc.G_AuthorDisp = Rname
Call doc.Save (True, True)
End If
Loop
Close file_no%
Print "Other information imported"
End Sub