@Echo off
REM #Doc: In this script you define customer TcSiteId settings
REM #Doc: This script is used by JobMgr JobScripts parameters
REM       for getting TcSiteId specific environment
REM       for getting NX specific environment

REM #toDo: please setup Customer TcPrompt settings

REM #New: 01.08.2016 /J.Fes first version
REM #LUp: 19.09.2016 /J.Fes add TCPrompt_Custom_Opt
REM #LUp: 26.01.2017 /J.Fes add 4tier
REM #LUp: 29.03.2017 /J.Fes add PathEnvAddPath.cmd


 if "%~1" neq "" set TcSiteId=%~1
 set TcPromptCmd=
 set TcPromptCmdOpt=

 set JobMgr_TCPromptGet_ResCode=-1
 set JobMgr_TCPromptGet_ResMsg=Unkown

 Call Echo "----------------------------------------------------------------------------"
 Call Echo "Executing TcPrompt_Custom.cmd [%TcSiteId%/%TCPrompt_Custom_Opt%]"

REM -- #Optional # Conncet Network drives !! -----------------------------------
REM Disk Connect [default=OFF]
set JobMgr_use_DiskConnect=OFF

if "%JobMgr_use_DiskConnect%" neq "ON" goto :Next
  set PLMShare_DiskConnectInfo=S: \\MyServer\ugsshare
  call ConnectNetUnc.cmd "PLMShare" S: \\MySerrver\PLMShare . . PLMshare_DiskConnectStatus
  Echo Connect Disk:%PLMShare_DiskConnectInfo% Status:%PLMshare_DiskConnectStatus%
  if /I not "%PLMshare_DiskConnectStatus%" equ "OK" goto :PLMShare_DiskConnectErr
:Next

REM -- #Dco: 26.01.2017/J.Fes add Info 4tier prompt
REM -- #Doc: 4tier:
REM     set UGII_UGMGR_COMMUNICATION=HTTP
REM     set UGII_UGMGR_HTTP_URL=http://10.145.0.203:10070/tc/aiws/aiwebservice
REM     please if TC 4tier settings for max concurrent 4tier-Server processes is sufficent
REM     count for pre running 4tier-processes should be: RfClient*1,25

REM -- get TC-prompt -----------------------------------------------------------

REM -- #Doc: Example:  Generic: fuer TC10
if /i "%TcSiteId%" neq "#Generic_Example1#" goto :Next
 REM SET TC_ROOT=d:\ugs\tc10
 REM SET TC_DATA=\\SRV_XXX\PLMShare\tc10data\windows
 set TcPromptCmd=%TC_DATA%\tc_profilevars.bat
 set TcPromptCmdOpt=
 set JobMgr_fccCheck_parentfsc_address=https://Customserver.dotx.doty:10010/
:Next

REM -- #Doc: Example: SIDT Standard:
if /i "%TcSiteId%" neq "#SIDT_Example1#" goto :Next
  set SIDT_DEBUG=0
  set TcPromptCmd=%UGS_SHR_DIR%\start_apps\windows\start_nx12.bat
  set TcPromptCmdOpt=de tc_prompt %TcSiteId% tc11
  REM #New:17.08.2017 /J:fes Check parentfsc_address please see fcc.xml
  set JobMgr_fccCheck_parentfsc_address=https://Customserver.dotx.doty:10010/
:Next

REM -- #Doc: Example: BCT-1 Prompt (preferred to use)
if /i "%TcSiteId%" neq "#BCT_Example1#" goto :Next
  REM --#ToDo: Check bctsi_progressbar.exe
  set TcPromptCmd=\\SRV_XXX\bctsi_custom\scripts\bctsi_env.bat
  set TcPromptCmdOpt=
  set JobMgr_fccCheck_parentfsc_address=https://Customserver.dotx.doty:10010/
:Next

