In this article, we will discuss the organization of 1C: Enterprise 7.7 auto-exchange using URBD (distributed database management) via an FTP server. To make the task more concrete, let us assume that we have a central office and several remote branches (outlets) that will exchange information with the central office through auto-exchange and distributed databases.
We will not dwell on the configuration of a distributed IB, assuming that you have already done this more than once. Our task is to reduce the “user component” of auto-exchange to a minimum, i.e. - to ensure that the user runs a single shortcut for auto-exchange, after the launch of which the information from the central database would fall into the periphery and vice versa. To organize all of the above, we will need an FTP server, as well as Internet access at all outlets. Suppose we have the following configuration of a distributed database (screenshot from the central information security):
At the same time, in the settings of the auto-exchange parameters, the mode is set to automatic, the upload directory is
C: \ DB \ CP , the download directory is
C: \ DB \ PC (where C: \ DB is actually the path to the central database), and the file names of the upload and downloads for the specified peripheral IB have the following meanings:
')
Peripheral information security | Download Directory | Download Directory | Upload File Name | Download File Name |
---|
MG1 (Rostov) | C: \ DB \ CP | C: \ DB \ PC | MG1C.zip | MG1D.zip |
MG2 (Novosibirsk) | C: \ DB \ CP | C: \ DB \ PC | MG2C.zip | MG2D.zip |
MG3 (Kaluga) | C: \ DB \ CP | C: \ DB \ PC | MG3C.zip | MG3D.zip |
- Create an AutoExchange subfolder in the base folder, i.e. create C: \ DB \ AutoExchange.
- Download the ncftpget.exe and ncftpput.exe utilities from the NcFTP Client Home Page and put them in the AutoExchange folder. This is a console version of the FTP client, in principle, one could use the standard ftp.exe built in the OS, but since there are certain problems with it (sometimes, when there is no possibility to connect to FTP servers in active mode, sending / receiving data is not occurs, a number of problems are also noted when Kaspersky Anti-Virus is installed, etc.), in general, to ensure reliable and uninterrupted data exchange, it is easier to use third-party utilities.
- Create an auto-exchange rules file in the AutoExchange folder, calling it _Exchange.prm :
[General] Quit = 1 AutoExchange = 1 Output=Exchange.log [AutoExchange] SharedMode = Y ReadFrom=* WriteTo=*
- Then in the same folder we will create a batch script file _runobmen.bat or _runobmen.cmd (to correctly display Cyrillic, plus if you use Cyrillic characters in paths and the like, you need to create the file in CP866 encoding, you can do it in same notepad, choosing Terminal as the font, the following file contents:
@echo off rem (c) Decker, 2011-2013, decker@compkaluga.ru set CP_Folder=%~dp0..\CP set PC_Folder=%~dp0..\PC rem set DebugMode=-d stdout set DebugMode= title color 0b setlocal enableextensions :fromftp echo . ncftpget.exe -u ftp_user -p ftp_pass -F %DebugMode% ftp.company.ru %PC_Folder% /MG1D.zip ncftpget.exe -u ftp_user -p ftp_pass -F %DebugMode% ftp.company.ru %PC_Folder% /MG2D.zip ncftpget.exe -u ftp_user -p ftp_pass -F %DebugMode% ftp.company.ru %PC_Folder% /MG3D.zip echo ErrorLevel: %ErrorLevel% echo 1...... start "" /wait /min "C:\Program Files\1Cv77\BIN\1cv7.exe" config /d"%~dp0..\" /N"obmen" /P"obmen" /@"%~dp0_Exchange.prm" :toftp echo . ncftpput.exe -u ftp_user -p ftp_pass -F %DebugMode% ftp.company.ru . %CP_Folder%\MG1C.zip ncftpput.exe -u ftp_user -p ftp_pass -F %DebugMode% ftp.company.ru . %CP_Folder%\MG2C.zip ncftpput.exe -u ftp_user -p ftp_pass -F %DebugMode% ftp.company.ru . %CP_Folder%\MG3C.zip echo ErrorLevel: %ErrorLevel% exit
- In this example, the ftp.company.ru FTP server (username is ftp_user, password is ftp_pass) with the help of ncftpget.exe MG1D.zip, MG2D.zip, MG3D.zip exchange files received from the peripheral databases are sequentially downloaded and added to the% folder PC_Folder%, i.e. in C: \ DB \ PC (boot directory). Then the 1C: Enterprise platform is launched with the user name obmen and the password obmen and an auto-exchange occurs. As a result, in the% CP_Folder% folder there are prepared download files for peripheral databases, which are then sequentially downloaded to the ftp server using ncftpput.exe. This completes the configuration of the exchange on the side of the central database, it is enough for users to display a shortcut to the created _runobmen.bat or _runobmen.cmd , making sure that the properties of the shortcut for this scenario are exactly the folder in which it is located.
- Setting auto-exchange in each of the peripheral databases is no different, except for the file _runobmen.bat or _runobmen.cmd . Consider this file on the example of the first peripheral database:
@echo off rem (c) Decker, 2011-2013, decker@compkaluga.ru set CP_Folder=%~dp0..\CP set PC_Folder=%~dp0..\PC rem set DebugMode=-d stdout set DebugMode= title color 0b setlocal enableextensions :fromftp echo . ncftpget.exe -u ftp_user -p ftp_pass -F %DebugMode% ftp.company.ru %CP_Folder% /MG1C.zip echo ErrorLevel: %ErrorLevel% echo 1...... start "" /wait /min "C:\Program Files\1Cv77\BIN\1cv7.exe" config /d"%~dp0..\" /N"obmen" /P"obmen" /@"%~dp0_Exchange.prm" :toftp echo . ncftpput.exe -u ftp_user -p ftp_pass -F %DebugMode% ftp.company.ru . %PC_Folder%\MG1D.zip echo ErrorLevel: %ErrorLevel% exit
- Here, the first step is to take the unload file of the MG1C.zip central database from the server and place it in the CP folder, then start the auto-exchange, and place the upload file from the MG1D.zip from the PC folder back to the server. A similar scenario is used in the other two peripheral databases, with the only difference in file names.
ps The article was first published on my website and blog, now decided to use it to get an invite to Habr. I hope someone it will be useful.
pps If the path to the folder with the database contains spaces (for example, spaces are contained in the name of one of the folders), then for bat to work correctly, when calling ncftpget and ncftput% CP_Folder% and% PC_Folder%, you must enclose in quotes. If the path to the folder is implied, then we take in quotes "% CP_Folder%", if the full path to the file, then the whole path is entirely, i.e. "% CP_Folder% \ MG1C.zip".