@echo off

set SrcDirParam=%1
echo SrcDirParam = %SrcDirParam%

set DestDirParam=%2
echo DestDirParam = %DestDirParam%

set includeOrExcludeFileParam=%3
echo includeOrExcludeFileParam = %includeOrExcludeFileParam%

rem https://winscp.net/forum/viewtopic.php?t=14707
rem https://winscp.net/eng/docs/scriptcommand_keepuptodate
:: Note - this extra call is to avoid a bug with %~f0 when the script
::        is executed with quotes around the script name.
call :getLock
exit /b

:getLock
:: The CALL will fail if another process already has a write lock on the script
call :main 9>>"%~f0"
exit /b
 
SET "WindowTitle=FootfallCam Update %DestDirParam%" 
:main
 
@REM synchronize remote directory with local
@REM this will only upload file and wont delete remote files
set winscpPath="C:\Program Files (x86)\WinSCP\winscp.com"

REM must be point to RetailCamModules Root Directory
set ftpCredential=ftp://update:qwer!234@192.168.2.71:45678/

REM set workingDirectory=C:\JenkinsHomeDir\workspace\Stage-RCCP\RetailCamControlPanel
set workingDirectory=%SrcDirParam%

REM set destinationDirectory=Test/
set destinationDirectory=%DestDirParam%

REM set includeOrExcludeFile="bin/;Content/;Scripts/;Views/;EmailTemplate/;api-js-scripts/;CodeInjection/;|*.config;*.cs;*.csproj;*.html;*.txt;*.xml;*.xsd;test.js"
set includeOrExcludeFile=%includeOrExcludeFileParam%

echo "synchronize remote %workingDirectory% %destinationDirectory% -filemask="%includeOrExcludeFile%""

%winscpPath% /command "open %ftpCredential%" "synchronize remote %workingDirectory% %destinationDirectory% -filemask="%includeOrExcludeFile%""  "exit"
 
@REM ping service monitor
REM curl --location -g --request GET "http://service-monitor.metatechnology.co.uk/monitor/ping?payload={%%22ServiceId%%22:%%222DE55273-6135-485F-9F29-5CF01590B099%%22}"
 
@rem Small Service 645F1CE5-B12D-493F-A463-7BBC354BC2E0
@rem Big Service   2DE55273-6135-485F-9F29-5CF01590B099
exit /b
