I have made modifications to my mail NSF. I put a menu with buttons to my AppointmentForm that just run a formula that creates an extra field item "MY_CUSTOM_ITEM" with a given value depending on the menu selection.
I have a program written in c# using Domino interop that looks more or less like this:
NotesSession session = new NotesSession();
session.Initialize("");
NotesDatabase db = session.GetDatabase(servername, "mymail.nsf", false);
That is done once, and 'session' and 'db' are stored in a class variable. Then I have a loop that periodically does something like this:
NotesDocumentCollection col = db.Search("Form = \"Appointment\" & StartTime < @Now & EndTime > @Now & !@Contains(MY_CUSTOM_ITEM;'somevalue')", null, 0);
object[] obj = (object[])doc.GetItemValue("MY_CUSTOM_ITEM");
string str = (string)obj[0];
If I set MY_CUSTOM_ITEM to 'anothervalue', save the appointment and start the program, I get str == 'anothervalue'. But if I change the appointment to contain, for example, MY_CUSTOM_ITEM='yetanothervalue', the following iterations of Search() will yield inconsistent results. Most of the time I get the initial result all the time I re-run db.Search(), which is one appointment with str=='anothervalue'. Sometimes I get str=='yetanothervalue', only to see str=='anothervalue' in the next iteration, without me changing anything about the appointment.
I tried the same program with some standard items from Notes appointment. In my case I tested with 'BookFreeTime', which is the item set when you click 'Mark available' in the appointment. In that case I didn't have any problems. Whenever I saved the appointment, Search() yielded a new collection with the updated appointment in it, whith the correct value of 'BookFreeTime'.
The only way I managed to make it work with MY_CUSTOM_ITEM was to instantiate a new NotesSession() on every iteration of the loop. But people are complaining of the amount of sessions being created, and I'm wondering if there is something I could do to make it work without instantiating one session in each iteration, but reusing the same session created at the beginning of the program execution.
Is there something like session.Refresh() or db.Refresh() that could do the trick?