This is a complete and working solution to scheduling a Webi with prompts for Business Objects XI R2 SDK.
SessionMgr oSessionMgr = new SessionMgr();
EnterpriseSession oEnterpriseSession = oSessionMgr.Logon(“user”, “pass”, “cmsname”, “secEnterprise”);
EnterpriseService oEnterpriseService = oEnterpriseSession.GetService(“InfoStore”);
InfoStore oInfoStore = new InfoStore(oEnterpriseService);
Smtp smtp = (Smtp) oInfoStore.Query(“Select SI_DEST_SCHEDULEOPTIONS, SI_PROGID From CI_SYSTEMOBJECTS Where SI_PARENTID=29 And SI_NAME=’CrystalEnterprise.Smtp’”)[1];
int iMinuteNumber = 1;
int iLogonNumber = -1;
string strToken = oEnterpriseSession.LogonTokenMgr.CreateWCAToken(“”,iMinuteNumber, iLogonNumber);
ReportEngines repEngines = new ReportEngines(strToken);
IReportEngine oReportEngine = repEngines.getService(ReportEngineType.WI_ReportEngine);
InfoObjects ios = oInfoStore.Query(String.Format(“Select * From CI_INFOOBJECTS Where SI_NAME = ‘{0}’ and SI_INSTANCE = ‘false’”, name));
if (io is Webi){
{
Webi webi = (Webi)io;
Webi webi_nu = new Webi(webi.PluginInterface);
webi_nu.SchedulingInfo.RightNow = true;
DestinationOptions destinationOptions = smtp.ScheduleOptions;
SmtpOptions smtpOptions = new SmtpOptions(destinationOptions);
//Setting of SMTP options subject, CC, TO, FROM, etc…
webi_nu.WebiFormatOptions.Format = CeWebiFormat.ceWebiFormatPDF;
smtpOptions.Attachments.Add(“application/pdf”, “%SI_NAME% %SI_STARTTIME%.%EXT%”);
IDocumentInstance ins = oReportEngine.OpenDocument(webi.ID);
ins.Refresh();
ReportParameterUtility.PopulateWebiPrompts(ins.GetPrompts(), webi_nu);
int idx = 0;
foreach (WebiPrompt o in webi_nu.Prompts)
{
o.Values.Clear();
foreach (string c in PARAMS[idx])
{
o.Values.Add(c);
}
idx++;
}
webi_nu.SchedulingInfo.Destination.SetFromPlugin(smtp);
oInfoStore.Schedule(ios);
}
Enjoy!

Loading ...