@Echo off

 setlocal
 rem ---------------------------------------------------------
 rem JobManager CheckBox_Main Script
 rem (c) J.Feuerstein 24.11.2006
 rem
 rem Aenderungs Info:
 rem User    Date/Time (Alt+D)        Infotext:
 rem J.Fes   24.11.2006 00:05         Ersterstellung 24.11.2006
 rem J.Fes   31.01.2013 11:59          Update Usage of NXCB_ANALYZE_NORMALIZED_MASS_PROPS
 rem J.Fes   21.02.2013 18:04          TC_SHARED_MEMORY_DIR eingearbeitet.
 rem ---------------------------------------------------------------------------
 rem                   User  Date/Time   Infotext:
 set MyApplCurVerInfo=J.Fes  02.06.2009  erst Erstellung
 set MyApplCurVerInfo=J.Fes  26.06.2009  Aktualiesierung TCE
 set MyApplCurVerInfo=J.Fes  07.01.2010  JobServerExtendCommandsTrigger eingefuegt
 set MyApplCurVerInfo=J.Fes  22.03.2010  Auswertung D.NX?.Err eingefuegt
 set MyApplCurVerInfo=J.Fes  22.04.2010  Excuting CheckBox isoliert
 set MyApplCurVerInfo=J.Fes  08.08.2012  ..JobManagerCmdTools.exe eingearbeitet.
 set MyApplCurVerInfo=J.Fes  26.02.2013  ..JobManagerCmdTools.exe eingearbeitet.



 rem -- JobParameter
 set JobObjectsPacket_NE=#JobObjectsPacket_NE#
 set JobObjectsPacketAllDetails_NE=#JobObjectsPacketAllDetails_NE#

 rem -- #Step: Globale Variablen des Scriptes einstellen -----------------------
 rem -- CB Allgemeine Variablen festlegen
 set NxCB_ResData_DP=%CmdCurRoot_DP%\JobTemp
 if not exist "%NxCB_ResData_DP%" md "%NxCB_ResData_DP%"

 rem -- temp dir organiesieren -------
 set temp_DP_org=%temp%
 set temp=%NxCB_ResData_DP%
 set tmp=%temp%
 cd /d "%temp%"

 rem -- LogFiles and Dir defs --------
 set NxCB_CgmData_DP=%NxCB_ResData_DP%
 set CB_partList_DPNE=%NxCB_ResData_DP%\zzCB01_InputPartList.txt
 set NxCB_Log_DPNE=%NxCB_ResData_DP%\zzCB02_RunExtractDataLog.txt
 set NxCB_ResultData_DPNE=%NxCB_ResData_DP%\zzCB03_ResultData.csv
 set NxCB_CBMoveToArchiv_csvlog_DPNE=%NxCB_ResData_DP%\zzCB04_CBMoveToArchiv_csvlog.txt
 set NxCB_CmdLog_DPNE=%NxCB_ResData_DP%\zzCB05_CBCmdCommandOutPut.txt


 rem -- Org CB DataRoot Archiv
 if not defined JobMgrDataOrg_Root_DP_Custom set JobMgrDataOrg_Root_DP_Custom=#12-Data#\JobMgrData

 set BinL_DP=%CmdCurRoot_DP%\..\BinL

 rem -- #Doc: NxCB_program_exe_NE must be set in JobMgr:[Scrip+Paramters] or in CheckBox_CustomerStart.cmd
 set NxCB_program_exe_DP=%JobScriptTemplateMinus1_DP%

 set NxCB_program_exe_DPNE=%NxCB_program_exe_DP%\%NxCB_program_exe_NE%
 set NxCB_program_exeL_DPNE=%BinL_DP%\%NxCB_program_exe_NE%


 rem -- #Step: Tools local kopieren --------------------------------------------
 rem set JobManagerCmdTools_L=%BinL_DP%\JobManagerCmdTools.exe
 set JobManagerCmdTools_L=%BinL_DP%\JobManagerCmdTools.exe
 rem copy JobManagerCmdTools.exe to local Computer
 robocopy /NP /NJS /NJH /NDL /NFL /R:2 /W:2 "%BinPublic_ClientServer_DP%" "%BinL_DP%" "JobManagerCmdTools.exe"
 rem 10.10.2012 J.Fes "%BinPublic_ClientServer_DP%\JobManagerCmdTools_Resources eingearbeitet
 robocopy /NP /NJS /NJH /NDL /NFL /R:2 /W:2 /MIR "%BinPublic_ClientServer_DP%\JobManagerCmdTools_Resources" "%BinL_DP%\JobManagerCmdTools_Resources" "*.*"
 robocopy /NP /NJS /NJH /NDL /NFL /R:2 /W:2 "%NxCB_program_exe_DP%" "%BinL_DP%" "%NxCB_program_exe_NE%"

 if /i "%JobMgr_Debug%" neq "ON" goto :JumbOver
     start "" Explorer "%temp%"
