2012-10-25 5 views
0

내가 같은 내부 도메인 내에서 최근 연락처보기에서 중복 된 항목을 찾기위한 코드를 작성해야 볼 수 있습니다. 나는 외부 인터넷 접촉을 만지지 않을거야. 거기에 어떤 특별한 속성이나 방법 (연꽃 스크립트에서?) 서버 냅과 모든보기 항목을 비교하는 것이 좋은 생각입니까? 누구든지이 일을하는 가장 좋은 방법을 제안 할 수 있습니까? 내가 충분히 얻을 경우찾기 중복 연락처

답변

1

확실하지 당신이 필요하지만, 여기에 내가 제안 무엇 무엇

내가보기 (최근 연락처)를 통해 걸어 코드의 작은 무리를 작성하고 목록을 작성 만의 고유 거기에 넣어 제안

한 쌍의 키/의사와 다른 장소에 모든 사본을 저장하십시오.

당신은 코드 에이전트를 만들 수 있습니다

Dim session As New NotesSession 
Dim view As NotesView 
Dim doc As NotesDocument 
Dim uniquedocs List As Variant 
Dim duplicates As string 
Dim key As String 

Set view = session.Currentdatabase.Getview("(Recent Contacts)") 
Set doc = view.Getfirstdocument() 
While Not doc Is Nothing 
    ' this is the unique key, please change it if you need 
    key = doc.Getitemvalue("MailDomain")(0) 

    If key <> "" Then 
     If Not IsElement(uniquedocs(key)) Then 
      Set uniquedocs(key) = doc 
     Else 
      If duplicates <> "" Then duplicates = duplicates & " | " 
      duplicates = duplicates & key 
     End If 
    End If 

    Set doc = view.Getnextdocument(doc) 
Wend 

MsgBox duplicates 

중복 (I, 그래서 그냥 고유 키가 당신을 위해 무엇을 필드 정의, 잘못된 키를 사용할 수 있습니다,주의하시기 바랍니다 것은) - 모든 메일 문자열입니다 있는 MsgBox 오류() & ""& ERL() 종료 하위 끝 숨보기에 적어도 2 개 접점 (최근 연락처)

+0

명확하게 내 요구 사항을 말해 보겠습니다. 로컬 names.nsf에서 모든 항목을 가져와야합니다. 각 문서 (연락처)를 서버와 비교해야합니다. NAB, 존재하지 않는 경우 해당 연락처를 삭제해야합니다. 지역 NAMES.NSF – Mythli

+0

에서 문서는 내가 서버 NAB의 "사람"보기에서 전체 이름 값을 얻을 문자열 배열에 저장되며, 다음과 같이 먼저 코드를 시도했다. 이렇게하는 것이 가장 좋은 방법입니까? 는 내가 그렇게 난에서 제거 것이다 중복되는 false를 반환하는 경우 는 루프 내에서 내가 전체 이름 의 서버 배열 (최근 연락처보기에서) 전체 이름 각 연락처를 비교합니다, 지역 NAB에서 모든 항목을 얻을 것이다 로컬 nab. – Mythli

+0

예, 당신이 쓴 것은 옳습니다. 나는 당신이 쓴 것과 똑같이 할 것입니다. –

0
Sub Initialize 
On Error GoTo errHandler 

Dim session As New NotesSession 
Dim db As NotesDatabase 
Dim currdb As NotesDatabase 
Dim view As NotesView 
Dim view1 As NotesView 
Dim vc As NotesViewEntryCollection 
Dim namesentry As NotesViewEntry 
Dim serdoc As NotesDocument 
Dim localdoc As NotesDocument 
Dim item As NotesItem 


Dim dname As String 
Dim serverfullName() As String 
Dim localfulName As String 
Dim formula As String 
Dim result As Variant 
Dim count As Integer 

'Getting all the documents from servers NAB ,put that in document collection 
Set db=session.GetDatabase("Myserver","names.nsf") 
Set view=db.GetView("People") 
Set vc = view.AllEntries 
Set namesentry = vc.Getfirstentry() 
ReDim Serverfullname(CInt(vc.Count)) 
count = 0 

'storing fullnames in array 
While Not namesentry Is Nothing 

    Set serdoc = namesentry.Document 
    serverfullName(count) = serdoc.Getitemvalue("FullName")(0) 
    Set namesentry = vc.Getnextentry(namesentry) 
    count = count + 1 
Wend 
'keeping the string format for Comparison 
Dim x As String 
Dim iteration As Integer 
x = "" 
iteration = 0 
ForAll i In Serverfullname 
    iteration = iteration + 1 
    If i ="" Then 
    ElseIf count = iteration Then 
     x = x + |"| + i + |"| 
    Else 
     x = x + |"| + i + |"| + ":" 
    End If 
End ForAll 
'MsgBox x 'Displaying servers fullname list 

'Geetting local NAB contacts 
Set currdb= session.CurrentDatabase 
Dim selFormula As String 
'creating New view to filter documents with same domain 
selFormula= {SELECT @UpperCase($AutoCreatedList) = "DIP" & @LowerCase(MailDomain)[email protected]("mydomain")} 
Call currdb.Createview("RecentView",selFormula) 
Set view1 = currdb.GetView("RecentView") 
Set localdoc = view1.GetFirstDocument 


While Not localdoc Is Nothing 

    localfulName = localdoc.Getitemvalue("FullName")(0) 
    Dim indexresult As Variant 
    Dim Formula1 As String 

    Formula1 = |@Contains(| & x & |;"| + Localfulname + |")| 
    'MsgBox Formula1 
    indexresult = Evaluate(Formula1) 
    If indexresult(0)= 0 Then 

     MsgBox " Duplicate entry " & localfulname & "." 
     'Call localdoc.Remove(true) 
    End If 

    Set localdoc = view1.Getnextdocument(localdoc) 
Wend 
Exit sub 

errHandler이 도메인 b