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

Generating an excelsheet with POI…

It’s very easy for an lotusscript developer to generate an excel sheet with some OLE… but when the code should be run on the server it’s getting bad.

My last entry was about to pass a vector to the java API from lotusscript. Here some background to create the excel sheet with POI.

Of course you should customize this code to fit your solution. If it run on the server with a lot of instances, remember to do some stress tests to avoid some servers issues.

Greetings…

First get – POI Export with poi 3.2

http://www.criverapr.com/2008/10/using-poi-to-export-lotus-notes-data-to.html

Second – ls2j and dynamic array
http://www-10.lotus.com/ldd/nd6forum.nsf/c21908baf7e06eb085256a39006eae9f/45bc5292d67167508525706500525a52?OpenDocument

Dynamic arrays in lotusscript with ls2j

Last week, I was facing a tricky issue. I wanted to use some java to create an excel sheet. The POI java API requires a java vector. I created a dynamic array in lotusscript (to adjust the numbers of rows of my excel sheet) but when I called the POI API I’ve got an ugly error. The trick is to declare a variant, then affect the dynamic array to the variant and pass it to the JAVA API. So easy !

http://www-10.lotus.com/ldd/nd6forum.nsf/c21908baf7e06eb085256a39006eae9f/45bc5292d67167508525706500525a52?OpenDocument

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

Lotusscript geo-loc part II

* Remember my last post… opening the brower for the user with the map of the place diplayed in the notes document… I’m doing it better.
* You need to know that the in Switzerland there is a special way to record localisation. So you need some code to convert it in GPS to use them in Google.
* Here some links for you background :

‘ Some backgroup doc                 :        http://www.swisstopo.admin.ch/internet/swisstopo/fr/home/topics/survey.html
‘ Online source                        :         http://www.swisstopo.admin.ch/internet/swisstopo/fr/home/products/software/products/skripts.html
‘ Java project to convert         :         http://www.i3s.unice.fr/~johan/gps/
‘ Online convertor                         :         http://topo.epfl.ch/misc/transcoco/transcoco_compute.php
* Here the GoogleMapStreetUrl version 2.0

Class GoogleMapStreetUrl

 Private sUrl            As String
 Private sStreet         As String
 Private sCity                 As String

 Private sZoom                As String

 Private apiUrl                List As String

 Private x                        As Double
 Private y                        As Double

 Private lat                As Double
 Private lng                As Double

 Private sGeoCode        As String

 Sub new()
 sZoom = 13

 apiUrl("STREET") = "http://maps.google.com/maps?f=q&source=s_q&hl=fr&geocode=&q=%LOC%,%STREET%"
 apiUrl("GEOCODE") = "http://maps.google.com/maps?f=q&source=s_q&hl=fr&geocode=&q=&sll=%1&z=%2&saddr=%3"

 'sUrl = "http://maps.google.com/maps?f=q&source=s_q&hl=fr&geocode=&q=%LOC%,%STREET%"
 End Sub

 Public Function setZoom(sZ As Integer) As Integer
 sZoom = Cstr(sZ)
 End Function

 Public Function setStreet(psStreet As String) As Integer
 sUrl = apiUrl("STREET")
 sStreet = Replace(psStreet, " ", "+")
 End Function

 Public Function setCity(psCity As String) As Integer
 sUrl = apiUrl("STREET")
 sCity = Replace(psCity, " ", "+")
 End Function

 Public Function getUrl() As String
 Dim sNewUrl As String
 sNewUrl = Replace(sUrl, "%LOC%",sCity)
 sNewUrl = Replace(sNewUrl, "%STREET%",sStreet)
 sNewUrl = Replace(sNewUrl, "%1", sGeoCode)
 sNewUrl = Replace(sNewUrl, "%3", sGeoCode)
 sNewUrl = Replace(sNewUrl, "%2", sZoom)
 getUrl = sNewUrl
 End Function

 Public Function setLatLong(lng As Double, lat As Double) As Integer
 sUrl =apiUrl("GEOCODE")
 sGeoCode = Cstr(lat) + "," + Cstr(lng)
 End Function

 Public Function setCH1903_YX(y As Double, x As Double) As Integer
 sUrl =apiUrl("GEOCODE")
 Dim g As New CH1903toWGS84
 sGeoCode = g.getLatLong(y, x)
 End Function

 Public Function setLat(lat As Double) As Integer
 sUrl =apiUrl("GEOCODE")

 End Function

 Public Function open() As String
 Dim url As String
 url = Me.getUrl()
 Call ShellExecute ( GetActiveWindow(), "open", url, "", "", WIN_NORMAL)
 End Function