:JumbOver

 rem -- #Step: Verzweigen in die erforderliche UnterRoutine CB_Action ----------
 if /I "%CB_Action%" neq "NxCB_Extract" goto :NxCB_Extract_StepOver
   call :NxCBox_Extract_UsingEnvironTC
:NxCB_Extract_StepOver

 if /I "%CB_Action%" neq "ResultGen" goto :ResultGen_StepOver
   rem -- #Step: Result Daten erzugen
   call :CB_ResultGen
:ResultGen_StepOver

 rem -- #Step: End of process --------------------------------------------------
:end
 Echo ---------------------------------------------------------------------
 Echo Job:[%JobName%] finished at:[%date% %time:~0,5%]
 Echo Info: all files in: [%temp%]
 Echo       will be zipt by JobClient and send to JobServer
 if /i "%JobMgr_Debug%" neq "ON" goto :JumbOverDebug
   Echo #debug: -- End --
   pause
:JumbOverDebug

 if /i "%JobMgr_TEST%" neq "ON" goto :JumbOverTest
   Echo #Test: -- End --
   pause
:JumbOverTest

 Call :ColorSet End
 cd /d "%temp_DP_org%"
 endlocal
goto :eof

rem ============================================================================
:NxCBox_Extract_UsingEnvironTC

  Call :Echo "--------------------------------------------------------------------------"
  rem Farbe auf JobColorJobIsExecuting setzen
  call :ColorSet IsExecuting

  rem 31.01.2013/J.Fes Value=TRUE Enables extract of CentreOfGravityN1 / MomentOfInertiaN1
  if not defined NXCB_ANALYZE_NORMALIZED_MASS_PROPS set NXCB_ANALYZE_NORMALIZED_MASS_PROPS=TRUE


  rem TC Environ einstellen
  call :TcNxSetEnviron

  call :Parse_ALL %UGII_LOAD_OPTIONS%        UGII_LOAD_OPTIONS
  call :Parse_ALL %UGII_LOCAL_USER_DEFAULTS% UGII_LOCAL_USER_DEFAULTS

  Call :Echo "--------------------------------------------------------------------------"
  Call :Echo "Extracting NxCB Data"
  Call :Echo "TcDb..............................: %TceSiteId%"
  Call :Echo "Use NX Version....................: %NxCB_UseNxVer%"
  Call :Echo "Nx CheckBox Para..................: %NxCheckBox_JobPara%"
  Call :Echo "NxCBProg.Path.....................: %BinL_DP%"
  Call :Echo "NxCBProg.exe......................: %NxCB_program_exe_NE%"
  Call :Echo "JobMgrData Root...................: %JobMgrDataOrg_Root_DP%"
  Call :Echo "NXCB_ANALYZE_NORMALIZED_MASS_PROPS: %NXCB_ANALYZE_NORMALIZED_MASS_PROPS%"
  Call :Echo "."
  Call :Echo "UGII_LOAD_OPTIONS.................: %UGII_LOAD_OPTIONS_NE%"
  Call :Echo "UGII_SITE_DIR.....................: %UGII_SITE_DIR%"
  Call :Echo "UGII_LOCAL_USER_DEFAULTS..........: %UGII_LOCAL_USER_DEFAULTS_NE%"
  Call :Echo "--------------------------------------------------------------------------"

  rem -- #Step: extrahieren + auflisten der via CB zu verarbeitenden Objecte
  set toRun=%JobManagerCmdTools_L%
  set toRun=%toRun% -Action "CBTools_2012_05"
  set toRun=%toRun% -SubAction "CBExtractInputListGen"
  set toRun=%toRun% -CBPara_partListGen "%CB_partList_DPNE%"
  set toRun=%toRun% -JobRoot_DP "%CmdCurRoot_DP%"
  set toRun=%toRun% -JobData1ToProcessDoPrint

  if /i "%JobMgr_Debug%" neq "ON" goto :JumbOverDebug
    set toRun=%toRun% -verbose -pause
    set testCmd_DPNE=%temp%\zzCB91_JC_CmdTools_Test_CBPara_partListGen_cmd.txt
    Echo %toRun%>"%testCmd_DPNE%"
    Echo #---------------------
    Echo #Debug: look at Test.cmd
    Echo  %testCmd_DPNE%
    pause
