문제

완전히 다른 프로그램을 위해 일부 자동화를 수행하는 C#을 사용하여 얼마 전에 프로그램을 만들었지 만 Lotus Notes 데이터베이스의 데이터에 액세스해야한다는 것을 알았습니다. 유일한 문제는 서버의 이름으로 데이터베이스를 열는 방법을 알아낼 수 있다는 것입니다 (session.getDatabase () 사용) ... Replica ID로 열리는 방법을 알 수 없습니다. 내가 어떻게 갈지 아는 사람이 있습니까? (서버가 변경 될 때마다 내 프로그램이 중단되는 것을 원하지 않습니다.)

public static string[] GetLotusNotesHelpTickets()
{
    NotesSession session = new NotesSession();
    session.Initialize(Password);
    // 85256B45:000EE057 = NTNOTES1A Server Replica ID
    NotesDatabase database = session.GetDatabase("NTNOTES1A", "is/gs/gshd.nsf", false);
    string SearchFormula = string.Concat("Form = \"Call Ticket\""
                                    , " & GroupAssignedTo = \"Business Systems\""
                                    , " & CallStatus = \"Open\"");
    NotesDocumentCollection collection = database.Search(SearchFormula, null, 0);
    NotesDocument document = collection.GetFirstDocument();
    string[] ticketList = new string[collection.Count];

    for (int i = 0; i < collection.Count; ++i)
    {
        ticketList[i] = ((object[])(document.GetItemValue("TicketNumber")))[0].ToString();
        document = collection.GetNextDocument(document);
    }

    document = null;
    collection = null;
    database = null;
    session = null;

    return ticketList;
}

이 코드는 정상적으로 작동하지만 서버가 ntnotes1a에서 변경되면 더 이상 아무것도 작동하지 않습니다.

도움이 되었습니까?

해결책

notesdbdirectory.opendatabasebyreplicaid (RID $) 메소드를 사용해야합니다. NotesDBDirectory를 얻으려면 세션의 getDBDirectory 메소드를 사용할 수 있습니다.

Set notesDbDirectory = notesSession.GetDbDirectory( serverName$ )

따라서 아래 코드를 사용하여 Replicaid의 데이터베이스를 얻을 수 있습니다.

public static string[] GetLotusNotesHelpTickets()
{
    NotesSession session = new NotesSession();
    session.Initialize(Password);

    Set notesDBDirectory = session.GetDbDirectory("NTNOTES1A")
    // 85256B45:000EE057 = NTNOTES1A Server Replica ID
    NotesDatabase database = notesDBDirectory.OpenDatabaseByReplicaID("85256B45:000EE057")
    string SearchFormula = string.Concat("Form = \"Call Ticket\""
                                    , " & GroupAssignedTo = \"Business Systems\""
                                    , " & CallStatus = \"Open\"");
    NotesDocumentCollection collection = database.Search(SearchFormula, null, 0);
    NotesDocument document = collection.GetFirstDocument();
    string[] ticketList = new string[collection.Count];

    for (int i = 0; i < collection.Count; ++i)
    {
        ticketList[i] = ((object[])(document.GetItemValue("TicketNumber")))[0].ToString();
        document = collection.GetNextDocument(document);
    }

    document = null;
    collection = null;
    database = null;
    session = null;

    return ticketList;
}

불행히도 이것은 문제의 절반 만 해결합니다. DBLINK 또는 북마크를 클릭 할 때 클라이언트가하는 것과 마찬가지로 클라이언트와 가장 가까운 서버의 특정 ReplicAid로 데이터베이스를 가져 오기 위해 메모를 알려주고 싶습니다. 그러나 Notes API를 사용하여 그렇게 할 수있는 방법이 없습니다.

내 제안은 이름으로 하드 코딩 된 잠재적 인 서버 목록을 통과하고 데이터베이스가 발견되었는지 확인하는 것입니다 (데이터베이스를 찾을 수없는 경우 OpenDatabaseByreplicaid 메소드가 ERR_SYS_FILE_NOT_FOUND (ERROR 0FA3)를 반환합니다). 이것이 좋은 옵션이 아닌 경우, 앱의 관리자 메뉴에서 서버 이름을 쉽게 노출시켜 서버 이름이 어느 시점에서 변경되면 쉽게 변경할 수 있습니다.

다른 팁

SET DATABASE = NEW NOTESDATABASE ( "") CALL DATABASE.OPENBYREPLICAID ( "Repid")

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top