cancel
Showing results for 
Search instead for 
Did you mean: 

report with a prompt it doesn't refresh using .net sdk

Former Member
0 Kudos

Hi, guys.

I've wrote a .net console application and it does refreshing and saving report, so I don't need manually to refresh and save report each time during deployment.

But the application works only for reports w/o prompts, does refresh and save programatically, but for report with a prompt it doesn't work and doesn't throw error.

Could you, pls, tell me what if wrong and what I'm missing in provided code below:

using System;

using System.Collections;

using System.Threading;

using System.Configuration;

using BusinessObjects.ReportEngine;

using CrystalDecisions.Enterprise;

SessionMgr sessionMgr = new SessionMgr();

EnterpriseSession enterpriseSession;

enterpriseSession = sessionMgr.Logon(admin, psw, server,

"secEnterprise");

EnterpriseService enterpriseService = enterpriseSession.GetService("InfoStore");

InfoStore ceInfoStore = new InfoStore(enterpriseService);

string strToken = enterpriseSession.LogonTokenMgr.CreateWCAToken("", 1, -1);

// Create the report engine object

ReportEngines webiReportEngines = new ReportEngines(strToken);

IReportEngine webiReportEngine = webiReportEngines.getService(ReportEngineType.WI_ReportEngine);

//get the list of reports listOfRptIDs to refresh

......

//get the list of reports to refresh

InfoObjects reportObjects = ceInfoStore.Query("Select * From "

+ " CI_INFOOBJECTS Where SI_PROGID='CrystalEnterprise.Webi' "

+ " AND SI_OWNER = 'Administrator'"

+ " AND SI_ID IN " + listOfRptIDs);

Console.WriteLine("Phase5: start refreshing the reports ");

for (int i = 0; i < reportObjects.Count; i++)

{

InfoObject report = (InfoObject) reportObjects[i+1];

Console.WriteLine(".... processing report='" + report.ID

+ "'>" + report.Title);

// Open the webi report using the report engine

IDocumentInstance webiDoc = webiReportEngine.OpenDocument(report.ID);

webiDoc.Refresh();

webiDoc.Save();

}

webiReportEngine.Close();

Accepted Solutions (1)

Accepted Solutions (1)

ted_ueda
Employee
Employee
0 Kudos

You have to set the prompt values for the document to complete.

Refresh() you can interpret to mean "reset this document". In a normal viewing workflow, you'd Refresh(), then SetPrompts(), then GetView().

Sincerely,

Ted Ueda

Answers (1)

Answers (1)

Former Member
0 Kudos

Ted, many thanks for replying for my request.

Yesterday night, I was playing with the code and I've realized that no setting portion, so I've modified the following code:

// Open the webi report using the report engine

IDocumentInstance webiDoc = webiReportEngine.OpenDocument(report.ID);

IPrompts prompts = webiDoc.GetPrompts();

foreach(IPrompt prompt in prompts)

{

string[] values = prompt.GetPreviousValues();

prompt.EnterValues(values);

string[] values1 = prompt.GetCurrentValues();

}

webiDoc.SetPrompts();

webiDoc.Refresh();

webiDoc.Save();

and it doesn't work. Then I've read your post again and noticed your comments about workflow. then I've change the order as you suggested and it works!!!!!!!!!!!

webiDoc.Refresh();

webiDoc.SetPrompts(); ////!!!!!!!!!!

webiDoc.Save();

Ted, thanks a lot, i'm truly impressed my your knowledge and experience. Very much appreciate your help.

Michael