@@ -33,7 +33,7 @@ Dim WorkingDirectory:WorkingDirectory = Replace(WScript.ScriptFullName,WScript.S | |||
set outFile = objFSO.CreateTextFile("\\kci-syn-cl01\PC Transfer\TrackingDataExport\temp.csv",True) | |||
End If | |||
'ToDo create a checkstatus function so I dont need four functions of create a case switch that responds to the status of jobs | |||
Dim KitID:CheckForFiles:KitID = CheckForJobsToCass() | |||
If KitID > 0 Then | |||
@@ -41,11 +41,81 @@ Dim WorkingDirectory:WorkingDirectory = Replace(WScript.ScriptFullName,WScript.S | |||
RunMailManager | |||
ImportCass | |||
End If | |||
KitID = CheckForReadyToLabel():If KitID > 0 Then:createTrackingInfoForKit(KitID):End If | |||
KitID = CheckForReadyToExportToSnailWorks():If KitID > 0 Then:CreateExportForSnailWorks(KitID):End If | |||
KitID = CheckForProofReady(KitID):If KitID > 0 Then:CreateProofForJurisdiction(KitID):End If | |||
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 | |||
WScript.Quit | |||
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 & ";") | |||
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")) & ".1up" | |||
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) | |||
Dim ElectionDate:ElectionDate=GetSetting("ElectionDate") | |||
objExportFile.Writeline("Election Date") | |||
objExportFile.Writeline("Full Name") | |||
objExportFile.Writeline("Alternate 1 Address") | |||
objExportFile.Writeline("Delivery Address") | |||
objExportFile.Writeline("City St ZIP+4") | |||
objExportFile.Writeline("") | |||
objExportFile.Writeline("*Voter ID*") | |||
objExportFile.Writeline("Precinct") | |||
objExportFile.Writeline("Ballot Number") | |||
objExportFile.Writeline("Clerk Name") | |||
objExportFile.Writeline("City or Township Name") | |||
objExportFile.Writeline("Return Address") | |||
objExportFile.Writeline("Return CSZ") | |||
objExportFile.Writeline("Jurisdiction IMB") | |||
While Not KitLabelsRs.EOF | |||
objExportFile.Writeline(ElectionDate) | |||
objExportFile.Writeline(KitLabelsRs("CassADDRESS1").Value) | |||
objExportFile.Writeline("") | |||
objExportFile.Writeline("*" & KitLabelsRs("VOTERID").Value & "*") | |||
KitLabelsRs.MoveNext | |||
Wend | |||
objExportFile.Close | |||
oConn.Execute("UPDATE KIT SET [Status] ='Done',[InkJetJob]=1 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 CheckStatusFor(StatusString) | |||
If oConn.State = 0 Then:oConn.Open(ConnectionString):End If | |||
Dim rs:Set rs = oConn.Execute("Select TOP 1 [ID] FROM [Kit] Where Status ='" & StatusString & "' and JobType='Purple Envelopes';") | |||
If Not rs.EOF Then | |||
CheckStatusFor = rs("ID").value | |||
Else | |||
CheckStatusFor = 0 | |||
End If | |||
If rs.State = 1 Then:rs.Close:End If | |||
If oConn.State = 1 Then:oConn.Close:End If | |||
End Function | |||
Function CreateProofForJurisdiction(KitID) | |||
Dim Qpdf:Set Qpdf = WScript.CreateObject("DebenuPDFLibraryAX1013.PDFLibrary") | |||
Dim Result:Result = Qpdf.UnlockKey("j564z3wi9i66k93cp3r798b3y") | |||
@@ -101,30 +171,6 @@ Function CreateProofForJurisdiction(KitID) | |||
End Function | |||
Function CheckForProofReady(KitID) | |||
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 to Proof' and JobType='Purple Envelopes';") | |||
If Not rs.EOF Then | |||
CheckForProofReady = rs("ID").value | |||
Else | |||
CheckForProofReady = 0 | |||
End If | |||
If rs.State = 1 Then:rs.Close:End If | |||
If oConn.State = 1 Then:oConn.Close:End If | |||
End Function | |||
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 & ";") | |||
@@ -151,8 +197,8 @@ Function CreateExportForSnailWorks(KitID) | |||
With objExportFile | |||
.Write("""H"",") 'Record Type Required value must be = "H" (Header) | |||
.Write(Truncate("5.1",5)) 'Version Required value must be ="5.1" for current release | |||
.Write(Truncate("KCI",50)) 'UserId Required | |||
.Write(Truncate(JurisdictionRs("Name").Value,50)) 'Client Name Required (will create new subaccount if not already defined) | |||
.Write(Truncate("KCI",50)) 'UserId Required | |||
.Write(Truncate(KitRs("Jcode").Value,50)) 'Client Name Required (will create new subaccount if not already defined) - We decideded to make this the juriscode | |||
.Write(Truncate("",50)) 'Parent Client Name Optional (use if 3-tier account structure) | |||
.Write(Truncate("Purple envelope - " & KitRs("JobNumber").Value,50)) 'Job Name Required | |||
.Write(Truncate("",50)) 'Job Description Optional | |||
@@ -174,7 +220,8 @@ Function CreateExportForSnailWorks(KitID) | |||
.Write(Truncate("",2)) 'ReportId1 | |||
.Write(Truncate("",255)) 'Report1Email | |||
.Write(Truncate("",2)) 'ReportId2 | |||
.Write("""""") 'Report2Email | |||
.Write(Truncate("",255)) 'Report2Email | |||
.Write("""N""") 'INFOONLY | |||
.Write(vbCrLf) | |||
While Not KitLabelsRs.EOF | |||
.Write("""D"",") 'RecordType Required value must be = “D” (Detail) | |||
@@ -222,6 +269,7 @@ Function CreateExportForSnailWorks(KitID) | |||
End Function | |||
Function createTrackingInfoForKit(KitID) | |||
oConn.Execute("UPDATE Kit SET Status ='Applying Serial Numbers' 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 JurisRs:set JurisRs = oConn.Execute("Select Right(IMB_Digits,9) as IMBZip FROM Jurisdiction Where JCode ='" & KitRs("Jcode") & "';"):Dim Jcode:Jcode = JurisRs("IMBZip"):JurisRs.Close | |||
@@ -271,22 +319,6 @@ Dim rs:Set rs = oConn.Execute("Select Value From [Settings] Where [Name] = '" & | |||
End Function | |||
Function CheckForReadyToLabel() | |||
Dim rs : set rs = oConn.Execute("Select TOP 1 ID from Kit Where Status ='Ready to Assign Labels' ORDER BY ID DESC;") | |||
If Not rs.EOF Then | |||
Dim kitId : kitId = rs("ID").value | |||
rs.Close | |||
CheckForReadyToLabel = KitID | |||
oConn.Execute("UPDATE Kit SET Status ='Applying Serial Numbers' WHERE ID =" & KitID & ";") | |||
Else | |||
CheckForReadyToLabel = 0 | |||
End If | |||
End Function | |||
Function CheckForFiles() | |||
@@ -397,7 +429,6 @@ End Function | |||
Function ValidImportCSV(CsvFileAsString) | |||
objCSV.LoadFromString(CsvFileAsString) | |||
If objCSV.NumColumns = 20 Then | |||
debug.WriteLine objCsv.GetCell(1,1) | |||
ValidImportCSV = True | |||
Else | |||
ValidImportCSV = False | |||
@@ -423,7 +454,6 @@ Sub ImportCass | |||
End Sub | |||
Sub RunMailManager | |||
'WshShell.Run "\\MM2012\APPS\BCC\MM2010\mailman.exe -p -j MMJOB.mjb -u DAN",1,True | |||
WshShell.Run "PsExec64.exe -i -e -u ntp\danielc -p SunBrightShine! \\MarkH2 ""\\MM2012\APPS\BCC\MM2010\mailman.exe"" -p -j MMJOB.mjb -u DAN",1,True | |||
End Sub | |||
Sub ExportMMCsv(KitId) | |||
Powered by TurnKey Linux.