Registering Programmatically Without the Task Server

Registering a document for publishing without the Task Server involves bypassing the Task Server and creating entries directly in the Meridian Enterprise Server database. Entries can be created by using the MeridianQueue object from within VBScript, a PowerUser user interface extension, or a .NET application.

Registering without using the Task Server has the advantage that no Task Server installation or hardware resources are required. This simplifies your system configuration. However, the disadvantage of registering without the Task Server is that it requires more complicated programing on your part to register documents for publishing. For information about programmatically registering documents using the Task Server, see Registering Programmatically With the Task Server.

You can take one of the following approaches to creating the database records:

  • Use VBScript with an ActiveX object.

    The advantage of this method is that you can protect your code from accidental or malicious misuse by compiling it in the ActiveX object. Another advantage is that you can generate GUID values to set as the PublishID field in the Meridian Enterprise Server database. However, the origin of publishing is still visible and susceptible to misuse by System Administrators. This method is further described below.

  • Use VB.NET in a PowerUser user interface extension or other application.

    The advantage of this method is that the origin of publishing and all of your code are not readily discernible. Developing user interface extensions is beyond the scope of this document. For information about the Meridian Enterprise APIs, see the Meridian Enterprise .NET API Reference Guide.

ClosedRegister Documents without Task Server

To register documents without using the Task Server:

  • Call the RegisterDocument method of the MeridianQueue object and pass at least a Document object and JobCode (publishing job name) property as shown in the following examples.

    For more information about the MeridianQueue object, see MeridianQueue Object.

    The job can be submitted by any event or command where a Document object exists. For more information about the Submit method, see Document Object Methods.

    Note:
    • In VBScript, you only have access to the selected document; therefore, publishing jobs can only be created for the selected document.

    • The WinMsgBox statement in the following example is not supported by the Meridian Enterprise Web Client.

ClosedExample using Meridian Enterprise VBScript

Sub PublishCommand_Execute(Batch)
  On Error Resume Next
  'Create the script object
  Dim Publisher
  Set Publisher = New PublisherScriptObject  
  'Register the selected document for publishing.
  Call Publisher.Queue.RegisterDocument("", "Job", Document.ID, , , , , ,"Custom.StringProperty")
  'Release the script object.
  Set Publisher = Nothing   
  If Err.Number <> 0 Then  
	  WinMsgBox "Publish failed: " +  Err.Description
  End If
End Sub

'Represents a wrapper of a COM object accessible from VBScript.
'Provides deterministic release of resources.
Class PublisherScriptObject
  Private underlyingObject

  'Initializes the COM object.
  Private Sub Class_Initialize()
      Set underlyingObject = AMCreateObject("BCPublisher.MeridianQueue")
    End Sub

  'Releases the COM object.
  Private Sub Class_Terminate()
      underlyingObject.Dispose()
        Set underlyingObject = Nothing
  End Sub

  'Gets the COM object.
  Public Property Get Queue
    Set Queue = underlyingObject
  End Property

End Class

ClosedExample using a Meridian Enterprise VB.NET extension

Private Sub btnPublish_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
  Handles btnPublish.Click

  Dim publisherQueue As Object = Nothing
  ' Get the selected document to publish.
  Dim document As BCDocument = ExtensionHost.CurrentObject

  Dim vaultId = String.Format( _
    "\\{0}\{1}", _
    ExtensionHost.Repository.AMServer.Address, _
    ExtensionHost.Repository.DataStoreName)

  Try
    ' Create the publisher object.
    ' Add a second parameter set to True to create the object on the server instead
    ' if automatic downloads to client computers are prohibited.
    publisherQueue = CreateObject("BCPublisher.MeridianQueue")

    ' Register the document for publishing.
    publisherQueue.RegisterDocument( _ 
      vaultId, "3BA9DF", document.ID, , , , , , "Custom.PublishStatus")

  Finally
    ' If the object was initialized, dispose explicitly.
    If publisherQueue IsNot Nothing Then
      publisherQueue.Dispose()
      publisherQueue = Nothing
    End If
  End Try
End Sub

ClosedExample using a Meridian Enterprise VB.NET application

Private Sub DoIt(ByVal repository As BCRepository)
  Dim publisherQueue As Object = Nothing

  ' Get document to publish.
  Dim document As BCDocument = repository.GetFSObject("\MyDocument.doc")
  ' Compile the vault identifier.
  Dim vaultId = String.Format("\\{0}\{1}", repository.AMServer.Address, repository.DataStoreName)

  Try
    ' Create the publisher object.
    publisherQueue = CreateObject("BCPublisher.MeridianQueue")

    ' Register the document for publishing.
    publisherQueue.RegisterDocument( _ 
      vaultId, "3BA9DF", document.ID, , , , , , "Custom.PublishStatus")

  Finally
    ' If the object was initialized, dispose explicitly.
    If publisherQueue IsNot Nothing Then
      publisherQueue.Dispose()
      publisherQueue = Nothing
    End If
  End Try
End Sub

2023