2006-06-23

Windows (XP): Remove or delete a service

To remove a service on windows XP, use the following command:


sc delete "<service name>"

2006-06-06

Notes: How to access .Net classes from LotusScript

IBM Technote: How to access .Net classes from LotusScript

Problem
You have created an object using Microsoft .Net and would like to create and use this object within LotusScript. How can this be done?
 
Solution
To create a .Net DLL that is accessible from LotusScript perform the following steps:

1. Create a C# Class Library Project with the following code:

using System;

public class MyTest
{
public string AppendStr(string s)
{
return s + " from inside the DLL";
}
}

Note: A Visual Basic Class Library could also be created.

2. To access this DLL from anywhere on the machine you will also need to create this DLL as a shared assembly and publish the your DLL to the Global Assembly Cache (GAC). Otherwise, the DLL will be created as a private assembly and you will only be able to create the object if the DLL is in the same directory as the calling program.

      To create this DLL as a shared assembly you will need to generate a cryptographically strong name for the assembly. To do this start up the Visual Studio Command Line prompt, and enter the following command:

      sn -k c:\MyTest.snk

      This will create an Assembly Key File name at the location c:\MyTest.snk


3. Open the AssemblyInfo.cs file of the project include the following line:

      [assembly: AssemblyKeyFile(@"c:\\MyTest.snk")]

      Note: For Visual Basic you will need to include this tag instead: <assembly: AssemblyKeyFile(@"c:\\MyTest.snk")>


4. Build the project. This will build the project with the value of the Assembly Key File and allow it to be published as a Shared Assembly to the Global Assembly Cache.

5. Using the Visual Studio Command Line, change to the directory where the DLL was generated, then publish the DLL to the Global Assembly Cache using the following command:

      GacUtil /i MyTest.dll


6. To make the objects in this DLL accessible via the COM interface, enter the following command:

      regasm MyTest.dll


7. To access the object contained in this DLL using LotusScript use the following code:

      Dim obj As Variant
      set obj = CreateObject("MyTest")
      MsgBox obj.AppendStr("This is")

      The message box will display "This is from inside the DLL."


In short, once the shared assembly is published as a COM component, it can be instantiated in LotusScript using the CreateObject() function. With the exception of Step 7, all of the steps are all specific to the deployment process of Microsoft .Net components. For further information regarding any of these utilities you should refer to the Microsoft web site or Microsoft support.

2006-05-11

Notes: After logout, authentication is no longer possible

Symptoms:

User presses the login button/link, inserts username and password and gets authenticated. Later he presses the logout button/link, and he is successfully logged out. If he tries to login again, he's unable to because the authentication form is never presented again (unless he closes the browser window and re-opens it).


Possible Solution:

In case the login link is like this:

top.location.href = "/database_path?OpenDatabase&Login">

change it to:

top.location.href = "/database_path?Login&redirectTo=database_path?OpenDatabase">

2006-05-10

Domino: Session Authentication via Lotus Script

Or how to login on the web via a notes agent:

