Processing ....
|
void SharedEmailDB::signNote(bool switchId) { // Sign the note (Agent)
LNAgent agent;
if (!isValid() ) {
if(!noteToSign.length())
throw ( "SharedEmailDB::signNote(): the note to be signed cannot
be empty." );
if( !dbFileName.length())
throw ( "SharedEmailDB::signNote(): the database cannot be empty." );
if( !templateName.length())
throw ( "SharedEmailDB::signNote(): the templateName cannot be empty." );
}
if (configuration.length() && switchId) {
NotesConnect * connection = getConnection();
if ( connection )
connection->switchID( configuration );
else
init(dbFileName, dbServer, configuration);
} else if (!getDatabase()->IsOpen() )
init();
*outLogger << "Opening Agent for signing..." << endl;
if (getDatabase()->GetAgent(noteToSign.c_str(), &agent))
throw ( "SharedEmailDB::signNote(): the note to be signed is not a
valid agent in %.", dbFileName.c_str() );
agent.Open();
if(!agent.IsOpen())
throw ( "SharedEmailDB::isOpen(): the note to be signed did not
successfully open: %s in: %s.", noteToSign.c_str(), dbFileName.c_str()
);
*outLogger << noteToSign << " is open. Deactivating..." << endl;
if(agent.SetIsEnabled(FALSE))
throw ( "SharedEmailDB::setIsEnabled(false): the note to be
in-activated did not successfully in-activate: %s in: %s.",
noteToSign.c_str(), dbFileName.c_str() );
*outLogger << noteToSign << " is deactive. Signing..." << endl;
if(agent.SetAllowPublicAccessUsers( FALSE ))
throw ( "SharedEmailDB::SetAllowPublicAccessUsers( LNBOOL flag ):
the note to be public did not successfully switch: %s in: %s.",
noteToSign.c_str(), dbFileName.c_str() );
*outLogger << noteToSign << " is public. Scheduling..." << endl;
if(agent.SetHoursAndMinutes(0, 5))
throw ( "SharedEmailDB::SetHoursAndMinutes(LNINT hours, LNINT
minutes): the note to be scheduled did not successfully schedule: %s
in: %s.", noteToSign.c_str(), dbFileName.c_str() );
*outLogger << noteToSign << " is Scheduled. Setting Document
Options..." << endl;
// Set one of the two available documents option
if(agent.SetAgentDocumentsOption (LNAGENTDOCUMENTSOPTION_ALL_IN_DB))
throw ( "SharedEmailDB::SetAgentDocumentsOption
(LNAGENTDOCUMENTSOPTION_ALL_IN_DB): the note to set documents not
successfully set: %s in: %s.", noteToSign.c_str(), dbFileName.c_str()
);
*outLogger << noteToSign << " has the agent document options set.
Setting start hour..." << endl;
if(agent.SetStartHour ( 1 ))
throw ( "SharedEmailDB::SetStartHour ( 1 ): the note to set start
hour not successfully set: %s in: %s.", noteToSign.c_str(),
dbFileName.c_str() );
*outLogger << noteToSign << " has the agent start hour set.
Scheduling..." << endl;
if(agent.SetAgentSchedule(LNAGENTSCHEDULE_EVERY_N_HOURS_AND_MINUTES))
throw ( "SharedEmailDB::SetAgentSchedule(LNAGENTSCHEDULE_EVERY_N_HOURS_AND_MINUTES):
the note to be schedule did not successfully schedule: %s in: %s.",
noteToSign.c_str(), dbFileName.c_str() );
*outLogger << noteToSign << "Signing ..." << endl;
if(agent.Sign())
throw ( "SharedEmailDB::signNote(): the note to be signed did not
successfully sign: %s in: %s.", noteToSign.c_str(), dbFileName.c_str()
);
*outLogger << noteToSign << " is signed. Activating ..." << endl;
// if(agent.SetRunAsWebUser(false))
// throw ( "SharedEmailDB::SetRunAsWebUser(false): the note to be
schedule do not run as webuser has failed to set: %s in: %s.",
noteToSign.c_str(), dbFileName.c_str() );
// *outLogger << noteToSign << " not running as webuser..." << endl;
if(agent.SetIsEnabled(TRUE))
throw ( "SharedEmailDB::setIsEnabled(true): the note to be
activated did not successfully activate: %s in: %s.",
noteToSign.c_str(), dbFileName.c_str() );
*outLogger << noteToSign << " is active. Setting Server..." << endl;
// LNString serverName = agent.GetServerName();
// if(agent.SetServerName( serverName ))
// throw ( "SharedEmailDB::SetServerName( &serverName ): the note
to have servername set did not successfully set: %s in: %s.",
noteToSign.c_str(), dbFileName.c_str() );
// *outLogger << noteToSign << " has the servername set. Saving..." << endl;
if(agent.Save())
throw ( "SharedEmailDB::signNote(): the note to be signed did not
sussessfully save: %s in: %s.", noteToSign.c_str(), dbFileName.c_str()
);
*outLogger << noteToSign << " saved. Executing." << endl;
/*************************************************************************
**** tried this to see if it would start working after executed. ****
// agent.Execute();
**************************************************************************/
agent.Close();
return;
}
|
|
 | |
|