From 5a620218770acff72865dbbb8531ab00a85bfa12 Mon Sep 17 00:00:00 2001 From: Daniel Covington Date: Wed, 12 Jun 2024 12:18:46 -0400 Subject: [PATCH] adding sftp functions --- ImportService/TrackingDataImport.vbs | 52 ++++++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 3 deletions(-) diff --git a/ImportService/TrackingDataImport.vbs b/ImportService/TrackingDataImport.vbs index 7ee9f7e..5e8f290 100644 --- a/ImportService/TrackingDataImport.vbs +++ b/ImportService/TrackingDataImport.vbs @@ -44,9 +44,55 @@ Dim WorkingDirectory:WorkingDirectory = Replace(WScript.ScriptFullName,WScript.S KitID = CheckStatusFor("Ready to Assign Labels"):If KitID > 0 Then:createTrackingInfoForKit(KitID):End If KitID = CheckStatusFor("Ready For Export"):If KitID > 0 Then:CreateExportForSnailWorks(KitID):End If KitID = CheckStatusFor("Ready to Proof"):If KitID > 0 Then:CreateProofForJurisdiction(KitID):End If - KitID = CheckStatusFor("Ready For Inkjet Export"):If KitID > 0 Then:ExportInkjetFile(KitID):End If + KitID = CheckStatusFor("Ready For Inkjet Export"):If KitID > 0 Then:ExportInkjetFile(KitID):End If + CheckSnailWorksPurpleEnvelopeExport + CheckSnailWorksTrakingKitExport WScript.Quit - +Sub CheckSnailWorksPurpleEnvelopeExport + +Dim Sftp:set Sftp = CreateObject("Chilkat_9_5_0.SFtp") + Dim objFolder + Dim success + Set objFolder = objFSO.GetFolder("\\kci-syn-cl01\PC Transfer\TrackingDataExport\Export Purple Envelopes") + + If objFolder.Files.Count > 0 Then + success = Sftp.Connect("sftp.snailworks.com",22) + success = Sftp.AuthenticatePw("KCIHotFolder2024FTPUser","Z!4WXLSQMM#f") + success = Sftp.InitializeSftp() + Dim file + For Each file In objFolder.Files + debug.WriteLine file.Path + Dim handle:handle = Sftp.OpenFile(file.Name,"writeOnly","createTruncate") + Sftp.UploadFile handle,file.Path + Sftp.CloseHandle handle + file.Delete + Next + End If + +End Sub + +Sub CheckSnailWorksTrakingKitExport + +Dim Sftp:set Sftp = CreateObject("Chilkat_9_5_0.SFtp") + Dim objFolder + Dim success + Set objFolder = objFSO.GetFolder("\\kci-syn-cl01\PC Transfer\TrackingDataExport\Export Tracking Kits") + + If objFolder.Files.Count > 0 Then + success = Sftp.Connect("sftp.snailworks.com",22) + success = Sftp.AuthenticatePw("KCI2024Type2FTPUser","Z!NXVRV5SH#f") + success = Sftp.InitializeSftp() + Dim file + For Each file In objFolder.Files + debug.WriteLine file.Path + Dim handle:handle = Sftp.OpenFile(file.Name,"writeOnly","createTruncate") + Sftp.UploadFile handle,file.Path + Sftp.CloseHandle handle + file.Delete + Next + End If + +End Sub Function ExportInkjetFile(KitID) If oConn.State = 0 Then:oConn.Open(ConnectionString):End If Dim KitRs:set KitRs = oConn.Execute("Select * From [Kit] Where [ID] =" & KitID & ";") @@ -273,7 +319,7 @@ Function CreateExportForSnailWorks(KitID) InStr(KitLabelsRs("CassADDRESS5").Value, ",") - 1),50)) 'City Optional .Write(Truncate(Mid(KitLabelsRs("CassADDRESS5").Value, _ InStr(KitLabelsRs("CassADDRESS5").Value, ",") + 2, 2),2)) 'State Optional - .Write Truncate(Right(KitLabelsRs("CassADDRESS5").Value,11),11) 'Zip Optional + .Write Choice(InStr(KitLabelsRs("CassADDRESS5").Value,"-"),Truncate(Right(KitLabelsRs("CassADDRESS5").Value,11),11),Truncate(Right(KitLabelsRs("CassADDRESS5").Value,5),5)) 'Zip Optional .Write(Truncate(KitRs("Jcode"),100)) 'UserDefined1 Optional - Summary fields only .Write(Truncate("",100)) 'UserDefined2 Optional - Summary fields only .Write(Truncate("",100)) 'UserDefined3 Optional - Summary fields only