@echo off
SETLOCAL
call settings.bat

echo.
echo +++ Export data to Doors Start +++
echo.

%DB_TOOL% %DB% -separator ; < ut_report_doors.sql
%DB_TOOL% %DB% -separator ; < ut_report_doors.sql > %REPORT_PATH%\UnitTestResultsToDOORS.csv

echo.

%DB_TOOL% %DB% -separator ; < it_report_doors.sql
%DB_TOOL% %DB% -separator ; < it_report_doors.sql > %REPORT_PATH%\IntegrationTestResultsToDOORS.csv


echo.
echo Exporting Timestamp to CSV
echo .headers on> %UT_TMP%\export_timestamp.tmp
echo .mode csv>> %UT_TMP%\export_timestamp.tmp
echo .output %REPORT_PATH_SQL%\\export_timestamp.csv>> %UT_TMP%\export_timestamp.tmp
echo select * from ( (select max(date) as date from ut_results), (select max(time) as time from ut_results where date = (select max(date) from ut_results)) )>> %UT_TMP%\export_timestamp.tmp
%DB_TOOL% %DB% < %UT_TMP%\export_timestamp.tmp


echo.
echo Exporting Module memory footprint to CSV
echo .headers on> %UT_TMP%\export_memory_footprint.tmp
echo .mode csv>> %UT_TMP%\export_memory_footprint.tmp
echo .output %REPORT_PATH_SQL%\\export_memory_footprint.csv>> %UT_TMP%\export_memory_footprint.tmp
echo select * from v_section_module_report>> %UT_TMP%\export_memory_footprint.tmp
%DB_TOOL% %DB% < %UT_TMP%\export_memory_footprint.tmp


echo.
echo Exporting Files with QAC or HIS warnings to CSV
echo .headers on> %UT_TMP%\export_files_with_qac_or_his.tmp
echo .mode csv>> %UT_TMP%\export_files_with_qac_or_his.tmp
echo .output %REPORT_PATH_SQL%\\export_files_with_qac_or_his.csv>> %UT_TMP%\export_files_with_qac_or_his.tmp
echo select * from v_q_results>> %UT_TMP%\export_files_with_qac_or_his.tmp
%DB_TOOL% %DB% < %UT_TMP%\export_files_with_qac_or_his.tmp


echo.
echo Exporting Unit Test compiler statistics to CSV
echo .headers on> %UT_TMP%\export_ut_compilerstatistics.tmp
echo .mode csv>> %UT_TMP%\export_ut_compilerstatistics.tmp
echo .output %REPORT_PATH_SQL%\\export_ut_compilerstatistics.csv>> %UT_TMP%\export_ut_compilerstatistics.tmp
echo select project, result from v_ut_results_compiler_statistics>> %UT_TMP%\export_ut_compilerstatistics.tmp
%DB_TOOL% %DB% < %UT_TMP%\export_ut_compilerstatistics.tmp


echo.
echo Exporting Module coverage statistics to CSV
echo .headers on> %UT_TMP%\export_ut_coverage_module.tmp
echo .mode csv>> %UT_TMP%\export_ut_coverage_module.tmp
echo .output %REPORT_PATH_SQL%\\export_ut_coverage_module.csv>> %UT_TMP%\export_ut_coverage_module.tmp
echo select * from v_ut_coverage_module>> %UT_TMP%\export_ut_coverage_module.tmp
%DB_TOOL% %DB% < %UT_TMP%\export_ut_coverage_module.tmp


echo.
echo +++ Export data to Doors Done +++
