@Echo off

 call Echo "**************************************************************************"
 call Echo "* Excuting TcSiteCons Script in PLMJobManager Environ                    *"
 call Echo "* Version: addPLM 13.03.2018 (c)                                         *"
 call Echo "**************************************************************************"

 rem ---------------------------------------------------------
 rem (c) J.Feuerstein 24.11.2006
 rem
 rem Aenderungs Info:
 rem User    Date/Time (Shift+strg+T)  Infotext:
 rem J.Fes   06.02.2013                Ersterstellung
 rem ---------------------------------------------------------
 rem Variablen ersetzungs Abschnitt
 rem Info die mit "#" Gitter eingeschlossenen Vaiablen werden vom JobServer
 rem vor dem senden an den JobClient ersetzt

 rem #Doc: Stand 15.02.2013 J.Fes
 rem #Doc: Die Steuerung des Ablaufes in diesem Script wird gesteuert von
 rem #Doc: den Einstellungen im JobServer  siehe hierzu settings
 rem #Doc:  Tab:['Scripts/Parma'] Def:['TcSc_*'] Spalte:['JC.Script(cmd).ParmExt']
 rem #Doc: Verwendet werden hierfuer die Variablen:
 rem #Doc:     'Action' 'TcSiteSource' 'TcSiteTarget'
 rem #Doc:
 rem #Doc: weitere Details siehe
 rem #Doc: ..\Dokumentation.Custom\TcSiteKon_DokumentationKonzept_JFES.pptx"


 rem get JobComputer Passworts
 set JobMgr_TcUser=%~1
 set JobMgr_TcPw=%~2
 set JobMgr_TcGroup=%~3
 if not defined JobMgr_TcGroup set JobMgr_TcGroup=dba

 rem New 09.12.2015 S.Gueth, define Object class ( Item/ItemRevision, default is Item)
 set ObjectClass=Item
 set CheckMetaData=ON
 set IgnoreMissingObjectsOnSourceSite=OFF
 set AttrError=OFF


 set title_strBase=TcSC:[%JobName%][%Action%]
 if /i "%JobMgr_Debug%" neq "ON" goto :JumbOverDebug
   Banner Debug:ON
   set title_strBase=%title_strBase%[Debug:%JobMgr_Debug%]
:JumbOverDebug

 if /i "%JobMgr_Test%" neq "ON" goto :JumbOverTest
   Banner Test:ON
   set title_strBase=%title_strBase%[Test:%JobMgr_Test%]
:JumbOverTest


 set title_str=%title_strBase%[%Date% %time:~0,5%][\\%ComputerName%]
 title %title_str%


 rem -- Path Variable erweitern
 rem set path=%CmdCurRoot_DP%;%BinL_DP%;%BinPublic_Custom_DP%;%BinPublic_ClientServer_DP%;%BinPublic_DP%;%Path%

 rem -- Start WatchDog #New 10.06.2013 J.Fes
 rem call "ProgStart_If_NotRuning.cmd" "PLMJobManagerWatchDog" "%BinPublic_DP%\PLMJobManagerWatchDog.exe"

 rem ---------------------------------------------------------
 rem temp dir Organiesieren
 set temp_DP_org=%temp%
 set temp=%CmdCurRoot_DP%\%Action%_tmp
 set tmp=%temp%
 if not exist "%temp%" md "%temp%"
 rem -- erf. Verzeichniss 'tc_multi' erzeugen
REM  if not exist "C:\temp\tc_multi" md "C:\temp\tc_multi"
REM  if not exist "%temp%\tc_multi" md "%temp%\tc_multi"
 rem #New 21.08.2014/J.Fes
 set TC_transfer_area=%temp%
 cd /d "%temp%"

REM  if "%JobMgr_DEBUG%" equ "ON" start "" Explorer "%temp%"

 set ErrLog_DPNE=%temp%\_TcSiteConsErrLog.txt

:StartJobProcessing

 Call :SetGlobalSettings

 if "%Action%" equ "DataShare"  set title_strBase=%title_strBase%[from:%TcSiteSource% to:%TcSiteTarget%][TcU:%JobMgr_TcUser%]
 if "%Action%" equ "DataSync"   set title_strBase=%title_strBase%[from:%TcSiteSource% to:%TcSiteTarget%][TcU:%JobMgr_TcUser%]
 set title_txt=%title_strBase%[Start:%Date%/%time:~0,8%][\\%ComputerName%]

 title %title_txt%
 call Echo "%title_txt%"
 call Echo "--------------------------------------------------------------------------"
 call Echo "JobInfo:"
 call Echo "JobName..........: %JobName%"
 call Echo "Computer.........: %ComputerName%"
 call Echo "TempDir..........: %temp%"
 call Echo "Start............: %Date%/%time:~0,8%"
 call Echo "JobMgr_Debug.....: %JobMgr_Debug%"
 call Echo "JobMgr_Test......: %JobMgr_Test%"
 call Echo "."
 call Echo "Action...........: %Action%"
 call Echo "TcSiteSource.....: %TcSiteID%"
 call Echo "TcSiteTarget.....: %TcSiteTarget%"
 call Echo "TcUser...........: %JobMgr_TcUser%"
 call Echo "--------------------------------------------------------------------------"

 if /i "%JobMgr_Debug%" equ "ON" pause

 if /I "%Action%" equ "DataShare"         call :DataShare& goto :end
 if /I "%Action%" equ "DSEvalExtractPre"  call :DSEvalExtractPre& goto :end
 if /I "%Action%" equ "DSEvalExtractPost" call :DSEvalExtractPost& goto :end
 if /I "%Action%" equ "DSEvalCompair"     call :DSEvalCompair& goto :end
 if /I "%Action%" equ "DataSync"          call :DataSync& goto :end
 if /I "%Action%" equ "FlipTheSwitch"     call :FlipTheSwitch& goto :end
 if /I "%Action%" equ "DataSetShare"      call :DataSetShare& goto :end
 rem wenn nichts passt dann:
 Call :ErrActionWrong

 goto :end

rem ===== DataShare ============================================================
:DataShare

 call Echo "+++## Start:DataShare: ##########################################+++"

REM  call Echo " -- Step:DataShare: Extract List of Items---------------------------"
REM  Call :ItemListGen

 rem -- #Step: set TC Job Environs
 call :TcSetJobEnviron


 call Echo " -- Step:DataShare: Run DataShare ----------------------------------"
 if /I  "%TCSiteTarget%" equ "!!unkown!!" (
   call :ColorSet ERR
   call Echo "------------------------------------------------------------------------"
   call Echo "ERR: TCSiteTarget: %TCSiteTarget%"
   call Echo "please check settings in TCSiteCons"
   call Echo "No DataShare Action will be Done!"
   pause
   goto :DataShare_Jumbover
 )
