Business Objects XI R2 Search Web Part Sharepoint Part II

No.of Views7219
Bookmarked1 times
Downloads 
Votes0
By  André Lage   On  27 Jul 2010 10:07:21
Tag : SharePoint , Development and Programming
In the sharepoint have the webpart for sharepoint for Business Objects search, but i use the Business Objects web services consumer common classes.
emailbookmarkadd commentsprint

Images in this article missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at info@codegain.com

 

Introduction

In the sharepoint have the webpart for sharepoint for Business Objects search, but i use the Business Objects web services consumer common classes. 

Image Loading

Implementation

You will need to convert the Business object Web Services in Class To do That you will need to follow this steps:

Path "C:\Programas\Microsoft Visual Studio 8\SDK\v2.0\Bin"
wsdl.exe /l:CS /n:BusinessObjects.DSWS.Session /out:Session.cs http://[CMS_SERVER]:8080/dswsbobje/services/session?WSDL
wsdl.exe /l:CS /n:BusinessObjects.DSWS.BICatalog /out:BICatalog.cs http://[CMS_SERVER]:8080/dswsbobje/services/bicatalog?WSDL
wsdl.exe /l:CS /n:BusinessObjects.DSWS.ReportEngine /out:ReportEngine.cs http://[CMS_SERVER]:8080/dswsbobje/services/reportengine?WSDL

 Code

using BusinessObjects.DSWS.Session;
using BusinessObjects.DSWS.BICatalog;
using BusinessObjects.DSWS.ReportEngine;

Note:You can downloa libray from here

 Full code

using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Web.UI;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.ComponentModel;
using System.Xml.Serialization;
using Microsoft.SharePoint.WebPartPages;
using System.Net;
using BusinessObjects.DSWS.Session;
using BusinessObjects.DSWS.BICatalog;
using BusinessObjects.DSWS.ReportEngine;

