Writing Code
 Crystal Reports Forum : Crystal Reports for Visual Studio 2005 and Newer : Writing Code
Message Icon Topic: CR / Business Objects .Net FW Post Reply Post New Topic
Author Message
p3t1
Newbie
Newbie


Joined: 10 Oct 2012
Location: Ireland
Online Status: Offline
Posts: 3
Quote p3t1 Replybullet Topic: CR / Business Objects .Net FW
    Posted: 31 Jan 2013 at 7:48am
Hi,

I'm making a small client to manage a BO server. Now I'm trying to sync all selected reports from server 1 to a server 2. But I'm not capable to get get the reports from the BO server 1.

I've already tried to download the file to a local file,
to add directly the InfoObject.File to the destination InfoObjectt. etc etc. But nothing worked so far

Someone can help me or give some hints, to solve this problem? I'm only looking for Crystal Reports reports.

Thank you
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3701
Quote hilfy Replybullet Posted: 31 Jan 2013 at 12:31pm
Which version of BO are you using?  If it's 3.1 or earlier, why not use the Import Wizard that comes with BO? It's certainly better than reinventing the wheel.
 
Having said that, I would look at the BusinessObject BIAR Import/Export 12.0 assembly.  That might help you get to what you're trying to do.  Also, I need to track it down, but I have C# code somewhere that, given the path to the filestore, will locate the .rpt file that a specific report object in the CMS is referring to.  I'll try to track it down for you.
 
-Dell
IP IP Logged
p3t1
Newbie
Newbie


Joined: 10 Oct 2012
Location: Ireland
Online Status: Offline
Posts: 3
Quote p3t1 Replybullet Posted: 31 Jan 2013 at 10:12pm
hi hilfy,

Yes I'm on version XI3.1. I'm having problems with import wizard because I have different root folder name between both serves. Like DEV server everything is under a DEV folder and in BO UAT is under UAT folder. When I try to use the import it tries to create under the same directory name. Import wizard would work perfectly if we could chose a destination folder. But as far as I know is not possible.

IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3701
Quote hilfy Replybullet Posted: 01 Feb 2013 at 2:30am
I found the code.  This is taken from a class that I wrote that updates reports in the CMS from a .rpt file that is outside of the CMS.  This method for updating the file of the report is totally unsupported by SAP, but it works for XI 3.1 (I haven't tried doing any of this in 4.0 yet....) "_rptPath" is the physical path to the input filestore, such as C:\Program Files (x86)\Business Objects\BusinessObjects Enterprise 12.0\FileStore\Input.  You would need code code to either enter it in your utility, pull it from a configuration file, or something of the sort.
You should be able to modify this for your needs.
    private void updRpt(string rptFile, string alias, string rptDescrip, int folderID)
    {
      string query = "Select * from CI_INFOOBJECTS where SI_ID = " + _rptID.ToString();
      using (InfoObjects io = _common.BOEInfoStore.Query(query))
      {
        if (io.Count > 0)
        {
          Report newRpt = (Report)io[1];
          //Strip the pointer to the file repository server off of the front of the path
          //and add the actual UNC file path to the input file repository files.
          string fileName = newRpt.Files[1].Name.Replace("frs://Input", _rootPath);
          fileName = fileName.Replace('/', '\\');
          FileInfo fi = new FileInfo(rptFile);
          fi.IsReadOnly = false;  //If we copy a read-only file, we can't overwrite it later.
          fi.CopyTo(fileName, true);
          newRpt.RefreshProperties();
           updateLogon(newRpt, alias);
          _common.BOEInfoStore.Commit(io);
        }
        else
        {
          _errMsg = "Unable to update report: Report Not Found";
        }
      }
    }
 
    private void updateLogon(Report newRpt, string alias)
    {
      for (int j = 1; j <= newRpt.ReportLogons.Count; j++)
      {
        //set the database alias, user ID, and password
        newRpt.ReportLogons[j].UseOriginalDataSource = false;
        newRpt.ReportLogons[j].CustomServerName = alias;
        newRpt.ReportLogons[j].CustomUserName = _rptUser;
        newRpt.ReportLogons[j].CustomPassword = _rptPW;
      }
    }
 
-Dell
IP IP Logged
p3t1
Newbie
Newbie


Joined: 10 Oct 2012
Location: Ireland
Online Status: Offline
Posts: 3
Quote p3t1 Replybullet Posted: 07 Feb 2013 at 6:11am
Thx Dell,

I'll give a try.

I've solved my problem temporarily using the load function, saving it to a temp report and afterwards add it to the new server. I know it wasn't the best solution but it worked :)


InfoObjects sourceInfoObjects = infoStoreFrom.Query("SELECT SI_ID, SI_CUID, SI_NAME, SI_FILES FROM CI_INFOOBJECTS WHERE SI_INSTANCE=0 and SI_ID=" + item.Key);
               if (sourceInfoObjects.Count != 0)
               {
                    //Retrieve the newly created report InfoObject
                    InfoObject rep = (InfoObject)sourceInfoObjects[1];
                    ReportDocument ndoc = new ReportDocument();
                    try
                    {
                        ndoc.Load(rep, infoStoreFrom.EnterpriseSession);
                        string tempPath = System.IO.Path.GetTempPath() + rep.Title + ".rpt";
                        ndoc.SaveAs(tempPath);
                        tempPath_folder.Add(tempPath, item.Value);
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
               }
            }
            add_report(infoStoreTo, tempPath_folder);
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.