2023-07-25 13:49:55 +02:00
@ ECHO OFF
2023-07-31 17:30:54 +02:00
SETLOCAL
2023-07-27 05:51:34 +02:00
echo Convert 1C external data processors ^& reports to 1C:EDT project
set ERROR_CODE = 0
2023-07-25 13:49:55 +02:00
IF not defined V8_VERSION set V8_VERSION = 8.3.20.2290
IF not defined V8_TEMP set V8_TEMP = %TEMP% \1c
set V8_TOOL = " C:\Program Files\1cv8\ %V8_VERSION% \bin\1cv8.exe "
2023-07-26 09:56:26 +02:00
IF not defined V8_RING_TOOL (
FOR /F " usebackq tokens=1 delims= " %% i IN ( `where ring` ) DO (
set V8_RING_TOOL = " %% i "
)
2023-07-25 13:49:55 +02:00
)
2023-07-27 11:34:52 +02:00
set LOCAL_TEMP = %V8_TEMP% \%~n0
set IB_PATH = %LOCAL_TEMP% \tmp_db
set XML_PATH = %LOCAL_TEMP% \tmp_xml
set WS_PATH = %LOCAL_TEMP% \edt_ws
2023-07-25 13:49:55 +02:00
2023-08-01 09:36:18 +02:00
set ARG = %1
IF defined ARG set ARG = %ARG:"=%
IF " %ARG% " neq " " set V8_SRC_PATH = %ARG%
2023-07-31 17:30:54 +02:00
set V8_SRC_FOLDER = %~dp1
set V8_SRC_FOLDER = %V8_SRC_FOLDER:~0,-1%
2023-08-01 09:36:18 +02:00
set ARG = %2
IF defined ARG set ARG = %ARG:"=%
IF " %ARG% " neq " " set V8_DST_PATH = %ARG%
set ARG = %3
IF defined ARG set ARG = %ARG:"=%
IF " %ARG% " neq " " set V8_BASE_CONFIG = %ARG%
2023-07-25 13:49:55 +02:00
2023-07-31 17:30:54 +02:00
IF not defined V8_SRC_PATH (
2023-07-27 05:51:34 +02:00
echo [ERROR] Missed parameter 1 - " path to folder containing data processors (*.epf) & reports (*.erf) in binary or XML format or path to binary data processor (*.epf) or report (*.erf) "
set ERROR_CODE = 1
) ELSE (
2023-07-31 17:30:54 +02:00
IF not exist " %V8_SRC_PATH% " (
echo [ERROR] Path " %V8_SRC_PATH% " doesn't exist ^( parameter 1^) .
2023-07-27 05:51:34 +02:00
set ERROR_CODE = 1
)
2023-07-25 13:49:55 +02:00
)
2023-07-31 17:30:54 +02:00
IF not defined V8_DST_PATH (
2023-07-27 05:51:34 +02:00
echo [ERROR] Missed parameter 2 - " path to folder to save 1C data processors & reports in 1C:EDT format "
set ERROR_CODE = 1
2023-07-25 13:49:55 +02:00
)
2023-07-31 17:30:54 +02:00
IF not exist " %V8_BASE_CONFIG% " (
echo [INFO] Path " %V8_BASE_CONFIG% " doesn't exist ^( parameter 3^) , empty infobase will be used.
set V8_BASE_CONFIG =
2023-07-25 13:49:55 +02:00
)
2023-07-27 05:51:34 +02:00
IF %ERROR_CODE% neq 0 (
echo ===
echo [ERROR] Input parameters error. Expected:
echo %% 1 - path to folder containing data processors ^( *.epf^) ^& reports ^( *.erf^) in binary or XML format
echo or path to binary data processor ^( *.epf^) or report ^( *.erf^)
echo %% 2 - path to folder to save 1C data processors ^& reports in 1C:EDT format
echo %% 3 - ^( optional^) path to 1C configuration ^( binary ^( *.cf^) , 1C:Designer XML format or 1C:EDT project^)
echo or folder contains 1C infobase used for convertion
echo .
exit /b %ERROR_CODE%
)
2023-07-25 13:49:55 +02:00
2023-07-27 11:34:52 +02:00
echo [INFO] Clear temporary files...
IF exist " %LOCAL_TEMP% " rd /S /Q " %LOCAL_TEMP% "
md " %LOCAL_TEMP% "
2023-07-31 17:30:54 +02:00
IF exist " %V8_DST_PATH% " rd /S /Q " %V8_DST_PATH% "
md %V8_DST_PATH%
2023-07-25 13:49:55 +02:00
2023-07-27 11:34:52 +02:00
echo [INFO] Set infobase for export data processor/report...
2023-07-31 17:30:54 +02:00
set BASE_CONFIG_DESCRIPTION = configuration from " %V8_BASE_CONFIG% "
2023-07-25 13:49:55 +02:00
2023-07-31 17:30:54 +02:00
IF " %V8_BASE_CONFIG% " equ " " (
2023-07-25 13:49:55 +02:00
md " %IB_PATH% "
2023-07-27 11:34:52 +02:00
echo [INFO] Creating infobase " %IB_PATH% " ...
2023-07-25 13:49:55 +02:00
set BASE_CONFIG_DESCRIPTION = empty configuration
%V8_TOOL% CREATEINFOBASE File=%IB_PATH% ; /DisableStartupDialogs
goto export
)
2023-07-31 17:30:54 +02:00
IF exist " %V8_BASE_CONFIG% \1cv8.1cd " (
2023-07-27 11:34:52 +02:00
echo [INFO] Basic config source type: Infobase
2023-07-25 13:49:55 +02:00
set BASE_CONFIG_DESCRIPTION = existed configuration
2023-07-31 17:30:54 +02:00
set IB_PATH = %V8_BASE_CONFIG%
2023-07-25 13:49:55 +02:00
goto export
)
2023-07-27 07:32:15 +02:00
md " %IB_PATH% "
2023-07-31 17:30:54 +02:00
call %~dp0 conf2ib.cmd " %V8_BASE_CONFIG% " " %IB_PATH% "
2023-07-27 07:32:15 +02:00
IF ERRORLEVEL 0 goto export
2023-07-25 13:49:55 +02:00
2023-07-31 17:30:54 +02:00
echo [ERROR] Error cheking type of basic configuration " %V8_BASE_CONFIG% " !
2023-07-27 05:51:34 +02:00
echo Infobase, configuration file ^( *.cf^) , 1C:Designer XML, 1C:EDT project or no configuration expected.
2023-07-25 13:49:55 +02:00
exit /b 1
: export
2023-07-27 11:34:52 +02:00
echo [INFO] Checking data processord ^& reports source type...
2023-07-25 13:49:55 +02:00
2023-07-31 17:30:54 +02:00
FOR /f %% f IN ( 'dir /b /a-d " %V8_SRC_PATH% \*.epf" " %V8_SRC_PATH% \*.erf"' ) DO (
2023-07-27 11:34:52 +02:00
echo [INFO] Source type: External data processors ^( epf^) ^& reports ^( erf^) binary files
2023-07-31 17:30:54 +02:00
set V8_SRC_FOLDER = %V8_SRC_PATH%
set V8_SRC_MASK = " %V8_SRC_PATH% \*.epf " " %V8_SRC_PATH% \*.erf "
2023-07-25 13:49:55 +02:00
goto export_epf
)
2023-07-31 17:30:54 +02:00
FOR /f %% f IN ( 'dir /b /a-d " %V8_SRC_PATH% \*.xml"' ) DO (
2023-07-27 11:34:52 +02:00
echo [INFO] Source type: 1C:Designer XML files folder ^( external data processors ^& reports^)
2023-07-31 17:30:54 +02:00
set XML_PATH = %V8_SRC_PATH%
set V8_SRC_MASK = " %V8_SRC_PATH% \*.xml "
2023-07-25 13:49:55 +02:00
goto export_xml
)
2023-07-31 17:30:54 +02:00
set V8_SRC_MASK = " %V8_SRC_PATH% "
IF /i " %V8_SRC_PATH:~-4% " equ " .xml " (
2023-07-27 11:34:52 +02:00
echo [INFO] Source type: 1C:Designer XML files ^( external data processor or report^)
2023-07-31 17:30:54 +02:00
set XML_PATH = %V8_SRC_FOLDER%
2023-07-25 13:49:55 +02:00
goto export_xml
)
2023-07-31 17:30:54 +02:00
IF /i " %V8_SRC_PATH:~-4% " equ " .epf " (
2023-07-27 11:34:52 +02:00
echo [INFO] Source type: External data processor binary file ^( epf^)
2023-07-25 13:49:55 +02:00
goto export_epf
)
2023-07-31 17:30:54 +02:00
IF /i " %V8_SRC_PATH:~-4% " equ " .erf " (
2023-07-27 11:34:52 +02:00
echo [INFO] Source type: External report binary file ^( erf^)
2023-07-25 13:49:55 +02:00
goto export_epf
)
2023-07-31 17:30:54 +02:00
echo [ERROR] Wrong path " %V8_SRC_PATH% " !
2023-07-25 13:49:55 +02:00
echo Folder containing external data processors ^& reports in binary or XML format, data processor binary ^( *.epf^) or report binary ^( *.erf^) expected.
exit /b 1
: export_epf
2023-07-31 17:30:54 +02:00
echo [INFO] Export data processors ^& reports from folder " %V8_SRC_PATH% " to 1C:Designer XML format " %XML_PATH% " using infobase " %IB_PATH% " with %BASE_CONFIG_DESCRIPTION% ...
2023-07-26 17:08:57 +02:00
md " %XML_PATH% "
2023-07-31 17:30:54 +02:00
FOR /f %% f IN ( 'dir /b /a-d %V8_SRC_MASK% ' ) DO (
2023-07-27 11:34:52 +02:00
echo [INFO] Building %% ~nf...
2023-07-31 17:30:54 +02:00
%V8_TOOL% DESIGNER /IBConnectionString File=" %IB_PATH% " ; /DisableStartupDialogs /DumpExternalDataProcessorOrReportToFiles " %XML_PATH% " " %V8_SRC_FOLDER% \ %% ~nxf "
2023-07-25 13:49:55 +02:00
)
: export_xml
2023-07-26 17:08:57 +02:00
md " %WS_PATH% "
2023-07-31 17:30:54 +02:00
echo [INFO] Export dataprocessors ^& reports from 1C:Designer XML format " %XML_PATH% " to 1C:EDT format " %V8_DST_PATH% " ...
call %V8_RING_TOOL% edt workspace import --project " %V8_DST_PATH% " --configuration-files " %XML_PATH% " --workspace-location " %WS_PATH% " --version " %V8_VERSION% "
2023-07-25 13:49:55 +02:00
2023-07-27 11:34:52 +02:00
echo [INFO] Clear temporary files...
IF exist " %LOCAL_TEMP% " rd /S /Q " %LOCAL_TEMP% "