REM -- #Doc: Example: BCT-2 Prompt (alternativ to use)
 if /i "%TcSiteId%" neq "#BCT_Example2#" goto :Next
  REM -- #ToDo: Check bctsi_progressbar.exe
  REM -- #Doc: search for start %BCTSI_BIN%\bctsi_progressbar.exe -on -text="%BCTSI_MSG_002%"
  set TcPromptCmd=\\SRV_XXX\bctsi_custom\scripts\bctsi_start.bat
  REM -- #CHK: Parmater3: NX10 oder NX100 --
  set TcPromptCmdOpt=env bct_v161 NX120 - tc101 plm1 de
  set JobMgr_fccCheck_parentfsc_address=http://Customserver.dotx.doty:10010/
:Next

REM -- #Doc: Example: addPLM - tc83
  if /i "%TcSiteId%" neq "tc83" goto :Next
    set TcPromptCmd=d:\ugs\tc83\tc_menu\tc83_tc83.bat
    set TcPromptCmdOpt=
    set JobMgr_fccCheck_parentfsc_address=http://Customserver.dotx.doty:10010/
:Next

REM -- #Doc: Example: addPLM - Nativ Test
 if /i "%TcSiteIdTarget%" equ "TC10" goto :intoTC10
 if /i "%TcSiteId%" equ "NativeFile2" goto :NativSite
 goto :Next

:NativSite
   set TcPromptCmd=C:\NX_Custom\SetUp_NxEnviron.cmd
   set TcPromptCmdOpt=
   if /I "%TCPrompt_Custom_Opt%" equ "NX100" set TcPromptCmdOpt=NX100 BATCH
   if /I "%TCPrompt_Custom_Opt%" equ "NX110" set TcPromptCmdOpt=NX110 BATCH
   if /I "%TCPrompt_Custom_Opt%" equ "NX120" set TcPromptCmdOpt=NX120 BATCH

   set JobMgr_TcUser=
   set JobMgr_TcPw=
   set CB_Integration=Nativ
   if not defined TcPromptCmdOpt if defined UGII_BASE_DIR goto :TcPromptCmdOkContinue
:Next

REM -- #Doc: Example: addPLM - TC.TEST
 if /i "%TcSiteId%" neq "tc10" goto :Next
  :intoTC10
  set TcPromptCmd=c:\splm\tc10\tc_menu\tc10_tc10.bat
  set TcPromptCmdOpt=
  if not defined UGII_SITE_DIR set UGII_SITE_DIR=%CmdCurRoot_DP%
  set JobMgr_fccCheck_parentfsc_address=pdmdev01:4544
:Next

REM -- #Doc: Example: addPLM - Nativ Test
 if /i "%TcSiteId%" neq "HIL_QS" goto :Next
   set TcPromptCmd=C:\NX_Custom\SetUp_NxEnviron.cmd
   set TcPromptCmdOpt=NX11 BATCH
   set JobMgr_TcUser=
   set JobMgr_TcPw=
   set CB_Integration=Nativ
:Next

REM -- #Doc: Setup custom  TCPrompt_Custom_Opt
if "%TCPrompt_Custom_Opt%" neq "??" goto :Next
 REM -- #DOC: do setup something depending on this settings
:Next


REM -- #Doc: check start TcPrompt
 if exist "%TcPromptCmd%" goto :TcPromptCmdFoundYES
 goto :TcPromptCmdFoundNO

:TcPromptCmdFoundNO
 REM -- #Doc: ERR Custom TC-Prompt not found
 call ErrorHandel "S" "TcPrompt:fnf" "[Missing:%TcPromptCmd%]"
 goto :End

:PLMShare_DiskConnectErr
 REM -- #Doc: ERR PLMShare
 call ErrorHandel "S" "PLMShare:ERR" "[%PLMShare_DiskConnectInfo% Status:%PLMshare_DiskConnectStatus%]"
 goto :End

:TcPromptCmdFoundYES
 REM -- #Doc: OK Now execute get Custom TC-Prompt
 call "%TcPromptCmd%" %TcPromptCmdOpt%