:JumbOverDebug

  rem -- ausfuehren JobManagerCmdTools_L
  Call %toRun%

  if /i "%JobMgr_Debug%" neq "ON" goto :JumbOverDebug
    Echo #---------------------
    Echo #Debug: content:
    Echo CB_partList_DPNE:[%CB_partList_DPNE%]
    Type "%CB_partList_DPNE%"
    Echo #---------------------
    Echo #Debug: Dir
    Echo NxCB_program_exe_DPNE:[%NxCB_program_exeL_DPNE%]
    Dir "%NxCB_program_exeL_DPNE%"
    pause
:JumbOverDebug

	  rem -- #Step: pruefen ob File %CB_partList_DPNE% gefunden wurde ----------------
  if not exist "%CB_partList_DPNE%" goto :JobProcessingErr_CB_partList_DPNE_notFount

  rem -- #Step: Cb NxCB_program_exe_DPNE command erstellen -Sheet=_All_ 05.02.2013 eingefuegt J.Fes
  if defined NxCheckBox_JobPara set JobParameter=%NxCheckBox_JobPara% -ExtractCGM_toDir="%NxCB_CgmData_DP%" -Sheet=_All_

  set toRun="%NxCB_program_exeL_DPNE%"
  set toRun=%toRun% -partList="%CB_partList_DPNE%"
  set toRun=%toRun% -log="%NxCB_Log_DPNE%"
  set toRun=%toRun% -result="%NxCB_ResultData_DPNE%"
  set toRun=%toRun% -outdir="%NxCB_ResData_DP%"
  set toRun=%toRun% %JobParameter%
  set toRun=%toRun% -pim=yes -u=%JobMgr_TcUser%

  Echo ------------------------------------------------------------------------>>"%NxCB_CmdLog_DPNE%"
  Echo NxCB Start %Date% %time%>>"%NxCB_CmdLog_DPNE%"
  Echo %toRun% -p=*********>>"%NxCB_CmdLog_DPNE%"
  rem  - clear Result
  set NxCB_RunResCode=
  if /i "%JobMgr_Debug%" neq "ON" goto :JumbOverDebug
    set >> "%temp%\zzEnviron1_BevorRunNxCB.txt"
:JumbOverDebug

  rem -- hier wird das NxCB Program aufgerufen
  rem -- hier wird das NxCB Program aufgerufen