REM  call :DataShare_Run
REM
REM :DataShare_Jumbover
REM  call Echo " -- Step:DataShare: Eval Results Datashare of Processed Items ------"
REM  Call :TcDataShare_EvalResult

 if /i "%JobMgr_Debug%" neq "ON" goto :JumbOverDebug2
   set TC_JOURNAL=FULL
   set TC_SQL_DEBUG=BPT
   set TC_TRACEBACK=1
:JumbOverDebug2

 if /i "%AttrError%" neq "ON" goto :JumbOverAttrError
   set TC_EXCLUDE_APN=TRUE
:JumbOverAttrError

 rem define datashare parameters
 set dataShareParam= -f=send
 set dataShareParam=%dataShareParam% -site=%TcSiteTarget%
 set dataShareParam=%dataShareParam% -log
  if /i "%ObjectClass%" neq "ItemRevision" goto :JumbOverObjectClass
   set dataShareParam=%dataShareParam% –classoffile=ItemRevision
:JumbOverObjectClass
 REM Includes and excluded are defined in TC site preferences
 REM TC_relation_required_on_export and TC_relation_export
 rem set dataShareParam=%dataShareParam% -include=IMAN_UG_altrep
 REM set dataShareParam=%dataShareParam% -include=IMAN_reference
 REM set dataShareParam=%dataShareParam% -include=Custom_BomInfo
 REM set dataShareParam=%dataShareParam% -include=Custom_KostenForm
 REM set dataShareParam=%dataShareParam% -include=IMAN_manifestation
 REM set dataShareParam=%dataShareParam% -include=IMAN_Simulation
 rem set dataShareParam=%dataShareParam% -exclude=TC_DefaultArrangement
 rem set dataShareParam=%dataShareParam% -exclude=TC_Arrangement
 rem set dataShareParam=%dataShareParam% -exclude=TC_BaseArrangementAnchor
 rem set dataShareParam=%dataShareParam% -exclude=TC_BaseArrangementAnchor
 REM set dataShareParam=%dataShareParam% -exclude=IMAN_UG_wave_part_link
 REM set dataShareParam=%dataShareParam% -exclude=IMAN_UG_part_family_link
 REM set dataShareParam=%dataShareParam% -exclude=IMAN_UG_expression
 REM set dataShareParam=%dataShareParam% -exclude=IMAN_UG_wave_part_position
 REM  DATA_SHARE: ***ERROR: No relation type of name "IMAN_UG_wave_part_position" exists
 if /i "%TransferOwnerShip%" neq "ON" goto :JumbOverTransferOwnerShip
   set dataShareParam=%dataShareParam% -transfer
 :JumbOverTransferOwnerShip


 set ImportUpdateListDir_DP=#DataRoot_CustomWorkInst_DP#\20-DataBase\22-ItemInfoLists

 call :ColorSet IsExecuting4
 set toRun="%JobManagerCmdTools_L%"
 set toRun=%toRun% -Action TcMultiSite_2012_02
 set toRun=%toRun% -Subaction DataShare
 set toRun=%toRun% -JobRoot_DP "%CmdCurRoot_DP%"
 set toRun=%toRun% -JobTemp_DP "%temp%"
 set toRun=%toRun% -ImportUpdateListDir_DP "%ImportUpdateListDir_DP%"
 set toRun=%toRun% -TcSiteId "%TcSiteId%"
  if not defined UserMappingFile_DPNE goto :JumpOver_UserMappFile
   set toRun=%toRun% -UserMappingFile_DPNE "%UserMappingFile_DPNE%"
 :JumpOver_UserMappFile
 if defined ImportLogsDir_DP set toRun=%toRun% -ImportLogsDir_DP "%ImportLogsDir_DP%"
 set toRun=%toRun% -ShellExecProg_DPNE data_share.exe
 set toRun=%toRun% -ShellExecArguments " %dataShareParam%"
 set toRun=%toRun% -ShellMaxDurationSEC 900
 set toRun=%toRun% -JobParaDoPrint
 set toRun=%toRun% -u "%JobMgr_TcUser%"
 set toRun=%toRun% -p "%JobMgr_TcPw%"
 set toRun=%toRun% -g "%JobMgr_TcGroup%"
 rem New 09.12.2015 S.Gueth
 if /i "%ObjectClass%" neq "ItemRevision" goto :JumbOverObjectClass
   set toRun=%toRun% -ClassOutType IR
:JumbOverObjectClass


if /i "%JobMgr_Debug%" neq "ON" goto :JumbOverDebug
 set toRun=%toRun% -verbose -pauseOnEnd -pause -JobData2ResultsDoPrint
 set toRunForPrint=%toRun:"=%
 Echo --------------------------------------------------------------------------
 Echo #Debug...: %~0
 Echo "toRun...: %toRunForPrint%"
 Echo --------------------------------------------------------------------------
 pause
:JumbOverDebug

 call %toRun%

 call Echo "+++## END:DataShare: ############################################+++"
goto :eof


rem ===== DSEvalExtractPre =====================================================
:DSEvalExtractPre

REM  if /i "%TcSiteId%" neq "WHP" goto :JumbOver_WHP
REM     set OracleClient_WHP_DP=%BinL_DP%\OraClient
REM     call Echo "Update OracleClient..."
REM     robocopy "%OracleClient_DP%" "%OracleClient_WHP_DP%" /MIR /Z /R:2 /W:2 >nul 2>nul
REM     set OracleClient_DP=%OracleClient_WHP_DP%
REM  :JumbOver_WHP

 call :ColorSet IsExecuting4

 set toRun="%JobManagerCmdTools_L%"
 set toRun=%toRun% -Action TcExtractData_2013_10
 set toRun=%toRun% -Subaction I_IR_BOM_DS_extract
 set toRun=%toRun% -JobRoot_DP "%CmdCurRoot_DP%"
 set toRun=%toRun% -JobMgrDataOrg_Root_DP "%JobMgrDataOrg_Root_DP%"
 set toRun=%toRun% -extract_PrePost pre
 set toRun=%toRun% -OraClient_DP "%OracleClient_DP%"
 set toRun=%toRun% -TcSQL_DP #TcSQL_DP#
 set toRun=%toRun% -JobData1ToProcessDoPrint
 set toRun=%toRun% -JobData2ResultsDoPrint
 set toRun=%toRun% -JobParaDoPrint
 if not defined VolumeReplaceFile_DPNE goto :JumpOver_VolReplaceFile
   set toRun=%toRun% -VolumeReplaceFile_DPNE "%VolumeReplaceFile_DPNE%"
 :JumpOver_VolReplaceFile
 if /i "%HashCodeGen%" neq "OFF" goto :JumbOverHashCodeGen
   set toRun=%toRun% -HashCodeGenOFF