:TcPromptCmdOkContinue
 set JobMgr_TCPromptGet_ResCode=0
 set JobMgr_TCPromptGet_ResMsg=OK

 REM #New: 30.05.2014 TC_SHARED_MEMORY_DIR
 if not defined TC_SHARED_MEMORY_DIR_Disable set TC_SHARED_MEMORY_DIR_Disable=true
 if /i "%TC_SHARED_MEMORY_DIR_Disable%" neq "true" goto :TC_SHARED_MEMORY_DIR_Enable

:TC_SHARED_MEMORY_DIR_Disable
 REM disable TC_SHARED_MEMORY_DIR:
 set TC_NO_TEXTSRV_SHARED_MEMORY=TRUE
 set TC_USE_METADATA_SHARED_MEMORY=FALSE
 set TC_USE_PREFS_SHARED_MEMORY=FALSE
 set TC_USE_LOV_SHARED_MEMORY=FALSE
 goto :Next

:TC_SHARED_MEMORY_DIR_Enable
 set TC_SHARED_MEMORY_DIR=%CmdCurRoot_DP%\..\TC_SHARED_MEMORY_%TcSiteId%
 if not exist "%TC_SHARED_MEMORY_DIR%" md "%TC_SHARED_MEMORY_DIR%"
 goto :Next

:Next
 rem -- Check FMS_HOME #New: 23.08.2018
 if not defined FMS_HOME if exist %tc_root%\tccs set FMS_HOME=%tc_root%\tccs

 Call Echo "----------------------------------------------------------------------------"
 Call Echo "TcSide..........................: %TcSiteId%"
 Call Echo "TC_DATA.........................: %TC_DATA%"
 Call Echo "TC_ROOT.........................: %TC_ROOT%"
 Call Echo "FMS_HOME........................: %FMS_HOME%"

 if not defined UGII_BASE_DIR goto :Next
 REM -- am Ende "\"  abschneiden
 if "%UGII_BASE_DIR:~-1%" equ "\" set UGII_BASE_DIR=%UGII_BASE_DIR:~0,-1%

:Next
 if not defined UGII_ROOT_DIR goto :next
 if "%UGII_ROOT_DIR:~-1%" equ "\" set UGII_ROOT_DIR=%UGII_ROOT_DIR:~0,-1%

:Next
 if not exist "%UGII_BASE_DIR%\nxbin" goto :Next
 REM -- #New: 30.01.2017/J.Fes add tp path .\nxbin since NX11
 set UGII_NXBIN_DIR=%UGII_BASE_DIR%\nxbin
 Call PathEnvAddPath.cmd "%UGII_NXBIN_DIR%"

:Next
 if not defined UGII_ROOT_DIR goto :Next
 Call PathEnvAddPath.cmd "%UGII_ROOT_DIR%"

:Next
 if not defined UGII_BASE_DIR goto :Next
 Call PathEnvAddPath.cmd "%UGII_BASE_DIR%"

:Next
 Call Echo "----------------------------------------------------------------------------"
 Call Echo "UGII_BASE_DIR...................: %UGII_BASE_DIR%"
 if defined UGII_ROOT_DIR  Call Echo "UGII_ROOT_DIR...................: %UGII_ROOT_DIR%"
 if defined UGII_NXBIN_DIR Call Echo "UGII_NXBIN_DIR..................: %UGII_NXBIN_DIR%"
 Call Echo "Path............................: %PATH%"
 call Echo "---------------------------------------------------------------------------"
 call Echo "JobMgr_TCPromptGet_ResCode......: %JobMgr_TCPromptGet_ResCode%"
 call Echo "JobMgr_TCPromptGet_ResMsg.......: %JobMgr_TCPromptGet_ResMsg%"

 goto :end
:end

if /i "%JobMgr_Debug%" neq "ON" goto :JumbOverDebug
 pause
 call Echo "---------------------------------------------------------------------------"
 call Echo "#Debug END......................: %~0"
 Echo "-- TC --------------------------------------------------------------------"
 set TC
 Echo "-- UG --------------------------------------------------------------------"
 set UG
 pause
:JumbOverDebug
