Autor Thema: Repalce Desigen - design task in Script  (Gelesen 3936 mal)

Offline yes2002

  • Aktives Mitglied
  • ***
  • Beiträge: 193
  • Ich liebe dieses Forum!
Repalce Desigen - design task in Script
« am: 30.01.03 - 16:34:21 »
Hallo,

per Script ändere ich bei ca. 50 DB die Information, auf welcher Basis die Datenbank aufbaut (Template inherited from). Das klappt auch.

Problem:
Nachdem der neue Templatename eingetragen wurde, möchte ich das Datenbank-Design refreshen und zwar per Agent und nicht manuell. Auch nicht mit dem Design-Task.

Vielen Dank!

Offline Performance

  • Gold Platin u.s.w. member:)
  • *****
  • Beiträge: 1.096
  • Geschlecht: Männlich
  • I love YaBB 1G - SP1!
Re:Repalce Desigen - design task in Script
« Antwort #1 am: 30.01.03 - 18:39:08 »
ist mir nicht bekannt das das mit skript gehen könnte, aber bekannt ist mir das es mit C-API geht.


cu
Wir können alles außer hochdeutsch !

Alles ist möglich, es ist nur eine Frage der Zeit oder des Geldes!

Offline yes2002

  • Aktives Mitglied
  • ***
  • Beiträge: 193
  • Ich liebe dieses Forum!
Lösung ....
« Antwort #2 am: 31.01.03 - 21:57:34 »
Hallo,

ich habe die Lösung in www.notes.net gefunden:

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

Offline Performance

  • Gold Platin u.s.w. member:)
  • *****
  • Beiträge: 1.096
  • Geschlecht: Männlich
  • I love YaBB 1G - SP1!
Re:Repalce Desigen - design task in Script
« Antwort #3 am: 01.02.03 - 10:13:33 »
- und funktioniert das einwandfrei ?
- werde auch mal testen


cu
Wir können alles außer hochdeutsch !

Alles ist möglich, es ist nur eine Frage der Zeit oder des Geldes!

 

Impressum Atnotes.de  -  Powered by Syslords Solutions  -  Datenschutz