:JumbOverHashCodeGen

 set toRunForPrint=%toRun:"=%

 if /i "%JobMgr_Debug%" neq "ON" goto :JumbOver1
  set toRun=%toRun% -verbose -pauseOnEnd
  Echo --------------------------------------------------------------------------
  Echo Bevor DSEvalExtractPre
  call Echo "toRun:%toRunForPrint%"
  pause
  Echo --------------------------------------------------------------------------
:JumbOver1


 call Echo "   ##### START DATASHARE EVALUATE EXTRAKT PRE #####" "" "NOECHO"
 call Echo "   - toRun:%toRunForPrint%" "" "NOECHO"
 call %toRun%
 call Echo "   ##### END DATASHARE EVALUATE EXTRAKT PRE #####" "" "NOECHO"

 if /i "%JobMgr_Debug%" neq "ON" goto :JumbOver2
  Echo --------------------------------------------------------------------------
  echo After DSEvalExtractPre
  Echo --------------------------------------------------------------------------
  pause
:JumbOver2

 call :ColorSet IsIdel

goto :eof


rem ===== DSEvalExtractPost ====================================================
:DSEvalExtractPost

 call :ColorSet IsExecuting4

 set toRun="%JobManagerCmdTools_L%"
 set toRun=%toRun% -Action TcExtractData_2013_10
 set toRun=%toRun% -Subaction I_IR_BOM_DS_extract
 set toRun=%toRun% -JobRoot_DP "%CmdCurRoot_DP%"
 set toRun=%toRun% -JobMgrDataOrg_Root_DP "%JobMgrDataOrg_Root_DP%"
 set toRun=%toRun% -extract_PrePost post
 set toRun=%toRun% -OraClient_DP "%OracleClient_DP%"
 set toRun=%toRun% -TcSQL_DP "#02-BinClient_Custom_DP#\_CustomTcSQL\%TcSiteTarget%"
 set toRun=%toRun% -JobData1ToProcessDoPrint
 set toRun=%toRun% -JobData2ResultsDoPrint
 set toRun=%toRun% -JobParaDoPrint
  if not defined VolumeReplaceFile_DPNE goto :JumpOver_VolReplaceFile
   set toRun=%toRun% -VolumeReplaceFile_DPNE "%VolumeReplaceFile_DPNE%"
 :JumpOver_VolReplaceFile
 set toRun=%toRun% -extract_FromSiteID "%TcSiteTarget%"
 if /i "%HashCodeGen%" neq "OFF" goto :JumbOverHashCodeGen
   set toRun=%toRun% -HashCodeGenOFF
:JumbOverHashCodeGen

 set toRunForPrint=%toRun:"=%

 if /i "%JobMgr_Debug%" neq "ON" goto :JumbOver1
  set toRun=%toRun% -verbose -pauseOnEnd
  Echo --------------------------------------------------------------------------
  Echo Bevor DSEvalExtractPost
  call Echo "toRun:%toRunForPrint%"
  pause
  Echo --------------------------------------------------------------------------
:JumbOver1


 call Echo "   ##### START DATASHARE EVALUATE EXTRAKT POST #####" "" "NOECHO"
 call Echo "   - toRun:%toRunForPrint%" "" "NOECHO"
 call %toRun%
 call Echo "   ##### END DATASHARE EVALUATE EXTRAKT POST #####" "" "NOECHO"

 if /i "%JobMgr_Debug%" neq "ON" goto :JumbOver2
  Echo --------------------------------------------------------------------------
  echo After DSEvalExtractPost
  Echo --------------------------------------------------------------------------
  pause
:JumbOver2

 call :ColorSet IsIdel

goto :eof


rem ===== DSEvalCompair ========================================================
:DSEvalCompair

 call :ColorSet IsExecuting4

 set toRun="%JobManagerCmdTools_L%"
 set toRun=%toRun% -Action TcMultiSite_2012_02
 set toRun=%toRun% -Subaction I_IR_BOM_DS_eval
 set toRun=%toRun% -JobRoot_DP "%CmdCurRoot_DP%"
 set toRun=%toRun% -JobMgrDataOrg_Root_DP "%JobMgrDataOrg_Root_DP%"
 set toRun=%toRun% -JobData1ToProcessDoPrint
 set toRun=%toRun% -JobData2ResultsDoPrint
 set toRun=%toRun% -JobParaDoPrint
 set toRun=%toRun% -TcSiteTarget %TcSiteTarget%
  if not defined UserMappingFile_DPNE goto :JumpOver_UserMappFile
   set toRun=%toRun% -UserMappingFile_DPNE "%UserMappingFile_DPNE%"
 :JumpOver_UserMappFile
 rem New 11.12.2015 S.Gueth
 if /i "%ObjectClass%" neq "ItemRevision" goto :JumbOverObjectClass
   set toRun=%toRun% -ClassOutType IR
:JumbOverObjectClass
 rem New 29.02.2016 S.Gueth
 if /i "%CheckMetaData%" neq "OFF" goto :JumbOverDontCheckMetaData
   set toRun=%toRun% -DontCheckMetaData
:JumbOverDontCheckMetaData
 if /i "%CheckGroups%" neq "OFF" goto :JumbOverDontCheckGroups
   set toRun=%toRun% -DoNotCheckGroups
:JumbOverDontCheckGroups
 if /i "%CheckLastModUser%" neq "OFF" goto :JumbOverDontCheckLastModUser
   set toRun=%toRun% -DoNotCheckLastModUser
:JumbOverDontCheckLastModUser
rem New 14.07.2016 S.Gueth
 if /i "%IgnoreMissingObjectsOnSourceSite%" neq "ON" goto :JumbOverIgnoreMissingObjectsOnSourceSite
   set toRun=%toRun% -IgnoreMissingObjectsOnSourceSite
:JumbOverIgnoreMissingObjectsOnSourceSite
 if /i "%CheckIfNamedRefFileExists%" neq "ON" goto :JumbOverIgnoreCheckIfNamedRefFileExists
   set toRun=%toRun% -CheckIfNamedRefFileExists
