Domino 9 und frühere Versionen > ND6: Administration & Userprobleme
Catchall Funktion benötigt
Zackmuc:
Danke für die zahlreichen Antworten und die flotte Hilfe :)
eknori:
die Frage ist ja, wie man die aufgelaufenen Dokumente bearbeitet. Macht man das in der mail.box, oder schaufelt man die fraglichen docs in eine zentrale DB ?
Gerade bei multiplen mailbox(es) wird die Frage interessant.
Mögen mich ein paar Leute jetzt verfluchen, ich poste jetzt einfach mal den CPP Code, der documents on hold in eine zentrale DB moved; dabei ist auch die Verwendung mehrerer mail.box(es) berücksichtigt.
Das ist jetzt hier keine Komplettlösung und die Algorithmen sind kein Geheimnis; schaut es euch an, ich werde keine Fragen zur Erstellung einer Komplettlösung hier beantworten. Auch nicht, wie die Zieldatenbank aussieht; das steht im Code!
Das Ganze kann man übrigens auch mit einem LS Agent machen. Das Handling der Docs bleibt euch überlassen; sind sie denn erst einmal in der DB
ach ja, bitte den Code nicht verwenden, ohne mich vorher gefragt zu haben ;D
//===========================================================================
// ADDIN: CATCHALL.CPP
//
// Description: move all documents from all used mail.box(es) to a database argv[1]
//
// SYNTAX: (at the Lotus server console) > load ncall <database.nsf> [Interval]
//
//===========================================================================
#define ERR_BUF_SIZE 512
#define MAX_INTERVAL 24*60
#define MIN_INTERVAL 1
#define DEFAULT_INTERVAL 60
#define THE_ADDIN_NAME "CATCHALL"
#define THE_ADDIN_VERSION " Ver.0.01"
#define THE_ADDIN_COPYRIGHT " (c) 2005, Heinz Ulrich Krause"
#define ADDIN_IDLE "Idle"
#define ADDIN_CONFIG "Reading configuration document"
#define ADDIN_MOVE "Moving documents"
#include <lncppapi.h>
#include "iostream"
#ifdef UNIX
#include <ctype.h>
#endif
int main (int argc, char *argv[] )
{
LNNotesSession s;
LNServerAddin addin;
LNDatabase mailDB, workDB;
LNString buffer, DbTitle, theBoxes, SearchFormula;
LNMessageQueue mqueue;
LNINT interval, i, k, m;
LNSTATUS error;
LNDocumentArray col;
/* Make the error handler throw all errors encountered during execution.*/
LNSetThrowAllErrors(TRUE);
try {
/* Initialize the C++ API Note: We need to do this before we process input parameters
because we are using the LNString class for inputs*/
s.Init(argc, argv);
/* Get ServerName */
char szServer[MAXUSERNAME+1];
error = SECKFMGetUserName (szServer);
interval = DEFAULT_INTERVAL; /* DEFAULT Addin interval 60 minutes */
if (argv[2]) /* overwrites DEFAULT Interval */
{
LNNumber newInterval = argv[2];
LNINT newInt = newInterval.GetValue();
if (newInt > MAX_INTERVAL)
{ /* OK, letz do it only once a day */
interval = MAX_INTERVAL;
}
else if (newInt == 0)
{ /* for those morons setting interval to ZERO */
interval = MIN_INTERVAL;
}
else
{ /* for those who know what they are doing */
interval = newInt;
}
}
/* Create a server add-in task with default status line.*/
s.GetServerAddin (THE_ADDIN_NAME, ADDIN_IDLE, &addin );
buffer = THE_ADDIN_NAME;
buffer += THE_ADDIN_VERSION;
buffer += THE_ADDIN_COPYRIGHT;
addin.AppendLogMessage(buffer);
buffer ="";
buffer = "Interval: ";
buffer += interval;
buffer += " minute(s)";
addin.AppendLogMessage( buffer); /* print interval minute(s) */
buffer ="";
buffer = TASK_QUEUE_PREFIX;
buffer += THE_ADDIN_NAME;
s.CreateMessageQueue( buffer, &mqueue); /* Create a message queue */
buffer ="";
/* Begin the addin task main processing loop. The call to addin.Idle() serves two functions.
First it relinquishes processor control to Domino allowing other tasks to run.
Secondly, addin.Idle() will return TRUE, when it has received a quit command from Domino meaning
a user has typed "tell myaddin quit" at the server console.*/
while (!addin.Idle()) /* main addin loop */
{
/* Do the operations that we do depending on interval */
if (addin.HaveMinutesElapsed (interval))
{
addin.SetDefaultStatusLineText(ADDIN_CONFIG);
/* first argument represents the configuration database;
Let's try to open the db */
LNString DatabasePathCatchAllDB;
DatabasePathCatchAllDB = argv[1];
s.GetDatabase( DatabasePathCatchAllDB, &workDB, szServer);
workDB.Open();
/* Find setup document*/
LNSearchOptions o;
o.SetNoteType (LNNOTETYPE_DOCUMENT);
o.SetBeginDate ("01/01/2005");
o.SetEndDate (s.GetCurrentDatetime());
workDB.Search ("Form=\"Setup\"", &col, &o);
LNDocument setupDoc = col[0];
setupDoc.Open();
LNText mboxes; /* get name of mailboxes, if multiple */
if (setupDoc.HasItem ("mailboxes"))
{ /* does item exist ? */
setupDoc.GetItem("mailboxes", &mboxes);
}
for (m=0; m<mboxes.GetCount(); m++)
{ /* for all mailboxes do ... */
s.GetDatabase(mboxes[m], &mailDB, szServer);
mailDB.Open(); /* open 'mail.box' */
/* Set options for db.Search */
o.SetNoteType (LNNOTETYPE_DOCUMENT);
o.SetBeginDate ("01/01/2005");
o.SetEndDate (s.GetCurrentDatetime());
/* Search for all docs im mail.box with routingState = 'HOLD' */
mailDB.Search ("RoutingState=\"HOLD\"", &col, &o);
k = col.GetCount();
if (!k == 0) /* is there something to do ?? */
{
buffer = THE_ADDIN_NAME;
buffer += ": ";
buffer += k;
buffer += " held documents found in ";
buffer += mailDB.GetTitle();
addin.AppendLogMessage( buffer); /* print number of docs found */
buffer ="";
s.GetDatabase(DatabasePathCatchAllDB, &workDB, szServer);
workDB.Open(); /* Zieldatenbank öffnen */
/* Iterate through the col moving each of the documents found
into the destination database. */
LNDocument Doc;
LNDocument NewDoc;
addin.SetDefaultStatusLineText(ADDIN_MOVE);
for (i = 0; i < k; i++)
{
Doc = col; /* Get the next document.*/
Doc.Open(); /* Open it.*/
workDB.CreateDocument(Doc, &NewDoc); /* Make an in-memory copy of it in the destination database.*/
NewDoc.Save(); /* Save the copy.*/
NewDoc.Close(); /* Close the copy.*/
Doc.Close(); /* Close the document.*/
error = mailDB.DeleteDocument(&Doc);/* Delete the document.*/
}
}
mailDB.Close(); /* close 'mail.box' */
}
setupDoc.Close();
workDB.Close(); /* close 'workDB' */
addin.SetDefaultStatusLineText(ADDIN_IDLE);
}
}
}
catch (LNSTATUS error) /* errorhandling */
{
char ErrorBuf[ERR_BUF_SIZE];
LNGetErrorMessage(error, ErrorBuf, ERR_BUF_SIZE);
addin.AppendLogMessage(ErrorBuf);
}
/* terminating */
buffer = THE_ADDIN_NAME;
buffer += ": Termination complete.";
addin.AppendLogMessage(buffer);
buffer ="";
s.Term(); /* Clean up and exit because we're done. */
return 0; /* Adios amigo! */
}
Manfred Dillmann:
Hi Ulrich,
das ist ja klasse. Und wie man sieht, ist sowas in CPP viel einfacher als in Java. Ich lasse das jetzt mit Java sein - darf ich also Deinen Code verwenden?
War nur ein Spass... ;D
Gruss
Manfred
eknori:
sollte eigentlich eine Aufforderung an dich sein, dass in Java umzusetzten. Die Struktur müsste eigentlich deckungsgleich sein... ;)
Und wg. verwenden; klar !!
Marinero Atlántico:
schüchterne Anfrage:
ist das aus der Notes C++ Doku?
Wenn ja. Wo gibt es die?
ist das normal, dass da main-Methoden so lang sind :'(
In Java wäre die Main Methode wesentlich kürzer :-*
Man würde den code zumindest auf ein paar private Methoden verteilen.
was für Barbaren
Navigation
[0] Themen-Index
[#] Nächste Seite
[*] Vorherige Sete
Zur normalen Ansicht wechseln