REM   start "JFProcessMonitor.exe" JFProcessMonitor.exe -w 3000 --processName %NxCB_program_exe_NE:~0,-4% --runtimeLimitSeconds 3600 --killChildProcesses
REM   start "JFProcessMonitor.exe" JFProcessMonitor.exe -w 3000 --processName %NxCB_program_exe_NE:~0,-4% --runtimeLimitSeconds 36000 --killChildProcesses
REM   --fileLastWriteTime "%temp%\*.syslog;60" --log ..
	

	rem new 22.02.2013 S.Gueth
	set JFProcessMonitor_program_exe_DP=\\w3\ugsshare\kba_custom_v4\applications_prod\JobManagerV2\03-BinPublic
	set JFProcessMonitor_program_exe_DPNE=%JFProcessMonitor_program_exe_DP%\JFProcessMonitor.exe
	set JFProcessMonitor_program_exeL_DPNE=%BinL_DP%\JFProcessMonitor.exe
	
	robocopy /NP /NJS /NJH /NDL /NFL /R:2 /W:2 "%JFProcessMonitor_program_exe_DP%" "%BinL_DP%" "JFProcessMonitor.exe"
	
	rem Monitors NxCB_program_exe_NE 
	rem  - mit max 2 Std Laufzeit 
	rem  - mit max 6gb Memory usage für 10+ min
	rem  - mit max 5 min ohne das neue files im JobTemp entstehen oder editiert werden	 
	set toMon=%JFProcessMonitor_program_exeL_DPNE%
	set toMon=%toMon% -w 30000 --n %NxCB_program_exe_NE:~0,-4%
	set toMon=%toMon% --runtimeLimitSeconds 7200 
	set toMon=%toMon% --killChildProcesses 
	set toMon=%toMon% --fileLastWriteTime "%NxCB_ResData_DP%\*.*;600" 
	rem set toMon=%toMon% --memoryUsageHigh 6000;300 
	rem set toMon=%toMon% --saveResultsTo %NxCB_ResData_DP%\zzJFProcessMonitor_log.xml
	start "JFProcessMonitor" %toMon%
    
	Call :Wait 2
	
  rem start "JFProcessMonitor.exe" JFProcessMonitor.exe -w 5000 --processName notepad.exe --runtimeLimitSeconds 5 --killChildProcesses
  Call %toRun% -p=%JobMgr_TcPw%
  rem -- errorlevel von Run CheckBox uebernehmen
  set NxCB_RunResCode=%errorlevel%

  REM   del nicht erf. cgm daten
  REM   del "%NxCB_CgmData_DP%\*DUMMY*.cgm"
  REM   del "%NxCB_CgmData_DP%\*_master_*.cgm">nul 2>nul

  call :TracAc "%0 [NxCB_RunResCode:%NxCB_RunResCode%]"
  call :TracAc "%0 [NxCB End.......: %Date% %time:~0,5%]"
  Echo NxCB ResultCode...: %NxCB_RunResCode%>>"%NxCB_CmdLog_DPNE%"
  Echo NxCB End..........: %Date% %time:~0,5%>>"%NxCB_CmdLog_DPNE%"
  Echo ------------------------------------------------------------------------>>"%NxCB_CmdLog_DPNE%"
  Echo Objects to process:>>"%NxCB_CmdLog_DPNE%"
  Type "%CB_partList_DPNE%">>"%NxCB_CmdLog_DPNE%"
  Echo ------------------------------------------------------------------------>>"%NxCB_CmdLog_DPNE%"
  rem -- inhalt von NxCB_CmdLog_DPNE vom lauf NxCB uebernehmen
  Echo NxCB cmd Output:>>"%NxCB_CmdLog_DPNE%"
  type "%NxCB_Log_DPNE%">>"%NxCB_CmdLog_DPNE%"
  goto :CBMoveCBFilesToCBArchiv


:JobProcessingErr_CB_partList_DPNE_notFount
  Echo Err:cannot finde file:[%CB_partList_DPNE%]
  goto :CBMoveCBFilesToCBArchiv

  rem -- #Step: Move Results into Archiv
