Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Function jobcomplete(ByVal jobId, ByVal unitNo, ByVal fluidType, ByVal quantity, ByVal endTime, ByVal acCondition)
- ' endTime = CType(Mid(endTime, 1, 19), String)
- ' log("-------- TIME DEBUG --------")
- ' log("FINISH TIME RECEIVED -> " & endTime)
- ' log("----------------------------")
- 'jobId, unitNo, fluidType, quantity, endTime, acCondition
- ''steps
- ''termine = 1 in conf_vol
- '' set heure_fin in temps_qte_cam (
- '' might have to insert into arrosage
- acCondition = CType(acCondition, Long)
- acCondition = CType(acCondition, String) ''messy workaround for tcp framing issue
- ''do we get this message only once per truck per flight?
- ''and do they all have the exact same end time?
- If fluidType = "4" Then fluidType = "2" ''normalize fluid type
- Dim magid
- magid = getmagid(unitNo)
- ' Dim finished
- ' finished = getdata("TEMPS_QTE_CAM", "HEURE_FIN", "DEGI_ID = '" & jobId & "' AND TYDE_ID = '" & fluidType & "' AND CAMION_ID <> '" & magid & "'")
- Dim d
- Dim year
- Dim month
- Dim day
- Dim hh
- Dim mm
- Dim ss
- Dim dt
- dt = gettimeUTC(endTime)
- 'ex 2010-10-08 10:37:52
- year = Mid(dt, 1, 4)
- month = Mid(dt, 6, 2)
- day = Mid(dt, 9, 2)
- hh = Mid(dt, 12, 2)
- mm = Mid(dt, 15, 2)
- ss = Mid(dt, 18, 2)
- '' DO A CHECK to see if this job has been completed from gestop.... if so, do nothing.. DTS 2011
- d = getdata("DEGIVRAGE", "STATUT_D_AVANCEMENT", "ID = '" & jobId & "'")
- If Len(d) <> 0 Then
- If d = "O" Then log("*********** ERROR - JOB COMPLETE (finish times) RECEIVED AFTER FLIGHT FINISHED IN GESTOP ID: " & jobId & " ************") : Exit Function
- If d = "A" Then log("*********** ERROR - JOB COMPLETE (finish times) RECEIVED AFTER FLIGHT FINISHED IN GESTOP ID: " & jobId & " ************") : Exit Function
- End If
- ''''
- ' If getdata2("SELECT COUNT(DEGI_ID) FROM TEMPS_QTE_CAM WHERE DEGI_ID = '" & jobId & "' AND HEURE_FIN IS NULL AND TYDE_ID = '" & fluidType & "'") = 1 Then
- If fluidType = "1" Then
- ' d = getdata("DEGIVRAGE", "to_char(TYPE_1_FINISH_TIME, 'YYYY-MM-DD HH24:MI:SS')", "ID = " & jobId) '' current time in the db
- d = getdata3("DEGIVRAGE", "to_char(TYPE_1_FINISH_TIME, 'YYYY-MM-DD HH24:MI:SS') TYPE_1_FINISH_TIME", "ID = " & jobId)
- If Len(d) = 0 Then
- db("UPDATE DEGIVRAGE SET TYPE_1_FINISH_TIME = to_date('" & year & "-" & month & "-" & day & " " & hh & ":" & mm & ":" & ss & "','YYYY-MM-DD HH24:MI:SS') WHERE (ID = " & jobId & ")")
- End If
- If Len(d) <> 0 Then ''there already exists a time in the database, compare
- endTime = gettimeUTC(endTime)
- Dim old As DateTime
- Dim nw As DateTime
- old = DateTime.ParseExact(d.ToString, "yyyy-MM-dd HH:mm:ss", Nothing)
- nw = DateTime.ParseExact(endTime.ToString, "yyyy-MM-dd HH:mm:ss", Nothing)
- If old < nw Then
- db("UPDATE DEGIVRAGE SET TYPE_1_FINISH_TIME = to_date('" & year & "-" & month & "-" & day & " " & hh & ":" & mm & ":" & ss & "','YYYY-MM-DD HH24:MI:SS') WHERE (ID = " & jobId & ")")
- ' log("Second Spray -> old time: " & old.ToString & " new time: " & nw.ToString)
- End If
- End If
- End If
- If fluidType = "2" Then ''type 4
- d = getdata3("DEGIVRAGE", "to_char(TYPE_4_FINISH_TIME, 'YYYY-MM-DD HH24:MI:SS') TYPE_4_FINISH_TIME", "ID = " & jobId)
- If Len(d) = 0 Then
- db("UPDATE DEGIVRAGE SET TYPE_4_FINISH_TIME = to_date('" & year & "-" & month & "-" & day & " " & hh & ":" & mm & ":" & ss & "','YYYY-MM-DD HH24:MI:SS') WHERE (ID = " & jobId & ")")
- End If
- If Len(d) <> 0 Then ''there already exists a time in the database, compare
- endTime = gettimeUTC(endTime)
- Dim old As DateTime
- Dim nw As DateTime
- old = DateTime.ParseExact(d.ToString, "yyyy-MM-dd HH:mm:ss", Nothing)
- nw = DateTime.ParseExact(endTime.ToString, "yyyy-MM-dd HH:mm:ss", Nothing)
- If old < nw Then
- db("UPDATE DEGIVRAGE SET TYPE_4_FINISH_TIME = to_date('" & year & "-" & month & "-" & day & " " & hh & ":" & mm & ":" & ss & "','YYYY-MM-DD HH24:MI:SS') WHERE (ID = " & jobId & ")")
- ' log("Second Spray -> old time: " & old.ToString & " new time: " & nw.ToString)
- End If
- End If
- End If
- '''
- '''termine = 1 for this mag
- ''special case: multiple sprays
- quantity += getdata("TEMPS_QTE_CAM", "QUANTITE_APP", "DEGI_ID = " & jobId & " AND CAMION_ID = '" & magid & "' AND TYDE_ID = '" & fluidType & "'")
- '''''''''''''''
- db("UPDATE CONF_VOL SET TERMINE = 1 WHERE DEGI_ID = " & jobId & " AND CAMION_ID = '" & magid & "'")
- db("UPDATE TEMPS_QTE_CAM SET HEURE_FIN = to_date('" & year & "-" & month & "-" & day & " " & hh & ":" & mm & ":" & ss & "','YYYY-MM-DD HH24:MI:SS') WHERE DEGI_ID = " & jobId & " AND CAMION_ID = '" & magid & "' AND TYDE_ID = '" & fluidType & "'")
- db("UPDATE TEMPS_QTE_CAM SET QUANTITE_APP = '" & quantity & "' WHERE DEGI_ID = " & jobId & " AND CAMION_ID = '" & magid & "' AND TYDE_ID = '" & fluidType & "'")
- ''ac condition handler
- ''first insert the value returned from vestergaard into cond_aero_cam
- '' is there a use for this????
- Dim cond
- cond = getdata("COND_AERO_CAM", "DATE_HRS", "COND_AERO_ID = '" & acCondition & "'")
- If Len(cond) = 0 Then
- db("INSERT INTO COND_AERO_CAM (ID, DEGI_ID, CAMION_ID, COND_AERO_ID, DATE_HRS) VALUES (COND_AERO_CAM_ID.nextval, " & jobId & ", " & magid & ", " & acCondition & ", to_date('" & year & "-" & month & "-" & day & " " & hh & ":" & mm & ":" & ss & "','YYYY-MM-DD HH24:MI:SS'))")
- Else
- db("UPDATE COND_AERO_CAM SET COND_AERO_ID = '" & acCondition & "' WHERE DEGI_ID = " & jobId & " AND CAMION_ID = '" & magid & "'")
- db("UPDATE COND_AERO_CAM SET DATE_HRS = to_date('" & year & "-" & month & "-" & day & " " & hh & ":" & mm & ":" & ss & "','YYYY-MM-DD HH24:MI:SS') WHERE DEGI_ID = " & jobId & " AND CAMION_ID = '" & magid & "'")
- End If
- ''
- '' next test to see if employee has ac conditions rights
- Dim eqpiste_id
- Dim eqpiste_employee_id
- Dim accondrights
- Dim camid
- camid = getdata("CAMION", "ID", "NO_CAMION = " & unitNo)
- eqpiste_id = getid(camid, year, month, day, hh, mm, ss)
- If eqpiste_id = 0 Then
- TextBox1.Text += vbCrLf & camid & year & month & day & hh & mm & ss
- log("************* IF YOU SEE THIS, YOU GOT ISSUES ... trouble....jobcomplete/eqpiste = 0 unitno: " & unitNo & "jobid: " & jobId & " fluid: " & fluidType)
- End If
- eqpiste_employee_id = getdata("EQ_PISTE", "PE_OPER_ID", "ID = " & eqpiste_id)
- accondrights = getdata("PERS_AEROMAG_2000", "ACC_COND_AERONEF", "ID = " & eqpiste_employee_id)
- ' MsgBox("Results: " & eqpiste_id & " " & eqpiste_employee_id & " " & accondrights)
- ''
- Try
- If accondrights = -1 Then ''employee does have rights to change ac cond
- Dim accond
- Dim prionew
- Dim prioold
- accond = getdata("DEGIVRAGE", "COND_AERO_ID", "ID = " & jobId)
- ' If accond = Nothing Then
- ' End If
- prioold = getdata("COND_AERONEF", "PRIORITE", "ID = " & accond)
- prionew = getdata("COND_AERONEF", "PRIORITE", "ID = " & acCondition)
- ' MsgBox("has access, results: ACCOND: " & accond & " OLD PRIO: " & prioold & " NEW PRIO: " & prionew)
- If prionew > prioold Then
- db("UPDATE DEGIVRAGE SET COND_AERO_ID = " & acCondition & " WHERE ID = " & jobId)
- End If
- End If
- Catch ex As Exception
- End Try
- End Function
Add Comment
Please, Sign In to add comment