Synchronize read/unread marks between user and delegate user

Hi All,I have a question.

We are trying to figure out if it is possible to synchronize the read/unread marks between the owner and the user who has delegate access to the same mail file.

Right now, the read/unread marks are attached to different user ID. If the operation can’t synchronize, it is not convenient for teamwork.

Thanks and Regards!

Edwin

Subject: synchronize read/unread marks between user and delegate user

hmmm no!

You could write your own read/unread mechanism that writes a flag to the document so you can see who has read it.

Subject: RE: synchronize read/unread marks between user and delegate user

I would not follow Marjan’s suggestion, since it means that all documents in a mailfile will be modified and that can causa huge performance problems during replication.

The unread administration is kept (from Notes 6 onwards) inside a mailfile. For each user there is a table with the ID’s of the unread documents. So what you need to do is to merge the unread marks from the owner with those of the delegate.

This can be done, since I did it, using C API functions.

Subject: RE: synchronize read/unread marks between user and delegate user

Where can I get a software like what you said?Will you share it with me?

Thanks^_^

Edwin

Subject: RE: synchronize read/unread marks between user and delegate user

Well, I expected this question; here is some sample code which I extracted from a larger function, so it could be that there is a small error in it. If you have a look at the reference db that comes with the C API SDK, you will find ample explications.

[declarations]

Declare Function NSFDbClose Lib “nnotes.dll” (Byval hDb As Long) As Integer

Declare Function NSFDbGetUnreadNoteTable Lib “nnotes.dll” (Byval hDb As Long, Byval UserName As String, Byval NameLength As Integer, Byval Create As Integer, hUnreadTable As Long) As Integer

Declare Function NSFDbOpen Lib “nnotes.dll” (Byval dbName As String, hDb As Long) As Integer

Declare Function NSFDbSetUnreadNoteTable Lib “nnotes.dll” (Byval hDb As Long, Byval UserName As String, Byval NameLength As Integer, Byval Flush As Integer, Byval hOriginalTable As Integer, Byval hUnreadTable As Long) As Integer

Declare Function NSFDbUpdateUnread Lib “nnotes.dll” (Byval hDb As Long, Byval hTable As Long) As Integer

Declare Function IDTableIntersect Lib “nnotes.dll” (Byval hTable1 As Long, Byval hTable2 As Long, hTable As Long) As Integer

Declare Function OSPathNetConstruct Lib “nnotes.dll” (Byval portname As String, Byval servername As String, Byval filename As String, Byval pathname As String) As Integer

Declare Function NSFNoteUpdate Lib “nnotes.dll” (Byval hNote As Long, Byval UpdateFlags As Integer) As Integer

[code]

Dim dbp As String*256

Dim dbpath As String

Dim status As Integer

Dim ownerlist As Long

Dim delegatelist As Long

Dim combinedlist As Long

Dim hDB as Long

status = OSPathNetConstruct(Null, , , dbp)

dbpath = Trim$(dbp)

status = NSFDbOpen(dbpath, hdb)

status = NSFDbGetUnreadNoteTable(hDB, , Len(), True, ownerlist)

status = NSFDbUpdateUnread(hDB, ownerlist)

status = NSFDbGetUnreadNoteTable(hDB, , Len(), True, delegatelist)

status = NSFDbUpdateUnread(hDB, delegatelist)

status = IDTableIntersect(ownerlist, delegatelist, combinedlist)

status = NSFDbSetUnreadNoteTable(hDB, < delegatename >, Len(), True, delegatelist, combinedlist)

IDDestroyTable(ownerlist)

IDDestroyTable(delegatelist)

IDDestroyTable(combinedlist)

status = NSFDbClose(hDB)

Subject: RE: synchronize read/unread marks between user and delegate user

Thank you very much for the help!I’ll look into it asap^_^

Subject: RE: synchronize read/unread marks between user and delegate user

Hi,

This looks like an interesting solution for the problem we have in our project. We want the unread table of the administrator of the system (user “system”) to be the same as each user’s unread table. In order to this, I have a c++ program that I run on each client to perform the same procedure you presented here.

Since the application is run on each user’s machine, it uses the user.id of that user to create the session. However when I want to read the “system” unread table, it throws an error saying"

You are not authorized to perform that operation

I added that user to the list of managers who has access to the “system”'s user mailfile although I know it’s a kind of an irony. It’s like two users that are each other’s manager. But even with this change, the error still persists. Does anyone know a better solution?

Here’s my code:

	DHANDLE hTable=NULLHANDLE,sTable,iTable,intersect=NULLHANDLE;

	DHANDLE combined=NULLHANDLE;

	session.Init();



	DHANDLE h=NULLHANDLE;



	char* pathname = new char[50];



	OSPathNetConstruct(NULL,"transducer","mail\\aghadiri.nsf",pathname);

	cout << pathname;



	status = NSFDbOpen(pathname,&h);



	DHANDLE hTable=NULLHANDLE,sTable,iTable,intersect=NULLHANDLE;

	DHANDLE combined=NULLHANDLE;



	status = NSFDbOpen(pathname,&h);

	OSLoadString(NULLHANDLE, ERR(status), szNotesError, 100);

	printf("Error %s.\n", szNotesError);



	DNCanonicalize(0L, NULL, "Amirali Ghadiri", CanonName,

                      MAXUSERNAME, &retLen);



	status = NSFDbGetUnreadNoteTable(

	h,

	CanonName,

	strlen (CanonName),

	TRUE, /* Create list if it's not already there */

	&hTable);





	status = NSFDbUpdateUnread(h,hTable);





	status = NSFDbGetUnreadNoteTable(h, 

		"system", 

		strlen("system"),

		TRUE, 

		&sTable);// This line throws the mentioned error





	status = NSFDbUpdateUnread(h, sTable);





	status = IDTableIntersect(hTable, sTable, &combined);





	status = NSFDbSetUnreadNoteTable(h, "system", strlen("system"), TRUE, sTable, combined);