:CBMoveCBFilesToCBArchiv

  set toRun=%JobManagerCmdTools_L%
  set toRun=%toRun% -Action "CBTools_2012_05"
  set toRun=%toRun% -SubAction "CBMoveCBFilesToCBArchiv"
  set toRun=%toRun% -Title "CB Data [%NxCB_UseNxVer%] Move to CB-Archiv"

  set toRun=%toRun% -JobRoot_DP "%CmdCurRoot_DP%"
  set toRun=%toRun% -JobData1ToProcessDoPrint
  set toRun=%toRun% -JobData2ResultsDoPrint

  set toRun=%toRun% -CBPara_outdir "%NxCB_ResData_DP%"
  set toRun=%toRun% -CBPara_result "%NxCB_ResultData_DPNE%"
  set toRun=%toRun% -CBPara_log "%NxCB_Log_DPNE%"
  set toRun=%toRun% -CBPara_ExtractCGM_toDir "%NxCB_CgmData_DP%"

  set toRun=%toRun% -CBDataOrg_MoveToArchiv_WithNameExt "%NxCB_UseNxVer%"
  set toRun=%toRun% -JobMgrDataOrg_Root_DP "%JobMgrDataOrg_Root_DP_Custom%"
  rem 10.10.2012/J.Fes new
  if defined JobMgrDataOrg_BaseNameSchema_Custom set toRun=%toRun% -JobMgrDataOrg_BaseNameSchema "%JobMgrDataOrg_BaseNameSchema_Custom%"
  rem new if "%CmdCurRoot_DP%\CheckBox_ResultClassification_Custom.xml"
  if exist "%CmdCurRoot_DP%\CheckBox_ResultClassification_Custom.xml" set toRun=%toRun% -ResultClassification_DPNE "%CmdCurRoot_DP%\CheckBox_ResultClassification_Custom.xml"

  set toRun=%toRun% -LogFile "%NxCB_CBMoveToArchiv_csvlog_DPNE%"

  if /i "%JobMgr_Debug%" neq "ON" goto :JumbOverDebug
    set toRun=%toRun% -verbose -test -pause -pauseOnEnd
    set testCmd_DPNE=%temp%\zzCB92_JC_CmdTools_Test_MoveToArchiv_WithNameExt_cmd.txt
    Echo %toRun%>"%testCmd_DPNE%"
    Echo #---------------------
    Echo #Debug: look at Test.cmd
    Echo  %testCmd_DPNE%
    pause
:JumbOverDebug
  rem -- ausfuehren JobManagerCmdTools_L
  Call %toRun%

  Call :ColorSet Idel
  goto :NxCBox_Extract_UsingEnvironTC_End


 :NxCBox_Extract_UsingEnvironTC_End
  if /i "%JobMgr_Debug%" neq "ON" goto :JumbOver
    set >"%CmdCurRoot_DP%\zzEnviron2_AfterRunNxCB.txt"
:JumbOver
 goto :eof

 rem ==========================================================================