:JumbOverIgnoreCheckIfNamedRefFileExists
 if /i "%CheckNamedRefFileSize%" neq "ON" goto :JumbOverIgnoreCheckNamedRefFileSize
   set toRun=%toRun% -CheckNamedRefFileSize
:JumbOverIgnoreCheckNamedRefFileSize

 set toRunForPrint=%toRun:"=%

 if /i "%JobMgr_Debug%" neq "ON" goto :JumbOver1
  set toRun=%toRun% -Verbose -pauseOnEnd
  Echo --------------------------------------------------------------------------
  Echo Bevor DSEvalCompair
  call Echo "toRun:%toRunForPrint%"
  pause
  Echo --------------------------------------------------------------------------
:JumbOver1


 call Echo "   ##### START DATASHARE EVALUATE COMPAIR #####" "" "NOECHO"
 call Echo "   - toRun:%toRunForPrint%" "" "NOECHO"
 call %toRun%
 call Echo "   ##### END DATASHARE EVALUATE COMPAIR #####" "" "NOECHO"

 if /i "%JobMgr_Debug%" neq "ON" goto :JumbOver2
  Echo --------------------------------------------------------------------------
  echo After DSEvalCompair
  Echo --------------------------------------------------------------------------
  pause
:JumbOver2

 call :ColorSet IsIdel

goto :eof


rem ===== DataSetShare ============================================================
:DataSetShare

 call Echo "+++## Start:DataSetShare: ##########################################+++"

 call Echo " -- Step:DataSetShare: Extract List of UIDs---------------------------"
 Call :ItemListGenUID

 rem -- #Step: set TC Job Environs
 call :TcSetJobEnviron

 rem check fcc parent adress, #New: 13.03.2018 S.Gueth
 call fccCheck.cmd

 call Echo " -- Step:DataSetShare: Run DataSetShare ----------------------------------"
 call :DataSetShare_Run

 call Echo " -- Step:DataSetShare: Eval Results DataSetShare of Processed Items ------"
 Call :TcDataShare_EvalResult

 call Echo "+++## END:DataShare: ############################################+++"
goto :eof

rem ===== DataShare =============================================================
:DataShare_Run
 rem #Doc:

 if /i "%JobMgr_Debug%" neq "ON" goto :JumbOverDebug2
   set TC_JOURNAL=FULL
   set TC_SQL_DEBUG=BPT
   set TC_TRACEBACK=1
:JumbOverDebug2

 if /i "%AttrError%" neq "ON" goto :JumbOverAttrError
   set TC_EXCLUDE_APN=TRUE
:JumbOverAttrError

 call :ColorSet IsExecuting3

 set toRun=data_share.exe
 set toRun=%toRun% -site="%TcSiteTarget%"
 set toRun=%toRun% -f=send
 set toRun=%toRun% -filename="%ItemList_DPNE%"
 set toRun=%toRun% -report="%report_DPNE%"
 set toRun=%toRun% -log
 set toRun=%toRun% -g=%JobMgr_TcGroup%
 set toRun=%toRun% -u=%JobMgr_TcUser%
 rem New 09.12.2015 S.Gueth
 if /i "%ObjectClass%" neq "ItemRevision" goto :JumbOverObjectClass
   set toRun=%toRun% –classoffile=ItemRevision
:JumbOverObjectClass
 REM Includes and excluded are defined in TC site preferences
 REM TC_relation_required_on_export and TC_relation_export
 REM set toRun=%toRun% -include=IMAN_UG_altrep
 REM set toRun=%toRun% -include=IMAN_reference
 REM set toRun=%toRun% -include=Custom_BomInfo
 REM set toRun=%toRun% -include=Custom_KostenForm
 REM set toRun=%toRun% -include=IMAN_manifestation
 REM set toRun=%toRun% -include=IMAN_Simulation
 rem set toRun=%toRun% -exclude=TC_DefaultArrangement
 rem set toRun=%toRun% -exclude=TC_Arrangement
 rem set toRun=%toRun% -exclude=TC_BaseArrangementAnchor
 rem set toRun=%toRun% -exclude=TC_BaseArrangementAnchor
 REM set toRun=%toRun% -exclude=IMAN_UG_wave_part_link
 REM set toRun=%toRun% -exclude=IMAN_UG_part_family_link
 REM set toRun=%toRun% -exclude=IMAN_UG_expression
 REM set toRun=%toRun% -exclude=IMAN_UG_wave_part_position
 REM  DATA_SHARE: ***ERROR: No relation type of name "IMAN_UG_wave_part_position" exists
 if /i "%TransferOwnerShip%" neq "ON" goto :JumbOverTransferOwnerShip
   set toRun=%toRun% -transfer
 :JumbOverTransferOwnerShip

 if /i "%JobMgr_Debug%" neq "ON" goto :JumbOverDebug
   set >>%temp%\zzDebugEnvironInfo.txt
   Echo #Debug:%~0
   Echo BEVOR..: run:Data_Share
   Echo %toRun% -P=***********
   pause
 :JumbOverDebug

 call :ColorSet IsExecuting

 set title_str=Job:[%JobName%][%TcSiteId%][%Date% %time:~0,5%][\\%ComputerName%]
 title %title_str%

 Echo.                                                                               .
 call :ColorSet IsExecuting
 call Echo "%titleRf_str%"
 call Echo "----------------------------------------------------------------------------"
 Call Echo "Job Settings:"
 Call Echo "----  ----  ----  ----  ----  ----  ----  ----  ----  ----  ----  ----  ----"
 Call Echo "JobName.................: %JobName%"
 Call Echo "Computer................: %ComputerName%"
 Call Echo "JobDir..................: %temp:~-50%"
 Call Echo "TcSideSource............: %TcSiteId%"
 Call Echo "TcSiteTarget............: %TcSiteTarget%"
 Call Echo "TcUser..................: %JobMgr_TcUser%"
 Call Echo "FMS_HOME................: %FMS_HOME%"
 Call Echo "TC_ROOT.................: %TC_ROOT%"
 Call Echo "TC_DATA.................: %TC_DATA%"
REM  Call Echo "Special Options.........:"
 Echo.

 call :Echo_toRun "NOECHO" "-p=*****"

 rem -- erf. Verzeichniss 'tc_multi' erzeugen
 if not exist "C:\temp\tc_multi" md "C:\temp\tc_multi"
 call Echo "   ##### START DATASHARE #####" "" "NOECHO"

 call %toRun% -p=%JobMgr_TcPw% >>"%CmdOutPut_DPNE%"
 call Echo "   ##### END DATASHARE #####" "" "NOECHO"


 if /i "%JobMgr_Debug%" neq "ON" goto :JumbOverDebug2
  Echo --------------------------------------------------------------------------
  Echo AFTER..: run data_share
  echo report_DPNE:["%report_DPNE%"]
  type "%report_DPNE%"
  Echo --------------------------------------------------------------------------
  pause
