title image


Smiley Lösung ...
Hi,

die Lösung stand in www.notes.net:



Option Public



Option Declare



Declare Function NSFDbOpen Lib "nnotes.dll" Alias "NSFDbOpen" _

(Byval Pathname As Lmbcs String, rethDB As Integer) As Integer

Declare Function NSFDbInfoGet Lib "nnotes.dll" Alias "NSFDbInfoGet" _

(Byval hDB As Integer, Byval retBuffer As Lmbcs String) As Integer

Declare Sub NSFDbInfoParse Lib "nnotes.dll" Alias "NSFDbInfoParse" _

(Byval Buffer As Lmbcs String, Byval InfoType As Integer, Byval retTitle As Lmbcs String, Byval TitleLen As Integer)

Declare Function NSFDbClose Lib "nnotes.dll" Alias "NSFDbClose" _

(Byval hDB As Integer) As Integer

Declare Sub NSFDbInfoModify Lib "nnotes.dll" Alias "NSFDbInfoModify" _

(Byval retBuffer As Lmbcs String, Byval Konst As Integer, Byval NewTemplateName As String)

Declare Function NSFDbInfoSet Lib "nnotes.dll" Alias "NSFDbInfoSet" _

( Byval hDB As Integer, Byval retBuffer As Lmbcs String) As Integer

Declare Sub NEMDisplayError Lib "NNOTESWS" Alias "NEMDisplayError" _

( Byval E As Long )

Declare Function DesignRefresh Lib "nnotes.dll" Alias "DesignRefresh" _

( Byval S As String, Byval hDB As Integer, Byval F As Integer _

, Byval zA As Integer, Byval zM As Integer) As Integer

Declare Function NSFNoteOpen Lib "nnotes.dll" Alias "NSFNoteOpen" _

( Byval db_handle As Integer, Byval note_id As Long, Byval open_flags As Integer, notehandle As Long) As Integer

Declare Function NSFItemSetText Lib "nnotes.dll" Alias "NSFItemSetText" _

( Byval hNote As Long, Byval ItemName As String, Byval retBuffer As Lmbcs String, Byval TextLength As Long) As Integer

Declare Function NSFNoteClose Lib "nnotes.dll" Alias "NSFNoteClose" _

(Byval note_handle As Long) As Integer

Declare Function NSFNoteUpdate Lib "nnotes.dll" Alias "NSFNoteUpdate" _

(Byval note_handle As Long, Byval update_flags As Integer) As Integer

Const INFOPARSE_TITLE=0

Const INFOPARSE_CATEGORIES=1

Const INFOPARSE_CLASS=2

Const INFOPARSE_DESIGN_CLASS=3

Const DESIGN_FORCE = 1

Const UPDATE_FORCE = &H0001

Const NOTE_ID_SPECIAL = &HFFFF0000

Const NOTE_CLASS_ICON = &H0010

Const OPEN_NOVERIFYDEFAULT=&H0002

Const FIELD_TITLE = "$TITLE"

Dim DBName As String

Dim DBServer As String

Dim TemplateName As String





%REM

Because I got some questions about the posts above, a last post with the solution!



This is only a sample script!! You can NOT use it for production!!!

If you get some problems with this script ==> I´m NOT responsible!!



With this script you can change the notesDatabase.DesignTemplateName - Property

and you can refresh the design of the database with the new DesignTemplate



ToDo:

copy this script into an Agent, change the Database, Servername and Templatename -Variables

and try it!!!



Requirement:

This script is not testet with Notes 4 or Notes Rnext

It is developed with R5.0.8 on W2K



Franz Aigner

Austria

%ENDREM





















Sub Initialize



Dim session As New NotesSession

Dim db As NotesDatabase

Dim StrTemplateName As String



If Not session.IsOnServer Then



TemplateName = "StdR50Mail" '* ==> new TemplateName





DBname = "99test.nsf" '* ==> Database on which you would change teh templatename

DBServer = "" '* ==> Servername on which the Template resids



Set db = session.GetDatabase("", DBName)

StrTemplateName = db.DesignTemplateName '* ==> the old template name



If SetDBTemplateName = True Then

Set db = session.GetDatabase("", DBName)

DBRefreshDesign '* Refresh Design

End If





Elseif session.IsOnServer Then

Messagebox ("This agent does not run on a server")

Else

Messagebox ("This agent does not run!" )

End If





End Sub

Function SetDBTemplateName As Integer



Dim CAPIErr As Integer

Dim hDB As Integer

Dim DBInfoBuffer As String * 128

Dim DBTitle As String * 128

Dim notehandle As Long

Dim retInfoGet As String * 128



SetDBTemplatename = False



CAPIErr = NSFDbOpen (DbName, hDB) '* open DB

Stop

If (CAPIErr = 0) Then

CAPIErr = NSFDbInfoGet (hDB, DBInfoBuffer) '* get InfoBuffer

If CAPIErr = 0 Then

Call NSFDbInfoModify (DBInfoBuffer, INFOPARSE_DESIGN_CLASS, Templatename ) '*change InfoBuffer ==> TemplateName

If CAPIErr = 0 Then

CAPIErr = NSFNoteOpen (hDB, NOTE_ID_SPECIAL + NOTE_CLASS_ICON, 0, notehandle&)

If CAPIErr = 0 Then

CAPIErr = NSFItemSetText (notehandle&, FIELD_TITLE, DBInfoBuffer, Len(DBInfoBuffer))

If CAPIErr = 0 Then

CAPIErr% = NSFNoteUpdate(NoteHandle&, UPDATE_FORCE)

If CAPIErr = 0 Then

CAPIErr = NSFNoteClose (notehandle&)

If CAPIErr = 0 Then

CAPIErr = NSFDbInfoSet (hDB, DBInfoBuffer) '* write InfoBuffer to database

If CAPIErr = 0 Then

SetDBTemplatename = True

Else

NEMDisplayError CAPIErr

End If

Else

NEMDisplayError CAPIErr

End If

Else

NEMDisplayError CAPIErr

End If

Else

NEMDisplayError CAPIErr

End If

Else

NEMDisplayError CAPIErr

End If

Else

NEMDisplayError CAPIErr

End If

NSFDbClose (hDB)

Else

NEMDisplayError CAPIErr

Messagebox ("Unable to get the database info buffer")

NSFDbClose (hDB)

End If

Else

NEMDisplayError CAPIErr

Messagebox ("Unable to open " & DBName & "; Error: " & Hex$(CAPIErr))

End If

End Function

Sub DBRefreshDesign



Dim CAPIErr As Integer

Dim hDB As Integer





CAPIErr = NSFDbOpen (DbName, hDB) '* open DB

Stop



If CAPIErr = 0 Then

'* Refresh design

CAPIErr = DesignRefresh(DBServer, hDB, 1, 0, 0)

If CAPIErr = 0 Then



Else

NEMDisplayError CAPIErr

End If

NSFDbClose (hDB)

Else

NEMDisplayError CAPIErr

Messagebox ("Unable to open " & DBName & "; Error: " & Hex$(CAPIErr))

End If



End Sub



geschrieben von

Login

E-Mail:
  

Passwort:
  

Beitrag anfügen

Symbol:
 
 
 
 
 
 
 
 
 
 
 
 
 

Überschrift: