|
|
@@ -3,6 +3,7 @@ Dim dev:dev = True |
|
|
Dim outFile |
|
|
Dim outFile |
|
|
Dim WaitTime:WaitTime = 15000 |
|
|
Dim WaitTime:WaitTime = 15000 |
|
|
Dim DataDirectory |
|
|
Dim DataDirectory |
|
|
|
|
|
Dim ExportDirectory |
|
|
Dim WshShell:Set WshShell = WScript.CreateObject("Wscript.Shell") |
|
|
Dim WshShell:Set WshShell = WScript.CreateObject("Wscript.Shell") |
|
|
Dim oConn:Set oConn = WScript.CreateObject("ADODB.Connection") |
|
|
Dim oConn:Set oConn = WScript.CreateObject("ADODB.Connection") |
|
|
Dim ConnectionString |
|
|
Dim ConnectionString |
|
|
@@ -19,10 +20,12 @@ Dim objCSV:Set objCsv = CreateObject("Chilkat_9_5_0.Csv") |
|
|
Dim WorkingDirectory:WorkingDirectory = Replace(WScript.ScriptFullName,WScript.ScriptName,"") |
|
|
Dim WorkingDirectory:WorkingDirectory = Replace(WScript.ScriptFullName,WScript.ScriptName,"") |
|
|
If dev Then |
|
|
If dev Then |
|
|
DataDirectory = WorkingDirectory & "test" |
|
|
DataDirectory = WorkingDirectory & "test" |
|
|
|
|
|
ExportDirectory = "\\kci-syn-cl01\PC Transfer\TrackingDataExport\" |
|
|
ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Engine Type=5;Data Source=F:\Development\Tracking_Kits\Data\webdata - Copy.mdb;" |
|
|
ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Engine Type=5;Data Source=F:\Development\Tracking_Kits\Data\webdata - Copy.mdb;" |
|
|
set outFile = objFSO.CreateTextFile("\\kci-syn-cl01\PC Transfer\TrackingDataExport\temp.csv",True) |
|
|
set outFile = objFSO.CreateTextFile("\\kci-syn-cl01\PC Transfer\TrackingDataExport\temp.csv",True) |
|
|
Else |
|
|
Else |
|
|
DataDirectory = "\\kci-syn-cl01\PC Transfer\TrackingDataImport" |
|
|
DataDirectory = "\\kci-syn-cl01\PC Transfer\TrackingDataImport" |
|
|
|
|
|
ExportDirectory = "\\kci-syn-cl01\PC Transfer\TrackingDataExport\" |
|
|
ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Engine Type=5;Data Source=C:\inetpub\Data\webdata - Copy.mdb;" |
|
|
ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Engine Type=5;Data Source=C:\inetpub\Data\webdata - Copy.mdb;" |
|
|
set outFile = objFSO.CreateTextFile("\\kci-syn-cl01\PC Transfer\TrackingDataExport\temp.csv",True) |
|
|
set outFile = objFSO.CreateTextFile("\\kci-syn-cl01\PC Transfer\TrackingDataExport\temp.csv",True) |
|
|
End If |
|
|
End If |
|
|
@@ -42,9 +45,117 @@ Dim WorkingDirectory:WorkingDirectory = Replace(WScript.ScriptFullName,WScript.S |
|
|
If KitID > 0 Then |
|
|
If KitID > 0 Then |
|
|
createTrackingInfoForKit(KitID) |
|
|
createTrackingInfoForKit(KitID) |
|
|
End If |
|
|
End If |
|
|
|
|
|
|
|
|
|
|
|
KitID = CheckForReadyToExportToSnailWorks() |
|
|
|
|
|
If KitID > 0 Then |
|
|
|
|
|
CreateExportForSnailWorks(KitID) |
|
|
|
|
|
End If |
|
|
WScript.Quit |
|
|
WScript.Quit |
|
|
|
|
|
|
|
|
|
|
|
Function CheckForReadyToExportToSnailWorks() |
|
|
|
|
|
If oConn.State = 0 Then:oConn.Open(ConnectionString):End If |
|
|
|
|
|
Dim rs:Set rs = oConn.Execute("Select TOP 1 [ID] FROM [Kit] Where Status ='Ready For Export' and JobType='Purple Envelopes';") |
|
|
|
|
|
If Not rs.EOF Then |
|
|
|
|
|
CheckForReadyToExportToSnailWorks = rs("ID").value |
|
|
|
|
|
Else |
|
|
|
|
|
CheckForReadyToExportToSnailWorks = 0 |
|
|
|
|
|
End If |
|
|
|
|
|
If rs.State = 1 Then:rs.Close:End If |
|
|
|
|
|
If oConn.State = 1 Then:oConn.Close:End If |
|
|
|
|
|
End Function |
|
|
|
|
|
|
|
|
|
|
|
Function CreateExportForSnailWorks(KitID) |
|
|
|
|
|
If oConn.State = 0 Then:oConn.Open(ConnectionString):End If |
|
|
|
|
|
Dim KitRs:set KitRs = oConn.Execute("Select * From [Kit] Where [ID] =" & KitID & ";") |
|
|
|
|
|
Dim KitLabelsRs: Set KitLabelsRs = oConn.Execute("SELECT InkjetRecords.ID, InkjetRecords.KitID, InkjetRecords.VOTERID, InkjetRecords.LASTNAME," &_ |
|
|
|
|
|
" InkjetRecords.FIRSTNAME, InkjetRecords.MIDDLENAME, InkjetRecords.SUFFIX, InkjetRecords.PRECINCT," &_ |
|
|
|
|
|
" InkjetRecords.ADDRESS1, InkjetRecords.ADDRESS2, InkjetRecords.ADDRESS3, InkjetRecords.ADDRESS4," &_ |
|
|
|
|
|
" InkjetRecords.ADDRESS5, InkjetRecords.APPSENT, InkjetRecords.APPRETURNED, InkjetRecords.BALSENT," &_ |
|
|
|
|
|
" InkjetRecords.BALRETURNED, InkjetRecords.CountingBoard, InkjetRecords.UOCAVASTATUS, InkjetRecords.EMAILADDRESS," &_ |
|
|
|
|
|
" InkjetRecords.PHONENUMBER, InkjetRecords.BALLOT_NUMBER, InkjetRecords.CassADDRESS1, InkjetRecords.CassADDRESS2," &_ |
|
|
|
|
|
" InkjetRecords.CassADDRESS3, InkjetRecords.CassADDRESS4, InkjetRecords.CassADDRESS5, InkjetRecords.KitLabelID," &_ |
|
|
|
|
|
" KitLabels.ID, KitLabels.KitID, KitLabels.OutboundSerial, KitLabels.InBoundSerial, KitLabels.OutboundIMB," &_ |
|
|
|
|
|
" KitLabels.InBoundIMB, KitLabels.OutboundIMBDigits, KitLabels.InBoundIMBDigits, KitLabels.OutboundIMBPNG," &_ |
|
|
|
|
|
" KitLabels.INBOUNDIMBPNG, KitLabels.SetNumber" &_ |
|
|
|
|
|
" FROM InkjetRecords" &_ |
|
|
|
|
|
" LEFT JOIN [KitLabels] ON InkjetRecords.KitLabelID = KitLabels.ID" & _ |
|
|
|
|
|
" WHERE InkjetRecords.KitID =" & KitID & " ;") |
|
|
|
|
|
Dim JurisdictionRs:Set JurisdictionRs = oConn.Execute("SELECT * FROM Jurisdiction WHERE JCode ='" & KitRs("Jcode").Value & "';") |
|
|
|
|
|
Dim ExportFileName:ExportFileName = objFSO.GetBaseName(KitRs("Filename")) & "_SW_EXPORT" |
|
|
|
|
|
|
|
|
|
|
|
If Not objFSO.FolderExists(ExportDirectory & KitRs("JobNumber").Value & "-" & JurisdictionRs("Name").value) Then:objFSO.CreateFolder(ExportDirectory & KitRs("JobNumber").Value & "-" & JurisdictionRs("Name").value):End If |
|
|
|
|
|
|
|
|
|
|
|
If objFSO.FileExists(ExportDirectory & KitRs("JobNumber").Value & "-" & JurisdictionRs("Name").value & "/" & ExportFileName) Then:objFSO.DeleteFile(ExportDirectory & KitRs("JobNumber").Value & "-" & JurisdictionRs("Name").value & "/" & ExportFileName):End If |
|
|
|
|
|
Dim objExportFile:set objExportFile = objFSO.CreateTextFile(ExportDirectory & KitRs("JobNumber").Value & "-" & JurisdictionRs("Name").value & "/" & ExportFileName,2) |
|
|
|
|
|
objExportFile.Write("H") 'Record Type Required value must be = "H" (Header) |
|
|
|
|
|
objExportFile.Write(PadString("5.1",5)) 'Version Required value must be ="5.1" for current release |
|
|
|
|
|
objExportFile.Write(PadString("?",50)) 'UserId Required |
|
|
|
|
|
objExportFile.Write(PadString(JurisdictionRs("Name").Value,50)) 'Client Name Required (will create new subaccount if not already defined) |
|
|
|
|
|
objExportFile.Write(PadString("",50)) 'Parent Client Name Optional (use if 3-tier account structure) |
|
|
|
|
|
objExportFile.Write(PadString("Purple envelope - " &_ |
|
|
|
|
|
KitRs("JobNumber").Value,50)) 'Job Name Required |
|
|
|
|
|
objExportFile.Write(PadString("",50)) 'Job Description Optional |
|
|
|
|
|
objExportFile.Write(PadString("",50)) 'Split Name Optional – will default to ‘Default’ |
|
|
|
|
|
objExportFile.Write(PadString("",80)) 'Split Description Optional |
|
|
|
|
|
objExportFile.Write(PadString("L",1)) 'Piece Type Required L-Letters, C-Cards, F-Flats |
|
|
|
|
|
objExportFile.Write(PadString(Year(Now()) & "/" &_ |
|
|
|
|
|
Right("0" & Month(Now()), 2) & "/" & Right("0" & Day(Now()), 2),10)) 'MailDate Required (YYYY/MM/DD) |
|
|
|
|
|
objExportFile.Write(PadString("N",1)) 'UploadType Required N = New job, new split A = Append new split to existing job R = Replace existing split |
|
|
|
|
|
objExportFile.Write(PadString("",8)) 'TrackedQuantity Optional |
|
|
|
|
|
objExportFile.Write(PadString("",8)) 'PiecesMailed Optional – shown as Estimated Quantity |
|
|
|
|
|
objExportFile.Write(PadString("",10)) 'Target InHomeDateStart Optional (YYYY/MM/DD) |
|
|
|
|
|
objExportFile.Write(PadString("",10)) 'Target InHomeDateEnd Optional (YYYY/MM/DD) |
|
|
|
|
|
objExportFile.Write(PadString("",100)) 'ConfirmationEmail Optional |
|
|
|
|
|
objExportFile.Write(PadString("",9)) 'JobId (SW) Optional for previously created jobs SWJobId |
|
|
|
|
|
objExportFile.Write(PadString("",4)) 'SplitId (SW) Optional for previously created jobs SWJobId |
|
|
|
|
|
objExportFile.Write(PadString(Choice(IsNull(KitRs("InboundSTID")),"O","R"),1))'TypeofTracking Required Values: O- Outbound Only I-Inbound Only R-Round Trip |
|
|
|
|
|
objExportFile.Write(PadString("",11)) 'ReturnedPostalRoutingCode |
|
|
|
|
|
objExportFile.Write(PadString("",2)) 'ReportId1 |
|
|
|
|
|
objExportFile.Write(PadString("",255)) 'Report1Email |
|
|
|
|
|
objExportFile.Write(PadString("",2)) 'ReportId2 |
|
|
|
|
|
objExportFile.Write(PadString("",255)) 'Report2Email |
|
|
|
|
|
objExportFile.Write(vbCrLf) |
|
|
|
|
|
While Not KitLabelsRs.EOF |
|
|
|
|
|
objExportFile.Write("D") 'RecordType Required value must be = “D” (Detail) |
|
|
|
|
|
objExportFile.Write(PadString("",20)) 'CustomerUniqueIdentifier Optional- any identifier you designate |
|
|
|
|
|
objExportFile.Write(PadString(KitLabelsRs("OutboundIMBDigits"),31)) 'IMB Required – Unencoded, numeric IMB |
|
|
|
|
|
objExportFile.Write(PadString((""),10)) 'Greeting Optional |
|
|
|
|
|
objExportFile.Write(PadString((""),50)) 'First Name Optional |
|
|
|
|
|
objExportFile.Write(PadString((""),2)) 'MI Optional |
|
|
|
|
|
objExportFile.Write(PadString((""),50)) 'Last Name Optional |
|
|
|
|
|
objExportFile.Write(PadString((""),10)) 'Suffix Optional |
|
|
|
|
|
objExportFile.Write(PadString((KitLabelsRs("CassADDRESS1").Value),100)) 'Full Name Optional |
|
|
|
|
|
objExportFile.Write(PadString((""),50)) 'Company Optional |
|
|
|
|
|
objExportFile.Write(PadString((""),50)) 'Title Optional |
|
|
|
|
|
objExportFile.Write(PadString(KitLabelsRs("CassADDRESS3").Value,128)) 'Address1 Optional |
|
|
|
|
|
objExportFile.Write(PadString(KitLabelsRs("CassADDRESS4").Value,128)) 'Address2 Optional |
|
|
|
|
|
objExportFile.Write(PadString(Left(KitLabelsRs("CassADDRESS5").Value, InStr(KitLabelsRs("CassADDRESS5").Value, ",") - 1),50)) 'City Optional |
|
|
|
|
|
objExportFile.Write(PadString(Mid(KitLabelsRs("CassADDRESS5").Value, InStr(KitLabelsRs("CassADDRESS5").Value, ",") + 2, 2),2)) 'State Optional |
|
|
|
|
|
objExportFile.Write PadString(Right(KitLabelsRs("CassADDRESS5").Value,11),11)'Zip Optional |
|
|
|
|
|
objExportFile.Write(PadString(KitRs("Jcode"),100)) 'UserDefined1 Optional - Summary fields only |
|
|
|
|
|
objExportFile.Write(PadString((""),100)) 'UserDefined2 Optional - Summary fields only |
|
|
|
|
|
objExportFile.Write(PadString((""),100)) 'UserDefined3 Optional - Summary fields only |
|
|
|
|
|
objExportFile.Write(PadString(KitLabelsRs("PRECINCT").Value & KitLabelsRs("BALLOT_NUMBER"),80)) 'UserDefinedIdentifier4 Optional – Allows for unique identifiers |
|
|
|
|
|
objExportFile.Write(PadString(KitLabelsRs("VOTERID").Value,80)) 'UserDefinedIdentifier5 Optional – Allows for unique identifiers |
|
|
|
|
|
objExportFile.Write(PadString((""),1)) 'SeedIndicator Optional - if true provide ‘Y’ |
|
|
|
|
|
objExportFile.Write(PadString((""),80)) 'InductionPoint Optional |
|
|
|
|
|
objExportFile.Write(PadString((""),10)) 'InductionDate Optional – Valid date format, ex. MM/DD/YYYY |
|
|
|
|
|
objExportFile.Write(PadString(Choice(IsNull(KitRs("InboundSTID")),"", _ |
|
|
|
|
|
KitLabelsRs("InBoundIMBDigits").Value),31)) 'InboundIMB Optional – numeric IMB for Round trip jobs only |
|
|
|
|
|
objExportFile.Write(PadString((""),24)) 'IMCB Optional – Container Barcode |
|
|
|
|
|
objExportFile.Write(PadString((""),24)) 'IMTB Optional – Tray Barcode |
|
|
|
|
|
objExportFile.Write(vbCrLf) |
|
|
|
|
|
KitLabelsRs.MoveNext |
|
|
|
|
|
Wend |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
objExportFile.Close |
|
|
|
|
|
oConn.Execute("UPDATE KIT SET [Status] ='Ready to Proof',[ExportedToSnailWorks] =#" & Now() & "# WHERE [ID] =" & KitID & ";") |
|
|
|
|
|
If KitRs.State = 1 Then:KitRs.Close:End If |
|
|
|
|
|
If KitLabelsRs.State = 1 Then:KitLabelsRs.Close: End If |
|
|
|
|
|
If JurisdictionRs.State = 1 Then:JurisdictionRs.Close:End If |
|
|
|
|
|
If oConn.State = 1 Then:oConn.Close:End If |
|
|
|
|
|
End Function |
|
|
|
|
|
|
|
|
Function createTrackingInfoForKit(KitID) |
|
|
Function createTrackingInfoForKit(KitID) |
|
|
Dim KitRs:set KitRs = oConn.Execute("Select * from Kit Where ID =" & KitID & ";") |
|
|
Dim KitRs:set KitRs = oConn.Execute("Select * from Kit Where ID =" & KitID & ";") |
|
|
Dim InkjetRs:Set InkjetRs = oConn.Execute("Select * from InkjetRecords Where KitID =" & KitID & ";") |
|
|
Dim InkjetRs:Set InkjetRs = oConn.Execute("Select * from InkjetRecords Where KitID =" & KitID & ";") |
|
|
@@ -313,4 +424,46 @@ Else |
|
|
PadLeft = originalString |
|
|
PadLeft = originalString |
|
|
End If |
|
|
End If |
|
|
|
|
|
|
|
|
|
|
|
End Function |
|
|
|
|
|
|
|
|
|
|
|
Function PadString(inputString, size) |
|
|
|
|
|
Dim paddedString |
|
|
|
|
|
Dim inputLength |
|
|
|
|
|
Dim i |
|
|
|
|
|
|
|
|
|
|
|
' Get the length of the input string |
|
|
|
|
|
inputLength = Len(inputString) |
|
|
|
|
|
|
|
|
|
|
|
' If the input string is already equal to or longer than the specified size, return it as is |
|
|
|
|
|
If inputLength >= size Then |
|
|
|
|
|
PadString = inputString |
|
|
|
|
|
Exit Function |
|
|
|
|
|
End If |
|
|
|
|
|
|
|
|
|
|
|
' Initialize the padded string with the input string |
|
|
|
|
|
paddedString = inputString |
|
|
|
|
|
|
|
|
|
|
|
' Pad spaces to the right of the input string until it reaches the specified size |
|
|
|
|
|
For i = 1 To (size - inputLength) |
|
|
|
|
|
paddedString = paddedString & " " |
|
|
|
|
|
Next |
|
|
|
|
|
|
|
|
|
|
|
' Return the padded string |
|
|
|
|
|
PadString = paddedString |
|
|
|
|
|
End Function |
|
|
|
|
|
|
|
|
|
|
|
Public Sub Assign(ByRef var, ByVal val) |
|
|
|
|
|
If IsObject(val) Then |
|
|
|
|
|
Set var = val |
|
|
|
|
|
Else |
|
|
|
|
|
var = val |
|
|
|
|
|
End If |
|
|
|
|
|
End Sub |
|
|
|
|
|
|
|
|
|
|
|
Public Function Choice(ByVal cond, ByVal if_true, ByVal if_false) |
|
|
|
|
|
If cond Then |
|
|
|
|
|
Assign Choice, if_true |
|
|
|
|
|
Else |
|
|
|
|
|
Assign Choice, if_false |
|
|
|
|
|
End If |
|
|
End Function |
|
|
End Function |