:CB_ResultGen
 rem Step: Result Daten erzeugen
 rem #ToDo: CB XML auswertung einbauen + TifGen

  rem -- CB.XML Auswertung und Tif Gen - - - -

  rem -- define defaults
  if not defined CgmToTif_cmdProg_Opt    set CgmToTif_cmdProg_Opt=default
  if not defined CgmToTif_cmdArgs_Opt    set CgmToTif_cmdArgs_Opt=default
  if not defined CBcompDifMergTifgen_Opt set CBcompDifMergTifgen_Opt=default
  if not defined CgmToTif_Opt            set CgmToTif_Opt=ON

  set toRun=%JobManagerCmdTools_L%
  set toRun=%toRun% -Action "CBTools_2012_05"
  set toRun=%toRun% -SubAction "CBResultGen"

  set toRun=%toRun% -JobRoot_DP "%CmdCurRoot_DP%"
  set toRun=%toRun% -JobData1ToProcessDoPrint
  set toRun=%toRun% -JobData2ResultsDoPrint

  set toRun=%toRun% -JobMgrDataOrg_Root_DP "%JobMgrDataOrg_Root_DP_Custom%"
  rem 10.10.2012/J.Fes new
  if defined JobMgrDataOrg_BaseNameSchema_Custom set toRun=%toRun% -JobMgrDataOrg_BaseNameSchema "%JobMgrDataOrg_BaseNameSchema_Custom%"
  rem 14.11.2012/J.Fes new
  if defined CBTifMergCopyToTifMergCollectionIfPPMgt set toRun=%toRun% -CBTifMergCopyToTifMergCollectionIfPPMgt "%CBTifMergCopyToTifMergCollectionIfPPMgt%"

  set toRun=%toRun% -CBExtrName1 %CB_Ver1%
  set toRun=%toRun% -CBExtrName2 %CB_Ver2%

  rem #Doc: CB_Setting_DPNE beinhaltet die Check Regeln fuer das Auswerten der CB-Daten
  set toRun=%toRun% -CB_Setting_DPNE "%CB_Setting_DPNE%"

  set toRun=%toRun% -CgmToTif %CgmToTif_Opt%
  set toRun=%toRun% -CgmToTif_cmdProg "%CgmToTif_cmdProg_Opt%"
  set toRun=%toRun% -CgmToTif_cmdArgs %CgmToTif_cmdArgs_Opt%
  set toRun=%toRun% -CBcompDifMergTifgen "%CBcompDifMergTifgen_Opt%"
  set toRun=%toRun% -ImageMagick_DP "%ImageMagickL_DP%"

  if defined CBCompairExtra_Opt set toRun=%toRun% %CBCompairExtra_Opt%

  rem #Doc: posible Options are:ControlByCheckBoxResults/Always/Never (new 30.08.2012 10:19)
  if not defined CBImageGenRule set CBImageGenRule=ControlByCheckBoxResults
  set toRun=%toRun% -CBImageGenRule "%CBImageGenRule%"


  if /i "%JobMgr_Debug%" neq "ON" goto :JumbOverDebug
    set toRun=%toRun% -verbose -pauseOnEnd
    set testCmd_DPNE=%temp%\zzCB93_JC_CmdTools_Test_CBResultGen_XML_TIF.cmd
    Echo %toRun%>"%testCmd_DPNE%"
    Echo #---------------------
    Echo #Debug: look at Test.cmd
    Echo  %testCmd_DPNE%
    pause
  :JumbOverDebug

  rem -- ausfuehren JobManagerCmdTools_L
  Call %toRun%
 goto :eof
