Domino 9 und frühere Versionen > Entwicklung

Real time numbering documents on both WEB and Notes Client

<< < (2/3) > >>

Rob Green:
Bogdan, beware, the locking mechanism only applies to the Web and NOT to the Notes Client. There is simply no process locking function in R5 !!! Your way by using a file is hereby the best and i wouldnt change it, since you can use it for the Web too, or was there a special reason you deny this solution here?

Read this please: http://www-10.lotus.com/ldd/today.nsf/62f62847467a8f78052568a80055b380/74bd0cdadb2602c385256b56001c0517?OpenDocument&Highlight=0,unique#Preparing%20an%20application%20for%20sequ


and Julie from IRIS:
Lets listen to Julie Kadashevich from IRIS:
Lock functions are currently supported for web agents
(unrelated to any hardware configurations), they are
not supported in Notes server-based agents (such as
scheduled agents).

The reason for that that the locks are effective within
the same PROCESS (such as a web server). And if one understands
the architecture of the scheduled agents, they are not always
within the same PROCESS. So it is unrelated to the mutilple processors
on the server.

By the way, this is probably obvious, but just stating it for
completeness, if you happen to use the same lock in two applications
than do not run in the same process - then nothing will happen (i.e.
no lock, no hang, no data protection). It is a NOOP.

Julie - iris

Toma Bogdan:

--- Zitat von: Rob Green am 04.06.03 - 12:27:11 ---Bogdan, beware, the locking mechanism only applies to the Web and NOT to the Notes Client.
--- Ende Zitat ---
I understood ...


--- Zitat von: Rob Green am 04.06.03 - 12:27:11 ---Your way by using a file is hereby the best and i wouldnt change it, since you can use it for the Web too, or was there a special reason you deny this solution here?

--- Ende Zitat ---

did you reffer at as I wrote ?

--- Zitat von: Toma Bogdan am 04.06.03 - 09:58:00 ---For the Notes Client I use script that lock a file which contains the current number

--- Code: --- Sub Initialize
  file% = Freefile
  Open "c:\\seqnum.bin" For Binary Access Read Write Lock Read As file%
   ' You can also use Open "\\NotesServer\SharedDirectory\seqnum.bin"
   ' if your client and server are Win95 or NT based.  Open can take
   ' a UNC path
  Get #file%, 1, SeqNum%
  SeqNum% = SeqNum% + 1
  Put #file%, 1, SeqNum%
  Close file%
  End Sub
--- Ende Code ---

--- Ende Zitat ---

I explain above:

--- Zitat von: Toma Bogdan am 04.06.03 - 09:58:00 ---This solution generate real time sequential number but it isn't very good because all users needs to have write right on the file system server (on a folder from the server)
--- Ende Zitat ---

And also this method isn't applicable on a Unix system (in case you didn't use Samba for mapping the specific folder)

So I don't want to depends for another ex-Notes db file (in this case the file seqnum.bin) ... and another reason is that somebody can modify the value from this file with a little effort....

Rob Green:
the writing right should be applied to a runon server agent and not a user triggered agent. So the server has the right to write. Could this be a way?

The problems are mentioned hereby already.

So you can try to use @unique in both worlds: Notes and Web.

Toma Bogdan:

--- Zitat von: Rob Green am 04.06.03 - 13:38:58 ---The writing right should be applied to a runon server agent and not a user triggered agent. So the server has the right to write. Could this be a way?

--- Ende Zitat ---

Do you talk about the Notes or the Web version ? Because the Web version that I wrote entirely below it seems that works all right ...
For the Notes version I can't use a runon server agent because I need to get a number when a user save a new doc into database.


--- Zitat von: Rob Green am 04.06.03 - 13:38:58 ---So you can try to use @unique in both worlds: Notes and Web.

--- Ende Zitat ---

Do you have an example of using @Unique for this problem (REAL TIME sequential number) ?

Rob Green:
@unique is not a sequential number, its a random number, see the help please  ;)

So the user needs the number immidiately? Where is there a problem with a runonserver agent? You can run the agent, wait until its finished and get the number visually back for the user.
See below the bold line:
"If agent.RunOnServer(doc.NoteID) = 0 Then"
Thats the user trigger mechanism. If the numbering process is finished you can reload your doc and get hereby the number for the user.

See the help:
This agent runs the agent named "Agent to be run parameter LotusScript," passing it the note ID of a newly created document.
Sub Initialize
  Dim s As New NotesSession
  Dim db As NotesDatabase
  Dim doc As NotesDocument
  Dim agent As NotesAgent
  Set db = s.CurrentDatabase
  REM Create document containing data to be passed
  Set doc = New NotesDocument(db)
  doc.TriggerUserName = s.UserName
  Call doc.Save(True, False)
  REM Start agent and pass note ID of document
  Set agent = _
  db.GetAgent("Agent to be run parameter LotusScript")
  If agent.RunOnServer(doc.NoteID) = 0 Then
    Messagebox "Agent ran",, "Success"
  Else
    Messagebox "Agent did not run",, "Failure"
  End If
End Sub
This is "Agent to be run parameter LotusScript." It accesses the passed note ID through ParameterDocID, accesses the referenced document, and removes it.
Sub Initialize
  Dim s As New NotesSession
  Dim agent As NotesAgent
  Set agent = s.CurrentAgent
  Dim db As NotesDatabase
  Dim doc As NotesDocument
  Set db = s.CurrentDatabase
  REM Get document used for passing data
  Set doc = db.GetDocumentByID(agent.ParameterDocID)
  REM Send mail containing passed data
  Dim memo As New NotesDocument(db)
  memo.Form = "Memo"
  memo.SendTo = s.UserName
  memo.Subject = "Message from LotusScript agent"
  memo.Body = "The agent was started by " _
  & doc.TriggerUserName(0)
  Call memo.Send(False)
  REM Delete document used for passing data
  Call doc.Remove(True)
End Sub

Hey, Bogdan, you dont like the Help DB, eh?  ;D ;D

Navigation

[0] Themen-Index

[#] Nächste Seite

[*] Vorherige Sete

Zur normalen Ansicht wechseln