Guest User

Untitled

a guest
May 22nd, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  Public Function jobcomplete(ByVal jobId, ByVal unitNo, ByVal fluidType, ByVal quantity, ByVal endTime, ByVal acCondition)
  2.         ' endTime = CType(Mid(endTime, 1, 19), String)
  3.  
  4.         '   log("-------- TIME DEBUG --------")
  5.        '   log("FINISH TIME RECEIVED -> " & endTime)
  6.        '   log("----------------------------")
  7.  
  8.  
  9.         'jobId, unitNo, fluidType, quantity, endTime, acCondition
  10.        ''steps
  11.        ''termine = 1 in conf_vol
  12.        '' set heure_fin in temps_qte_cam (
  13.        '' might have to insert into arrosage
  14.  
  15.         acCondition = CType(acCondition, Long)
  16.         acCondition = CType(acCondition, String) ''messy workaround for tcp framing issue
  17.  
  18.  
  19.  
  20.         ''do we get this message only once per truck per flight?  
  21.        ''and do they all have the exact same end time?
  22.        If fluidType = "4" Then fluidType = "2" ''normalize fluid type
  23.  
  24.         Dim magid
  25.         magid = getmagid(unitNo)
  26.  
  27.  
  28.         '   Dim finished
  29.        '  finished = getdata("TEMPS_QTE_CAM", "HEURE_FIN", "DEGI_ID = '" & jobId & "' AND TYDE_ID = '" & fluidType & "' AND CAMION_ID <> '" & magid & "'")
  30.  
  31.         Dim d
  32.         Dim year
  33.         Dim month
  34.         Dim day
  35.         Dim hh
  36.         Dim mm
  37.         Dim ss
  38.         Dim dt
  39.         dt = gettimeUTC(endTime)
  40.         'ex 2010-10-08 10:37:52
  41.        year = Mid(dt, 1, 4)
  42.         month = Mid(dt, 6, 2)
  43.         day = Mid(dt, 9, 2)
  44.  
  45.         hh = Mid(dt, 12, 2)
  46.         mm = Mid(dt, 15, 2)
  47.         ss = Mid(dt, 18, 2)
  48.  
  49.  
  50.  
  51.         '' DO A CHECK to see if this job has been completed from gestop.... if so, do nothing.. DTS 2011
  52.  
  53.         d = getdata("DEGIVRAGE", "STATUT_D_AVANCEMENT", "ID = '" & jobId & "'")
  54.  
  55.         If Len(d) <> 0 Then
  56.  
  57.             If d = "O" Then log("*********** ERROR - JOB COMPLETE (finish times) RECEIVED AFTER FLIGHT FINISHED IN GESTOP ID: " & jobId & " ************") : Exit Function
  58.             If d = "A" Then log("*********** ERROR - JOB COMPLETE (finish times) RECEIVED AFTER FLIGHT FINISHED IN GESTOP ID: " & jobId & " ************") : Exit Function
  59.  
  60.  
  61.         End If
  62.         ''''
  63.  
  64.  
  65.  
  66.  
  67.    
  68.         '   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
  69.  
  70.         If fluidType = "1" Then
  71.             ' d = getdata("DEGIVRAGE", "to_char(TYPE_1_FINISH_TIME, 'YYYY-MM-DD HH24:MI:SS')", "ID = " & jobId) '' current time in the db
  72.            d = getdata3("DEGIVRAGE", "to_char(TYPE_1_FINISH_TIME, 'YYYY-MM-DD HH24:MI:SS') TYPE_1_FINISH_TIME", "ID = " & jobId)
  73.  
  74.             If Len(d) = 0 Then
  75.                 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 & ")")
  76.             End If
  77.  
  78.             If Len(d) <> 0 Then ''there already exists a time in the database, compare
  79.                endTime = gettimeUTC(endTime)
  80.                 Dim old As DateTime
  81.                 Dim nw As DateTime
  82.  
  83.                 old = DateTime.ParseExact(d.ToString, "yyyy-MM-dd HH:mm:ss", Nothing)
  84.                 nw = DateTime.ParseExact(endTime.ToString, "yyyy-MM-dd HH:mm:ss", Nothing)
  85.  
  86.                 If old < nw Then
  87.                     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 & ")")
  88.                     '       log("Second Spray -> old time: " & old.ToString & " new time: " & nw.ToString)
  89.  
  90.                 End If
  91.  
  92.  
  93.             End If
  94.  
  95.         End If
  96.  
  97.         If fluidType = "2" Then  ''type 4
  98.            d = getdata3("DEGIVRAGE", "to_char(TYPE_4_FINISH_TIME, 'YYYY-MM-DD HH24:MI:SS') TYPE_4_FINISH_TIME", "ID = " & jobId)
  99.  
  100.             If Len(d) = 0 Then
  101.                 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 & ")")
  102.             End If
  103.  
  104.             If Len(d) <> 0 Then ''there already exists a time in the database, compare
  105.                endTime = gettimeUTC(endTime)
  106.                 Dim old As DateTime
  107.                 Dim nw As DateTime
  108.  
  109.                 old = DateTime.ParseExact(d.ToString, "yyyy-MM-dd HH:mm:ss", Nothing)
  110.                 nw = DateTime.ParseExact(endTime.ToString, "yyyy-MM-dd HH:mm:ss", Nothing)
  111.  
  112.                 If old < nw Then
  113.                     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 & ")")
  114.                     '   log("Second Spray -> old time: " & old.ToString & " new time: " & nw.ToString)
  115.  
  116.                 End If
  117.  
  118.  
  119.             End If
  120.  
  121.  
  122.         End If
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.         '''
  131.  
  132.         '''termine = 1 for this mag
  133.        ''special case:  multiple sprays
  134.  
  135.         quantity += getdata("TEMPS_QTE_CAM", "QUANTITE_APP", "DEGI_ID = " & jobId & " AND CAMION_ID = '" & magid & "' AND TYDE_ID = '" & fluidType & "'")
  136.  
  137.         '''''''''''''''
  138.  
  139.         db("UPDATE CONF_VOL SET TERMINE = 1 WHERE DEGI_ID = " & jobId & " AND CAMION_ID = '" & magid & "'")
  140.         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 & "'")
  141.         db("UPDATE TEMPS_QTE_CAM SET QUANTITE_APP = '" & quantity & "' WHERE DEGI_ID = " & jobId & " AND CAMION_ID = '" & magid & "' AND TYDE_ID = '" & fluidType & "'")
  142.  
  143.         ''ac condition handler
  144.  
  145.         ''first insert the value returned from vestergaard into cond_aero_cam
  146.        '' is there a use for this????
  147.  
  148.         Dim cond
  149.         cond = getdata("COND_AERO_CAM", "DATE_HRS", "COND_AERO_ID = '" & acCondition & "'")
  150.  
  151.         If Len(cond) = 0 Then
  152.             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'))")
  153.         Else
  154.             db("UPDATE COND_AERO_CAM SET COND_AERO_ID = '" & acCondition & "' WHERE DEGI_ID = " & jobId & " AND CAMION_ID = '" & magid & "'")
  155.             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 & "'")
  156.         End If
  157.  
  158.         ''
  159.  
  160.  
  161.  
  162.         '' next test to see if employee has ac conditions rights
  163.        Dim eqpiste_id
  164.         Dim eqpiste_employee_id
  165.         Dim accondrights
  166.         Dim camid
  167.  
  168.         camid = getdata("CAMION", "ID", "NO_CAMION = " & unitNo)
  169.  
  170.         eqpiste_id = getid(camid, year, month, day, hh, mm, ss)
  171.         If eqpiste_id = 0 Then
  172.             TextBox1.Text += vbCrLf & camid & year & month & day & hh & mm & ss
  173.  
  174.             log("************* IF YOU SEE THIS, YOU GOT ISSUES  ... trouble....jobcomplete/eqpiste = 0 unitno: " & unitNo & "jobid: " & jobId & " fluid: " & fluidType)
  175.         End If
  176.  
  177.  
  178.         eqpiste_employee_id = getdata("EQ_PISTE", "PE_OPER_ID", "ID = " & eqpiste_id)
  179.  
  180.         accondrights = getdata("PERS_AEROMAG_2000", "ACC_COND_AERONEF", "ID = " & eqpiste_employee_id)
  181.  
  182.         '   MsgBox("Results: " & eqpiste_id & " " & eqpiste_employee_id & " " & accondrights)
  183.  
  184.         ''
  185.        Try
  186.             If accondrights = -1 Then ''employee does have rights to change ac cond
  187.                Dim accond
  188.                 Dim prionew
  189.                 Dim prioold
  190.                 accond = getdata("DEGIVRAGE", "COND_AERO_ID", "ID = " & jobId)
  191.                 '      If accond = Nothing Then
  192.  
  193.                 ' End If
  194.  
  195.                 prioold = getdata("COND_AERONEF", "PRIORITE", "ID = " & accond)
  196.                 prionew = getdata("COND_AERONEF", "PRIORITE", "ID = " & acCondition)
  197.  
  198.                 '  MsgBox("has access, results: ACCOND: " & accond & " OLD PRIO: " & prioold & " NEW PRIO: " & prionew)
  199.  
  200.  
  201.                 If prionew > prioold Then
  202.                     db("UPDATE DEGIVRAGE SET COND_AERO_ID = " & acCondition & " WHERE ID = " & jobId)
  203.  
  204.                 End If
  205.  
  206.  
  207.  
  208.  
  209.             End If
  210.  
  211.         Catch ex As Exception
  212.  
  213.         End Try
  214.  
  215.     End Function
Add Comment
Please, Sign In to add comment