End Class

Public Class CH1903toWGS84

 '
 ' Class to convert CH1903 to WGS84
 ' Some backgroup doc                 :        http://www.swisstopo.admin.ch/internet/swisstopo/fr/home/topics/survey.html
 ' Online source                        :         http://www.swisstopo.admin.ch/internet/swisstopo/fr/home/products/software/products/skripts.html
 ' Java project to convert         :         http://www.i3s.unice.fr/~johan/gps/
 ' Online convertor                         :         http://topo.epfl.ch/misc/transcoco/transcoco_compute.php

 ' one sample
 '        CH1903        Y        537546
 '        CH1903        X        151681
 '
 ' --> gives
 '        WGS84        longitude        6.625644
 '         WGS84        latitude        46.514783

 Public Function getLatLong(y As Double, x As Double) As String
 Dim sTxt As String
 sTxt = Cstr(Me.CHtoWGSlat(y,x))
 sTxt = sTxt + "," + Cstr(Me.CHtoWGSlng(y,x))
 getLatLong = sTxt
 End Function

 Public Function CHtoWGSlat(y As Double, x As Double) As Double

 Dim  y_aux         As Double
 Dim  x_aux         As Double
 Dim         lat                 As Double

 y_aux = (y - 600000)/1000000
 x_aux = (x - 200000)/1000000

 lat = 16.9023892 +  3.238272 * x_aux -  0.270978 * (y_aux ^ 2) -  0.002528 * (x_aux ^ 2)        -  0.0447   * (y_aux ^ 2) * x_aux        -  0.0140   * (x_aux ^ 3)

 lat = lat * 100/36

 CHtoWGSlat = lat
 End Function

 Public Function CHtoWGSlng(y As Double, x As Double)  As Double
 Dim  y_aux         As Double
 Dim  x_aux         As Double
 Dim         lng                 As Double

 y_aux = (y - 600000)/1000000
 x_aux = (x - 200000)/1000000

 lng = 2.6779094 + 4.728982 * y_aux         + 0.791484 * y_aux * x_aux        + 0.1306   * y_aux * (x_aux ^ 2)
 lng = lng * 100/36
 CHtoWGSlng = lng
 End Function

End Class

Lotus script – GoogleMap localisation class

Hello, this simple class allows to display a google map from the lotus notes client ! There’s missing the Window’s API reference. Tell me if you want the lss file with all the references…

Greetings !

Class GoogleMapStreetUrl
Private sUrl As String
Private sStreet As String
Private sCity As String
Sub new()
End Sub
Public Function setStreet(psStreet As String) As Integer
sStreet = Replace(psStreet, ” “, “+”)
End Function
Public Function setCity(psCity As String) As Integer
sCity = Replace(psCity, ” “, “+”)
End Function
Public Function getUrl() As String
Dim sNewUrl As String
sNewUrl = Replace(sUrl, “%LOC%”,sCity)
sNewUrl = Replace(sNewUrl, “%STREET%”,sStreet)
getUrl = sNewUrl
End Function
Public Function open() As String
Dim url As String
url = Me.getUrl()
Call ShellExecute ( GetActiveWindow(), “open”, url, “”, “”, WIN_NORMAL)
End Function
End Class

Easy lotusscript picklist class for your apps…

When creating your application it’s always painful to remember how to generate a picklist… here comes in play my class (which is part of my own private framework).

Which 3 lines of code, I’m doing a picklist… let me explain…

Dim pl As New DbPickList(Nothing)
pl.setView("ClasseByName")
Set docRet = pl.getSingleDocument()

The first line allows you to create the picklist object which contain the notesuiworkspace object. The class contains member functions to set every parameter of the original picklist function. Defaults values are set when instantiating the object. There is two basic function to display the picklist 1. getSingleDocument() which return a simple document and getMultipleDocuments() which give you the notesdocumentcollection. Give a look to the class, it’s easy.

Link to the lss file

First download the .lss file and put everything in a script library. Then you should add the use statement.
The class allows you to customize easily the picklist but it is more convenient than the ugly function from the notesUiworkspace… give it a try and enjoy.

One cool thing is to derivate the class and then create all the picklist you need in a new class, then you’ve got centralized your picklists in a central class which allows to simplify the maintenance cycle of your app.

Greetings.