Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: How to automate publishing of CR to BOE XI? Post Reply Post New Topic
Author Message
aquariansp
Newbie
Newbie


Joined: 22 Feb 2007
Online Status: Offline
Posts: 14
Quote aquariansp Replybullet Topic: How to automate publishing of CR to BOE XI?
    Posted: 26 May 2007 at 4:16am

Hi

Client has an application which uses Crystal Reports 8.5 .
The application runs and generates around 40 to 50 reports everyday.

All these instances get stored in a folder on the hard disk.

Issue: Need to publich all these reports onto BOE XI R2. Need to automate the whole process of opening these reports in Crystal Reports XI and saving them to a folder on the BOE XI R2.

How do we do this?

Your quick solutions and responses would be highly appreciated

thanks in advance

~aquariansp

aquariansp
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 28 May 2007 at 12:47pm
So, you're looking to publish the "instances" that the client application generates, is that correct?
 
Unless the instances themselves are created in BOE (i.e., run from a report template that's already been published in BOE) the reports will NOT show up as part of the standard BOE structure  - that is, navigate to folder, click on Report Title to view latest instance or click on History and then on the instance that you want to see.
 
Having said that, there are a couple of ways that you can do this.  For both methods, I would set up a folder for each report that has the report title.  I would then publish the file with the Title set to the report name plus the date it was run.
 
1.  Publish the report with data.  The trick to doing this is that BOE still has to be able to log in to the database that the report was run on.  It doesn't refresh the data, but for some reason it still has to be able to log on.  (I know this one from experience!)  The report will then be viewed through whichever Crystal viewer the users have set up in their Preferences.
 
2.  Export the report to PDF or Excel and publish that file.  BOE will then know how to display the file.  This code is easier than for step 1, but the users won't be able to export the report to a different format.
 
I have example code for both methods.  Let me know which one you're interested in and I'll post it.
 
-Dell
IP IP Logged
aquariansp
Newbie
Newbie


Joined: 22 Feb 2007
Online Status: Offline
Posts: 14
Quote aquariansp Replybullet Posted: 28 May 2007 at 10:10pm
hi Dell,
thanks for the reply.
 
i think i need to clearly explain my requirement.
 
client has crystal reports in 8.5 version being generated to a folder.
 
i just need to publish them to Business Objects Enterprise XI R2.
 
i can do this by using the publishing wizard..but the issue is the client wants an automation script which should run daily at a specified time,
take each report, open it in Crystal Reports XI and publish it to the Enterprise.
 
I have an idea that this can be done through SDK, but never did SDK programming.
 
Please help.
 
thanks in advance
 
~aquariansp
aquariansp
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 29 May 2007 at 7:15am
So you're trying to publish the report "templates" that will actually be run in BO XI?  Or are you trying to publish the report "instances" that have data included in them?  If it's the templates, are they always new reports or will some of them be updates of existing reports?  How do you know which folder to publish them to?
 
Here, again, I have sample code, but I want to make sure that I understand what you're trying to do so that I can get the correct code to you.  Also, this won't be a "script" it will be an executable program that they'll be able to schedule through the Windows Scheduler or run manually.
 
-Dell
IP IP Logged
aquariansp
Newbie
Newbie


Joined: 22 Feb 2007
Online Status: Offline
Posts: 14
Quote aquariansp Replybullet Posted: 29 May 2007 at 10:56pm
We are trying to publish reports with data included in them. we just need to publish them to some new folder on the Enterprise.
 
Script or a executable program is not a problem.
 
eagerly awaiting your reply along with the code
 
thanks in advance
 
~aquariansp
aquariansp
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 30 May 2007 at 9:31am
Since you're publishing instances with data, I suggest that you create a folder for each report title and then you'll publish the instances to the appropriate folder based on title.  You'll also need to set a unique title for each instance that you'll publish - I suggest adding the timestamp of the file to the title - if you don't, BOE will make it unique with "(1)", "(2)", etc after the title.
 
Here is some sample code for the actual publishing piece with minimal error handling - it's in C# so if you're working in VB you'll have to translate it (I'm sorry, I've never worked in VB so I can do it for you...)  The _infoStore is a variable that's private to the class where all this code resides.  It's set up when the code logs into the CMS.  There's good sample code for logging in to the CMS out in the BusinessObjects Developer Library which you can get to here:  http://diamond.businessobjects.com/developer/library

private bool addRpt(string rptFile, string rptPath,

    string rptTitle, string dbType, string dbServer,
    string dbName, string dbUser, string dbPW)
{
  bool result = true;
  Debug.WriteLine("addRpt");
  try
  {
    _errMsg = string.Empty;
    int folderID = getFolderIDFromPath(rptPath);

    if (folderID > -1)
    {
      InfoObjects infoObjects =
        _infoStore.NewInfoObjectCollection();
      PluginManager pluginManager =
        _infoStore.PluginManager;
      PluginInfo pluginInfo = pluginManager.GetPluginInfo
        ("CrystalEnterprise.Report");
      InfoObject infoObj = infoObjects.Add(pluginInfo);
      Report newRpt = (Report)infoObj;
      try
      {
        newRpt.Files.Add(rptFile);
        newRpt.Properties.Add("SI_PARENTID", folderID);
        newRpt.KeepSavedData = true;
        newRpt.NeedsLogon = false;
        newRpt.EnableThumbnail = false;
        newRpt.Title = rptTitle;

        for (int i = 1; i <= newRpt.ReportLogons.Count;
             i++)
        {
          newRpt.ReportLogons.UseOriginalDataSource =
            false
;
          newRpt.ReportLogons.CustomServerName =
            dbServer;
          newRpt.ReportLogons.CustomDatabaseName =
            dbName;
          newRpt.ReportLogons.CustomUserName = dbUser;
          newRpt.ReportLogons.CustomPassword = dbPW;
          newRpt.ReportLogons.PromptOnDemandViewing =
            false
;
        }
          
        _infoStore.Commit(infoObjects);
        Debug.WriteLine(rptTitle + " Published");
      }
      finally
      {
        infoObjects.Dispose();
        pluginManager.Dispose();
        pluginInfo.Dispose();
        infoObj.Dispose();
        newRpt.Dispose();
      }
    }
  }
  catch (Exception ex)

  {
    Debug.WriteLine("Unable to Add Report.  Error=" +

        ex.Message);
    result = false;
  }
  return result;

}


//Get the ID of the folder where we're going to publish the instance
private int getFolderIDFromPath(string folderPath)
{
  Debug.WriteLine("getFolderIDFromPath");
  int parentID = -1;
  try
  {
    string path = folderPath;
    int index = path.IndexOf('\\');
    if (index == 0)
    {
      path = path.Substring(1);  //strip off leading '\'
      index = path.IndexOf('\\');
    }
    string folderName;
    parentID = 0;
    while ((index > 0) && (parentID >= 0))
    {
      folderName = path.Substring(0, index).Trim();
      parentID = getIDFromName(folderName, parentID);
      path = path.Substring(index + 1);
      index = path.IndexOf('\\');
    }
    if (path != "")
    {
      parentID = getIDFromName(path.Trim(), parentID);
    }
  }
  catch (Exception ex)
  {
    Debug.WriteLine("Unable to get folder ID.  Error=" +

      ex.Message);
  }
  return parentID;

}


//get an id based on the name of the object and the id of its parent.
private int getIDFromName(string objectName, int parentID)
{
  //we're not going to trap the error here - we'll propagate it up to the calling method
  int result = -1;
  //get the ID of the Object
  string query = "Select SI_ID"
    + " From CI_INFOOBJECTS "
    + " Where SI_NAME='" + objectName + "'"
    + "   and SI_PARENTID=" + parentID.ToString();

  using (InfoObjects infoObjects = _infoStore.Query(query))
  {
    if (infoObjects.Count > 0)
      result = infoObjects[1].ID;
  }
  return result;
}

IP IP Logged
aquariansp
Newbie
Newbie


Joined: 22 Feb 2007
Online Status: Offline
Posts: 14
Quote aquariansp Replybullet Posted: 30 May 2007 at 10:49pm
Hi Dell,
Thanks a lot for posting the code.
 
I think the client needs it in VB. Anyway will try it out and let you know.
 
Appreciate your help.
 
regards
~aquariansp
aquariansp
IP IP Logged
aquariansp
Newbie
Newbie


Joined: 22 Feb 2007
Online Status: Offline
Posts: 14
Quote aquariansp Replybullet Posted: 02 Jun 2007 at 2:52am
Hi Dell,
Could you quickly let me know of how and where i need to use the code given by..
 
please give me of where i place the code and how do i go about running this piece of code.
 
kindly reply at the earliest.
 
thanks in advance
 
regards
aquariansp
aquariansp
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.031 seconds.