External connections



External connection is one of the methods for integrating with other systems. The main task addressed by an external connection is ensuring reliable and fast program access to 1C:Enterprise 8 data from third-party applications.

Differences from Automation Server

Generally speaking, the operation over an external connection is similar to the Automation Server mode. The key differences are as follows:

  • In the Automation Server mode, full 1C:Enterprise 8 application is launched, while in the external connection mode, a small in-proc COM server is launched.

  • In the external connection mode, UI-related functions are unavailable.

  • The application module is not active in the external connection mode. Instead, the external connection module is used.


Benefits

The external connection mode has the following advantages over the Automation Server mode:

  • a connection is established faster as it doesn't require creating a dedicated operating system process—instead, all the actions are performed in the activating process

  • faster references to properties and methods of 1C:Enterprise 8 objects, as the request doesn't require establishing the interprocess communication

  • lower load on the operating system resources

Example

To organize access to 1C:Enterprise 8 data over an external connection, the developer has to do the following:

  • create a COM connection manager that will establish a connection

  • using the received external connection object, refer to available methods, properties, and objects of the connected database

A good example is referring to 1C:Enterprise 8 infobase over an external connection from an MS Visual Basic program.

The infobase is located in the following directory: c:\InfoBases\Trade. In 1C:Enterprise 8, the developer creates a CatalogManager.Goods object and a new group of items titled ***** Export from Excel ******. Data from the MS Excel sheet is written to the newly-created catalog group:

 

Sub Excel_to_trade () 

Dim cntr As Object 
Dim trade As Object  
Dim Item As Object 

Set cntr = CreateObject («V82.COMConnector»)                                   'Create COM Connection Manager
Set trade = cntr.Connect («File=""c:\InfoBases\Trade»»; Usr=""Director»»;»)     'Get External Connection
Set GoodsCatalog = trade.Directories.Goods 
Set GoodsGroup = GoodsCatalog.CreateGroup () 

GoodsGroup.Name = «***** Export from Excel ******» 
GoodsGroup.Write 

N = 100   'Lines in Document 
For Count = 1 To N  

Set Item = GoodsCatalog.CreateItem ()  
Item.Name = Application.Cells (Count, 2).Value  
Item.Ret_Price = Application.Cells (Count, 3).Value  
Item.Small_Wholesale_Price = Application.Cells (Count, 4).Value  
Item.Wholesale_Price = Application.Cells (Count, 5).Value  
Item.Parent = GoodsGroup.Link  

Item.Write 

Next Count

End Sub

Execution Context

In the external connection mode, the external connection module handles the tasks handled by the application module. This module may have event handlers that may contain actions performed upon initializing and terminating the connection.

Procedures, functions, and global variables, determined in an external connection module with the code word Export, become—as in the case of the application module—part of the global context.

An external connection with 1C:Enterprise 8 infobase provides full access to the global context and may have the following in properties:

  • system constants

  • values of objects set in the configurator accessed through managers (e.g. constants, enumerations, directories, documents, document journals, reports, processing, charts of characteristic types, charts of accounts, charts of calculation types, and registers)

  • variables defined in the external connection module with the code word Export

An external connection may have the following as its methods:

  • system procedures and functions

  • procedures and functions of the external connection module and common modules, defined with the code word Export

  • extra method NewObject

Connection Pool

Open external connections can be saved to a pool for further reuse. This helps save resources and facilitate the experience of a user that previously connected to a respective infobase saved in the pool.

Use Cases

An external connection can allow web access to 1C:Enterprise 8 database:


Also, an external connection enables 1C:Enterprise 8 to exchange its XML documents with a third-party application:


Next page: Client/Server automation

Be the first to know tips & trick on business application development!

A confirmation e-mail has been sent to the e-mail address you provided .

Click the link in the e-mail to confirm and activate the subscription.