Home Server

Access Values in AutoSearchField

edited May 2004 in Server
I'm looking for a way to log each runned report, with its selected
values/parameters.

This is my routine that i run in the beforepublish on the Server Side.


The report works fine, with the selected values in the GetAutosearch-
Values-Form. But in my log-procedure i'm still getting the defaults
entered at design-time.

Is there another event that i should use or what ????





if (aEventParams.Report is TppReport) then

begin

lReport := TppReport(aEventParams.Report);

lReport.Parameters.Add(aEventParams.SessionParameters);

// Log It

Params := '';

for iLoop := 0 to aEventParams.SessionParameters.Count - 1 do

Params := Params + 'SP:' + aEventParams.SessionParameters.
ItemsByIndex[iLoop].Name + '=' + aEventParams.SessionParameters.
ItemsByIndex[iLoop].AsString + ' ';

for iLoop := 0 to aEventParams.ReportParameters.Count - 1 do

Params := Params + 'RP:' + aEventParams.ReportParameters.
ItemsByIndex[iLoop].Name + '=' + aEventParams.ReportParameters.
ItemsByIndex[iLoop].AsString + ' ';

for iLoop := 0 to lReport.AutoSearchFieldCount - 1 do

begin

case VarType(lReport.AutoSearchFields[iLoop].Value) of

varDate : Params := Params + 'AS:' + lReport.
AutoSearchFields[iLoop].FieldName + '=' + FormatDateTime('dd/mm/yyyy',
lReport.AutoSearchFields[iLoop].Value) + ' ';

varSmallInt,

varShortInt,

varByte,

varWord,

varInteger : Params := Params + 'AS:' + lReport.
AutoSearchFields[iLoop].FieldName + '=' + IntToStr(lReport.
AutoSearchFields[iLoop].Value) + ' ';

varLongWord,

varInt64,

varDouble : Params := Params + 'AS:' + lReport.
AutoSearchFields[iLoop].FieldName + '=' + FloatToStr(lReport.
AutoSearchFields[iLoop].Value) + ' ';

varOleStr,

varString : Params := Params + 'AS:' + lReport.
AutoSearchFields[iLoop].FieldName + '=' + lReport.
AutoSearchFields[iLoop].Value + ' ';

end;

end;

qryInsert_Logging.Parameters.ParamByName('xUser').Value :=
aEventParams.SessionParameters['AccountName'].Value;

qryInsert_Logging.Parameters.ParamByName('xReport').Value :=
StringReplace(aEventParams.ReportName, ' ', '', [rfReplaceAll]);

qryInsert_Logging.Parameters.ParamByName('xComment').Value :=
Params;

qryInsert_logging.ExecSQL;

LogIt('RbSrv', 'Params', Params)

end;

Comments

  • edited May 2004

    I researched this and the ReportVolume.BeforePublishReport event occurs too
    early. Try attaching an event-handler to the
    Report.OnGetAutoSearchFieldValues event. That is the first event to fire
    after the AutoSearchField values have been received from the client.

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


    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited May 2004
    Nard,

    All my reports have rap code, i prefer not to use hardcode-delpji.
    I'm even modifying 1 external datasource from out of this event in
    rap. Works fine.

    I suppose this means i will have to create a passtrough function to
    get these values registered, or would there be another way to access
    the database (for write) in rap ??



    4/05/2004 21:51:26

  • edited May 2004
    Your example code showed the user of aEventParams, so I assumed that you are
    using the ReportVolume event.

    The Report.OnGetAutoSearchValues event is available to RAP. You are
    correct - to access the database will require one or more custom
    pass-through functions.


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

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited May 2004
    Nard,

    Would there be a way to access the session settings from the report
    in RAP-Passtrough.

    My problem is that i want to log each started report, some of them
    come by a webtier, other by regular clients.

    I was logging in the before publish as already mentioned but that's
    to soon. I need to log the report-autosearch values but also the
    session-parameters, they containt the launching-user'.

    How can i access session parameters from the report.

    Based on the tppReport, because as far as i know that the only thing
    i could pass from the report to the passthrough function.



    Kind Regards
  • edited May 2004

    In the ReportVolume.BeforePublishReport event transfer the SessionParameters
    to the Report.Parameters[] array. The Server Custom Parameters demo shows
    how to do this...



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


    Best regards,

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