Ver código fonte

The files will import now

pull/6/head
Daniel Covington 7 meses atrás
pai
commit
8b214473fd
2 arquivos alterados com 98 adições e 1 exclusões
  1. BIN
      Dependancies/nssm.exe
  2. +98
    -1
      ImportService/TrackingDataImport.vbs

BIN
Dependancies/nssm.exe Ver arquivo


+ 98
- 1
ImportService/TrackingDataImport.vbs Ver arquivo

@@ -1,6 +1,7 @@
Option Explicit
Dim dev:dev = True
Dim DataDirectory
Dim ConnectionString
Dim glob:set glob = CreateObject("Chilkat_9_5_0.Global")
Dim success:success = glob.UnlockBundle("KENTCM.CB1022025_RGzBPM5J655e")

@@ -13,9 +14,14 @@ Dim objCSV:Set objCsv = CreateObject("Chilkat_9_5_0.Csv")
Dim WorkingDirectory:WorkingDirectory = Replace(WScript.ScriptFullName,WScript.ScriptName,"")
If dev Then
DataDirectory = WorkingDirectory & "test"
ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Engine Type=5;Data Source=F:\Development\Tracking_Kits\Data\webdata - Copy.mdb;"
Else
DataDirectory = "\\kci-syn-cl01\PC Transfer\TrackingDataImport\"
ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Engine Type=5;Data Source=C:\inetpub\Data\webdata - Copy.mdb;"
End If
CheckForFiles

Function CheckForFiles()
@@ -30,7 +36,8 @@ Dim objFSO:Set objFSO = CreateObject("Scripting.FileSystemObject")
For Each objFile In objFolder.Files
Dim CsvString:CsvString = ConvertCsvToString(objFile.Path)
If ValidImportCSV(CsvString) Then
WScript.Echo objFile.Path & " Is a Valid CSV for Importing"
SetupKit CsvString,objFile.Name
End If
Next
Else
@@ -40,6 +47,95 @@ Dim objFSO:Set objFSO = CreateObject("Scripting.FileSystemObject")
End If
End Function

Function ValidJcode(jcode)
Dim oConn
Set oConn = WScript.CreateObject("ADODB.Connection")
oConn.ConnectionString = ConnectionString
oConn.Open
Dim oRs
set oRs = oConn.Execute("Select * from Jurisdiction Where [JCode] = '" & jcode & "';")
If oRs.EOF Then
ValidJcode = 0
Else
ValidJcode = 1
End If
oRs.Close
oConn.Close
End Function


Function SetupKit(CsvString,FileName)
Dim JobNumber:JobNumber = Mid(FileName,9,6)
Dim JCode:JCode = Left(Filename,5)
If IsNumeric(JobNumber) Then
If ValidJcode(JCode) Then
WScript.Echo FileName & " Is a Valid CSV for Importing"
Dim oConn:Set oConn = WScript.CreateObject("ADODB.Connection")
oConn.ConnectionString = ConnectionString
oConn.Open
oConn.Execute("Insert Into Kit ([JobNumber], [Jcode], [CreatedOn]) VALUES ('" & JobNumber & "','" & JCode & "',#" & Now() & "#);")
Dim rs : set rs = oConn.Execute("Select TOP 1 ID from Kit ORDER BY ID DESC")
Dim kitId : kitId = rs("ID").value
rs.close
'objCsv.LoadFromString(CsvString)
Dim i
For i = 1 To objCSV.NumRows
'debug.WriteLine objCsv.GetCell(i,0)
' debug.WriteLine("Insert Into [InkjetRecords] (KitID,VOTERID,LASTNAME,FIRSTNAME,MIDDLENAME" & _
' ",SUFFIX,PRECINCT,ADDRESS1,ADDRESS2,ADDRESS3,ADDRESS4,ADDRESS5,APPSENT,APPRETURNED,BALSENT,BALRETURNED" & _
' ",CountingBoard,UOCAVASTATUS,EMAILADDRESS,PHONENUMBER,BALLOT_NUMBER) VALUES (" & CInt(kitId) & ",'" & objCsv.GetCell(i,0) & _
' "','" & objCSV.GetCell(i,1) & _
' "','" & objCsv.GetCell(i,2) & _
' "','" & objCsv.GetCell(i,3) & _
' "','" & objCsv.GetCell(i,4) & _
' "','" & objCsv.GetCell(i,5) & _
' "','" & objCsv.GetCell(i,6) & _
' "','" & objCsv.GetCell(i,7) & _
' "','" & objCsv.GetCell(i,8) & _
' "','" & objCsv.GetCell(i,9) & _
' "','" & objCsv.GetCell(i,10) & _
' "','" & objCsv.GetCell(i,11) & _
' "','" & objCsv.GetCell(i,12) & _
' "','" & objCsv.GetCell(i,13) & _
' "','" & objCsv.GetCell(i,14) & _
' "','" & objCsv.GetCell(i,15) & _
' "','" & objCsv.GetCell(i,16) & _
' "','" & objCsv.GetCell(i,17) & _
' "','" & objCsv.GetCell(i,18) & _
' "','" & objCsv.GetCell(i,19) & _
' "')")
oConn.Execute("Insert Into [InkjetRecords] (KitID,VOTERID,LASTNAME,FIRSTNAME,MIDDLENAME" & _
",SUFFIX,PRECINCT,ADDRESS1,ADDRESS2,ADDRESS3,ADDRESS4,ADDRESS5,APPSENT,APPRETURNED,BALSENT,BALRETURNED" & _
",CountingBoard,UOCAVASTATUS,EMAILADDRESS,PHONENUMBER,BALLOT_NUMBER) VALUES (" & kitId & _
",'" & objCsv.GetCell(i,0) & _
"','" & objCsv.GetCell(i,1) & _
"','" & objCsv.GetCell(i,2) & _
"','" & objCsv.GetCell(i,3) & _
"','" & objCsv.GetCell(i,4) & _
"','" & objCsv.GetCell(i,5) & _
"','" & objCsv.GetCell(i,6) & _
"','" & objCsv.GetCell(i,7) & _
"','" & objCsv.GetCell(i,8) & _
"','" & objCsv.GetCell(i,9) & _
"','" & objCsv.GetCell(i,10) & _
"','" & objCsv.GetCell(i,11) & _
"','" & objCsv.GetCell(i,12) & _
"','" & objCsv.GetCell(i,13) & _
"','" & objCsv.GetCell(i,14) & _
"','" & objCsv.GetCell(i,15) & _
"','" & objCsv.GetCell(i,16) & _
"','" & objCsv.GetCell(i,17) & _
"','" & objCsv.GetCell(i,18) & _
"','" & objCsv.GetCell(i,19) & _
"')")
Next
oConn.Close
End If
End If

End Function
Function ConvertCsvToString(FilePath)
Dim objFSO:Set objFSO = CreateObject("Scripting.FileSystemObject")
Dim objCsvFile:set objCsvFile = objFSO.OpenTextFile(FilePath)
@@ -62,6 +158,7 @@ End Function
Function ValidImportCSV(CsvFileAsString)
objCSV.LoadFromString(CsvFileAsString)
If objCSV.NumColumns = 20 Then
debug.WriteLine objCsv.GetCell(1,1)
ValidImportCSV = True
Else
ValidImportCSV = False


Carregando…
Cancelar
Salvar

Powered by TurnKey Linux.