Home Server
New Blog Posts: Merging Reports - Part 1 and Part 2

WebTier.ProcessWebRequest crash

edited March 2008 in Server
Hello,

When trying a report with several autosearch fields I sometimes get a
crash in ProcessWebRequest.
It seems that the program simply "dies".
I checked the LogFiles directory and no files are generated.
There are four autosearch fields in this report.
The crash happens when I fill autosearch fields with a particular set of
values, but with other similar set it works.
How can I debug ProcessWebRequest ?

D7 with RB Server 903
I am using a TrsWebTier encapsulated inside a Com server used from an
ASP.net client

Thanks in advance for any tips/ideas
Bye
Nicola

Comments

  • edited March 2008
    I tried with your isapi dll client and it works...
    So the problem is in my code...
    Could the problem be the fact that I don't check the cache before trying
    to initialize the autosearch (as you do in one example)?
    I'll try in that way ...


  • edited March 2008
    I started from your WebTierComserver example.
    I added a public method for getting a list of the autosearch fields of a
    given report.
    The asp.net client reads the list and build a form
    to fill them in.
    Once the as are filled in the form there is a
    print button which resembles a json string with
    all the as and send it back to another public method
    of WebTierComserver for print.
    In this method, after parsing the string of as values,
    I call processwebrequest to generate the report.
    It seems that the problem is in the way I fill autosearch fields.
    The string sent by the asp.net client form is parsed in an array
    with structure:
    table name - field name - value

    I iterate on every autosearch looking for the combination table name-
    field name and, when I find it, I set the SearchExpression.

    The code is like this:

    if WebTier.RequiresAutoSearchParameters(RsWebRequestCustom) then
    if WebTier.GetAutoSearchParameters(RsWebRequestCustom) then
    FillASParams(jsASParams,sWebRequestCustom.AutoSearchParameters);

    In FillAsParams I do something like this (
    ppAsParams is the WebRequest.AutoSearchParameters property and
    sValue is the value sent by the client for AS
    ASName is the AS (autosearch) FieldName
    TableName is the TableName)

    for g := 0 to ppASParams.Count-1 do
    begin
    // for each group loop the as fields
    for f := 0 to ppASParams[g].FieldCount-1 do
    begin
    if (ppAsParams[g].Fields[f].TableName = TableName) and
    (ppAsParams[g].Fields[f].FieldName = ASName) then
    begin
    if sValue <> '' then
    begin
    ppAsParams[g].Fields[f].SearchExpression := sValue;
    end
    else
    begin
    ppAsParams[g].Fields[f].ShowAllValues := true;
    ppAsParams[g].Fields[f].SearchExpression := '';
    end;

    end;
    end;

    I really don't understand where the problem is.
    The unique example (at least the unique I am aware of) of
    a webtier with custom parameters has only one parameter
    and simply set it with:

    if (aWebRequest.AutoSearchParameters.Count > 0) then
    begin
    aWebRequest.AutoSearchParameters[0].Fields[0].SearchExpression :=
    lsCompanySearchExpression;
    aWebRequest.AutoSearchParameters[0].Fields[0].ShowAllValues :=
    lbShowAllValues;
    end;

    In my case I have a variable, unknown at runtime, number of as parameters.

    Any help will be very appreciated .....
    as always thanks ...
    Bye
    Nicola

  • edited March 2008

    What are the datatypes of the autosearch parameters?

    If you trace your custom code, what are the values that get assigned?

    Perhaps, try an incremental approach. Start with one AutoSearchParameter and
    test. Then add a second one and test, etc.



    --
    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited March 2008
    Nard Moseley (Digital Metaphors) wrote:
    The first AS (which gives me the problem) is an integer.
    Then I have a string and a date which work.
    It is quite strange. The value I enter is simply ignored
    but if I enter the value 10 I have the crash
    From 1 to 9 the value is simply ignored (i traced the sql queries and I
    saw that there is no where clause)
    Note that I am sure that my server and the report are ok because with
    your generic web tier client this selection works fine.

    SearchExpression is a string isn't it ? So I enter all values as strings
  • edited March 2008
    The problem seems only on that integer parameter but I set all
    auto search fields the same way ...
    Do I need to treat as differently according to the data type ?
    It doesn't seem so from all examples I saw (mostly win32) ..... ? ??


  • edited March 2008
    In your example there is also this call:

    aWebRequest.ContentParameters['Refresh'].AsBoolean := True;

    What does it do ?
    Do I need to refresh something after setting the as (=autosearch) values ?

  • edited March 2008
    Perhaps may you tell me which are the conditions that rbserver (or
    rbwebtier) check
    to decide to *not* insert the where clause (=use the autosearch
    value provided) in the sql ?

  • edited March 2008
    Yes, SearchExpression is a string. I can think of no reason why string and
    date work and integer does not. I was thinking that date might be given you
    an issue (because of formats).


    --
    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited March 2008

    That tells the WebTier to ask the server to regenerate the report, rather
    than use any cached pages. The WebTier can cache pages for performance.
    --
    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com


    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited March 2008

    When AutoSearch ShowAllValues is True, then Where condition is generated.
    Therefore, if all autosearch parameters have ShowAllValues set to True, then
    no SQL Where clause would be generated.


    --
    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited March 2008
    Now forcing ShowAllValues := false for all AS fields with a not null
    value I got the where condition, thanks.
    But I still have the problem and this error still puzzles me.
    Here is my actual state of the art about this:

    1. I am sure that the exception is not in my rb server code. After the
    crash I launched a query to the same report with the same offending
    AS value and it works as expected. So the crash is in ProcessWebRequest.
    Is there anyway to debug this ? For example to debug (poor man version)
    server code I use printing messages in the system event window.
    Is there anything similar ?

    2. If I use the offending AS *along with others* it works.
    The error happens when it is used alone (and with some specific values)
    only. See:

    This is the sql ran by RB Server with all AS filled:

    SELECT V_TABLE_7.F9, V_TABLE_7.F2, V_TABLE_7.F1,
    V_TABLE_7.F3, V_TABLE_7.F10
    FROM V_TABLE_7 V_TABLE_7
    WHERE ( V_TABLE_7.F9 = 1 )
    AND ( V_TABLE_7.F1 BETWEEN 'riga a' AND 'riga z' )
    AND ( V_TABLE_7.F2 BETWEEN TO_DATE('2004/01/01','YYYY/MM/DD')
    AND TO_DATE('2004/12/31','YYYY/MM/DD') )

    this sql works perfectly. The critical as is the F9 field.
    The critical (but not unique I found at least another) value is 10 BUT

    if I use 10 along with other parameters it still works and I get:

    SELECT V_TABLE_7.F9, V_TABLE_7.F2, V_TABLE_7.F1,
    V_TABLE_7.F3, V_TABLE_7.F10
    FROM V_TABLE_7 V_TABLE_7
    WHERE ( V_TABLE_7.F9 = 10 )
    AND ( V_TABLE_7.F1 BETWEEN 'riga a' AND 'riga z' )
    AND ( V_TABLE_7.F2 BETWEEN TO_DATE('2004/01/01','YYYY/MM/DD')
    AND TO_DATE('2004/12/31','YYYY/MM/DD') )

    The dump print of the AS Structure corresponding to the above SQL is this:

    f[0] V_TABLE_7 F9 1 false
    f[1] V_TABLE_7 F1 "riga a","riga z" false
    f[2] V_TABLE_7 F2 01/01/2004,31/12/2004 false
    f[3] V_TABLE_7 F10 true

    The fourth column is the as value. The fifth is the ShowAllValues. I
    forced the value to true if the client has not specified a value
    for that as field.

    When filling only the F9 as field with value 10 I have this structure
    from my WebComTier:

    f[0] V_TABLE_7 F9 10 false
    f[1] V_TABLE_7 F1 true
    f[2] V_TABLE_7 F2 true
    f[3] V_TABLE_7 F10 true


    This causes the crash. It didn't reach the rb server so I have no sql.
    There are sql for dictionary tables but it fails to reach the above
    query to actual data.

    I have a print out after the call to ProcessWebRequest which is never
    reached:

    OutputDebugString('TRBWebTier.PrintReport: prima di ProcessWebRequest');
    sRBOutput :=
    aWebTierModule.WebTier.ProcessWebRequest(RsWebRequestCustom);
    OutputDebugString('TRBWebTier.PrintReport: dopo ProcessWebRequest');


    So I am sure the crash in in trsWebTier.ProcessWebRequest.
    After that I don't need to restart rb server. With another client and
    the same parameter 10 it works .....

    The crash involves also the visual studio internal web server
    I have to restart it (I am using VS2005 with the internal file system
    based web server).

    Ever seen something similar ?
    Many thanks
    Bye
    Nicola



  • edited March 2008
    I *probably* found the problem in my code. Not sure but ...
    Many thanks sorry for the mail overflooding
    One last question:
    In my solution I use two sessions id (one the first time to get and send
    to the client the as fields list, and one when the client wants to
    print). I call each time :
    rsWebSessionManager.gWebSessionManager.GetSessionForRequest

    Would it be better to send the session id on the first call
    and have the client reuse it on the next call ?

    Thanks
    Bye
    NIcola
  • edited March 2008

    The WebTier is designed to assign a SessionID for managing each client. A
    client session can consist of previewing many reports. The WebTier is
    optimized to handle common scenarios, such as a user previews report A, then
    report B, then returns to report A.

    Therefore I would try to use the same session id for client preview and
    print.


    --
    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com



    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
This discussion has been closed.