Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more: , +
I'm planning Crystal reports from my application to Crystal Reports Server in the email queue. I want to sent the reports as pdf. Sending emails works fine. In the CMS (Crystal Reports Server) I can see the history and scheduled reports with their parameters.

I would like to retrieve the parameters and used email addresses in my application for completed reports (history) and scheduled reports.

If I retrieve the history, the infoObjects that are scheduled as "Report", but when I retrieve them from the history it appears they are not object type Report but type Pdf:

string query = "Select SI_ID, SI_NAME, SI_OWNER, SI_DESCRIPTION,  SI_STATUS, SI_STATUSINFO " +
                ",SI_RECURRING, SI_SCHEDULEINFO.SI_OUTCOME " +
                "FROM CI_INFOOBJECTS " +
                "WHERE SI_KIND='CrystalReport' AND SI_RECURRING=0";


dt.Columns.Add("Naam");
dt.Columns.Add("Weetniet");
dt.Columns.Add("Eigenaar");
dt.Columns.Add("Status");
dt.Columns.Add("");
dt.Columns.Add("");




InfoObjects infoObjects = infoStore.Query(query);
foreach (InfoObject infoObject in infoObjects)
{
    try
    {
        Report report = (Report)infoObject;
        dt.Rows.Add(
          infoObject.Title,
          infoObject.Properties["SI_NAME"],
          infoObject.Properties["SI_OWNER"],
          infoObject.SchedulingInfo.Status,
          (CeScheduleType)infoObject.SchedulingInfo.Type,

          infoObject.Properties["SI_STATUSINFO"]
          );
    }
    catch (Exception e)
    {
        Alert.Show("Fout in opvragen geschiedenis\n" + e);
    }
}

throws the exception:
Unable to cast object of type 'CrystalDecisions.Enterprise.Desktop.Pdf' to type 'CrystalDecisions.Enterprise.Desktop.Report'.

For the Pdf Object I cannot find the properties to find the email addresses and parameters. Since I can see these in the CMS, they must be there somewhere...

Does anyone know how to do this?
Posted
Updated 19-May-11 21:57pm
v2

1 solution

Found it myself. You need to get the properties of the parent report, which is the original crystal report.
So first select the parent SI_ID:
C#
getParameters(infoObject.ParentID.ToString());


Here is the procedure to get the params:
C#
private string getParameters(string objectID)
{
    string query = "Select * FROM CI_INFOOBJECTS WHERE SI_ID = " + objectID;
    string result = "";
    InfoObjects infoObjects = infoStore.Query(query);

    Report report = (Report)infoObjects[1];
    ReportParameters reportParameters = report.ReportParameters;
    for (int i = 1; i <= reportParameters.Count; i++)
    {
        ReportParameter reportParameter = reportParameters[i];
        result += reportParameter.ValueDisplayString;
    }

    return result;
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900