|
|
@@ -29,16 +29,81 @@ Dim WorkingDirectory:WorkingDirectory = Replace(WScript.ScriptFullName,WScript.S |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CheckForFiles |
|
|
|
Dim KitID:KitID = CheckForJobsToCass() |
|
|
|
If KitID > 0 Then |
|
|
|
ExportMMCsv(KitID) |
|
|
|
RunMailManager |
|
|
|
ImportCass |
|
|
|
End If |
|
|
|
Dim KitID |
|
|
|
' CheckForFiles |
|
|
|
' KitID = CheckForJobsToCass() |
|
|
|
' If KitID > 0 Then |
|
|
|
' ExportMMCsv(KitID) |
|
|
|
' RunMailManager |
|
|
|
' ImportCass |
|
|
|
' End If |
|
|
|
oConn.Open(ConnectionString) |
|
|
|
KitID = CheckForReadyToLabel() |
|
|
|
If KitID > 0 Then |
|
|
|
createTrackingInfoForKit(KitID) |
|
|
|
End If |
|
|
|
|
|
|
|
WScript.Quit |
|
|
|
|
|
|
|
Function createTrackingInfoForKit(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 SerialNumberStart:SerialNumberStart = GetSetting("SerialNumberStart") |
|
|
|
Dim serialOffset:serialOffset = GetSetting("SerialOffset") |
|
|
|
Dim serialStart:serialStart = CLng(GetSetting("SerialNumberStart")) + CLng(GetSetting("SerialOffset")) |
|
|
|
Dim Counter:Counter=0 |
|
|
|
Dim KitLabelID |
|
|
|
Dim KitLabelRs |
|
|
|
Dim Step : If KitRs("InboundSTID") <> "" Then : Step = 2 : Else Step = 1 |
|
|
|
serialStart = PadLeft(serialStart + CLng(Counter),9,"0") |
|
|
|
While Not InkjetRs.EOF |
|
|
|
|
|
|
|
If Step = 1 Then |
|
|
|
oConn.Execute("INSERT INTO KitLabels (KitID,OutboundSerial,OutboundIMBDigits) " &_ |
|
|
|
"VALUES(" & KitID & ",'" & serialStart & "','" & KitRs("OutBoundSTID").Value & serialStart & "000000000" & "');") |
|
|
|
Set KitLabelRs = oConn.Execute("SELECT TOP 1 [ID] FROM KitLabels ORDER BY ID DESC") |
|
|
|
KitLabelID = KitLabelRs("ID").Value |
|
|
|
oConn.Execute("UPDATE InkjetRecords Set [KitLabelID]=" & KitLabelID & " WHERE ID=" & InkjetRs("ID") & ";") |
|
|
|
serialStart = serialStart + 1 |
|
|
|
Else |
|
|
|
' oConn.Execute("INSERT INTO KitLabels (KitID,OutboundSerial,InBoundSerial,OutbondIMBDigitds,InBoundIMBDigits) " &_ |
|
|
|
' "VALUES(" & KitID & ",' & ") |
|
|
|
End If |
|
|
|
InkjetRs.MoveNext |
|
|
|
Wend |
|
|
|
|
|
|
|
|
|
|
|
End Function |
|
|
|
|
|
|
|
Function GetSetting(settingName) |
|
|
|
|
|
|
|
Dim rs:Set rs = oConn.Execute("Select Value From [Settings] Where [Name] = '" & settingName & "';") |
|
|
|
|
|
|
|
If Not rs.EOF Then |
|
|
|
GetSetting = rs(0).value |
|
|
|
rs.Close |
|
|
|
Else |
|
|
|
SetSetting = 0 |
|
|
|
rs.Close |
|
|
|
End If |
|
|
|
|
|
|
|
|
|
|
|
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() |
|
|
@@ -230,4 +295,17 @@ oConn.Open |
|
|
|
CheckForJobsToCass = 0 |
|
|
|
End If |
|
|
|
'oConn.Close |
|
|
|
End Function |
|
|
|
|
|
|
|
Public Function PadLeft(originalString,desiredLength,Char) |
|
|
|
Dim padLength |
|
|
|
padLength = desiredLength - Len(originalString) |
|
|
|
If padLength > 0 Then |
|
|
|
' Left pad the string with zeros |
|
|
|
PadLeft = String(padLength, Char) & originalString |
|
|
|
Else |
|
|
|
' If the original string is already longer or equal to the desired length, no padding is needed |
|
|
|
PadLeft = originalString |
|
|
|
End If |
|
|
|
|
|
|
|
End Function |