From f3b801270037e15440feb09a1cb8130ccc5fdf49 Mon Sep 17 00:00:00 2001 From: Daniel Covington Date: Thu, 9 May 2024 10:33:41 -0400 Subject: [PATCH] Getting outbound labels generated --- ...igration_14_Alter_Kit_Table_With_STIDS.asp | 20 ++++ ...er_InkJetRecords_Table_With_KitLabelID.asp | 16 ++++ Data/Migrations/migrate.asp | 1 + ImportService/TrackingDataImport.vbs | 94 +++++++++++++++++-- 4 files changed, 123 insertions(+), 8 deletions(-) create mode 100644 Data/Migrations/Migration_14_Alter_Kit_Table_With_STIDS.asp create mode 100644 Data/Migrations/Migration_15_Alter_InkJetRecords_Table_With_KitLabelID.asp diff --git a/Data/Migrations/Migration_14_Alter_Kit_Table_With_STIDS.asp b/Data/Migrations/Migration_14_Alter_Kit_Table_With_STIDS.asp new file mode 100644 index 0000000..5d78c71 --- /dev/null +++ b/Data/Migrations/Migration_14_Alter_Kit_Table_With_STIDS.asp @@ -0,0 +1,20 @@ +<% +Class Migration_14_Alter_Kit_Table_With_STIDS + Public Migration + + Public Sub Up + Migration.Do "ALTER TABLE [Kit] " &_ + "ADD [OutboundSTID] VARCHAR(20);" + Migration.Do "ALTER TABLE [Kit] " &_ + "ADD [InboundSTID] VARCHAR(20);" +End Sub + + Public Sub Down + Migration.Do "ALTER TABLE [Kit] " &_ + "DROP COLUMN [OutBoundSTID];" + Migration.Do "ALTER TABLE [Kit] " &_ + "DROP COLUMN [InboundSTID];" + End Sub +End Class + Migrations.Add "Migration_14_Alter_Kit_Table_With_STIDS" + %> \ No newline at end of file diff --git a/Data/Migrations/Migration_15_Alter_InkJetRecords_Table_With_KitLabelID.asp b/Data/Migrations/Migration_15_Alter_InkJetRecords_Table_With_KitLabelID.asp new file mode 100644 index 0000000..6fb279b --- /dev/null +++ b/Data/Migrations/Migration_15_Alter_InkJetRecords_Table_With_KitLabelID.asp @@ -0,0 +1,16 @@ +<% +Class Migration_15_Alter_InkJetRecords_Table_With_KitLabelID + Public Migration + + Public Sub Up + Migration.Do "ALTER TABLE [InkjetRecords] " &_ + "ADD [KitLabelID] Long;" +End Sub + + Public Sub Down + Migration.Do "ALTER TABLE [InkjetRecords] " &_ + "DROP COLUMN [KitLabelID];" + End Sub +End Class + Migrations.Add "Migration_15_Alter_InkJetRecords_Table_With_KitLabelID" + %> \ No newline at end of file diff --git a/Data/Migrations/migrate.asp b/Data/Migrations/migrate.asp index 69d0a5e..ec30525 100644 --- a/Data/Migrations/migrate.asp +++ b/Data/Migrations/migrate.asp @@ -43,6 +43,7 @@ Migrations.Tracing = false + <% Sub HandleMigration putl "Starting Version: " & Migrations.Version & "" diff --git a/ImportService/TrackingDataImport.vbs b/ImportService/TrackingDataImport.vbs index 43a47d2..fcacdc6 100644 --- a/ImportService/TrackingDataImport.vbs +++ b/ImportService/TrackingDataImport.vbs @@ -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 \ No newline at end of file