rem ============================================================================
:TcNxSetEnviron
 Echo --------------------------------------------------------------------------
 Echo - set tc environ                                                         -
 Echo --------------------------------------------------------------------------

 rem ## NX Umgebungsvariablen setzen (wenn Erforderlich !!)
 rem "\" am Ende er pfade abschneiden
 if "%UGII_BASE_DIR:~-1%"=="\" set UGII_BASE_DIR=%UGII_BASE_DIR:~0,-1%
 if "%UGII_ROOT_DIR:~-1%"=="\" set UGII_ROOT_DIR=%UGII_ROOT_DIR:~0,-1%

 rem -- Suchpath angepasst erforderlich da sonst die API Programme nicht starten
 set Path=%UGII_BASE_DIR%;%UGII_ROOT_DIR%;%Path%

 rem zur Kontrolle: im Nx*.syslog suchen nach:
 rem - Processing customer default values file ..StartUp\NX4_CheckBox.dpv
 rem - Customer Default Settings:
 rem - UGMGR_StructureUpdateOnLoad
 rem - NX Manager Load Options Are
 rem - NX/Manager:
 rem - using FMS

 rem #Doc: moegliche Werte fuer: UGMGR_StructureUpdateOnLoad:
 rem UGMGR_StructureUpdateOnLoad none           = Keine
 rem UGMGR_StructureUpdateOnLoad existing       = Vorhandene Komponenten
 rem UGMGR_StructureUpdateOnLoad complete       = Abgeschlossen
 rem UGMGR_StructureUpdateOnLoad add_positioned = Komponenten hinzufügen die über eine Position verfügen
 if defined UGII_LOAD_OPTIONS_NE if exist "%CmdCurRoot_DP%\startup\%UGII_LOAD_OPTIONS_NE%" set UGII_LOAD_OPTIONS=%CmdCurRoot_DP%\startup\%UGII_LOAD_OPTIONS_NE%


 rem -- UG-Variablen setzen ----------------------------------------------------
 set UGII_TMP_DIR=%temp%
 set UGII_UGSOLIDS_TMP=%UGII_TMP_DIR%

 set UGII_UGMGR_USE_CACHE=
 set UGII_DISABLE_PREVIEW=on
 set UGII_DISABLE_QAF_NAMED_REFS=on

 rem -- IMAN-Variablen setzen --------------------------------------------------
 set IMAN_SQL_DEBUG=
 set IMAN_TMP_DIR=%temp%
 set IMAN_KEEP_SYSTEM_LOG=TRUE
 set UGII_KEEP_SYSTEM_LOG=TRUE
 set IMAN_Journalling=OFF
 set IMAN_journaling=OFF
 set IMAN_TRACEBACK=OFF
 set IMAN_Journal_Modules=NONE
 set API_JOURNAL=NONE
 set APB_SCHEMA=

 rem -- TC-Variablen setzen ----------------------------------------------------
 set TC_SQL_DEBUG=
 set TC_TMP_DIR=%temp%
 set TC_KEEP_SYSTEM_LOG=TRUE
 set TC_Journalling=OFF
 set TC_Journaling=OFF
 set TC_TRACEBACK=OFF

 rem -- Multiprozessor support -------------------------------------------------
 rem set UGII_SMP_ENABLE=1
 set UGII_SMP_ENABLE=

 rem -- TC_SHARED_MEMORY_DIR new 21.02.2013 18:01 J.Fes ------------------------
 set TC_SHARED_MEMORY_DIR=%CmdCurRoot_DP%\..\TC_SHARED_MEMORY
 if not exist "%TC_SHARED_MEMORY_DIR%" md "%TC_SHARED_MEMORY_DIR%"

 goto :eof




rem ============================================================================
rem ##### ------------ Standard Subroutines ----------------------------- ######
rem ============================================================================
:ColorSet
 rem -- cmd Color Farbinfo:
 REM    0 = Schwarz        8 = Dunkelgrau
 REM    1 = Dunkelblau     9 = Blau
 REM    2 = Dunkelgrün     A = Grün
 REM    3 = Blaugrün       B = Zyan
 REM    4 = Dunkelrot      C = Rot
 REM    5 = Lila           D = Magenta
 REM    6 = Ocker          E = Gelb
 REM    7 = Hellgrau       F = Weiß

 rem -- Farben nach Status setzen
 rem Gelb Schwarz
 if /I "%1"=="IsExecuting" set JobColorLast=E0
 rem Gelb Schwarz
 if /I "%1"=="IsIdel"      set JobColorLast=70
 rem Hellgrau Schwarz
 if /I "%1"=="End"         set JobColorLast=70
 if /I "%1"=="Ende"        set JobColorLast=70
 rem Gruen Schwarz
 if /I "%1"=="Ok"          set JobColorLast=A0
 rem Rot Schwarz
 if /I "%1"=="Err"         set JobColorLast=C0

 rem jetzt die Farbe setzen
 if not "%JobColorLast%"=="" color %JobColorLast%
 goto :eof

rem ============================================================================
:Wait
 set waitTime=2
 if not "%1"=="" set waitTime=%1
 CHOICE /C:w /N /T:w,%waitTime% "warte [%waitTime% sec] oder 'w' fuer weiter druecken."
 goto :eof