:JumbOverDebug2

goto :eof

rem ===== DataSetShare =============================================================
:DataSetShare_Run
 rem #Doc:

 call :ColorSet IsExecuting3

 set toRun=data_share.exe
 set toRun=%toRun% -site="%TcSiteTarget%"
 set toRun=%toRun% -f=send
 set toRun=%toRun% -filename="%ItemList_DPNE%"
 set toRun=%toRun% -report="%report_DPNE%"
 set toRun=%toRun% -log
 set toRun=%toRun% -g=%JobMgr_TcGroup%
 set toRun=%toRun% -u=%JobMgr_TcUser%
 set toRun=%toRun% -attach
 set toRun=%toRun% -classoffile=Tagstring
rem set toRun=%toRun% -include=IMAN_UG_altrep
rem set toRun=%toRun% -include=IMAN_reference
rem set toRun=%toRun% -include=KBA_BomInfo
rem set toRun=%toRun% -include=KBAKostenForm
 if /i "%TransferOwnerShip%" neq "ON" goto :JumbOverTransferOwnerShip
   set toRun=%toRun% -transfer
 :JumbOverTransferOwnerShip

 if /i "%JobMgr_Debug%" neq "ON" goto :JumbOverDebug
   set >>%temp%\zzDebugEnvironInfo.txt
   Echo #Debug:%~0
   Echo BEVOR..: run:Data_Share
   Echo %toRun% -P=***********
   pause
 :JumbOverDebug


 call :Echo_toRun "NOECHO" "-p=*****"

 call Echo "   ##### START DATASHARE #####" "" "NOECHO"
 call %toRun% -p=%JobMgr_TcPw% >>"%CmdOutPut_DPNE%"
 call Echo "   ##### END DATASHARE #####" "" "NOECHO"


 if /i "%JobMgr_Debug%" neq "ON" goto :JumbOverDebug2
  Echo --------------------------------------------------------------------------
  Echo AFTER..: run data_share
  echo report_DPNE:["%report_DPNE%"]
  type "%report_DPNE%"
  Echo --------------------------------------------------------------------------
  pause
:JumbOverDebug2

goto :eof

rem ===== DataSync =============================================================
:DataSync

 call Echo "+++## Start:DataSync: ###########################################+++"
 call :ColorSet IsExecuting3

 call Echo " -- Step:DataSync: Extract List of Ir's ----------------------------"
 Call :ItemListGen

 rem -- #Step: set TC Job Environs
 call :TcSetJobEnviron

 set toRun=data_sync.exe -site=CustomSite
 set toRun=%toRun% -u=idsm -p=#idsmpw# -g=dba
 set toRun=%toRun% -filename="%ItemList_DPNE%"
 set toRun=%toRun% -report="%report_DPNE%"
 set toRun=%toRun% -sync
 set toRun=%toRun% -force
 set toRun=%toRun% -update
 set toRun=%toRun% -dmo
 set toRun=%toRun% -all_revisions
 set toRun=%toRun% -verbose
 set toRun=%toRun% -log
 set toRun=%toRun% -exclude=IMAN_reference
 set toRun=%toRun% -exclude=IMAN_UG_part_family_link
 set toRun=%toRun% -efc

 rem 24.02.2012 17:53 -all_revisions ergäntzt
 rem 24.02.2012 21:04 Test  2: -exclude=IMAN_reference sieht schon besser aus
 rem 24.02.2012 22:53 Test 3:  -exclude=IMAN_UG_part_family_link
 rem 24.02.2012 22:53 Test 3:  -efc exclude folder contents


 if "%JobMgr_DEBUG%" equ "xON" (
  Echo --------------------------------------------------------------------------
  Echo %toRun%
  Echo --------------------------------------------------------------------------
  pause
 )
 set>"%temp%\zz_info_DataSync_tc8w_tc8r_Environ.txt"
 echo %toRun%>"%temp%\zz_info_DataSync_tc8w_tc8r_Command.txt"
 rem -- Start data_sync
 Echo %title_txt%
 Echo Info: DataSync Output see:["%CmdOutPut_DPNE%"]
REM  %toRun%>>"%CmdOutPut_DPNE%"

 if "%JobMgr_DEBUG%" equ "xON" (
  pause
 )

 call Echo "+++## END:DataSync: #############################################+++"

goto :eof


rem ===== FlipTheSwitch ============================================================
:FlipTheSwitch

 call Echo "+++## Start:FlipTheSwitch: ##########################################+++"

 call Echo " -- Step:FlipTheSwitch: Extract List of Items---------------------------"
 call :ItemListGen

:FlipTheSwitch_Next
 rem -- #Step: set TC Job Environs
 call :TcSetJobEnviron

 call Echo " -- Step:FlipTheSwitch: Run FlipTheSwitch ----------------------------------"
 call :FlipTheSwitch_Run

 call Echo " -- Step:FlipTheSwitch: Eval Results FlipTheSwitch of Processed Items ------"
 Call :TcFlipTheSwitch_EvalResult

 call Echo "+++## END:FlipTheSwitch: ############################################+++"

goto :eof

rem ===== FlipTheSwitch =============================================================
:FlipTheSwitch_Run

 call :ColorSet IsExecuting3

if /i "%JobMgr_Debug%" neq "ON" goto :JumbOverDebug2
 set TC_JOURNAL=FULL
 set TC_SQL_DEBUG=BPT
 set TC_TRACEBACK=1
