2023-08-01 16:05:34 +03:00
@ rem ----------------------------------------------------------
@ rem This Source Code Form is subject to the terms of the
@ rem Mozilla Public License, v.2.0. If a copy of the MPL
@ rem was not distributed with this file, You can obtain one
@ rem at http://mozilla.org/MPL/2.0/.
@ rem ----------------------------------------------------------
@ rem Codebase: https://github.com/ArKuznetsov/1CFilesConverter/
@ rem ----------------------------------------------------------
2023-08-01 17:37:57 +03:00
@ ECHO OFF
2023-07-25 14:49:55 +03:00
2023-09-08 07:49:45 +03:00
SETLOCAL ENABLEDELAYEDEXPANSION
2023-07-31 18:30:54 +03:00
2023-10-05 10:59:12 +03:00
IF not defined V8_ENCODING set V8_ENCODING = 65001
2023-10-05 11:12:31 +03:00
chcp %V8_ENCODING% > nul
2023-10-05 10:59:12 +03:00
2023-08-01 17:52:20 +03:00
set CONVERT_VERSION = UNKNOWN
2023-09-07 07:47:33 +03:00
IF exist " %~dp0 ..\VERSION " FOR /F " usebackq tokens=* delims= " %% i IN ( " %~dp0 ..\VERSION " ) DO set CONVERT_VERSION = %% i
2023-08-01 17:52:20 +03:00
echo 1C files converter v.%CONVERT_VERSION%
2023-09-07 18:34:43 +03:00
echo ======
2023-09-08 12:03:32 +03:00
echo [INFO] Convert 1C external data processors ^& reports to 1C:Designer XML format
2023-07-27 06:51:34 +03:00
set ERROR_CODE = 0
2023-07-25 14:49:55 +03:00
2023-12-21 10:27:20 +03:00
IF exist " %cd% \.env " IF " %V8_SKIP_ENV% " neq " 1 " (
2023-10-10 16:26:43 +03:00
FOR /F " usebackq tokens=* " %% a in ( " %cd% \.env " ) DO (
2024-05-24 19:52:59 +03:00
FOR /F " tokens=1* delims== " %% b IN ( " %% a " ) DO (
2023-09-06 17:04:33 +03:00
IF not defined %% b set " %% b= %% c "
)
)
)
2024-10-09 10:28:36 +03:00
IF not defined V8_VERSION set V8_VERSION = 8.3.23.2040
2023-07-25 14:49:55 +03:00
IF not defined V8_TEMP set V8_TEMP = %TEMP% \1c
2023-09-08 12:03:32 +03:00
echo [INFO] Using 1C:Enterprise, version %V8_VERSION%
echo [INFO] Using temporary folder " %V8_TEMP% "
2024-10-09 10:28:36 +03:00
IF not defined V8_TOOL set V8_TOOL = " %PROGRAMW6432% \1cv8\ %V8_VERSION% \bin\1cv8.exe "
2023-08-09 23:28:45 +03:00
IF " %V8_CONVERT_TOOL% " equ " designer " IF not exist %V8_TOOL% (
echo Could not find 1C:Designer with path %V8_TOOL%
2023-10-05 09:21:00 +03:00
set ERROR_CODE = 1
goto finally
2023-08-09 23:28:45 +03:00
)
2023-10-03 19:19:10 +03:00
2023-09-07 18:34:43 +03:00
echo [INFO] Start conversion using " designer "
2023-07-27 12:34:52 +03:00
set LOCAL_TEMP = %V8_TEMP% \%~n0
set IB_PATH = %LOCAL_TEMP% \tmp_db
set WS_PATH = %LOCAL_TEMP% \edt_ws
2023-07-25 14:49:55 +03:00
2023-08-01 10:36:18 +03:00
set ARG = %1
IF defined ARG set ARG = %ARG:"=%
IF " %ARG% " neq " " set V8_SRC_PATH = %ARG%
2023-07-31 18:30:54 +03:00
set V8_SRC_FOLDER = %~dp1
set V8_SRC_FOLDER = %V8_SRC_FOLDER:~0,-1%
2023-08-01 10:36:18 +03:00
set ARG = %2
IF defined ARG set ARG = %ARG:"=%
IF " %ARG% " neq " " set V8_DST_PATH = %ARG%
2023-07-25 14:49:55 +03:00
2023-07-31 18:30:54 +03:00
IF not defined V8_SRC_PATH (
2023-07-27 06:51:34 +03:00
echo [ERROR] Missed parameter 1 - " path to folder containing data processors (*.epf) & reports (*.erf) in binary or EDT project or path to binary data processor (*.epf) or report (*.erf) "
set ERROR_CODE = 1
) ELSE (
2023-07-31 18:30:54 +03:00
IF not exist " %V8_SRC_PATH% " (
echo [ERROR] Path " %V8_SRC_PATH% " doesn't exist ^( parameter 1^) .
2023-07-27 06:51:34 +03:00
set ERROR_CODE = 1
)
2023-07-25 14:49:55 +03:00
)
2023-07-31 18:30:54 +03:00
IF not defined V8_DST_PATH (
2023-07-27 06:51:34 +03:00
echo [ERROR] Missed parameter 2 - " path to folder to save 1C data processors & reports in 1C:Designer XML format "
set ERROR_CODE = 1
2023-07-25 14:49:55 +03:00
)
2023-09-06 12:47:19 +03:00
IF defined V8_BASE_IB (
set V8_BASE_IB = %V8_BASE_IB:"=%
) ELSE (
echo [INFO] Environment variable " V8_BASE_IB " is not defined, temporary file infobase will be used.
set V8_BASE_IB =
)
IF defined V8_BASE_CONFIG (
set V8_BASE_CONFIG = %V8_BASE_CONFIG:"=%
) ELSE (
echo [INFO] Environment variable " V8_BASE_CONFIG " is not defined, empty configuration will be used.
2023-07-31 18:30:54 +03:00
set V8_BASE_CONFIG =
2023-07-25 14:49:55 +03:00
)
2023-07-27 06:51:34 +03:00
IF %ERROR_CODE% neq 0 (
2023-09-07 18:34:43 +03:00
echo ======
2023-07-27 06:51:34 +03:00
echo [ERROR] Input parameters error. Expected:
echo %% 1 - path to folder containing data processors ^( *.epf^) ^& reports ^( *.erf^) in binary or EDT project
echo or path to binary data processor ^( *.epf^) or report ^( *.erf^)
echo %% 2 - path to folder to save 1C data processors ^& reports in 1C:Designer XML format
echo .
2023-10-05 09:21:00 +03:00
goto finally
2023-07-27 06:51:34 +03:00
)
2023-07-25 14:49:55 +03:00
2023-07-27 12:34:52 +03:00
echo [INFO] Clear temporary files...
IF exist " %LOCAL_TEMP% " rd /S /Q " %LOCAL_TEMP% "
md " %LOCAL_TEMP% "
2024-10-04 10:46:15 +03:00
IF exist " %V8_DST_PATH% " IF " %V8_DP_CLEAN_DST% " equ " 1 " (
2023-10-05 16:19:02 +03:00
del /f /s /q " %V8_DST_PATH% \*.* " > nul
rd /S /Q " %V8_DST_PATH% "
)
2023-07-31 18:30:54 +03:00
IF not exist " %V8_DST_PATH% " md " %V8_DST_PATH% "
2023-07-25 14:49:55 +03:00
2023-07-27 12:34:52 +03:00
echo [INFO] Set infobase for export data processor/report...
2023-09-06 12:47:19 +03:00
IF " %V8_BASE_IB% " equ " " (
2023-07-25 14:49:55 +03:00
md " %IB_PATH% "
2023-09-06 12:47:19 +03:00
echo [INFO] Creating temporary file infobase " %IB_PATH% " ...
2023-09-08 07:49:45 +03:00
set V8_BASE_IB_CONNECTION = File=" %IB_PATH% " ;
2024-10-09 10:28:36 +03:00
set V8_DESIGNER_LOG = %LOCAL_TEMP% \v8_designer_output.log
2023-10-05 10:55:27 +03:00
%V8_TOOL% CREATEINFOBASE !V8_BASE_IB_CONNECTION! /DisableStartupDialogs /Out " !V8_DESIGNER_LOG! "
2024-10-09 10:28:36 +03:00
FOR /F " tokens=* delims= " %% i IN ( !V8_DESIGNER_LOG! ) DO IF " %% i " neq " " echo [WARN] %% i
2023-09-06 12:47:19 +03:00
goto prepare_ib
2023-07-25 14:49:55 +03:00
)
2023-09-06 12:47:19 +03:00
IF /i " %V8_BASE_IB:~0,2% " equ " /F " (
set IB_PATH = %V8_BASE_IB:~2%
echo [INFO] Basic config type: File infobase ^( !IB_PATH! ^)
set V8_BASE_IB_CONNECTION = File=" !IB_PATH! " ;
goto prepare_ib
2023-07-25 14:49:55 +03:00
)
2023-09-06 12:47:19 +03:00
IF /i " %V8_BASE_IB:~0,2% " equ " /S " (
set IB_PATH = %V8_BASE_IB:~2%
FOR /F " tokens=1,2 delims=\ " %% a IN ( " !IB_PATH! " ) DO (
set V8_BASE_IB_SERVER = %% a
set V8_BASE_IB_NAME = %% b
)
set IB_PATH = !V8_BASE_IB_SERVER! \!V8_BASE_IB_NAME!
echo [INFO] Basic config type: Server infobase ^( !V8_BASE_IB_SERVER! \!V8_BASE_IB_NAME!^)
set V8_BASE_IB_CONNECTION = Srvr=" !V8_BASE_IB_SERVER! " ;Ref=" !V8_BASE_IB_NAME! " ;
goto prepare_ib
)
IF exist " %V8_BASE_IB% \1cv8.1cd " (
set IB_PATH = %V8_BASE_IB%
echo [INFO] Basic config type: File infobase ^( !V8_SRC_PATH! ^)
set V8_BASE_IB_CONNECTION = File=" !IB_PATH! " ;
goto prepare_ib
)
: prepare_ib
IF " %V8_BASE_CONFIG% " equ " " goto export
2023-09-06 13:20:22 +03:00
IF not exist " %IB_PATH% " md " %IB_PATH% "
2023-07-31 18:30:54 +03:00
call %~dp0 conf2ib.cmd " %V8_BASE_CONFIG% " " %IB_PATH% "
2023-07-27 08:32:15 +03:00
IF ERRORLEVEL 0 goto export
2023-07-25 14:49:55 +03:00
2023-07-31 18:30:54 +03:00
echo [ERROR] Error cheking type of basic configuration " %V8_BASE_CONFIG% " !
2023-07-27 06:51:34 +03:00
echo Infobase, configuration file ^( *.cf^) , 1C:Designer XML, 1C:EDT project or no configuration expected.
2023-10-05 09:21:00 +03:00
set ERROR_CODE = 1
goto finally
2023-07-25 14:49:55 +03:00
: export
2023-08-01 17:37:57 +03:00
2023-07-27 12:34:52 +03:00
echo [INFO] Checking data processord ^& reports source type...
2023-07-25 14:49:55 +03:00
2023-07-31 18:30:54 +03:00
set V8_SRC_IS_EDT = 0
IF exist " %V8_SRC_PATH% \DT-INF\ " (
IF exist " %V8_SRC_PATH% \src\ExternalDataProcessors\ " set V8_SRC_IS_EDT = 1
IF exist " %V8_SRC_PATH% \src\ExternalReports\ " set V8_SRC_IS_EDT = 1
2023-07-25 14:49:55 +03:00
)
2023-07-31 18:30:54 +03:00
IF " %V8_SRC_IS_EDT% " equ " 1 " (
2023-07-27 12:34:52 +03:00
echo [INFO] Source type: 1C:EDT project
2023-10-05 09:21:00 +03:00
goto finally
2023-07-25 14:49:55 +03:00
)
2023-07-31 18:30:54 +03:00
set V8_SRC_MASK = " %V8_SRC_PATH% "
IF /i " %V8_SRC_PATH:~-4% " equ " .epf " (
2023-07-27 12:34:52 +03:00
echo [INFO] Source type: External data processor binary file ^( epf^)
2023-07-25 14:49:55 +03:00
goto export_epf
)
2023-07-31 18:30:54 +03:00
IF /i " %V8_SRC_PATH:~-4% " equ " .erf " (
2023-07-27 12:34:52 +03:00
echo [INFO] Source type: External report binary file ^( erf^)
2023-07-25 14:49:55 +03:00
goto export_epf
)
2023-08-01 13:32:02 +03:00
FOR /F " delims= " %% f IN ( 'dir /b /a-d " %V8_SRC_PATH% \*.epf" " %V8_SRC_PATH% \*.erf"' ) DO (
echo [INFO] Source type: External data processors ^( epf^) ^& reports ^( erf^) binary files
set V8_SRC_FOLDER = %V8_SRC_PATH%
set V8_SRC_MASK = " %V8_SRC_PATH% \*.epf " " %V8_SRC_PATH% \*.erf "
goto export_epf
)
2023-07-25 14:49:55 +03:00
2023-07-31 18:30:54 +03:00
echo [ERROR] Wrong path " %V8_SRC_PATH% " !
2023-07-26 10:56:26 +03:00
echo Folder containing external data processors ^& reports in binary or EDT project, data processor binary ^( *.epf^) or report binary ^( *.erf^) expected.
2023-10-05 09:21:00 +03:00
set ERROR_CODE = 1
goto finally
2023-07-25 14:49:55 +03:00
: export_epf
2023-09-06 12:47:19 +03:00
echo [INFO] Export data processors ^& reports from folder " %V8_SRC_PATH% " to 1C:Designer XML format " %V8_DST_PATH% " using infobase " %IB_PATH% " ...
2023-10-05 10:55:27 +03:00
set V8_DESIGNER_LOG = %LOCAL_TEMP% \v8_designer_output.log
2023-08-01 13:32:02 +03:00
FOR /F " delims= " %% f IN ( 'dir /b /a-d %V8_SRC_MASK% ' ) DO (
2023-07-27 12:34:52 +03:00
echo [INFO] Building %% ~nf...
2023-10-05 10:55:27 +03:00
%V8_TOOL% DESIGNER /IBConnectionString %V8_BASE_IB_CONNECTION% /N" %V8_IB_USER% " /P" %V8_IB_PWD% " /DisableStartupDialogs /Out " !V8_DESIGNER_LOG! " /DumpExternalDataProcessorOrReportToFiles " %V8_DST_PATH% \ %% ~nf.xml " " %V8_SRC_FOLDER% \ %% ~nxf "
FOR /F " tokens=* delims= " %% i IN ( !V8_DESIGNER_LOG! ) DO IF " %% i " neq " " echo [WARN] %% i
2023-07-25 14:49:55 +03:00
)
2023-10-05 09:35:44 +03:00
set ERROR_CODE = %ERRORLEVEL%
2023-10-05 09:21:00 +03:00
goto finally
2023-07-26 15:40:27 +03:00
: export_xml
2023-07-31 18:30:54 +03:00
echo [INFO] Export dataprocessors ^& reports from 1C:EDT project " %V8_SRC_PATH% " to 1C:Designer XML format " %V8_DST_PATH% " ...
2023-07-27 12:34:52 +03:00
2023-07-26 15:40:27 +03:00
md " %WS_PATH% "
2023-07-27 12:34:52 +03:00
2024-03-05 17:05:47 +03:00
IF not defined RING_TOOL (
2023-10-03 19:19:10 +03:00
FOR /F " usebackq tokens=1 delims= " %% i IN ( `where ring` ) DO (
2024-03-05 17:05:47 +03:00
set RING_TOOL = " %% i "
2023-10-03 19:19:10 +03:00
)
)
2024-10-09 10:28:36 +03:00
IF not defined EDTCLI_TOOL (
IF defined V8_EDT_VERSION (
IF %V8_EDT_VERSION:~0,4% lss 2024 goto checktool
set EDT_MASK = " %PROGRAMW6432% \1C\1CE\components\1c-edt- %V8_EDT_VERSION% * "
) ELSE (
set EDT_MASK = " %PROGRAMW6432% \1C\1CE\components\1c-edt-* "
)
FOR /F " tokens=* " %% d IN ( '"dir /B /S !EDT_MASK! | findstr /r /i ".*1c-edt-[0-9]*\.[0-9]*\.[0-9].*""' ) DO (
IF exist " %% d\1cedtcli.exe " set EDTCLI_TOOL = " %% d\1cedtcli.exe "
)
)
: checktool
IF not defined RING_TOOL IF not defined EDTCLI_TOOL (
echo [ERROR] Can't find " ring " or " edtcli " tool. Add path to " ring.bat " to " PATH " environment variable, or set " RING_TOOL " variable with full specified path to " ring.bat " , or set " EDTCLI_TOOL " variable with full specified path to " 1cedtcli.exe " .
2023-10-05 09:21:00 +03:00
set ERROR_CODE = 1
goto finally
2023-10-03 19:19:10 +03:00
)
2024-10-09 10:28:36 +03:00
IF defined EDTCLI_TOOL (
echo [INFO] Start conversion using " edt cli "
call %EDTCLI_TOOL% -data " %WS_PATH% " -command export --project " %V8_SRC_PATH% " --configuration-files " %V8_DST_PATH% "
) ELSE (
echo [INFO] Start conversion using " ring "
call %RING_TOOL% edt@%V8_EDT_VERSION% workspace export --project " %V8_SRC_PATH% " --configuration-files " %V8_DST_PATH% " --workspace-location " %WS_PATH% "
)
2023-10-05 09:35:44 +03:00
IF not ERRORLEVEL 0 (
set ERROR_CODE = %ERRORLEVEL%
)
2023-07-26 15:40:27 +03:00
2023-10-05 09:21:00 +03:00
: finally
2023-07-25 14:49:55 +03:00
2023-07-27 12:34:52 +03:00
echo [INFO] Clear temporary files...
IF exist " %LOCAL_TEMP% " rd /S /Q " %LOCAL_TEMP% "
2023-10-05 09:21:00 +03:00
exit /b %ERROR_CODE%