More on Http Utilities 2

CharlesIPTI

Active Member
Licensed User
Longtime User
http://www.b4x.com/forum/basic4andr...ynchronous-asynchronous-just-plain-krazy.html

That helped a little for a specific scenario.. but I have another situation where I am making several repeated calls to Http Util2.

These several calls operate on the contents of a list one element at a time.

But two or three manipulations are done to each object. -- THATS Three seperate Calls to Three Separate HttpUtil2 methods per object in sequence
And again these must be done in order..

example I have a list of Wiggles, each Wiggle must be painted, stamped and renumbered with a special tag.

I have to process each Wiggle from my lstWiggles and send each one through THREE separate Calls to HttpUtils2..

Of course as it is presently structured the job_done isn't finished for the paint method callwhen its already trying to do the stamped and renumbered method calls to HttpUtils2..etc etc..

Please advise


thank you .. Heres my failed attempts in code as I have tried the Job done as well as a sub to house all the calls as they are called from the Activity_Create all to no avail Thank you


B4X:
' sub AssimililateOrders  is called conditionally from Activity_create
'when I need to harvest orders based upon a scan from an handheld scanner---   
' next loop when bLocationScanValidated = true
If bMapLocOrderListCreated = False Then   
' Boolean Toggle True When iRemainderBins decremented to 0         
AssimililateOrders   'GetNext Order & Assign Order to Cart --> into recall Activity_Create(False)
End If
Else
bMapLocOrderListCreated = True




Sub AssimililateOrders()
 
    intCurrentBinNo = lstOrders.Size

'    If intCurrentBinNo < MAX_BIN_COUNT Then
      
      
      If  lstOrders.Size  > 0 Then
               If iRemainderBins > 0 Then

                                    DoEvents
                              GetNextOrder  'cycle this until  MAX_BIN_COUNT         
                                    DoEvents
                              CalculateNextAvailablePosition                      
                                    DoEvents
                              AssignOrderToCart
                                    DoEvents 
                     
             End If
      End If

End Sub


B4X:
' section of job done in select case statement 


#Region------------{ GetNextOrder  }--------------------

                  Case "GetNextOrder"         
                  
                  iStream = Job.GetInputStream()      'PostGetNextOrder
                  GetNextOrderParser.Initialize         
                              
                  If iStream.BytesAvailable > 0 Then                                       
                        GetNextOrderParser.Parse(iStream, "GetNextOrderParser")            '                                                                                                                                                               
                  Else   
                        Msgbox("Http GetNextOrderParser ERROR: " & CRLF &  LastException.Message,  "GetNextOrderParser")                                          
                  End If                                                
                                          
                     DoEvents
                     'DebugInfo                                                               
'                      CalculateNextAvailablePosition                      
'                     AssignOrderToCart
'                                                
         'Activity_Create(False)   'Multi Process GetNext Then AddToCart no activity_Create here

#End Region


Specific example Addendum a getNextorder requested from the webService
returns to me an orderId back but the Web Service also creates an entry in a SQL table with the orderID it provided me .... unless I can perform my operations on this returned data in sequence the next call to the web service returns the SAME orderID and it of course writes a duplicate to the table with the same orderID...

HttpUtil1 did not behave like this
 

thedesolatesoul

Expert
Licensed User
Longtime User
Of course as it is presently structured the job_done isn't finished for the paint method callwhen its already trying to do the stamped and renumbered method calls to HttpUtils2..etc etc..
Why do you start the next job before the first is finished?

You should use a counter or a statemachine to queue 3 tasks one after the other.

Lets say
Job id:0 Paint
Job id:1 Stamp
Job id:3 Renumber

Total jobs = 3

Normally you should just start DoPaint at the initial trigger.
In job done, make a sub like DoNextTask
In DoNextTask
B4X:
if Jobid=0 then 'We have completed Paint
  Jobid = 1
   DoPaint
elsif Jobid=1 then 'We have completed Stamp
   Jobid = 2
   DoRenumber
elsif Jobid=2 then 'We have completed Renumber
   Jobid = 0
   StartANewTask 'if needed or do nothing
end if
 
Upvote 0

CharlesIPTI

Active Member
Licensed User
Longtime User
But !!!!!

In Job Done -- After the Sax Parser Call ?!?!?!
Or before ..

If After the Sax Parser Call ----whats to stop it from activating this code portion while the Sax Parser is still doing its Job?

AND more importantly before the SaxParser is Done with its job ..


:( Thank you so much for jumping on this ... I'm trying NOT to have to revert to using HTTP Util1 in B4a 2.02

I was going to try Job.Complete in the Job_Done Select Case against JobName, but Complete needs a parameter (ID)

Job.Complete(Id as Int) As String

Can you override the CompleteJob in httputil2
Sub CompleteJob hey wait thats what the Job_Done is already doing Hmmmmm Grrrrrr
 
Last edited:
Upvote 0

thedesolatesoul

Expert
Licensed User
Longtime User
Sorry I didnt notice the Sax parser.

Do you need the data your parse from the Sax parser before the next call?

I think it is better to wait till the Sax parser finishes its job.
While I dont know how your xml looks like it will be something like this in the EndElement sub.

B4X:
Sub Parser_EndElement (Uri As String, Name As String, Text As StringBuilder)
                  If Name = "item" Then
                   'End of Processing of Element
                   DoStartNextTask
                End If    
End sub

You just need to identify the entry and exit points of one job, and then make a loop over that.
 
Upvote 0
Top