:JumbOverDebug2

 	rem Monitors NxCB_program_exe_NE
  rem  - wartet fuer 5 sec ob ein neuer process startet
 	rem  - mit max 2 Std = 2*60*60=7200 [sec] Laufzeit
 	rem  - mit max 5 min ohne das neue files im temp entstehen oder editiert werden
 	set toMon=%PMon_exeL_DPNE%
  set toMon=%toMon% -w 5000 -p 0
  set toMon=%toMon% --n %FlipTheSwitch_N%
 	set toMon=%toMon% --runtimeLimitSeconds 7200
 	set toMon=%toMon% --killChildProcesses
 	set toMon=%toMon% --fileLastWriteTime "%temp%\*.*;300"
 	set toMon=%toMon% --saveResultsTo %temp%\zzFlipTheSwitch_PMon_log.xml

  set toRun=%FlipTheSwitch_L%
  set toRun=%toRun% -input="%ItemList_DPNE%"
  set toRun=%toRun% -output="%report_DPNE%"
  set toRun=%toRun% -g=%JobMgr_TcGroup%
  set toRun=%toRun% -u=%JobMgr_TcUser%
  set toRun=%toRun% -nodryrun

  if /i "%JobMgr_Debug%" neq "ON" goto :JumbOverDebug
    set >>%temp%\zzDebugEnvironInfo.txt
    Echo #Debug:%~0
    Echo BEVOR..: run:FlipTheSwitch
    Echo %toRun% -P=***********
    pause
  :JumbOverDebug

 rem -- #Step: Start ProcessMonitor for next comming FlipTheSwitch Process
 start /MIN "JFProcessMonitor" %toMon%

 set toRunForPrint=%toRun:"=%
 call Echo "   - toRun:%toRunForPrint% -p=*****" "" "NOECHO"

 call %toRun% -p=%JobMgr_TcPw% >>"%CmdOutPut_DPNE%"

 if /i "%JobMgr_Debug%" neq "ON" goto :JumbOverDebug2
  Echo --------------------------------------------------------------------------
  Echo AFTER..: run FlipTheSwitch
  echo report_DPNE:["%report_DPNE%"]
  type "%report_DPNE%"
  Echo --------------------------------------------------------------------------
  pause
:JumbOverDebug2

goto :eof


rem ===== ItemList Gen ========================================================
:ItemListGen

 call :ColorSet IsExecuting2
 Echo.
 set toRun="%JobManagerCmdTools_L%"
 set toRun=%toRun% -Action TcMultiSite_2012_02
 set toRun=%toRun% -SubAction DataSync
 set toRun=%toRun% -InputList_DPNE "%ItemList_DPNE%"
 set toRun=%toRun% -JobRoot_DP "%CmdCurRoot_DP%"
 rem New 09.12.2015 S.Gueth
 if /i "%ObjectClass%" neq "ItemRevision" goto :JumbOverObjectClass
   set toRun=%toRun% -ClassOutType IR
:JumbOverObjectClass

 if /i "%JobMgr_Debug%" neq "ON" goto :JumbOverDebug1
  set toRun=%toRun% -verbose -pauseOnEnd
  Echo --------------------------------------------------------------------------
  Echo JobManagerCmdTools.exe
  call Echo "toRun:%toRunForPrint%"
  pause
  Echo --------------------------------------------------------------------------
:JumbOverDebug1

 set toRunForPrint=%toRun:"=%
 call Echo "   - toRun:%toRunForPrint%" "" "NOECHO"
 call %toRun%

 if /i "%JobMgr_Debug%" neq "ON" goto :JumbOverDebug2
  Echo --------------------------------------------------------------------------
  echo ItemList_DPNE:["%ItemList_DPNE%"]
  type "%ItemList_DPNE%"
  Echo --------------------------------------------------------------------------
  pause
:JumbOverDebug2

goto :eof

rem ===== ItemList Gen UID ========================================================
:ItemListGenUID

 call :ColorSet IsExecuting2
 Echo.
 set toRun="%JobManagerCmdTools_L%"
 set toRun=%toRun% -Action JobDataExtract_2013_10
 set toRun=%toRun% -Subaction InputListExtract
 set toRun=%toRun% -inputList_DPNE "%ItemList_DPNE%"
 set toRun=%toRun% -JobRoot_DP "%CmdCurRoot_DP%"
 set toRun=%toRun% -format "#ObjectPuid#"

 if /i "%JobMgr_Debug%" neq "ON" goto :JumbOverDebug1
  set toRun=%toRun% -verbose -pauseOnEnd
  Echo --------------------------------------------------------------------------
  Echo JobManagerCmdTools.exe
  call Echo "toRun:%toRunForPrint%"
  pause
  Echo --------------------------------------------------------------------------
:JumbOverDebug1

 set toRunForPrint=%toRun:"=%
 call Echo "   - toRun:%toRunForPrint%" "" "NOECHO"
 call %toRun%

 if /i "%JobMgr_Debug%" neq "ON" goto :JumbOverDebug2
  Echo --------------------------------------------------------------------------
  echo ItemList_DPNE:["%ItemList_DPNE%"]
  type "%ItemList_DPNE%"
  Echo --------------------------------------------------------------------------
  pause
:JumbOverDebug2

goto :eof

rem ===== Auswerten DataShare Ergebniss ========================================
:TcDataShare_EvalResult
  rem 20.08.2014 12:48
 set ImportUpdateListDir_DP=#DataRoot_CustomWorkInst_DP#\20-DataBase\22-ItemInfoLists

 call :ColorSet IsExecuting4
 set toRun="%JobManagerCmdTools_L%"
 set toRun=%toRun% -Action TcMultiSite_2012_02
 set toRun=%toRun% -Subaction DataShare
 set toRun=%toRun% -DataShare_Report_DPNE "%report_DPNE%"
 set toRun=%toRun% -JobRoot_DP "%CmdCurRoot_DP%"
 set toRun=%toRun% -JobTemp_DP "%temp%"
 set toRun=%toRun% -ImportUpdateListDir_DP "%ImportUpdateListDir_DP%"
 set toRun=%toRun% -TcSiteId "%TcSiteId%"
 rem New 09.12.2015 S.Gueth
 if /i "%ObjectClass%" neq "ItemRevision" goto :JumbOverObjectClass
   set toRun=%toRun% -ClassOutType IR
:JumbOverObjectClass

if /i "%Action%" neq "DataShare" goto :JumbOver1
 set toRun=%toRun% -ImportLogsDir_DP "%ImportLogsDir_DP%"
:JumbOver1


if /i "%JobMgr_Debug%" neq "ON" goto :JumbOverDebug
 set toRun=%toRun% -verbose -pauseOnEnd
 set toRunForPrint=%toRun:"=%
 Echo --------------------------------------------------------------------------
 Echo #Debug...: %~0
 Echo "toRun...: %toRunForPrint%"
 Echo --------------------------------------------------------------------------
 pause
:JumbOverDebug


 set toRunForPrint=%toRun:"=%
 call Echo "   ##### START EVALUATE RESULT #####" "" "NOECHO"
 call Echo "   - toRun:%toRunForPrint%" "" "NOECHO"
 call %toRun%
 call Echo "   ##### END EVALUATE RESULT #####" "" "NOECHO"

 if /i "%JobMgr_Debug%" neq "ON" goto :JumbOver2
  Echo --------------------------------------------------------------------------
  echo report_DPNE:["%report_DPNE%"]
  type "%report_DPNE%"
  Echo --------------------------------------------------------------------------
  pause
