Archive

Archive for August, 2009

Search Using SPQuery in MOSS 2007


public DataTable BindData(string txtNumber, string txtTitle, string strOriginator)
{

WindowsIdentity objWindowsIdentity = WindowsIdentity.GetCurrent();
WindowsImpersonationContext objWindowsImpersonationContext = null;
RevertToSelf();
SPQuery oquery = null;
SPSite siteCollection = null;
SPWeb topLevelSite = null;
SPListItemCollection myitems = null;
try
{
objWindowsImpersonationContext = WindowsIdentity.GetCurrent().Impersonate();
siteCollection = new SPSite(System.Configuration.ConfigurationManager.AppSettings[“SPDocumentLibrary”]);

topLevelSite = siteCollection.AllWebs[System.Configuration.ConfigurationManager.AppSettings[“TopLevelSite”]];
SPList list = topLevelSite.Lists[System.Configuration.ConfigurationManager.AppSettings[“ListName”]];
topLevelSite.AllowUnsafeUpdates = true;

//Create an instance of SPQuery Object
oquery = new SPQuery();

if (((txtEcretsNumber != “”) & (txtTitle != “”)) || ((txtTitle != “”) & (strOriginator != “”)) || ((strOriginator != “”) & (txtEcretsNumber != “”)))
{
oquery.Query = “”;
}
else
{
if ((txtEcretsNumber != “”) || (txtTitle != “”) || (strOriginator != “”))
{
oquery.Query = “”;
}
}
if (txtEcretsNumber != “”)
{
oquery.Query += “” + txtEcretsNumber + “”;
}
if (txtTitle != “”)
{
oquery.Query += “” + txtTitle + “”;
}
if (strOriginator != “”)
{
oquery.Query += “” + strOriginator + “”;
}
if (((txtEcretsNumber != “”) & (txtTitle != “”)) || ((txtTitle != “”) & (strOriginator != “”)) || ((strOriginator != “”) & (txtEcretsNumber != “”)))
{
oquery.Query += “”;
}
else
{
if ((txtEcretsNumber != “”) || (txtTitle != “”) || (strOriginator != “”))
{
oquery.Query += “”;
}
}

DataTable dtNewItems;
//Assign the query object to myitems List Collection
if ((oquery.Query != “”) & (oquery.Query != null))
{
myitems = list.GetItems(oquery);
dtNewItems = myitems.GetDataTable();
}
else
{
myitems = list.Items;
//Get the Datatable for ALL the list items
dtNewItems = myitems.GetDataTable();
}
return dtNewItems;
}
catch (Exception ex)
{
throw ex;
}
finally
{
objWindowsImpersonationContext.Undo();
topLevelSite.AllowUnsafeUpdates = false;
siteCollection.Dispose();
topLevelSite.Dispose();
}
}

Advertisements

Get List Item From List Library


private void RunSearch()
{
//set the search string (this normally comes from the UI)
string searchString = “blah”;

//Set the datasource and bind the results
//to the Datagrid (dgSerSearchResults already exists)
dgSeRSearchResults.DataSource = ReturnFilterItems(searchString);
dgSeRSearchResults.DataBind();
}

private DataTable ReturnFilteredItems(string filterText)
{
//Get the list you are search on
SPList currentList = this.CurrentWeb.Lists[this.ListName];
//Get ALL of the list items from the List
SPListItemCollection listItems = currentList.Items;

//Get the Datatable for ALL the list items
DataTable dtListItems = listItems.GetDataTable();
//Clone the structure of the existing list into a new empty Datatable
DataTable dtNewItems = dtListItems.Clone();

//Loop through each row in the existing list
foreach (DataRow row in dtListItems.Rows)
{
//Loop through each Column in the Row
foreach (DataColumn column in dtListItems.Columns)
{
//Test to see if the Column contents contain the filter Text
if (row[column].ToString().Contains(filterText))
{
//Import the row from the DataTable with
//ALL the items into the New Empty Datatable
dtNewItems.ImportRow(row);
//Break out of the foreach looping the columns
break;
}
}
}
//Return the new datatable
Return dtNewItems;
}

Ref:http://blog.gemsolution.co.uk/2009/01/28/searching-across-all-fields-using-splist-object/

Validate User in MOSS


private void ValidateUser()
{
try
{
string strNoUser = string.Empty;
SPSite siteCollection = null;
SPWeb topLevelSite = null;
string strDocLibraryLink = System.Configuration.ConfigurationManager.AppSettings[“SPDocumentLibrary”].ToString();
siteCollection = new SPSite(strDocLibraryLink);

topLevelSite = siteCollection.AllWebs[ConfigurationManager.AppSettings[“TopLevelSite”].ToString()];

SPUser currentUser = topLevelSite.CurrentUser;
if (currentUser.Equals(strNoUser))
{
Response.Redirect(“UnauthorizedUserPage.aspx”);
}
}
catch (Exception ex)
{
objCommonMethods = new CommonMethods();
LabelSettings(true);
objCommonMethods.DisplayMessage(this.spnErrMsg, “Error”, ex.Message + ” Error While Validate Current User with MOSS”);

}
}

Sharepoint Content for Developers


SharePoint 2007 for Developers
Chapter 1 – Introduction to SharePoint Development

Chapter 2 – Managing Content with Lists and Libraries
Chapter 4 – SharePoint Security

Chapter 5 – Backup and Restore Strategies
Chapter 6 – SharePoint Portal operations and Administration