Print "<HTML>"
Print "<BODY TEXT=""FFFFFF"" BGCOLOR=""FFFFFF"" onLoad=""document.forms[0].submit()"">"
Print "<FORM METHOD=post ACTION=""/names.nsf?Login"" NAME=""_AlfaLogin"">"
Print "<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.0//EN"">"
Print "<HTML>"
Print "<INPUT NAME=""Username"" VALUE=""" + sUsername + """ TYPE=hidden maxlength=256>"
Print "<INPUT NAME=""Password"" VALUE=""" + sPassword + """ TYPE=hidden maxlength=500>"
Print "<INPUT NAME=""RedirectTo"" VALUE=" + sRedirectTo + " type=hidden>"
Print "</HTML>"
Print "</FORM>"
Print "</BODY>"
Print "</HTML>"

2006-05-09

Notes: View doesn't refresh

Symptoms:
  • permanently shows the Refresh Icon
  • the "NoCache" parameter on the dblookup "doesn't work"
  • the view.Refresh statement doesn't refresh the view

Problem:

The view probably uses @Now or @Today formulas in the Selection Formula or in a column, which prevents the view's index to be updated (it's always out-of-date as these formulas force the calculation to go to the minute:second detail).


Solution:

Use this formula instead: @TextToTime("Today") - it calculates only to the year-month-day so that the index only updates once a day.

2006-04-28

Notes client: action bar properties are not rendered in the client

If the display border property of a view or form action bar is set to Always but it doesn't show when viewed in the client, check under File -> Preferences -> User Preferences -> Additional Options and make sure the option "Standard dialog boxes" is not checked.

Windows: Usb Hub is not recognized ("Unknown device")

If Windows XP does not recognize a Usb hub, and categorizes it as an "Unknown Device" even after updating the drivers, unplug the electrical cord from the hub and try again.

2006-04-06

Notes: Bubble Sorting a Document Collection

«Searching a database using db.ftsearch is pretty fast and efficient but ordering based on a field value in the documents is not possible. What is required is something akin to a SQL ORDER BY clause but alas we don't have one and have to resort to sorting the collection the old fashioned way... by implementing a bubble sort.

Usage

Dim vCollection As NotesDocumentCollection Set vCollection = vSearchDatabase.ftsearch(aQuery, 501, FT_SCORES, FT_FUZZY) Set vCollection = Global_SortCollection(vCollection, "Person_Surname")

The sort function requires two parameters, the first a NotesDocumentCollection with documents in it and the second a field name to use to sort the documents, in the example above the documentcollection "vCollection" will be sorted by "Person_Surname".

The function works by converting the document collection into an array of documents, doing a bubble sort on the array and then converting the array back into a new document collection.


The Code

Function Global_SortCollection(aCollection As NotesDocumentCollection, aField As String) As Variant Dim vCollectionDB As NotesDatabase Dim vDocTemp As NotesDocument Dim vCollectionSorted As NotesDocumentCollection Dim vDocArray() As String Dim vLower As Integer Dim vUpper As Integer Dim vBottomMax As Integer Dim vLoop As Integer Dim vLoopTopHalf As Integer Dim vLoopBottomHalf As Integer Dim vMidPoint As Integer Dim vTarget As String Set vCollectionDB = aCollection.Parent Redim vDocArray(aCollection.count-1) As String 'CONVERT DOCUMENT COLLECTION TO ARRAY Let vLoop = 0 Set vDocTemp = aCollection.GetFirstDocument Do While Not vDocTemp Is Nothing vDocArray(vLoop) = vDocTemp.GetItemValue(aField)(0) + "~" + vDocTemp.UniversalID Set vDocTemp = aCollection.GetNextDocument(vDocTemp) vLoop = vLoop + 1 Loop 'SHELL SORT THE ARRAY vLower = Lbound( vDocArray( ) ) vUpper = Ubound( vDocArray( ) ) vMidPoint = 1 'DETERMINE A STARTING MID POINT TO THE ARRRAY Do vMidPoint = (3*vMidPoint) + 1 Loop Until vMidPoint > vUpper - vLower + 1 'LOOP THROUGH THE ARRAY Do vMidPoint = vMidPoint \ 3 vBottomMax = vLower + vMidPoint - 1 For vLoopTopHalf = vBottomMax + 1 To vUpper vTarget = vDocArray(vLoopTopHalf) vLoopBottomHalf = vLoopTopHalf 'COMPARE TOP HALF OF ARRAY WITH BOTTOM HALF Do While vDocArray( vLoopBottomHalf - vMidPoint ) > vTarget vDocArray(vLoopBottomHalf) = vDocArray(vLoopBottomHalf - vMidPoint) vLoopBottomHalf = vLoopBottomHalf - vMidPoint If (vLoopBottomHalf <= vBottomMax) Then Exit Do Loop If (vLoopBottomHalf <> vLoopTopHalf) Then vDocArray(vLoopBottomHalf) = vTarget Next Loop Until vMidPoint = 1 'CREATE A NEW EMPTY DOC COLLECTION Set vCollectionSorted = vCollectionDB.Search("",Nothing,0) 'CONVERT ARRAY TO DOC COLLECTION For vLoop = 0 To Ubound(vDocArray) Set vDocTemp = vCollectionDB.GetDocumentByUNID(Strrightback(vDocArray(vLoop), "~")) Call vCollectionSorted.AddDocument(vDocTemp) Next vLoop 'RETURN THE DOCUMENT COLLECTION Set Global_SortCollection = vCollectionSorted End Function


Conclusion
A simple yet extremely useful function that belongs in everyone's global routines script library.»




(Source)

2006-04-05

Notes - Lotus Script: Resume without error

Scenario:

A script ends and returns the "Resume without error" message, even though no error was thrown during it's execution.
Checking the Error$ function, it may return the message "Variant does not contain a container".


Possible solution:

Include in the script the "Option Declare" statement, correct all errors (undeclared variables) and save it.

2006-03-27

Domino: Extend Authentication For Websites, Single Sign-on and Persistent Sessions

Ever wanted to be able to authenticate users on your Domino Web Server using a Web Service, against a MySQL database, a text file or some other external source? Or how about changing the default Domino behaviour so that user sessions remain active for days or weeks. It's easy and I'll show you how using Apache Tomcat and a simple Java Servlet.

More >

Notes - Web: Ajax Drag-n-Drop Sorting of Documents

«Imagine the following situation - say you've got a set of documents which are all children of one container document. From within this parent container document you want to be able to quickly change the order in which the child documents appear. Sound familiar?»

More >

Tools: Yahoo! UI Library

«The Yahoo! User Interface Library is a set of utilities and controls, written in JavaScript, for building richly interactive web applications using techniques such as DOM scripting, HTML and AJAX. The UI Library Utilities facilitate the implementation of rich client-side features by enhancing and normalizing the developer's interface to important elements of the browser infrastructure (such as events, in-page HTTP requests and the DOM.»

More >

Domino: ajax picklist (either for names.nsf or other dbs)

«One of the things which has bugged me for a long time is getting a good name picker.(...)So the requirements:
.A generic popup window which allows a user to select one or many values from a very large view (100,000 documents plus)
.It has to perform well
.It has to be cross browser compatable (at least IE and Firefox)
.It has to be easily re-usable»


More >

***


«I needed a name picker for a project I'm working on. After looking at various solutions available I couldn't find one I was happy with and decided to the revisit the approach and write my own. (...) What I've tried to move away from is the convention that a Name Picker must, for some reason, be a popup window.»


More >

Domino: Ajax Powered Login

«Getting tired of ugly Domino login forms or faceless browser pop up dialogs? Once again showing a flair for melding various techniques, Mark Barton brings us an elegant, cutting edge modal login interface utilizing DHTML, Ajax, and JSON JavaScript notation.»
More >

2006-01-12

Notes - LotusScript: function returning a notes document

Problem:
Even though the document is instatiated inside the function it is not returned to the calling code.
 
Explanation:
You're probably declaring and setting the value of the NotesDocument's parent database inside the function, which is outside the scope of the calling function. As a result, although you return the right document, the containing database is no longer open.

You can either pass the database *and* the document and pass them both back, or you can declare the database globally
.