Lotus Domino:创建导入日志 [英] Lotus Domino: Create import log

查看:88
本文介绍了Lotus Domino:创建导入日志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个数据库:一个数据库保存员工的摘要信息,另一个数据库保存员工的序列号.在database1上,我具有此代理,可让您导入包含员工更新记录的文本文件.但是,为了使该代理成功导入文本文件记录,要导入的文本文件必须具有与数据库2相同的序列号记录.顺便说一句,但是导入时我需要创建一个日志,但是仍然不知道如何解决这个问题.必须在字段上查看日志(导入的日期,导入的成功和失败文件).你能帮我吗?这是我的代码:

I have two databases: one holds the employee summary info, and the other one holds the serial number of the employee. On the database1, I have this agent that lets you import text file which contains updated records of the employee. But, In order for this agent to import a text file records successfully, the text file to be import must have a serial number record same as on the database2. It's working by the way, but I need to create a log when importing, still got no idea on how to resolve this. The logs(date imported, success and fail file imported) must be viewed on the fields. Can you help me out? Here's my code:

LoadAPMSAWDdoc

LoadAPMSAWDdoc

Sub LoadAPMSAWDdoc(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")
'12/20/2005
Dim LocView As notesview
Dim LocDoc As NotesDocument
Dim subsidiary As String
Print "Loading APMSAWD - Award Information"

Set cdb = Session.CurrentDatabase
'12/20/2005
'StaffServerName = cdb.Server 
Set LocView = cdb.GetView("LsvLocationProfile")
'02/07/2006
'Set LocDoc = LocView.getdocumentbykey(cdb.Server)
Set LocDoc = LocView.getfirstdocument
StaffServerName = LocDoc.z_ExtServer(0)

 'SearchFormula$ = "Select Form = ""dfAward""  & @Date(s_Created) != @Date(@Today) "


If (ibmmy = True) And (ibmgdc = True) Then
SearchFormula$ = "Select Form = ""dfAward""  "
ElseIf  (ibmmy = True) Then 
SearchFormula$ = "Select Form = ""dfAward"" & I_GDCEmployee = ""IBM MY""" 
Else 
SearchFormula$ = "Select Form = ""dfAward"" & I_GDCEmployee = ""IBM GDC""" 
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 + "apmsawd.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 "LoadAPMSAWDdoc - 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))

    AB = 0
    For i = 29 To 0 Step -1               
        x1 = 8 + (i * 50)
        x2 = 11 + (i * 50)
        x3 = 41 + (i * 50)
        x4 = 49 + (i * 50)

        temp = Strconv(Trim$(Mid$(tmp,x2,30)),3)
        If temp <> "" Then
            Redim Preserve ACode(AB)
            Redim Preserve ADes(AB)
            Redim Preserve ADate(AB)
            Redim Preserve AAmt(AB)
            Acode(AB) = Trim$(Mid$(tmp,x1,3))
            ADes(AB) = temp
            If Trim$(Mid$(tmp,x3,8)) <> "" Then
                AD1 = Setdate(Trim$(Mid$(tmp,x3,8)), "mm/dd/yy", Datef)               
                ADate(AB) = Cdat(Format(AD1, Cdatf))
                     'Datenumber ( Val(Trim$(Mid$(tmp,x3+6,2))) , Val(Trim$(Mid$(tmp,x3+3,2))) , Val(Trim$(Mid$(tmp,x3,2))) )
            Else
                ADate(AB) = Null
            End If
            AAmt(AB) = Val(Trim$(Mid$(tmp,x4,9)))
            AB = AB + 1
        Else 
            Exit For
        End If
    Next

    subsidiary = Filter(CStr(SerialNo))
    If (subsidiary = "AMY" And ammmy = True) Or (subsidiary  = "ADC" And aaadc = True) Then

    Set doc = New NotesDocument(db)
    doc.Form = "dfAward"
    doc.E_StaffSerialNo = SerialNo
    doc.I_GDCEmployee = subsidiary
    If AB = 0 And Trim$(Mid$(tmp,1461,30))  = "" Then
        Redim Preserve ACode(AB)
        Redim Preserve ADes(AB)
        Redim Preserve ADate(AB)
        Redim Preserve AAmt(AB)
        ACode(0) = ""
        ADes(0) = ""
        ADate(0) = Null
        AAmt(0) = Null
    End If
    doc.E_AwardType = ADes
    doc.E_AwardDate = ADate
    doc.E_AwardAmt = AAmt
    doc.G_AuthorDisp = Rname
    doc.s_created = Now
    Call doc.Save (True, True)

    End If
Loop

Close file_no% 
Print "Award information imported"

End Sub

对不起,如果我只发布了一些函数,因为我的代码太长,无法在此处容纳.

I'm sorry if I only posted some functions coz my code is too long and can't fit here.

推荐答案

首先:完全删除符合搜索条件的所有文档,然后直接将它们重新添加,这是非常糟糕的做法.

First of all: It is VERY bad practice, to permanently delete all documents that match a search criteria just to directly afterwards add them back.

删除存根将爆炸,并且该数据库将变得越来越慢,并且在某些时候将不再可用.

Deletion stubs will explode and this database will become slower and slower and at some point will not be usable anymore.

更好地构建用于标识文档的密钥,使用该密钥获取文档,然后在必要时进行更新...

Better build a key to identify the document, get the document using the key and then update if necessary...

我通常会建立一个包含所有键/unid(或文档,如果没有太多的话)的列表,并在处理后从该列表中删除在源"(在您的情况下为文本文档)中找到的任何文档.

I usually build a list with all keys / unids (or documents, if there are not to much of them) and remove any document found in the "source" (text document in your case) from that list after processing.

运行完导入文件后,列表中剩下的任何文档都可以删除...

Any document left in the list after running through the import file can be deleted...

Dim lstrUnids List as String

Set doc = Tdoc.GetFirstDocument()
While not doc is Nothing
    lstrUnids( doc.E_StaffSerialNo(0) ) = doc.UniversalID
    set doc = TDoc.GetNextDocument(doc)
Wend

但是现在回到您的问题:

But now back to your Question:

要编写简单的日志,可以使用NotesLogClass.您可以登录到数据库(模板:Agent Log),登录到邮件或登录到Agents日志(读取复杂)甚至文件.

To write a simple Log you can use the NotesLog- Class. You can either log to a database (Template: Agent Log ), log to a mail or log to the Agents log (complicated to read) or even to a file.

只需这样做:

Dim agLog as New NotesLog( "MyImportLog" )
Call agLog.OpenNotesLog( Server , logdbPath )
...
Call agLog.LogMessage( "Award information imported" )
...
Call agLog.Close() 'IMPORTANT !!!!

这篇关于Lotus Domino:创建导入日志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