Check if a OOO agent is activated on lotus notes databases…

This week I was asked to get all the activated out of office agent. I have activated the ooo agent on the server, so getting the info from the profile is not a solution.

If you launch your administrator client you could see that there is a column which indicates if the ooo is activated. This means that the property is set on the database file attribute.

 

 

Reading the web I found this post :

http://www-10.lotus.com/ldd/nd85forum.nsf/DateAllFlatWeb/37db9f50dc3f5515852576110067fb03?OpenDocument

So you can write this in a simple function :

Public Function isOOO(db as notesdatabase) As Integer
                On Error Goto errorHandler        
                If app.se.NotesBuildVersion < 379 Then
                        Call app.logError(“too old version 8.5x”)
                        Exit Function
                End If
                
                ‘ *** DBOPT_OUTOFOFFICEENABLED passed as a number to compile in R7 client
                If db.GetOption( 74 ) Then
                        isOOO = True
                Else
                        isOOO = False
                End If
                Exit Function
errorHandler:
                Dim sMsg As String
                sMsg =   Typename(Me) + “-” + Error + “-” +Cstr(Err()) & ” at line number ” & Erl() &  ” ” & Lsi_info(12) & ” ” & Lsi_info(2)
                Call app.logErrorExt(sMsg, Nothing)        
End Function

Agent to create a backup of you names.nsf weekly

As an administrator, I often need to put me back in time to check something on the domino infrastructure. My Domino Domain is very small so I can afford to make a backup of my names.nsf every week.

This class, creat a copy of each documents of the names.nsf, zip it and attach it to a document… enjoy !


import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;

import lotus.domino.*;
import java.io.*;
import java.util.zip.*;

/* -----------------------------------------------------------------------------------------------------------------------
* Class : JavaAgent
* Date : 12.01.2011
* Author : Pierre Koerber
* Desc. : Permet de faire un backup du PAB et de le zipper.
*/

public class JavaAgent extends AgentBase {

public void NotesMain() {

try {

Session session = getSession();
AgentContext agentContext = session.getAgentContext();

// get the curr db
Database curDb ;
curDb = agentContext.getCurrentDatabase() ;

// (Your code goes here)
Database db ;
db = session.getDatabase(curDb.getServer(), "names.nsf") ;

DateTime timenow = session.createDateTime("Today");
timenow.setNow();

String sName = new String("") ;
String sZipName = new String("") ;
sName = db.getFilePath() ;

System.out.println("OS current temporary directory is " + System.getProperty("java.io.tmpdir"));

sName = System.getProperty("java.io.tmpdir") ;
sName = sName + "names_backup_" + timenow.getDateOnly().replace('.', '_') + ".nsf";

sZipName = System.getProperty("java.io.tmpdir") ;
sZipName = sZipName + "names_backup_" + timenow.getDateOnly().replace('.', '_') + ".zip";

// copy the database
System.out.println("Create a copy of the names.nsf =" + db.getServer() + "-" + db.getFilePath()) ;

this.deleteIfExist(sName) ;
Database newDb ;
newDb = db.createCopy("", sName) ;

// copy all the documents
DocumentCollection dc ;
Document d ;

dc = db.getAllDocuments() ;
d = dc.getFirstDocument() ;

while(d != null){

// No deletion stubs...
if (d.isDeleted() == false){
d.copyToDatabase(newDb) ;
}
d = dc.getNextDocument() ;
}

// Compress the stuff
System.out.println("Compressing file from " + sName + " to " + sZipName) ;

// delete the files if exist
this.deleteIfExist(sZipName) ;

// compress the database
this.doZipExt(sName,sZipName) ;

// create a document and attach the backup
System.out.println("Attach everything to the archive document") ;
Document doc ;
doc = curDb.createDocument() ;

doc.replaceItemValue("backupName", "Sauvegarde names.nsf of " + db.getServer() + " - " + timenow.getDateOnly()) ;
doc.replaceItemValue("Subject", doc.getItemValueString("backupName")) ;
doc.replaceItemValue("backupDate", timenow) ;
doc.replaceItemValue("agentName", agentContext.getCurrentAgent().getName()) ;
doc.replaceItemValue("Form", "backup") ;

lotus.domino.RichTextItem rt = doc.createRichTextItem("Body") ;
rt.embedObject(EmbeddedObject.EMBED_ATTACHMENT,null, sZipName, "archive") ;

// Save the document
doc.save(true, true);

// delete the database
this.deleteIfExist(sName) ;
this.deleteIfExist(sZipName) ;
System.out.println("Done");

} catch(Exception e) {
e.printStackTrace();
}
}

public void deleteIfExist(String sName){
File f = new File(sName) ;
if (f.exists()) {
System.out.println("File : " + sName + " deleted");
f.delete() ;
}

}

public void doZipExt(String sFileName, String sZipFileName) throws IOException{
System.out.println("Creating zip file :" + sZipFileName) ;

File sourceFile = new File(sFileName) ;

// Create our zip file
ZipOutputStream zipfile = new ZipOutputStream(new FileOutputStream(sZipFileName));
FileInputStream filetozip = new FileInputStream(sFileName);
zipfile.putNextEntry(new ZipEntry(sourceFile.getName()));

// Loop through the contents writing it to the zip file output stream.
int len;
byte[] buffer = new byte[1024];

while ((len = filetozip.read(buffer)) > 0) {
zipfile.write(buffer,0,len);
}

// Close the entry and the current file.
zipfile.closeEntry();
filetozip.close();
// When done, close the zip file.
zipfile.close();
}

}

