-
Notifications
You must be signed in to change notification settings - Fork 0
/
elm_transmitter.cmd
91 lines (69 loc) · 2.7 KB
/
elm_transmitter.cmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION
SET DEC_FILE=%1
SET ACTION=%2
CLS
SET SWISSDIR=C:\Program Files (x86)\SwissDecTX4
SET SWISSDEC=C:\Program Files (x86)\SwissDecTX4\SwissDecTX
SET CYGWIN=C:\cygwin
SET CYGBIN=%CYGWIN%\bin
SET XMLLINT=%CYGBIN%\xmllint.exe
SET DIRNAME=%CYGBIN%\dirname.exe
SET BASENAME=%CYGBIN%\basename.exe
SET DATECMD=%CYGBIN%\date.exe ^+%%Y%%m%%d%%H%%M
FOR /F "tokens=*" %%G IN ('%DATECMD%') DO @SET XDATE=%%G
FOR /F "tokens=*" %%G IN ('%DIRNAME% %1') DO @SET BASEPATH=%%G
FOR /F "tokens=*" %%G IN ('%BASENAME% %1') DO @SET DEC_FILE=%%G
FOR /F "tokens=*" %%G IN ('%BASENAME% -s .xml %1') DO @SET XML_FILE=%%G
SET JOB_FILE=%XML_FILE%_job.xml
SET PLA_FILE=%XML_FILE%_pla.xml
SET LOG_FILE=%XDATE%\%XML_FILE%_log.log
PUSHD "%BASEPATH%"
%CYGBIN%\MKDIR -p %XDATE%
IF "%ACTION%"=="PING" GOTO:PING
IF "%ACTION%"=="DECLARE" GOTO:DECLARE
IF "%ACTION%"=="STATUS" GOTO:STATUS
IF "%ACTION%"=="DATA" GOTO:DATA
:PING
SET ACTION=PING
"%SWISSDEC%" PING > %LOG_FILE%
IF NOT ERRORLEVEL 0 GOTO:ERROR
ECHO %ACTION% OK... %ERRORLEVEL%
REM IF "%ACTION%"=="PING" GOTO:END
:DECLARE
SET ACTION=TX
SET RES_FILE=%XDATE%\%XML_FILE%_%ACTION%_res.xml
SET EIV_FILE=%XDATE%\%XML_FILE%_%ACTION%_eiv.xml
SET ANS_FILE=%XDATE%\%XML_FILE%_%ACTION%_ans.xml
"%SWISSDEC%" %ACTION% -dec %DEC_FILE% -res %RES_FILE% -eiv %EIV_FILE% -ans %ANS_FILE% -job %JOB_FILE% >> %LOG_FILE%
IF NOT ERRORLEVEL 0 GOTO:ERROR
ECHO %ACTION% OK... %ERRORLEVEL%
REM IF "%ACTION%"=="DECLARE" GOTO:FORMAT
:STATUS
SET ACTION=STATUS
SET RES_FILE=%XDATE%\%XML_FILE%_%ACTION%_res.xml
SET EIV_FILE=%XDATE%\%XML_FILE%_%ACTION%_eiv.xml
SET ANS_FILE=%XDATE%\%XML_FILE%_%ACTION%_ans.xml
SET END_FILE=%XDATE%\%XML_FILE%_%ACTION%_end.xml
"%SWISSDEC%" %ACTION% -dec %DEC_FILE% -job %JOB_FILE% -res %RES_FILE% -eiv %EIV_FILE% -ans %ANS_FILE% -pla %PLA_FILE% -end %END_FILE% >> %LOG_FILE%
IF NOT ERRORLEVEL 0 GOTO:ERROR
ECHO %ACTION% OK... %ERRORLEVEL%
REM IF "%ACTION%"=="STATUS" GOTO:FORMAT
:DATA
SET ACTION=DATA
SET RES_FILE=%XDATE%\%XML_FILE%_%ACTION%_res.xml
SET EIV_FILE=%XDATE%\%XML_FILE%_%ACTION%_eiv.xml
SET ANS_FILE=%XDATE%\%XML_FILE%_%ACTION%_ans.xml
SET OUT_FILE=%XDATE%\%XML_FILE%_%ACTION%_out.xml
"%SWISSDEC%" %ACTION% -dec %DEC_FILE% -pla %PLA_FILE% -dom TaxAtSource -res %RES_FILE% -eiv %EIV_FILE% -ans %ANS_FILE% -out %OUT_FILE% >> %LOG_FILE%
IF NOT ERRORLEVEL 0 GOTO:ERROR
ECHO %ACTION% OK... %ERRORLEVEL%
REM IF "%ACTION%"=="DATA" GOTO:FORMAT
:FORMAT
REM $ for f in *.xml ; do xmllint $f --format --output $f ; done
FORFILES /S /P %XDATE% /M *.xml /D 0 /C "cmd /c %XMLLINT% @file --format --output @file"
:ERROR
IF NOT ERRORLEVEL 0 ECHO %ACTION% FAILED... %ERRORLEVEL%
:END
PAUSE
POPD