:JumbOver2

 call :ColorSet IsIdel
goto :eof
rem ----------------------------------------------------------------------------

rem ===== Auswerten des FlipTheSwitch Ergebniss ========================================
:TcFlipTheSwitch_EvalResult

 set JobMgrDataOrg_Root_DP_Custom=#12-Data#\JobMgrData

 call :ColorSet IsExecuting4
 set toRun="%JobManagerCmdTools_L%"
 set toRun=%toRun% -Action TcMultiSite_2012_02
 set toRun=%toRun% -Subaction FlipTheSwitch
 set toRun=%toRun% -FlipTheSwitch_Report_DPNE "%report_DPNE%"
 set toRun=%toRun% -JobRoot_DP "%CmdCurRoot_DP%"
 set toRun=%toRun% -JobMgrDataOrg_Root_DP "%JobMgrDataOrg_Root_DP_Custom%"
 rem set toRun=%toRun% -ImportUpdateListDir_DP "%ImportUpdateListDir_DP%"
 rem set toRun=%toRun% -TcSiteId "%TcSiteId%"

 if /i "%JobMgr_Debug%" neq "ON" goto :JumbOver1
  set toRun=%toRun% -verbose -pauseOnEnd
  Echo --------------------------------------------------------------------------
  Echo JobManagerCmdTools.exe
  call Echo "toRun:%toRunForPrint%"
  pause
  Echo --------------------------------------------------------------------------
:JumbOver1

 set toRunForPrint=%toRun:"=%
 call Echo "   - toRun:%toRunForPrint%" "" "NOECHO"
 call %toRun%

 if /i "%JobMgr_Debug%" neq "ON" goto :JumbOver2
  Echo --------------------------------------------------------------------------
  echo report_DPNE:["%report_DPNE%"]
  type "%report_DPNE%"
  Echo --------------------------------------------------------------------------
  pause
:JumbOver2

 call :ColorSet IsIdel
goto :eof
rem ----------------------------------------------------------------------------

rem ===== Global Environs ======================================================
:SetGlobalSettings

 rem setzt globale Environs fuer dieses Script
 set ItemList_DPNE=%temp%\1_%Action%_ItemList.txt

 rem -- define data_share Logfiles
 set CmdOutPut_DPNE=%temp%\2_%Action%_CmdOutPut_Log.txt
 set report_DPNE=%temp%\3_%Action%_Report.txt

REM  rem -- #Doc: erstmal leer machen damit weiter nur def. einstellungen genommen werden
REM  SET TC_DATA=
REM  SET TC_ROOT=
REM  set JobMgr_TcGroup=dba
REM
REM
REM  rem setzen der Einstellungen in abhaenigkeit von der TcSiteTarget
REM  if /i "%TcSiteId%" neq "VC_HAMBURG" goto :jumbOverVC_HAMBURG
REM    REM    call ConnectNetUnc.cmd "UgsShare RB" R: \\PLMServer\ugsshare . . Ugsshare_DiskConnectResult_RB
REM    REM    Echo Connect Laufwerk:%ConnectNetUnc_to_Info% Status:"%Ugsshare_DiskConnectResult_RB%"
REM    REM    if /I not "%Ugsshare_DiskConnectResult_RB%"=="OK" goto :Ugsshare_DiskConnectErr
REM    SET TC_DATA=\\whmtest002\ugsshare$\vchhdata\win32
REM    SET TC_ROOT=G:\appl\ugs\tc83
REM    set TcSiteSource=%TcSiteId%
REM    set TcSiteTarget=TBVC
REM    rem Path to IDSM Import.Log on IDSM Target Server
REM    set ImportLogsDir_DP=\\WHMTEST001\UG_TEMP$
REM :jumbOverVC_HAMBURG

goto :eof



rem ============================================================================
:Ugsshare_DiskConnectErr
 set ErrLog_DPNE=%temp%\__Err_Ugsshare_DiskConnect.txt
 rem schreibt die erweiterten Infos an einen ErrLogFile
 Echo Err: erf. Netzwerkverb. fuer: %TcSiteId% [%ConnectNetUnc_to_Info%] konnte nicht richtig verbunden werden!!>>"%ErrLog_DPNE%"
 Echo Computer: %ComputerName% >>"%ErrLog_DPNE%"
 Echo User:     %UserName% >>"%ErrLog_DPNE%"
 Echo --------------------------------------------------------------------->>"%ErrLog_DPNE%"
 type "%ErrLog_DPNE%"
 Echo !!Einstellungen oder Netzwerkverbindungen pruefen!!
 cmd
 Pause
 goto :eof

rem ===== Echo toRun new 29.07.2013/J.Fes  =====================================
:Echo_toRun
 REM  20.07.2013 12:41 auskommentiert da sonst der Fehler wegen es ^& Zeichens kommt
 call set toRunForPrint=%toRun:&=+%
 call set toRunForPrint=%toRunForPrint:"='%
 if "%~2" neq "" call set toRunForPrint=%toRunForPrint% %~2
 if "%~3" neq "" call set toRunForPrint=%toRunForPrint% %~3
 if "%~4" neq "" call set toRunForPrint=%toRunForPrint% %~4
 call Echo "   - toRun:%toRunForPrint%" "" "%~1"
goto :eof

rem =====TcSetJobEnviron =========================================================
:TcSetJobEnviron

set temp=%CmdCurRoot_DP%\%Action%_tmp

 rem -- TC-Variablen umbiegen -------------------------------------------
 set TC_SQL_DEBUG=
 set TC_TMP_DIR=%temp%
 set IMAN_TMP_DIR=%temp%
 set TC_KEEP_SYSTEM_LOG=TRUE
 set TC_Journalling=OFF
 set TC_Journaling=OFF
 set TC_TRACEBACK=OFF
call Echo
call Echo #Debug:-TC_TMP_DIR-:-[%TC_TMP_DIR%]
call Echo #Debug:-TC_KEEP_SYSTEM_LOG-:-[%TC_KEEP_SYSTEM_LOG%]
 rem 20.02.2013 18:08 umgebogen
 set TC_SHARED_MEMORY_DIR=%CmdCurRoot_DP%\..\TC_SHARED_MEMORY
 if not exist "%TC_SHARED_MEMORY_DIR%" md "%TC_SHARED_MEMORY_DIR%"