Lotus notes FT-Search, looking for non present field…

I wanted to do a lotusscript FT-search of the non existence of a field in documents… let’s begin some head aches… hopefully with google I found quickly a solution.

NOT [fieldname] is present

Thanks to Alan… here the full post :

http://www.alanlepofsky.net/alepofsky/alanblog.nsf/dx/searching-for-blank-fields?opendocument&comments

show nlcache reset – reset du names lookup domino

Hello, this comand will reset the domino names.nsf cache ! it will allow the user that you’ve just put in a group to have access to an app… be careful, this command has a significant cost on your server !

Greetings

Lotus Notes : simple soft delete form your application

Hi,

In our application it’s a common task to delete document but before granting the deletion, we want to be able to discard the modification…

Here the simpliest soft delete agent in your database, it juste rename the form name which should be enough in every lotus application.

FIELD Form := "DELETED_" + Form;
SELECT @All

Just put all this code in a lotus notes agent and you’re done !

Greetings.

How to import PNG images in Lotus Notes 6.x and 7.x

When trying to include png images, you will be stuck with these old clients… one simple workaround found on the www…

Lotus Notes does not support importing of PNG images into Rich Text by default but you can add that feature by adding the following line to your Notes Clients notes.ini file:

EDITIMP18=PNG Image,0,_IW4W,,.PNG,,8,

A remain of the past – the dusty console

After sometimes of laziness, (I’m too much playing with facebook and twitter) I’m back on my blog…

Which one of you is an old enough notes freak to remember the dusty old console which was the bread and butter of the dark age of the domino administration ? at this time to administrate a notes server you only need a strong knowledge of the domino directory and a simple console… old good times !

The old console remains in lotus notes today, and you can call it which a simple macro :

@Command([AdminRemoteConsole]) ;

Of course you need the rights to do it, it could be very useful when you are stuck with a “simple” notes client…

Install the domino server java console

For me the java console is a lost gem for the notes administrators.

It is a good feature because it allows to administrate all your server from one single point. It will run the console separatly from your notes client, and this is good because the admin client sucks ! it give you more but that’s not the subject of this post.

This article allows you to configure your Windows server to make it run.

First you should modify the start of your server to make it load the domino controller and the java console.

Take “the HKEY_LOCAL_MACHINE\System\CurrentControllSet\Services” key and look for the Lotus Domino key.  In there you will find an entry called ImagePath.  The add to the service’s parameter the -c to load the domino controler and the -jc if you want to load the java console the machine.

domino-server-registry

After that your server should start as in this picture :

domino-server-reg-edit

You could start the console from your notes client directory to have the same on you computer… nice isn’it.

Action to populate a custom user signature…

One big week for “myLife 2.0″

This was a great week for my blog. I’m not a regular blogger (it takes so much times) but this week I was referenced on the famous http://www.codestore.net… it has boosted my visits… that’s pretty cool.

eMail signature, 2 choices

What about the corporate signature. There is a lot of way to do it, since R7 you can customize it and manage it on the notes server… but if you want to allow your users to manage their signature this TIP is for you.

eMail signature, HTML or Text based ?

The next point is to know if you want a fancy and flashy HTML signature with pictures (hey, we’re living in the third millenium !). From my point of view, I prefer a text based signature, it’s simple, it works in all the case… so it’s profesionnal… the HTML is nice but it is impredictable to know how it will be seen on the user device (hey, users aren’t only reading their eMail on their computer…).