namespace SearchBOXI
{
[Guid("a836931e-01ff-4c72-b7b3-ed18c1d97fc3")]
[Themeable(true)]
[XmlRoot("http://aaclage.blogspot.com")]
[ToolboxData("<{0}:SearchBO runat=\"server\" />")]
public class SearchBOXI : Microsoft.SharePoint.WebPartPages.WebPart
{
#region Variables
string html;
private string _BOServer = "http://localhost:8080";
private string _Password;
private string _Login;
private string _Domain;
private string _URLSession = "http://localhost:8080/dswsbobje/services/session";
private Button BtSearch;
private Label LbSearch;
private TextBox TxtSearch;
protected Auth _Auth;
private String link;
#endregionpublic enum Auth
{
secEnterprise, secLDAP, secWinAD
};
public SearchBOXI()
{
this.ExportMode = WebPartExportMode.All;
}
#region Public Personalizable Properties
[WebBrowsable(true)]
[Personalizable(PersonalizationScope.User)]
[WebDescription("Business Objects Server Name")]
[Category("Business Objects Option")]
[WebDisplayName("Business Objects Server Name")]
public string BOServer
{
get{
return _BOServer;
}
set { _BOServer = value; }
}
[WebBrowsable(true)]
[Personalizable(PersonalizationScope.User)]
[WebDescription("URL Web Service Session")]
[Category("Business Objects Option")]
[WebDisplayName("URL Web Service Session")]
public string URLSession
{
get { return _URLSession; }
set { _URLSession = value; }
}
[WebBrowsable(true)]
[Personalizable(PersonalizationScope.User)]
[WebDescription("Login")]
[Category("Business Objects Authentication")]
[WebDisplayName("Login")]
public string Login
{
get { return _Login; }
set { _Login = value; }
}
[WebBrowsable(true)]
[Personalizable(PersonalizationScope.User)]
[WebDescription("Password")]
[Category("Business Objects Authentication")]
[WebDisplayName("Password")]
public string Password
{
get { return _Password; }
set { _Password = value; }
}
[WebBrowsable(true)]
[Personalizable(PersonalizationScope.User)]
[WebDescription("Domain")]
[Category("Business Objects Authentication")]
[WebDisplayName("Domain")]
public string Domain
{
get { return _Domain; }
set { _Domain = value; }
}
[WebBrowsable(true)]
[Category("Business Objects Authentication")]
[DefaultValue(SearchBOXI.Auth.secEnterprise)]
[Personalizable(PersonalizationScope.User)]
[WebDescription("Authentication")]
[WebDisplayName("Authentication")]
public Auth Author
{
get { return _Auth; }
set { _Auth = value; }
}
#endregion#region Create Child Control 
protected override void CreateChildControls()
{
this.BtSearch = new Button();
this.BtSearch.ID = "_BtSearch";
this.BtSearch.Text = "Search";
this.BtSearch.Click += new EventHandler(BtSearch_Click);
this.LbSearch = new Label();
this.LbSearch.ID = "_LbSearch";
this.LbSearch.Text = "Document Search BO";
this.TxtSearch = new TextBox();
this.TxtSearch.Width = Unit.Pixel(250);
this.TxtSearch.ID = "_TxtSearch";
this.Controls.Add(LbSearch);
this.Controls.Add(BtSearch);
this.Controls.Add(TxtSearch);
base.CreateChildControls();
}
#endregionvoid BtSearch_Click(object sender, EventArgs e)
{
Search();
}
private void Search()
{
try{
BusinessObjects.DSWS.Connection boConnection = null;
string boConString = URLSession;
boConnection = new BusinessObjects.DSWS.Connection(boConString);
boConnection.Credentials = CredentialCache.DefaultCredentials;
//boConnection.Credentials = new NetworkCredential(Login, Password, Domain);boConnection.IsKerberosAuthenticationEnabled = true;
EnterpriseCredential boCredential = new EnterpriseCredential();

if (Domain.Trim().Equals(""))
{ boCredential.Domain = string.Empty; }
else { boCredential.Domain = Domain; }

if (Login.Trim().Equals(""))
{ boCredential.Login = string.Empty; }
else { boCredential.Login = Login; }

if (Password.Trim().Equals(""))
{ boCredential.Password = String.Empty; }
else{ boCredential.Password = Password; }

if (Auth.secEnterprise == Author)
{ boCredential.AuthType = "secEnterprise"; }
else if (Auth.secLDAP == Author)
{ boCredential.AuthType = "secLDAP"; }
else if (Auth.secWinAD == Author)
{ boCredential.AuthType = "secWinAD"; }

Credential val = new Credential();
Session boSession = new Session(boConnection);
SessionInfo boSI = boSession.Login(boCredential);
string Token = boSI.DefaultToken;
String[] strBOCatURL = boSession.GetAssociatedServicesURL("BICatalog");
BICatalog boCatalog = BICatalog.GetInstance(boSession, strBOCatURL[0]);
ReportEngine oDSWRE = new ReportEngine(boCatalog.Connection, boSession.ConnectionState);
BusinessObjects.DSWS.BICatalog.SortType[] mySort = new BusinessObjects.DSWS.BICatalog.SortType[1];
mySort[0] = BusinessObjects.DSWS.BICatalog.SortType.NAMEASC;
SimpleSearch mySearch = new SimpleSearch();
mySearch.InAuthor = Login;
mySearch.InName = this.TxtSearch.Text.Trim();
mySearch.ObjectType = "documents";
link = "";
BICatalogObject[] searchResults = boCatalog.Search(mySearch, mySort, null, null, InstanceRetrievalType.ALL);
foreach (BICatalogObject myBOCatObject in searchResults)
{
link = BOServer + "/businessobjects/enterprise115/desktoplaunch/InfoView/CrystalEnterprise_Webi/view.do?objId=" + myBOCatObject.UID + "&logonToken=" + Token;
html = link;

}
boSession.Logout();

}
catch (Exception ex)
{
html = "No values...
" + ex.Message;
}
}
protected override void Render(HtmlTextWriter writer)
{
try{
EnsureChildControls();
this.LbSearch.RenderControl(writer);
writer.Write("
");
this.TxtSearch.RenderControl(writer);
this.BtSearch.RenderControl(writer);
writer.Write("
");
writer.Write(html);
}
catch (Exception ex)
{
writer.Write(ex.Message + " " + ex.StackTrace);
}
}
}
}

That's all.enjoy the search with business object.

 
Sign Up to vote for this article
 
About Author
 
André Lage
Occupation-Not Provided
Company-Not Provided
Member Type-Senior
Location-Portugal
Joined date-09 Jun 2010
Home Page-Not Provided
Blog Page-Not Provided
 
 
Other popularSectionarticles
Comments
There is no comments for this articles.
Leave a Reply
Title:
Display Name:
Email:
(not display in page for the security purphase)
Website:
Message:
Please refresh your screen using Ctrl+F5
If you can't read this number refresh your screen
Please input the anti-spam code that you can read in the image.
^ Scroll to Top