Design of dynamically refresh login page form with LotusScript

Source: Internet
Author: User

Design of dynamically refresh login page form with LotusScript
1. Check whether the domcfg. nsf library exists on the server. If not, test your own domcfg. nsf Library to the server. If yes, execute 2.
2. The slave server's domcfg. search for the logon page in the NSF library. If yes, first convert the "$ loginuserform" form into dxl, then, change the nodevalue of the Name node under the form node to "$ loginuserform" + time, and then export the dxl file to domcfg. NSF Library (this operation saves the original logon page form ).
3. Export the "$ loginuserform" form in the self-designed database to dxl, and then import it to the domcfg. nsf library on the server.

In addition:
The same is true if you want to directly modify a form. Because domino database design, forms, views, and so on are all standard XML files, if you want to modify the form design, you can first export the form into a dxl file (XML format), and then, modify the specific node in dxl directly, and then re-import the dxl file to implement dynamic modification to the form design.

Option public
Option compare nocase

Sub initialize
On Error goto errhandle
Dim session as notessession
Dim db1 as notesdatabase
Dim DB2 as notesdatabase
Dim NC as notesnotecollection
Dim NC2 as notesnotecollection
Dim stream as notesstream
Dim exporter as notesdxlexporter
Dim importer as notesdxlimporter
Dim importer0 as notesdxlimporter
Dim form as notesform
Dim NID as string

Dim file1 as string
Dim file2 as string
Dim file3 as string
Dim outputfile as string

Dim timestr as string

Dim inputstream as notesstream, outputstream as notesstream
Dim domparser as notesdomparser
Dim docnode as notesdomdocumentnode
Dim docrootnode as notesdomnode

File1 = ""
File2 = ""
File3 = ""
Flag = false
Timestr = Replace (replace (CSTR (now ),"-",""),":",""),"","")

Set session = new notessession
Set db1 = session. currentdatabase
'First determine whether the current server has a logon Database
Set DB2 = new notesdatabase (db1.server, "domcfg. nsf ")
'If no database is logged on
If not db2.isopen then
Set DB2 = db1.createfromtemplate (db1.server, "domcfg. nsf", true)
Else
Set form = db2.getform ("$ loginuserform ")
'If the logon page exists, first, back up the login page '''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''
If not form is nothing then
Set NC = db2.createnotecollection (false)
Call nc. buildcollection
Set NC2 = db2.createnotecollection (false)
Nc2.selectforms = true
Call nc2.buildcollection
Nid = nc2.getfirstnoteid
'Look up the logon page form
Forall F in db2.forms
If not F. issubform then
If F. Name = "$ loginuserform" then
NC. Add (NID)
Exit forall
End if
Nid = nc2.getnextnoteid (NID)
End if
End forall
'Export the form to a dxl file, which is stored in a temporary folder.
Set stream = session. createstream
File2 = "C: templogin_back _" & timestr & "1.dxl"
Call stream. Open (file2)
Set exporter = session. createdxlexporter (NC, Stream)
Call exporter. Process
Call stream. Close
'Delete the original logon page
Call form. Remove
'Read the dxl file (XML file) and modify the logon Page name.
File3 = "C: templogin_back _" & timestr & "2.dxl"
Set session = new notessession
Set outputstream = session. createstream
Outputstream. Open (file3)
Set inputstream = session. createstream
Inputstream. Open (file2)
If inputstream. bytes> 0 then
Set domparser = session. createdomparser (inputstream)
Call domparser. Process
Set docnode = domparser. Document
Set docrootnode = docnode. documentelement
If not docrootnode. isnull then
'Modify the nodevalue of the subordinate node name of the form node in the file.
Call changenode (docrootnode, timestr)
Call domparser. setoutput (outputstream)
Call domparser. serialize
End if
End if
'Import backup login page
Set importer0 = session. createdxlimporter (outputstream, DB2)
Importer0.designimportoption = 2
Call importer0.process
Set importer0 = nothing
Call outputstream. truncate
Call inputstream. truncate
Call outputstream. Close
Call inputstream. Close
End if

'Import login page '''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''' '''
Set NC = db1.createnotecollection (false)
Call nc. buildcollection
Set NC2 = db1.createnotecollection (false)
Nc2.selectforms = true
Call nc2.buildcollection
Nid = nc2.getfirstnoteid
'Get the login page form of the current library
Forall F in db1.forms
If not F. issubform then
If F. Name = "$ loginuserform" then
NC. Add (NID)
Exit forall
End if
Nid = nc2.getnextnoteid (NID)
End if
End forall
'Export to dxl file, which exists in the Temporary Folder
Set stream = session. createstream
File1 = "C: templogin _" & timestr & ". dxl"
Call stream. Open (file1)
'Import dxl to the domcfg library.
Set exporter = session. createdxlexporter (NC, Stream)
Set importer = session. createdxlimporter (stream, DB2)
Importer. designimportoption = 2
Call exporter. Process
Call importer. Process
Call stream. truncate
Call stream. Close
End if

Exit sub
Errhandle:
Msgbox CSTR (ERL) & "& error
End sub

'Modify the name attribute value of the form node.
Sub changenode (childnode2 as notesdomnode, str1 as string)
On Error goto errhandle
Dim docnamemap as notesdomnamednodemap
Dim childnode3 as notesdomnode
Dim tempnode as notesdomnode
Dim I as integer

While not childnode2.isnull
If childnode2.nodetype <> 3 then
If childnode2.haschildnodes then
Set childnode3 = childnode2.firstchild
While not childnode3.isnull
Call changenode (childnode3, str1)
If not childnode3.isnull then
Set childnode3 = childnode3.nextsibling
End if
Wend
End if
End if
Set docnamemap = childnode2.attributes
For I = 1 to docnamemap. numberofentries
Set tempnode = docnamemap. getitem (I)
If tempnode. nodevalue = "$ loginuserform" then
Tempnode. nodevalue = "$ loginuserform _" & str1
Exit sub
End if
Next
Set childnode2 = childnode2.nextsibling
Wend
Exit sub
Errhandle:
Msgbox "changenode:" & CSTR (ERL) & "," & error $
End sub

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.