rem ============================================================================
:Echo
 rem Echos Text auf die Console und in eine Datei (wenn angegeben)
 rem Call :Echo "Result Message.........: %JobResMsg%"   "%CmdLog_DPNE%" "MailCmd_Protokoll_DPNE%"
 setlocal

   rem - TextToEcho erstellen
   set TextToEcho=%1
   set TextToEcho=%TextToEcho:"=%
   if "%TextToEcho%" equ ""  set TextToEcho=.
   if "%TextToEcho%" neq "." set TextToEcho= %TextToEcho%

   rem - Ausgabe in File
   set EchoToFile_DPNE=
   if "%2" neq "" (
    set EchoToFile_DPNE=%2
    set EchoToFile_DPNE=!EchoToFile_DPNE:"=!
    Echo!TextToEcho! >>"!EchoToFile_DPNE!"
   )

   set EchoToFile_DPNE=
   if "%3" neq "" (
    set EchoToFile_DPNE=%3
    set EchoToFile_DPNE=!EchoToFile_DPNE:"=!
    Echo!TextToEcho! >>"!EchoToFile_DPNE!"
   )

   rem - Ausgabe Console
   Echo%TextToEcho%

   rem - Ausgabe in :TracAc
   if "%TextToEcho%" neq "." call :TracAc "%TextToEcho%"

 :EchoEnd
 endlocal
 goto :eof

rem ============================================================================
:Parse_ALL
 rem parst alle File Bezeichner aus
 rem "\" abschneiden
 set Parse_all$temp=%~dp1
 set Parse_all$temp=%Parse_all$temp:~0,-1%
 set %2_DP=%Parse_all$temp%
 set %2_D=%~d1
 rem "\" hinten und vorne abschneiden
 set Parse_all$temp=%~p1
 set Parse_all$temp=%Parse_all$temp:~1,-1%
 set %2_P=%Parse_all$temp%
 set %2_NE=%~nx1
 set %2_N=%~n1
 set %2_E=%~x1
 set %2_DPNE=%1
 set %2_DPN=%~dpn1
 set Parse_all$temp=
goto :eof


rem ============================================================================
:TracAc
 rem example: Call :TracAc "%0 [MyInfo XYZ]"
 setlocal
 set TracAc_DPNE=%CmdCurRoot_DP%\zzTracActionInfo_log.txt
 set P1=%1
 set P2=%2
 set P3=%3
 set P4=%4
 set P5=%5
 set P6=%6
 set P7=%7
 set P8=%8
 set P9=%9
 if DEFINED P1 set P1=%P1:"=%& Echo %date% %time:~0,8% %P1%>>"%TracAc_DPNE%"
 if DEFINED P2 set P2=%P2:"=%& Echo %date% %time:~0,8% %P2%>>"%TracAc_DPNE%"
 if DEFINED P3 set P3=%P3:"=%& Echo %date% %time:~0,8% %P3%>>"%TracAc_DPNE%"
 if DEFINED P4 set P4=%P4:"=%& Echo %date% %time:~0,8% %P4%>>"%TracAc_DPNE%"
 if DEFINED P5 set P5=%P5:"=%& Echo %date% %time:~0,8% %P5%>>"%TracAc_DPNE%"
 if DEFINED P6 set P6=%P6:"=%& Echo %date% %time:~0,8% %P6%>>"%TracAc_DPNE%"
 if DEFINED P7 set P7=%P7:"=%& Echo %date% %time:~0,8% %P7%>>"%TracAc_DPNE%"
 if DEFINED P8 set P8=%P8:"=%& Echo %date% %time:~0,8% %P8%>>"%TracAc_DPNE%"
 if DEFINED P9 set P9=%P9:"=%& Echo %date% %time:~0,8% %P9%>>"%TracAc_DPNE%"
 endlocal
 goto :eof