One dusty old script…

Going back my archives from the time when I was a full-time admin (one year ago) I found this little gems. So here one dusty old script from my archive… it was one of my first one I wrote when I began to administrate a domino domain.

The purpose of this script is to send a button to the users to let them edit their signature. This script composes a text user signature from the data in the nab (STEP 1, 2, 3). Then the script sends an eMail to the administrator to allow the tracking (STEP4) . Finally it presents the signature  to the user to allow to correct it. (STEP5)

You can put this script in a button (TEST it before and remove the steps you don’t need)

So, I hope it will help you to make your users happier !!!

Greetings

@REM “-STEP1-Parameters—————————–” ;
srv := “yourServerName” ;
db := “names.nsf”;

@REM “-Retrieve the user data in the nab-” ;
Line := “————————————————————————–” ;
Nom := @Name([CN] ; @UserName) ;
eMail := @DbLookup ( “” : “NoCache”;srv:db;”($Users)”;@UserName;”InternetAddress”) ;
fct := @DbLookup ( “” : “NoCache”;srv:db;”($Users)”;@UserName;”????”) ;
tele := @DbLookup ( “” : “NoCache”;srv:db;”($Users)”;@UserName;”Phone”) ;

@REM “-STEP2-ADDRESS LINES ——————————–” ;
Adresse1 := @If(@IsError(fct);”Function : ” ;fct) ;
Adresse2 := “Your company NAME”  ;
Adresse3 := “City number” ;
Adresse4 := “Tel. ++41(0)27.7.661.” + @If(@IsError(tele);”" ;tele) ;
Adresse5 := “Fax. ++41(0)27.7.661.485″ ;
Adresse6 := “EMail    : “  + @If(@IsError(eMail);”";eMail) ;
Adresse7 := “Internet : http://www.yourCompany.com” ;

@REM “-STEP3-Create the signature ——————————–” ;
Signature := @NewLine +  @NewLine + Line + @NewLine + Nom + @NewLine + Adresse1 + @NewLine + @NewLine + Adresse2 + @NewLine + Adresse3 + @NewLine + @NewLine + Adresse4 + @NewLine + Adresse5 + @NewLine +   @NewLine +  Adresse6 + @NewLine + Adresse7 + @NewLine +Line ;

@REM “-Set it to the user profile ——————————–” ;
@SetProfileField(“CalendarProfile” ; “EnableSignature” ; “1″) ;
@SetProfileField(“CalendarProfile” ; “SignatureOption” ; “1″) ;
@SetProfileField(“CalendarProfile” ; “Signature_1″ ; Signature) ;

@REM “-STEP4-Send an eMail to the admin to check follow-up purpose, could be a mailing db ——————————–” ;
@MailSend( “pierre koerber” ; “” ; “” ; “Mise à jour signature ” + @Name([CN] ; @UserName) ; “” ; “”) ;

@REM “-STEP5-Display the dialog to the user, to edit purpose ——————————–” ;
Texte :=”In the next windows, you could check the signature that will be added in your eMails.” + + @Char(13) + @Char(13) + “Cliquez sur l’onglet signature et contrôlez :” + @Char(13) + “1. La fonction” + @Char(13) + “2. Le no de FAX” + @Char(13) + “3. L’adresse eMail” ;
@Prompt([Ok];”Validation” ; Texte) ;
@Command([ToolsRunMacro];”(Preferences)”)

My favorite free apps under Windows…

Here my version 1.0 of my favorites windows applications… enjoy !

1. Development and source editing : Notespad ++

A powerfull text editor with multi-tab and add-on… try it, and rock your text editing…

2. JAVA IDE -> eclipse

The perfect JAVA editor and rich client plateform. It made me change my mind upon JAVA.

3. Image editing – the gimpShop

A free spin-off software from the Gimp… easier for time to time image editing.

4. Icon editing – free

This program is the perfect icon editor… great… and very useful.

5. PDF creator

Make your PC a real PDF engine… very good program, with command automation capabilities

6. Remote control – client and Server

If you don’t have windows XP pro or vista pro… you can install this to have a remote access on your machines… great stuff

7. FTP – client and server

The perfect FTP tool… could be easily integrated in a client or server solution.

8. Folder size

Something which seems missing in windows explorer… try it and stick to it…

Follow

Get every new post delivered to your Inbox.