param(
[string]$cFilename="TaxBill-2026-1",[string]$cSERVERNAME="ocsql23",[string]$cDBNAME="DY2025",[int]$nPROPERTYKEY="1"
)

$cCountyname = 'oconee'

#Specify variables and pass parameters and specify format of report PDF (to keep things simple)
$url = "http://ocsql23/ReportServer/Pages/ReportViewer.aspx?/GATCSReports/taxbill_prebill&ReportSvr="+$cSERVERNAME+"&ReportDB="+$cDBNAME+"&PROPERTYKEY="+$nPROPERTYKEY+"&rs:Format=pdf"

$webclient = New-Object System.Net.WebClient
$webclient.UseDefaultCredentials = $TRUE

$file = "\\ocsql23\tco\gatcs\exports\email_bills\"+$cFilename+".pdf"
$webclient.DownloadFile($url,$file)


# FTP #
#we specify the directory where all files that we want to upload  
$Dir="\\ocsql23\tco\gatcs\exports\email_bills\"    


#ftp server 
$ftp = "ftp://ftp.gatcs.net/"+$cCountyname+"/email_bills/" 
$user = "oconee@gatcs.net" 
$pass = "gatcsuser2021" 
$cUploadname = $cFilename+".pdf" 

$ftpclient = New-Object System.Net.WebClient 

$ftpclient.Credentials = New-Object System.Net.NetworkCredential($user,$pass)  

#list every sql server trace file 
foreach($item in (dir $Dir $cUploadname)){ 
    "Uploading $item..." 
    $uri = New-Object System.Uri($ftp+$item.Name) 
    $ftpclient.UploadFile($uri, $item.FullName) 
 } 


