'============================================================================== ' COPYRIGHT: Blue Fish Development Group ' All rights reserved. ' ' PROCEDURE NAME: ...create_method.ebs ' ' DESCRIPTIVE NAME: dmdeveloper.com - Utility Function for Creating a Method ' '============================================================================== ' FUNCTION: ' This docbasic routine contains a utility function for creating a ' dm_mehtod object. ' '============================================================================== ' DEPENDENCIES: N/A ' ' RESTRICTIONS: N/A ' ' EXTERNAL REFERENCES: N/A ' '============================================================================== ' CHANGE HISTORY: ' Date Author Description ' --------- ------ ----------- ' 09 Jan 97 MJT Initial code ' 05 Mar 00 MJT Updated for dmdeveloper.com ' '============================================================================== Option Explicit '****************************************************************************** ' User-Defined Types '****************************************************************************** '****************************************************************************** ' Public (Global) Variables '****************************************************************************** Public g_strAppTitle as String '------------------------------------------------------------------------------ ' Public Variables for reporting '------------------------------------------------------------------------------ Public g_intLogFileNum as Integer Public g_blnWriteToStatusBar as Boolean Public g_blnShowMessageBox as Boolean Public g_blnPrintToLogFile as Boolean Public g_blnPrintToServerLogFile as Boolean Public g_strLogFileName as String Public g_intReportStatus as Integer '****************************************************************************** ' Private (Module-Level) Variables '****************************************************************************** '****************************************************************************** ' Constants '****************************************************************************** Const vbCRLF as String = Chr$(13) & Chr$(10) '------------------------------------------------------------------------------ ' Constants for reporting '------------------------------------------------------------------------------ Const intREPORT_CLIENT_NONE as Integer = 1 Const intREPORT_CLIENT_LOGFILE as Integer = 2 Const intREPORT_CLIENT_MSGBOX as Integer = 4 Const intREPORT_CLIENT_STATUSBAR as Integer = 8 Const intREPORT_CLIENT_ALL as Integer = 14 Const intREPORT_SERVER_NONE as Integer = 15 Const intREPORT_SERVER_LOGFILE as Integer = 16 Const intREPORT_SERVER_SERVERLOG as Integer = 32 Const intREPORT_SERVER_ALL as Integer = 48 '------------------------------------------------------------------------------ ' Constants for ACLs '------------------------------------------------------------------------------ Const intACL_DELETE_ACCESS as Integer = 7 Const intACL_WRITE_ACCESS as Integer = 6 Const intACL_VERSION_ACCESS as Integer = 5 Const intACL_RELATE_ACCESS as Integer = 4 Const intACL_READ_ACCESS as Integer = 3 Const intACL_BROWSE_ACCESS as Integer = 2 Const intACL_NONE_ACCESS as Integer = 1 Const intACL_ACCESSOR_NAME as Integer = 0 Const intACL_ACCESSOR_PERMIT as Integer = 1 '------------------------------------------------------------------------------ ' Constants for Message Boxes '------------------------------------------------------------------------------ Const vbOKOnly as Integer = 0 'Display OK button only. Const vbOKCancel as Integer = 1 'Display OK and Cancel buttons. Const vbAbortRetryIgnore as Integer = 2 'Display Abort, Retry, and Ignore buttons. Const vbYesNoCancel as Integer = 3 'Display Yes, No, and Cancel buttons. Const vbYesNo as Integer = 4 'Display Yes and No buttons. Const vbRetryCancel as Integer = 5 'Display Retry and Cancel buttons. Const vbCritical as Integer = 16 'Display Critical Message icon. Const vbQuestion as Integer = 32 'Display Warning Query icon. Const vbExclamation as Integer = 48 'Display Warning Message icon. Const vbInformation as Integer = 64 'Display Information Message icon. Const vbDefaultButton1 as Integer = 0 'First button is default. Const vbDefaultButton2 as Integer = 256 'Second button is default. Const vbDefaultButton3 as Integer = 512 'Third button is default. Const vbDefaultButton4 as Integer = 768 'Fourth button is default. Const vbApplicationModal as Integer = 0 'Application modal Const vbSystemModal as Integer = 4096 'System modal Const vbOK as Integer = 1 'OK Const vbCancel as Integer = 2 'Cancel Const vbAbort as Integer = 3 'Abort Const vbRetry as Integer = 4 'Retry Const vbIgnore as Integer = 5 'Ignore Const vbYes as Integer = 6 'Yes Const vbNo as Integer = 7 'No '****************************************************************************** ' Declare the functions outside this module. '****************************************************************************** '****************************************************************************** ' Declare the functions in this module. '****************************************************************************** '------------------------------------------------------------------------------ ' Helper Routines for reporting '------------------------------------------------------------------------------ Declare Sub OpenLogFile(strFileName as String) Declare Sub CloseLogFile() Declare Sub PrintToLogFile(strMessage as String) Declare Sub Report(strMessage as String) Declare Sub SetupReporting(intReportType as Integer, Optional strClientLogFile as Variant) Declare Sub ShowStatus(strMessage as String) '------------------------------------------------------------------------------ ' Helper Routines for Creating ACLs '------------------------------------------------------------------------------ Declare Function CreateACL(strACLName as String, ByRef vntACLDef() as Variant) as Boolean Declare Function BeginTran() as Boolean Declare Function Commit() as Boolean Declare Sub Abort() '------------------------------------------------------------------------------ ' Routines for Creating ACLs '------------------------------------------------------------------------------ Declare Function CreateSampleACLs() as Boolean '****************************************************************************** ' SUB: Main ' ' Description: The entry point to the procedure - this is the function that ' gets called when you double-click the procedure in Workspace ' ' Parameters: None '****************************************************************************** Sub Main() Dim strDocbaseOwner as String Dim strCmd as String Dim iStatus as Integer Dim strQuery as String Dim strObjectID as String Dim strObjectName as String Dim strRunAsServer as String Dim strLaunchAsync as String Dim strMethodType as String Dim strMethodVerb as String Dim strUseMethodContent as String Dim blnImportContentFile as Boolean Dim strContentFileName as String Dim strContentFileFormat as String '-------------------------------------------------------------------------- ' Setup the inital variables that describe the method ' These variables are currently set up for a docbasice method with content '-------------------------------------------------------------------------- ' strObjectName is the name of the method. Each method name must be unique '-------------------------------------------------------------------------- strObjectName = "" '-------------------------------------------------------------------------- ' strRunAsServer determines if the method will run as dmadmin, a superuser '-------------------------------------------------------------------------- strRunAsServer = "T" '-------------------------------------------------------------------------- ' strLaunchAsync determines if the client will wait while the method ' completes '-------------------------------------------------------------------------- strLaunchAsync = "F" '-------------------------------------------------------------------------- ' strMethodType is the type of the method - it tells the server to place ' a -f flag on the command line, which tells GAWK and Docbasic the name of ' the script file. Valid values are ' - "dmbasic" if the content will be a docbasic procedure ' - "GAWK" if the content is a GAWK script ' - Leave it blank if the program to be executed is an external program '-------------------------------------------------------------------------- strMethodType = "dmbasic" '-------------------------------------------------------------------------- ' strMethodVerb is the path to the program that will be executed. If you ' are using docbasic, you must include the name of the subroutine as well, ' using the -e flag to specify the name of the subroutine ' Example: ".\dmbasic -eMain" '-------------------------------------------------------------------------- strMethodVerb = ".\dmbasic -eMain" '-------------------------------------------------------------------------- ' strUseMethodContent tells the Server that the content of the method is ' to be used. It is used in conjunction with the strMethodType argument '-------------------------------------------------------------------------- strUseMethodContent = "T" '-------------------------------------------------------------------------- ' blnImportContentFile tells this procedure that that you want to add the ' content to the methood when you create the method. It is used in ' conjuntion with strContentFileName abd strContentFileFormat '-------------------------------------------------------------------------- blnImportContentFile = False '-------------------------------------------------------------------------- ' strContentFileName is the path to the file that will be used as the ' method content '-------------------------------------------------------------------------- strContentFileName = "c:\Temp\method.ebs" '-------------------------------------------------------------------------- ' strContentFileFormat is the format of the content file. '-------------------------------------------------------------------------- strContentFileFormat = "crtext" '-------------------------------------------------------------------------- ' End of variable initalization '-------------------------------------------------------------------------- ' Get the Docbase Owner '-------------------------------------------------------------------------- strQuery = "select object_name from dm_server_config" strCmd = "query,c," & strQuery strCollection = dmAPIGet(strCmd) iStatus = dmAPIExec("next,c," & strCollection) If iStatus = 0 Then strDocbaseOwner = "" Else strCmd = "get,c," & strCollection & ",object_name" strDocbaseOwner = dmAPIGet(strCmd) End If strCmd = "close,c," & strCollection If dmAPIExec(strCmd) = 0 THEN MsgBox "Error Closing Query Collection.", 48 '-------------------------------------------------------------------------- ' Create the Method Object and set the attributes '-------------------------------------------------------------------------- strCmd = "create,c,dm_method" strObjectID = dmAPIGet(strCmd) If strObjectID = "" Then MsgBox "Error Creating Method Object" Exit Sub End If strAttributeName = "object_name" strCmd = "set,c," & strObjectID & "," & strAttributeName strValue = strObjectName iStatus = dmAPISet(strCmd, strValue) If iStatus = 0 Then MsgBox "Error setting " & strAttributeName Exit Sub End If strAttributeName = "method_verb" strCmd = "set,c," & strObjectID & "," & strAttributeName strValue = strMethodVerb iStatus = dmAPISet(strCmd, strValue) If iStatus = 0 Then MsgBox "Error setting " & strAttributeName Exit Sub End If strAttributeName = "use_method_content" strCmd = "set,c," & strObjectID & "," & strAttributeName strValue = strUseMethodContent iStatus = dmAPISet(strCmd, strValue) If iStatus = 0 Then MsgBox "Error setting " & strAttributeName Exit Sub End If If strUseMethodContent = "T" and blnImportContentFIle Then strCmd = "setfile,c," & strObjectID & "," & strFileName & "," & strFormat iStatus = dmAPIExec(strCmd) If iStatus = 0 Then MsgBox "Error executing setfile" Exit Sub End If End If strAttributeName = "method_type" strCmd = "set,c," & strObjectID & "," & strAttributeName strValue = strMethodType iStatus = dmAPISet(strCmd, strValue) If iStatus = 0 Then MsgBox "Error setting " & strAttributeName Exit Sub End If strAttributeName = "launch_async" strCmd = "set,c," & strObjectID & "," & strAttributeName strValue = strLaunchAsync iStatus = dmAPISet(strCmd, strValue) If iStatus = 0 Then MsgBox "Error setting " & strAttributeName Exit Sub End If strAttributeName = "run_as_server" strCmd = "set,c," & strObjectID & "," & strAttributeName strValue = strRunAsServer iStatus = dmAPISet(strCmd, strValue) If iStatus = 0 Then MsgBox "Error setting " & strAttributeName Exit Sub End If '-------------------------------------------------------------------------- ' Create the Method Object and set the attributes '-------------------------------------------------------------------------- strCmd = "save,c," & strObjectID iStatus = dmAPIExec(strCmd) If iStatus = 0 Then MsgBox "Error saving object. Message From server was " & dmAPIGet("getmessage,c") Exit Sub Else MsgBox "Method Object Created Successfully. Object ID = " & strObjectID End If End Sub