Project

General

Profile

Routine of station setuprestoration after crash » goodsdirtool.bat

Edvīns Liepa, 2021-07-15 13:58

 
@echo off

if "%*"=="" (
echo Usage: "%~n0 DSN [extract|load]"
exit 1
)

setlocal EnableExtensions EnableDelayedExpansion

set mastersoft_dir=C:\Mastersoft
set dbadm=%mastersoft_dir%\Deployment\DbAdm\DbAdm.exe
set sysexp=%mastersoft_dir%\Deployment\SysExp\SysExp.exe

set dsn=IPSDATABASE
set operation=extract
if "%1" neq "" (
set dsn=%1
if "%2" neq "" set operation=%2
)

if "%operation%" equ "extract" (
echo Goods directories will be extracted from %dsn%
) else (
if "%operation%" equ "load" (
echo Goods directories will be loaded to %dsn%
) else (
echo Unknown command. Exiting...
goto:eof
)
)
set /p UserAgree=Continue? (y/n):
if /I "%UserAgree%" neq "y" (
goto:eof
)

if "%operation%" equ "extract" (
echo Extracting goods directories...
if ERRORLEVEL 1 goto:eof
%sysexp% --opts=nokey --raw --table=6 %dsn% data_06.csv
if ERRORLEVEL 1 goto:eof
%sysexp% --opts=nokey --raw --table=47 %dsn% data_47.csv
if ERRORLEVEL 1 goto:eof
%sysexp% --opts=nokey --raw --table=49 %dsn% data_49.csv
if ERRORLEVEL 1 goto:eof
%sysexp% --opts=nokey --raw --table=30 %dsn% data_30.csv
if ERRORLEVEL 1 goto:eof
) else (
echo Loading goods directories...
%dbadm% --opts=nokey --clear --tables=6 --dsn=%dsn%
if ERRORLEVEL 1 goto:eof
%sysexp% --opts=nokey --raw --table=6 data_06.csv %dsn%
if ERRORLEVEL 1 goto:eof

%dbadm% --opts=nokey --clear --tables=47 --dsn=%dsn%
if ERRORLEVEL 1 goto:eof
%sysexp% --opts=nokey --raw --table=47 data_47.csv %dsn%
if ERRORLEVEL 1 goto:eof

%dbadm% --opts=nokey --clear --tables=49 --dsn=%dsn%
if ERRORLEVEL 1 goto:eof
%sysexp% --opts=nokey --raw --table=49 data_49.csv %dsn%
if ERRORLEVEL 1 goto:eof

%dbadm% --opts=nokey --clear --tables=30 --dsn=%dsn%
if ERRORLEVEL 1 goto:eof
%sysexp% --opts=nokey --raw --table=30 data_30.csv %dsn%
if ERRORLEVEL 1 goto:eof
)

echo Done.
    (1-1/1)