From bed6faede6ca79279b825574e8a9593d58019c63 Mon Sep 17 00:00:00 2001 From: Mark Strendin Date: Tue, 23 Jul 2024 14:29:41 -0600 Subject: [PATCH] We no longer use Clevr, so we no longer need Clevr sync stuff (#12) --- Config/config.xml.example | 6 -- Tasks/Clevr.ps1 | 152 -------------------------------------- 2 files changed, 158 deletions(-) delete mode 100644 Tasks/Clevr.ps1 diff --git a/Config/config.xml.example b/Config/config.xml.example index c386293..4b7b57c 100644 --- a/Config/config.xml.example +++ b/Config/config.xml.example @@ -30,12 +30,6 @@ - - - - - - diff --git a/Tasks/Clevr.ps1 b/Tasks/Clevr.ps1 deleted file mode 100644 index a671677..0000000 --- a/Tasks/Clevr.ps1 +++ /dev/null @@ -1,152 +0,0 @@ -param ( - [Parameter(Mandatory=$true)][string]$ConfigFile, - [Parameter(Mandatory=$true)][string]$ScratchDirectory, - [Parameter(Mandatory=$true)][string]$LogDirectory - ) - - -# ################################################# -# File names for FTP transactions -# ################################################# - -$JobName = "Clevr" -$CSVGetFiles = @( - @{ - MSSName = "Clevr-Staff.txt" - VendorName = "LSKYClevrStaff.txt" - }, - @{ - MSSName = "Clevr-Students.txt" - VendorName = "LSKYClevrStudents.txt" - }, - @{ - MSSName = "Clevr-StudentDemographics.txt" - VendorName = "LSKYClevrStudentDemographics.txt" - }, - @{ - MSSName = "Clevr-Locations.txt" - VendorName = "clevrLocations.txt" - } -) - - -# ################################################# -# Ensure that necesary folders exist -# ################################################# - -if ((test-path -Path $ScratchDirectory) -eq $false) { - New-Item -Path $ScratchDirectory -ItemType Directory -} - -if ((test-path -Path $LogDirectory) -eq $false) { - New-Item -Path $LogDirectory -ItemType Directory -} - -$ActualScratchPath = $(Resolve-Path $ScratchDirectory) -$ActualLogPath = $(Resolve-Path $LogDirectory) -$ActualConfigFilePath = $(Resolve-Path $ConfigFile) - -# ################################################# -# Functions -# ################################################# - -function Get-FullTimeStamp { - $now=get-Date - $yr=("{0:0000}" -f $now.Year).ToString() - $mo=("{0:00}" -f $now.Month).ToString() - $dy=("{0:00}" -f $now.Day).ToString() - $hr=("{0:00}" -f $now.Hour).ToString() - $mi=("{0:00}" -f $now.Minute).ToString() - $timestamp=$yr + "-" + $mo + "-" + $dy + "-" + $hr + $mi - return $timestamp - } - -# ################################################# -# Load config file -# ################################################# -if ((test-path -Path $ActualConfigFilePath) -eq $false) { - Throw "Config file not found. Specify using -ConfigFile." -} - -$configXML = [xml](Get-Content $ActualConfigFilePath) -$MSSSFTPHost = $configXml.Settings.MySchoolSask.SFTPHost -$MSSSFTPUser = $configXml.Settings.MySchoolSask.SFTPUser -$MSSSFTPPrivateKeyPath = $configXml.Settings.MySchoolSask.SFTPPrivateKeyPath -$MSSSFTPHostKey = $configXml.Settings.MySchoolSask.SFTPHostKey -$WinSCPPath = $configXml.Settings.Utilities.WinSCPPath -$SevenZipPath = $configXml.Settings.Utilities.SevenZipPath -$LogFilePassword = $configXml.Settings.LogFilePassword -$VendorSFTPHost = $configXml.Settings.Clevr.SFTPHost -$VendorSFTPUser = $configXml.Settings.Clevr.SFTPUser -$VendorSFTPPassword = $configXml.Settings.Clevr.SFTPPassword -$VendorSFTPHostKey = $configXml.Settings.Clevr.SFTPHostKey - -# Should probably check to make sure all these things have values... - - - -$OrigLocation = Get-Location -set-location $ActualScratchPath - -# ################################################# -# Retrieve file from MSS SFTP -# ################################################# - -$SFTPCommands = @() -$SFTPCommands += "OPEN $MSSSFTPUser@$MSSSFTPHost -privatekey=$MSSSFTPPrivateKeyPath -hostkey=$MSSSFTPHostKey" -foreach($file in $CSVGetFiles) { - $SFTPCommands += "GET $($file.MSSName)" - $SFTPCommands += "RM $($file.MSSName)" -} -$SFTPCommands += "BYE" - - -$WinSCPLogFile = Join-Path $ActualScratchPath "winscp-mss.log" -. $WinSCPPath/winscp.com /command $SFTPCommands /log="$WinSCPLogFile" /loglevel=0 - - -# ################################################# -# Rename files to be what the vendor expects -# ################################################# - -foreach($file in $CSVGetFiles) { - Rename-Item -Path $($file.MSSName) -NewName $($file.VendorName) -} - - -# ################################################# -# Send files to vendor -# ################################################# - -$SFTPCommands = @() -$SFTPCommands += "OPEN $VendorSFTPUser@$VendorSFTPHost -password=$VendorSFTPPassword -hostkey=$VendorSFTPHostKey" -foreach($file in $CSVGetFiles) { - $SFTPCommands += "PUT $($file.VendorName)" -} -$SFTPCommands += "BYE" - -$WinSCPLogFile = Join-Path $ActualScratchPath "winscp-vendor.log" -. $WinSCPPath/winscp.com /command $SFTPCommands /log="$WinSCPLogFile" /loglevel=0 - -# ################################################# -# Clean up scratch directory -# ################################################# - -$todayLogFileName = Join-Path $ActualLogPath "$(Get-FullTimeStamp)-$($JobName).7z" -. $SevenZipPath/7za.exe a -t7z $todayLogFileName -mx9 "-p$LogFilePassword" "$ActualScratchPath/*.*" -xr!".placeholder" - -# Clear the rest of the scratch folder -Get-ChildItem $ActualScratchPath | -Foreach-Object { - if ($_.Name -ne ".placeholder") { - Remove-Item $_.FullName - } -} - -# ################################################# -# Finished -# ################################################# - - -write-host "Done" -set-location $OrigLocation \ No newline at end of file