REM  Echo #Debug: TC_SHARED_MEMORY_DIR : [%TC_SHARED_MEMORY_DIR%]
REM  pause
goto :eof

rem ===== ErrTcSiteDefsWrong ===================================================
:ErrTcSiteTargetWrong
 set title_txt=%title_strBase% ERR:[TcTargetSite wrong:%TcSiteTarget%][%Date%/%time:~0,8%]
 title %title_txt%
 call Echo "--------------------------------------------------------------------------"
 rem call :ErrLogHeaderWrite
 call Echo "%title_txt%" "%ErrLog_DPNE%"
 call Echo "Recived wrong TcSiteTarget:[%TcSiteTarget%]" "%ErrLog_DPNE%"
 call Echo "." "%ErrLog_DPNE%"
 call Echo "Valid Sites are:" "%ErrLog_DPNE%"
 call Echo " - TBVC (defined since 20.08.2014)" "%ErrLog_DPNE%"
 call Echo "." "%ErrLog_DPNE%"
 call Echo "Please check settings in:" "%ErrLog_DPNE%"
 call Echo " - JobMgr Scripts" "%ErrLog_DPNE%"
 call Echo " - JobServer definition in 'Scripts/Param.' ScriptName: TCSiteCon*" "%ErrLog_DPNE%"
 call Echo "." "%ErrLog_DPNE%"
 call Echo "Job will stop processing no action will continue" "%ErrLog_DPNE%"

 Type "%ErrLog_DPNE%"
 Echo.
 Echo after press enter you will see the error reason in notepad editor ....
 pause
 start " " Notepad.exe "%ErrLog_DPNE%"
 pause
 exit
goto :end

rem ===== ErrActionWrong =======================================================
:ErrActionWrong
 set title_txt=%title_strBase% ERR:[wrong Action:%Action%][%Date%/%time:~0,8%]
 title %title_txt%
 call Echo "--------------------------------------------------------------------------"
 rem call :ErrLogHeaderWrite
 call Echo "%title_txt%" "%ErrLog_DPNE%"
 call Echo "Recived wrong TcSiteCons Action:[%Action%]" "%ErrLog_DPNE%"
 call Echo "." "%ErrLog_DPNE%"
 call Echo "Valid Actions are:" "%ErrLog_DPNE%"
 call Echo " - DataShare" "%ErrLog_DPNE%"
 call Echo " - DataSync" "%ErrLog_DPNE%"
 call Echo "." "%ErrLog_DPNE%"
 call Echo "Please check settings in:" "%ErrLog_DPNE%"
 call Echo " - JobMgr Scripts" "%ErrLog_DPNE%"
 call Echo " - JobServer definition in 'Scripts/Param.' ScriptName: TCSiteCon*" "%ErrLog_DPNE%"
 call Echo "." "%ErrLog_DPNE%"
 call Echo "Job will stop processing no action will continue" "%ErrLog_DPNE%"

 Type "%ErrLog_DPNE%"
 Echo.
 Echo after press enter you will see the error reason in notepad editor ....
 pause
 start " " Notepad.exe "%ErrLog_DPNE%"
 pause
 exit
goto :end

rem ===== TCPromtError =========================================================
:TcPromptErr
REM  %TC_DATA%\tc_profilevars.bat
REM   SET TC_ROOT=D:\ugs\tc83\2tier
REM  SET TC_DATA=

 set title_txt=%title_strBase% ERR:[Get TcPrompt][%Date%/%time:~0,8%]
 title %title_txt%
 call Echo "--------------------------------------------------------------------------"
 rem call :ErrLogHeaderWrite
 call Echo "%title_txt%" "%ErrLog_DPNE%"
 call Echo "TC Prompt not found TC_DATA\tc_profilevars.bat: %TC_DATA%\tc_profilevars.bat" "%ErrLog_DPNE%"
 call Echo "." "%ErrLog_DPNE%"
 call Echo "Values are:" "%ErrLog_DPNE%"
 call Echo " - TC_ROOT:[%TC_ROOT%]" "%ErrLog_DPNE%"
 call Echo " - TC_DATA:[%TC_DATA%]" "%ErrLog_DPNE%"
 call Echo "." "%ErrLog_DPNE%"
 call Echo "Please check settings in:" "%ErrLog_DPNE%"
 call Echo " - JobMgr Scripts" "%ErrLog_DPNE%"
 call Echo " - JobServer definition in 'Scripts/Param.' ScriptName: TCSiteCon*" "%ErrLog_DPNE%"
 call Echo "." "%ErrLog_DPNE%"
 call Echo "Job will stop processing no action will continue" "%ErrLog_DPNE%"

 Type "%ErrLog_DPNE%"
 Echo.
 Echo after press enter you will see the error reason in notepad editor ....
 pause
 start " " Notepad.exe "%ErrLog_DPNE%"
 pause
 exit
 goto :end



rem ============================================================================
:ColorSet
 rem -- Farben nach Status setzen
 rem Gelb Schwarz
 if /I "%1"=="IsExecuting" set JobColorLast=E0
 if /I "%1"=="IsExecuting1" set JobColorLast=30
 if /I "%1"=="IsExecuting2" set JobColorLast=20
 if /I "%1"=="IsExecuting3" set JobColorLast=E0
 if /I "%1"=="IsExecuting4" set JobColorLast=B0
 rem Blaugrün Schwarz
 if /I "%1"=="IsIdel"      set JobColorLast=30
 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

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

rem == ENDE ====================================================================
:end

 cd /D "%SystemDrive%"
 call Echo "--------------------------------------------------------------------------"
 call Echo "CleanUp: %temp%\%userName%2TierTransientVolume"
 rd /s /q "%temp%\%userName%2TierTransientVolume"

 call Echo "--------------------------------------------------------------------------"
 call Echo "Job:%JobName% finished at:%date% %time%"
 call Echo "Info: all files in:"
 call Echo "Dir.: %CmdCurRoot_DP:~-75%"
 call Echo "will be zipt by JobClient and send to JobServer"

if /i "%JobMgr_Test%" neq "ON" goto :JumbOverTest
  Echo --------------------------------------------------------------------------
  Banner Test:End
  pause
  Echo --------------------------------------------------------------------------
:JumbOverTest
if /i "%JobMgr_Debug%" neq "ON" goto :JumbOverDebug
  Echo --------------------------------------------------------------------------
  Banner Debug:End
  Echo --------------------------------------------------------------------------
  pause
:JumbOverDebug

goto :eof
