Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Performance Issues ?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Performance Issues ?

    Hi All

    I have the following code, after a SQL select statement to populate a repeating section dialog with data from another table and view .. the code and populate works ok , however if I have more than or 20 or 30 records I see performance issues on my alpha server and if a I close the dialog and try and re-open I just get the "working" message unless I close my browser ...., on much smaller queries all appears to work as expected

    Does anybody know of a more streamlined way to populate a dialog ?


    eval("j.Invoice_number_A5INSTANCE" + alltrim(str(cnt))) = rs.Data("Invoice_number")
    eval("j.TC_Invoice_Number_A5INSTANCE" + alltrim(str(cnt))) = rs.Data("TC_Invoice_number")
    eval("j.Lead_surname_A5INSTANCE" + alltrim(str(cnt))) = rs.Data("Lead_pax_surname")
    eval("j.Date_of_Travel_A5INSTANCE" + alltrim(str(cnt))) = rs.Data("DOT")
    eval("j.Invoice_Amount_A5INSTANCE" + alltrim(str(cnt))) = str(rs.Data("Invoice_amount"),10,2)

    ' invoice_balance = rs.data("Invoice_amount") - rs.data("total_paid")

    eval("j.Amount_A5INSTANCE" + alltrim(str(cnt))) = str(rs.Data("Outstanding"),12,2)

    eval("j.Clerk_added_A5INSTANCE" + alltrim(str(cnt))) = session.cu
    eval("j.date_added_A5INSTANCE" + alltrim(str(cnt))) = date()
    eval("j.Agency_A5INSTANCE" + alltrim(str(cnt))) = session.Agency_ID

    end while

    thanks in advance

    john

    #2
    Re: Performance Issues ?

    Originally posted by canc View Post
    Hi All

    I have the following code, after a SQL select statement to populate a repeating section dialog with data from another table and view .. the code and populate works ok , however if I have more than or 20 or 30 records I see performance issues on my alpha server and if a I close the dialog and try and re-open I just get the "working" message unless I close my browser ...., on much smaller queries all appears to work as expected

    Does anybody know of a more streamlined way to populate a dialog ?


    eval("j.Invoice_number_A5INSTANCE" + alltrim(str(cnt))) = rs.Data("Invoice_number")
    eval("j.TC_Invoice_Number_A5INSTANCE" + alltrim(str(cnt))) = rs.Data("TC_Invoice_number")
    eval("j.Lead_surname_A5INSTANCE" + alltrim(str(cnt))) = rs.Data("Lead_pax_surname")
    eval("j.Date_of_Travel_A5INSTANCE" + alltrim(str(cnt))) = rs.Data("DOT")
    eval("j.Invoice_Amount_A5INSTANCE" + alltrim(str(cnt))) = str(rs.Data("Invoice_amount"),10,2)

    ' invoice_balance = rs.data("Invoice_amount") - rs.data("total_paid")

    eval("j.Amount_A5INSTANCE" + alltrim(str(cnt))) = str(rs.Data("Outstanding"),12,2)

    eval("j.Clerk_added_A5INSTANCE" + alltrim(str(cnt))) = session.cu
    eval("j.date_added_A5INSTANCE" + alltrim(str(cnt))) = date()
    eval("j.Agency_A5INSTANCE" + alltrim(str(cnt))) = session.Agency_ID

    end while

    thanks in advance

    john
    Can you return javascript to the browser instead of running eval? You can use setValue for repeating sections (http://wiki.alphasoftware.com/%7Bdia...Value%20Method).

    'Using Javascript to Set Control Values and the Row Count in a Repeating Section -- Recommended For Maximum Efficiency (Advanced users)
    '---------------------------------------------------------------------------------------------------------------------------
    'When setting the value of a large number of controls, you will improve performance if you generate the Javascript directly,
    'rather than setting properties in the e.control object (as described above) and then having Alpha Five generate the Javascript from this object.
    I roughly translated what you have above into a template that you could use to generate the javascript in the onDialogInitialize event (that's where the quote above was taken.) It's important to note that you need to define "{dialog.Object}" as something that's inserted, otherwise when you compile and output the template, {dialog.Object} is interpreted as xbasic (eg, a variable named dialog with a property Object) and fails. Read more about compileStringTemplate here: http://wiki.alphasoftware.com/~alpha...plate+Function

    ***Note: I have modified this because the old version didn't work because there were no rows allocated for the repeating section and the javascript would not do what you expect (it would just set the first row of the repeating section, or last row, if the {Row} was greater than the total rows in the repeating section***

    Code:
    ' rs is defined however you defined it earlier
    
    'Define a variable that will insert {dialog.Object} into our generated javascript
    dim dlgObj = "{dialog.Object}"
    
    'Define a template that will be used to generate JavaScript to set values
    '{ and } are used to define xbasic in the template that will be executed/replaced by local variables
    dim tmpl as c =<<%TXT%
    {dlgObj}.setValue('INVOICE_NUMBER:{Row}',{rs.Data("Invoice_number")});
    {dlgObj}.setValue('TC_INVOICE_NUMBER:{Row}',{rs.Data("TC_Invoice_number")});
    {dlgObj}.setValue('LEAD_SURNAME:{Row}','{rs.Data("Lead_pax_surname")}');
    {dlgObj}.setValue('DATE_OF_TRAVEL:{Row}',{rs.Data("DOT")});
    {dlgObj}.setValue('INVOICE_AMOUNT:{Row}',{str(rs.Data("Invoice_amount"),10,2)});
    {dlgObj}.setValue('AMOUNT:{Row}','{str(rs.Data("Outstanding"),12,2)}');
    {dlgObj}.setValue('CLERK_ADDED:{Row}','{session.cu}');
    {dlgObj}.setValue('DATE_ADDED:{Row}',{date()});
    {dlgObj}.setValue('AGENCY:{Row}',{session.Agency_ID});
    %TXT%
    
    'Create the template for use in our loop!
    dim setVal as p
    setVal =  CompileStringTemplate(tmpl)
    
    
    dim js as c =<<%js%
    //This will initialize the repeating section with enough rows so that our 
    //setValue function calls we add to js later will work:
    var setFocusToFirst = true;
    var nullOutExistingData = true;
    var repeatingSectionId = 'CONTAINER_1'; //Replace CONTAINER_1 with the name of your repeating section
    
    //Note: We will define totalRows later - when we have a record count - and prepend it to 'js'
    {dialog.object}._setRepeatingSectionRowCount(repeatingSectionId, totalRows, setFocusToFirst,nullOutExistingData);
    %js%
    
    dim cnt as n = 1
    while (your while criteria)
        ' Whatever else you're doing in your while loop here
        ' cnt is defined somewhere, I assume...
    
        dim Row as n = cnt 
        'Add javascript to set all those values for us for this Row
        *concat(js, setVal.output())
    
        ' The rest of whatever you do
        cnt = cnt + 1
    end while
    
    'Total rows would be cnt - 1 because on the last time through the while, cnt will be incremented for the NEXT iteration - which doesn't happen
    dim totalRowsJs as c = "var totalRows = " + (cnt-1) + ";"
    
    'Add the definition for totalRows to js so our repeating section can allocate the appropriate number of records.
    'You want to add totalRowsJs before the rest of the javascript - because we define the number of 
    'repeating section records BEFORE we add all the data to the repeating section:
    js = totalRowsJs + js
    
    e.javascript = js
    This code may or may not execute copy-paste. You will have to debug any errors in the above... BUT, the point is, Alpha states that generating the javascript yourself will be faster. So, it's worth trying out.
    Last edited by TheSmitchell; 11-15-2013, 04:58 PM.
    Alpha Anywhere latest pre-release

    Comment


      #3
      Re: Performance Issues ?

      Hi thanks very much for your help, just a quick question thou..

      When I try and run the code I get

      ReferenceError: rs is not defined

      And can't quite work out why ..., code is below any advice greatly appreciated


      function populate_container as c (e as p)

      dim cn as SQL::Connection

      connection = session.db_connection
      cn.open(connection)

      if cn.open(connection) then

      dim dlgObj as c = "{dialog.Object}"

      dim js as c = ""

      dim args as SQL::Arguments

      dim cnt as n = 0

      dim sqlCommand as c = <<%sql%
      SELECT Invoice_number, tc_invoice_number,Surname,date_of_travel,Amount,
      COALESCE(Amount,0)- coalesce(payment_allocated,0)- coalesce(paid_direct, 0) AS Outstanding
      FROM Sales_Ledger
      where account_number = :Account_number
      %sql%

      args.add("Account_number",e.datasubmitted.Account)

      if cn.Execute(sqlCommand,args) then

      dim invoice_balance as n

      dim rs as SQL::ResultSet

      rs = cn.ResultSet

      dim tmpl as c =<<%longstring%
      {dlgObj}.setValue('INVOICE_NUMBER:{ROW}',rs.Data("Invoice_number"));
      %longstring%

      'Create the template for use in our loop!
      dim setVal as p
      setVal = CompileStringTemplate(tmpl)


      while rs.NextRow()
      ' cnt = cnt + 1

      dim Row as n = cnt

      Row = cnt
      ' 'Add javascript to set all those values for us for this Row

      *concat(js, setVal.output())

      ' populate_container = "alert('Support error: " + js_escape(js) + "');"
      cnt = cnt + 1
      end while
      else
      populate_container = "alert('Support error: " + js_escape(cn.CallResult.Text) + "');"

      end if
      end if

      populate_container = populate_container + JS


      end function

      Comment


        #4
        Re: Performance Issues ?

        Originally posted by canc View Post
        Hi thanks very much for your help, just a quick question thou..

        When I try and run the code I get

        ReferenceError: rs is not defined

        And can't quite work out why ..., code is below any advice greatly appreciated

        Code:
        function populate_container as c (e as p)
            dim cn as SQL::Connection
            connection = session.db_connection
            cn.open(connection)
        
            if cn.open(connection) then
                dim dlgObj as c = "{dialog.Object}"
                dim js as c = ""
                dim args as SQL::Arguments
                dim cnt as n = 0
            
                dim sqlCommand as c = <<%sql%
        SELECT Invoice_number, tc_invoice_number,Surname,date_of_travel,Amount, 
        COALESCE(Amount,0) - COALESCE(payment_allocated,0) - COALESCE(paid_direct, 0) AS Outstanding  
        FROM Sales_Ledger 
        WHERE account_number = :Account_number 
        %sql%
                          
                args.add("Account_number",e.datasubmitted.Account)
         
                if cn.Execute(sqlCommand,args) then	
                    dim invoice_balance as n		
                    dim rs as SQL::ResultSet
                    rs = cn.ResultSet
        		
                    dim tmpl as c =<<%longstring%
        {dlgObj}.setValue('INVOICE_NUMBER:{ROW}',[B][COLOR="#FF0000"]{rs.Data("Invoice_number")}[/COLOR][/B]);
        %longstring%
        
                    'Create the template for use in our loop!
                    dim setVal as p
                    setVal =  CompileStringTemplate(tmpl)
        
                    while rs.NextRow()
                        'cnt = cnt + 1
                        dim Row as n = cnt
        
                        Row = cnt
                        'Add javascript to set all those values for us for this Row
                        *concat(js, setVal.output())
        
                        'populate_container = "alert('Support error: " + js_escape(js) + "');"
                        cnt = cnt + 1
                    end while
                else
                    populate_container = "alert('Support error: " + js_escape(cn.CallResult.Text) + "');"
                end if
            end if
        
            populate_container = populate_container + JS
        end function
        You're missing curly brackets in your tmpl definition around rs.Data("Invoice_Number").

        ---
        Sarah
        Alpha Anywhere latest pre-release

        Comment


          #5
          Re: Performance Issues ?

          Hi Sarah

          thanks for replying, I get the following using curly brackets
          13:00:49.315 POST http://travelcloudsystem.co.uk:84/__a5RunDialog.a5w [HTTP/1.1 200 OK 501ms]
          13:00:49.770 SyntaxError: syntax error

          thanks in advance

          john

          Comment


            #6
            Re: Performance Issues ?

            Originally posted by canc View Post
            Hi Sarah

            thanks for replying, I get the following using curly brackets
            13:00:49.315 POST http://travelcloudsystem.co.uk:84/__a5RunDialog.a5w [HTTP/1.1 200 OK 501ms]
            13:00:49.770 SyntaxError: syntax error

            thanks in advance

            john
            That's a pretty useless error message. Put a debug(1) at the top of your code and step through it in working preview. That should give you a better idea of what's going on/wrong.
            Alpha Anywhere latest pre-release

            Comment

            Working...
            X