Chapter 7 – Authentication

Chapter 8 – InfoPath

Chapter 9– SharePoint Object Model

Chapter 10- Web parts

Chapter 11-Business data catalog and CAML

Chapter 12- Event Receivers

Chapter 13- Features

Solutions or Packages

Chapter 14- Workflows

Chapter 15- SharePoint Pages

Chapter 16- Working with SharePoint Designer

Chapter 17- Site Definitions

Styles and Themes
Chapter 18- Business Intelligence

Chapter 19- Extending MOSS 2007 Search

MOSS Advanced Search


Go to the central administration -> Shared Services
Under the Search Menu, click on Search Settings.
In the Configure Search Settings page, click on Metadata Property Mappings
In the Metadata Property Mappings page, click on New Managed Property
Enter the Property Name and add the crawled properties that you want to add by clicking on the Add mappings button.
# Click OK. Once you have created the new custom managed property, go to the Advanced Search page.

* Click on Site Settings and then on “Edit Page”
* Click on Edit Menu of the Webpart and then Select “Modify Shared Web part”

In the Advanced Search Box Pane, click on the Properties Menu and then select the content in the Properties Text Box. In order that your Managed Properties appears in the Properties lists, you need to make changes in the XML file content.

Ref:: http://www.codeproject.com/KB/sharepoint/MOSS_Advanced_Search.aspx

Categories: MOSS 2007, SHAREPOINT

Business Data Catalog


Business Data Catalog, a new feature introduced in Microsoft Office SharePoint Server 2007, provides an easy way to integrate business data from back-end server applications, such as SAP or Siebel, within Office SharePoint Server 2007 without writing any code. This section contains overview information and step-by-step, how-to procedures for programming with the Business Data Catalog.

Overview

Business Data Catalog is a new business integration feature in Microsoft Office SharePoint Server 2007. It is a shared service and it enables Office SharePoint Server 2007 to surface business data from back-end server applications without any coding. Business Data Catalog bridges the gap between the portal site and your business applications and enables you to bring in key data from various business applications to Office SharePoint Server 2007 lists, Web Parts, search, user profiles, and custom applications.

Business Data Catalog provides built-in support for displaying data from databases and Web services. That is, you can use Business Data Catalog to display data from your SAP, Siebel, or other line-of-business (LOB) application via Web services or databases.

Business Data Catalog is the key infrastructural component around which the other Business Data features of Office SharePoint Server 2007 are built

Business Data Web Parts
Microsoft Office SharePoint Server 2007 includes five default Business Data Web Parts: Business Data List, Business Data Item, Business Data Item Builder, Business Data Related List, and Business Data Actions. These Web Parts rely on the Business Data Catalog, and offer three main benefits:

*

No required coding, and reusability These Web Parts enable you to display business data on your portal site without writing any code. Also, these Web Parts are generic and reusable and can show any type of data ( entity) registered in the Business Data Catalog.
*

Connectability These Web Parts support Web Part connections and make it easier to create Master-Detail applications without writing any code. For example, you can display customers and their details using the Business Data List and Business Data Item Web Parts by simply connecting them. These Web Parts can also be integrated in dashboards.
*

Customization These Web Parts support WYSIWYG editing in Microsoft Office SharePoint Designer 2007 and can be customized using XSLT transformations.

Types of Business Data Web Parts

The following table provides a brief description of the Business Data Web Parts.
Web Part Description

Business Data List Web Part

Displays a list of entity instances from a business application registered in the Business Data Catalog. For example, you can use a Business Data List Web Part to display the customers or orders from the AdventureWorks database.

Business Data Item Web Part

Displays the details of an entity instance from a business application. For example, you can use a Business Data Item Web Part to display the details of a particular customer or order from the AdventureWorks database.

Business Data Related List Web Part

Displays a list of related entity instances from a business application. For example, you can use a Business Data Related List Web Part to display all the orders for a particular customer from the AdventureWorks database.

Business Data Actions Web Part

Displays a list of actions associated with an entity as defined in the Business Data Catalog. For example, you can use a Business Data Actions Web Part to display all the actions that portal users can perform on the Customer entity. Some examples of these actions are to send an e-mail message to a customer or to edit the address of a customer.

Business Data Item Builder Web Part

Creates a Business Data item based on parameters in the query string and provides it to other Web Parts. This Web Part is used only on Business Data profile pages.

Architecture
http://msdn.microsoft.com/en-us/library/ms499729.aspx

Video:Ref:http://www.lightningtools.com/bdc-meta-man/moss-business-data-catalog-getting-started.aspx

Categories: MOSS 2007, SHAREPOINT

Enable Search in MOSS 2007 Site


Go to Central Administration –>Site Settings –> under Site Administration–> Click on Seach Visibility Link.
Here Select: “Always index all ASPX pages on this site” Option.

Even after you enable the search visibility on your site and if you start search for a keyword on your site pages it will not work until the Crawling process will be run.

Crawling
There is a Crawling Service running on all Sharepoint conent pages to index all content,if you start your search for a new added content before the crawling process start by including the new content on its schedule,you will not get your search results.

Configure My Crawling process on MOSS 2007:
Go to Central Administration site–>Share Services link under Share Services Administration–>Click on Search Settings -> Content Sources and Crawl Schedules -> Edit the Content Source which is exist–>Update your crawling services as you want.

Categories: SHAREPOINT