on 10-15-2008 11:48 PM
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();
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
98 | |
11 | |
11 | |
10 | |
10 | |
8 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.