Showing posts with label MOSS 2007. Show all posts
Showing posts with label MOSS 2007. Show all posts

Thursday, April 15, 2010

SharePoint Key Words

What is portal




Portal is a web application that gathers information from various desperate sources to share the information among the users .


The portals has the following significant features


• collabaration


• security


• personalization


• customization


• search , etc




Site which are not portals are called vertical portal or Vortals




Windows share point services 3.0 is free licensing it has less feature compare to Moss 2007




Ghost able – stored in content database




Un ghost able – stored in hard disk



Web part




Web part is a custom control , created by a developer and deployed on to the share point site with the extension dwp or webpart(recommended) .



Web part zone




Web part zone is a logical area created by the designer on a web part page where the web part can be dropped.




Web part page




Page, which contain web parts.




There are two type of deployment


• stand alone Installation (Deployment ) – Everything is there in the same system .


• web form Installation ( Web garden) -


A Web garden is an application pool that is configured with more than one worker process. (Web gardens are to be distinguished from Web farms, which use multiple servers for a Web site.)





Hierarchy


Central administration


site administrator




Top-level sites

Top level site 1 - Top level site 2




Role




Administrator – can create sites, content, users, application, manage forms.


Designer – can create manage content and design of the website


Contributor – can only contribute to existing content .


Reader – no other permission except view.




Feature




Feature are new innovation in Moss 2007 these are plug gable component which actually modifies the structure, layout programming capability of share point site .


When you create a SharePoint site, it helps to understand where your site is in relation to the entire site hierarchy. The following three SharePoint concepts are important to know understand:


• Top-level Web site The default, top-level site provided by a Web server. To open the top-level Web site, you supply the URL of the server—for example, http://My_server — without specifying a page name or subsite. Administrators go to this site to change settings for the entire site collection.


• Subsite A complete Web site stored in a named subdirectory of the top-level Web site. Each subsite can have administration, authoring and browsing permissions that are independent from the top-level Web site and other subsites. A subsite can also have subsites of its own. Because every site below the top-level site is actually a subsite, each subsite is generally called simply a site. To open a subsite, you supply the URL of the server and any subsites—for example, http://My_server/My_site — without specifying a page name.


• Site collection A set of Web sites on a Web server, all of which have the same owner and share administration settings. Each site collection contains exactly one top-level Web site and can also contain one or more subsites. There can be multiple site collections on each Web server.


• SharePoint Online is the business collaboration platform for the Enterprise and the Web hosted by Microsoft. It provides the robust capabilities of Microsoft SharePoint Server as a cloud-based service that can help connect and empower people and reduce costs. By removing the operational burden that comes from managing the infrastructure associated with on-premises software your IT team can more rapidly respond to business needs and deliver sustainable competitive advantage for your organization.


• Application page: Allows the use of inline custom code. Application pages or "_layout" pages are stored on the SharePoint Web server and made available via a Microsoft Internet Information Services (IIS) virtual directory. Though application pages behave much like other ASPX pages and allow the use of inline custom code, they differ from content pages in that they cannot be used to host SharePoint features such as dynamic Web Parts and Web Part zones.


• Content type: A reusable collection of settings to apply to a certain category of content such as documents and folders. Content types are designed to help users organize their SharePoint content in a more meaningful way.


• Custom action: Represents a link, toolbar button, menu item, or any control that can be added to a toolbar or menu that appears in the UI. We define custom actions by using a custom action element within a feature definition file. We can bind custom actions to a list type, content type, file type, or programmatic identifier (ProgID).


• Event receiver: Evaluator of an event and definer of the behavior of an application. Windows SharePoint Services 3.0 allows us to define event handlers within libraries, lists, and sites. Event receivers can be defined by using a receiver element within a feature definition file.


• Feature: A package of Windows SharePoint Services elements that can be activated for a specific scope and that helps users accomplish a particular goal or task. Windows SharePoint Services 3.0 introduces this inherently portable and modular functionality, which simplifies modification of sites through site definitions.


• Master page: Pages that provide a consistent layout and appearance (look and feel) for SharePoint sites. They allow us to factor out layout, structure, and interface elements such as headers, footers, navigation bars, and content placeholders. Master pages in ASP.NET 2.0 and master pages in Windows SharePoint Services work in the same way.


• Module: A file or collection of file instances that define the location where the files are installed during site creation. Modules are frequently used to implement a Web Part Page in the site. We can define modules by using a module element within a feature definition file.


• SharePoint Web farm: A group of Office SharePoint 2007 servers that share the same configuration database. All site content and all configuration data is shared for all front-end Web servers in a server farm.


• Site definition: A set of files that includes a master XML configuration file that is stored on all front-end Web servers. A site definition provides the basic blueprint for how sites look, what lists they include, their default navigational structures, and so on.


• Site template: A package containing a set of differences and changes from a base site definition that is created through the UI or through implementation of the object model. The site template package is stored as a .cab-based file that can be downloaded or uploaded to site collections by users with the appropriate rights. Site templates offer a measure of portability to SharePoint applications.


• Solution: A file that is a bundling of all the components for extending Windows SharePoint Services in a particular way. A solution file has a .cab-based format with a .wsp extension. A solution is a deployable, reusable package that can contain a set of Features, site definitions, and assemblies that apply to sites, and that you can enable or disable individually. We can use the solution file to deploy the contents of a Web Part package, including assemblies, class resources, and other package components.


• Theme: A group of files (CSS, images) that allow you to define the appearance (look and feel) of Web pages. Themes in ASP.NET 2.0 and themes in SharePoint Products and Technologies work in the same way. Themes are used to help organizations to brand their portals and team sites. Office SharePoint Server 2007 includes a set of predefined themes. However, as a developer, we can create custom themes for our company.


Wednesday, September 12, 2007

Impersonation in SharePoint 2007 using Elevated privileges

When I was working with giving permission for the logged in user to access data from BDC , I found so many articles which talks about Impersonation ...

when Searching more for simpler method i got a method which helps in
Executing code with elevated privileges .

The code goes like this

SPSecurity.CodeToRunElevated elevatedMethod = new SPSecurity.CodeToRunElevated(pullUserData);
SPSecurity.RunWithElevatedPrivileges(elevatedMethod);


where pullUserData() is a void method which gets data from BDC.


private void pullUserData()
{
string userName = getUserName(); // "domain\\b" ;
userprofile.UserProfileService myuser = new UserProfileService();
userprofile.PropertyData[] userprop = null;

// here userprofile is web service method
http://localhost/_vti_bin/userprofileservice.asmx

myuser.Credentials = System.Net.CredentialCache.DefaultCredentials;
myuser.PreAuthenticate = true;
long test = myuser.GetUserProfileCount();
userprop = myuser.GetUserProfileByName(userName);

for (int i = 0; i < userprop.Length; i++)
{
if (userprop[i].Name != null)
{
if (userprop[i].Name.Trim().ToLower() == gblAttribute.Trim().ToLower())
{

if (userprop[i].Values[0] != null)
{
gblResult = userprop[i].Values[0].Value.ToString();

}

}
}
}

}


Friday, August 31, 2007

Get BDC Data In Sharepoint with Web Service

Get the Users from Business Data Catalog (BDC) programmatically

I got a chance to work in getting users from BDC in sharepoint.

Initially I tryed by getting users from UserInformationList using CAML query
after that I got web service things which made my job easy


The BDC allows you to create a XML metadata file describing a database or web service to SharePoint so that SharePoint can query this data source to make its data available within the portal. Once registered in your SharePoint environment this data can be displayed in the Business Data web parts (described later in this posting) or as lookup information for list/library columns (and column templates).


user this Web service Interface to get user profiles

http://localhost/_vti_bin/userprofileservice.asmx


The below code will give me User data from particular user


public string getUserValuesfromBDC(string attribute)

{ string myvalues = string.Empty;

try
{




string userName = getUserName(); // "VMTPG\\b" ;

userprofile.UserProfileService myuser = new UserProfileService();
userprofile.PropertyData[] userprop = null;

myuser.Credentials = System.Net.CredentialCache.DefaultCredentials;
long test = myuser.GetUserProfileCount();
userprop = myuser.GetUserProfileByName(userName);
for (int i = 0; i <>

{
if (userprop[i].Name != null)

{
if (userprop[i].Name.Trim().ToLower() == attribute.Trim().ToLower())

{
try
{
if (userprop[i].Values[0] != null)
{
myvalues = userprop[i].Values[0].Value.ToString();
return myvalues;

}
}
catch { }

}
}
}


}
catch

{ }

return myvalues;
}





To Get All Users as Data Set


protected void Button1_Click(object sender, EventArgs e)
{

GridView1.AutoGenerateColumns = true ;
GridView1.DataSource = getAllUserValuesfromBDC();
GridView1.DataBind();

}


public DataSet getAllUserValuesfromBDC()
{
string myvalues = string.Empty;
string fieldname = string.Empty;

DataSet ds = new DataSet();
try
{
DataTable mydt = new DataTable();

userinfo.UserProfileService myuser = new UserProfileService();
userinfo.PropertyData[] userprop = null;
userinfo.GetUserProfileByIndexResult myindx = null;

myuser.Credentials = System.Net.CredentialCache.DefaultCredentials;
long userCount = myuser.GetUserProfileCount();
int uCount = Convert.ToInt32(userCount);


// To add column to the data table
myindx = myuser.GetUserProfileByIndex(0);
if (myindx != null)
{
for (int m = 0; m < myindx.UserProfile.Length; m++)
{
try
{
if (myindx.UserProfile[m].Name != null)
{
mydt.Columns.Add(myindx.UserProfile[m].Name);
}
}
catch{}
}
}


// To add the Row value to Table
for (int k = 0; k < userCount; k++)
{
myindx = myuser.GetUserProfileByIndex(k);
DataRow dr = mydt.NewRow();

if (myindx != null)
{
for (int m = 0; m < myindx.UserProfile.Length; m++)
{
try
{
if (myindx.UserProfile[m].Name != null && myindx.UserProfile[m].Values[0].Value != null)
{
dr[myindx.UserProfile[m].Name] = myindx.UserProfile[m].Values[0].Value;
}
}
catch
{
}
}
mydt.Rows.Add(dr);
}
}
ds.Tables.Add(mydt);

}
catch
{

}
return ds;
}


Hope this will be more user full

Thursday, August 30, 2007

How to Get Survey Data from Sharepoint

Get the Survey data of Site in sharepoint

SPWeb web = SPContext.Current.Web;

string parentUrl = SPContext.Current.Web.Site.RootWeb.Url;


string currentURL = Survey List Url;

SPSite site = new SPSite(currentURL);
SPWebCollection spcollection = site.AllWebs;
string inputsite = p_strUrl ;

SPListCollection myweblist

html += "

";
for (int k = 0; k < spcollection.Count; k++)
{
if (inputsite.ToLower().Trim() == spcollection.Names[k].ToLower().Trim())
{
myweblist = spcollection[k].Lists;
for (int i = 0; i < myweblist.Count; i++)
{
if (myweblist[i].BaseType.ToString() == "Survey")
{
Assignmentvalue = myweblist[i].Title;

string urlAssignmentvalue = myweblist[i].DefaultViewUrl ;

html += "";

}
}
}
}
html += "
>" + Assignmentvalue + "
";

How to Get Discussion Board Data from Share point

Get the data of DiscussionCategory using SPQuery


Get the SpWeb

SPWeb web = SPContext.Current.Web;

using ( web = site.OpenWeb())
{

SPQuery query = new SPQuery();

discussionBoardUrl is the url which points to Discussion Board Exist

SPList list = web.GetListFromUrl(discussionBoardUrl);


Query the SpList to get Item Collection


string qLess = string.Empty;
qLess +=
" ";


query.Query = qLess;


SPListItemCollection listCollection = list.GetItems(query);
string subject = string.Empty;
string category = string.Empty;
litDiscussion.ID = "discussionBoard";

Loop with Each ITem In List Collection

string html = "";

ArrayList arrCategory = new ArrayList();
foreach (SPListItem listItem in listCollection)
{
string lcategory = listItem.GetFormattedValue("DiscussionCategory");
if (arrCategory != null && listCollection.Count > 0 && !arrCategory.Contains(lcategory.ToLower().Trim()))
arrCategory.Add(lcategory.Trim());

}


html = "

";
html += "";


int count = 0;

for (int k = 0; k < arrCategory.Count; k++ )
{
category = arrCategory[k].ToString() ;
html += "

";


foreach (SPListItem listItem in listCollection)
{
string lcategory = listItem.GetFormattedValue("DiscussionCategory");

Arranging Category under that Discussion topics

if (arrCategory[k].ToString().ToLower().Trim() == lcategory.ToLower().Trim())
{
count = count + 1;
string last = listItem.GetFormattedValue("Last Updated");
subject = listItem.GetFormattedValue("Subject");
html += "

";


}

if (count >= displayCount)
{
break;
}
}
html += "";
if (count >= displayCount)
{
break;
}
}
html += "

Discussion Board

" + category + "

> " + subject + "
";
litDiscussion.Text = html;

Monday, July 16, 2007

pagination in datagrid webpart in sharepoint

The Best way to bind datagrid with the Pagination property and Edit and update command .


I was stuck in Adding pagination property to datagrid which was created under sharepoint webparts .

The Next pagination is working but Prev Pagination is not working. I tryed with somany ways but not able to find out .

Atlast I rearranged the code which handle viewstate properly ..

This is the code which works properly ...

public class TestHOF : WebPart
{

// To get the data from databse
public static DataSet getData()
{
DataSet ds = new DataSet();

return ds;
}
//======================================================================
///
/// Method to get connection string from web.config
///

//======================================================================
public static string GetConnectionstring()
{
string connStr = string.Empty;
try
{
connStr = ConfigurationManager.ConnectionStrings["ConnectionString"].ToString();
}
catch
{


}

return connStr;
}

private MyDataGrid grid;

private bool DynamicColumnsAdded
{
get
{
object o = ViewState["DynamicColumnsAdded"];
if (o != null)
{
return (bool)o;
}
return false;
}
set
{
ViewState["DynamicColumnsAdded"] = value;
}
}

protected override void CreateChildControls()
{
grid = new MyDataGrid();
grid.ID = "DataGridInsideWebPart";
grid.AllowPaging = true;
grid.PageSize = 5;
grid.PagerStyle.Mode = PagerMode.NextPrev;
grid.PagerStyle.NextPageText = "Next";
grid.PagerStyle.PrevPageText = "Prev";
grid.ItemCommand += new DataGridCommandEventHandler(this.LanguageGrid_ItemCommand);
grid.UpdateCommand += new DataGridCommandEventHandler(this.LanguageGrid_UpdateCommand);
grid.PageIndexChanged += new DataGridPageChangedEventHandler(grid_PageIndexChanged);
grid.AutoGenerateColumns = false;

this.Controls.Add(grid);
ChildControlsCreated = true;
}

void grid_PageIndexChanged(object source, DataGridPageChangedEventArgs e)
{
//throw new Exception("The method or operation is not implemented.");
grid.CurrentPageIndex = e.NewPageIndex;
grid.DataSource = getHOFMembersData();
grid.DataBind();
}

protected override void OnLoad(EventArgs e)
{
EnsureChildControls();
if (!DynamicColumnsAdded)
{
AddColumns();
}
if (!Page.IsPostBack)
{
grid.DataSource = getData() ;
grid.DataBind();
}
base.OnLoad(e);

}

public void LanguageGrid_ItemCommand(Object sender, DataGridCommandEventArgs e)
{
if (e.CommandName == "Edit")
{
Page.Response.Write("Edit:" + e.Item.ItemIndex);
this.LanguageGrid_EditItem(sender, e);
}
if (e.CommandName == "Update")
{
Page.Response.Write("Update:" + e.Item.ItemIndex);
this.LanguageGrid_UpdateCommand(sender, e);
}
}

public void LanguageGrid_EditItem(Object sender, DataGridCommandEventArgs e)
{
grid.EditItemIndex = e.Item.ItemIndex;
grid.DataBind(); // Refreshes the grid
}

public void LanguageGrid_UpdateCommand(Object sender, DataGridCommandEventArgs e)
{
string language = e.Item.Cells[0].Text;
grid.EditItemIndex = -1;
grid.DataBind();
}

protected override void LoadViewState(object savedState)
{
EnsureChildControls();
object[] stateArr = (object[])savedState;
base.LoadViewState(stateArr[0]);
grid.LoadDGViewState(stateArr[1]);
if (DynamicColumnsAdded)
{
AddColumns();
}
}

protected override object SaveViewState()
{
object[] state = new object[2];
state[0] = base.SaveViewState();
state[1] = grid.SaveDGViewState();
return state;
}

private void AddColumns()
{
BoundColumn languages = new BoundColumn();
languages.DataField = "CategoryId";
languages.HeaderText = "CategoryId";

EditCommandColumn edit = new EditCommandColumn();
edit.ButtonType = ButtonColumnType.LinkButton;
edit.EditText = "Edit";
edit.UpdateText = "Update";
grid.Columns.Add(languages);
grid.Columns.Add(edit);

DynamicColumnsAdded = true;
}

private class MyDataGrid : DataGrid
{
public void LoadDGViewState(object state)
{
this.LoadViewState(state);
}

public object SaveDGViewState()
{
return this.SaveViewState();
}
}






}

Thursday, July 12, 2007

WebService in Sharepoint

One of the majour part which I have worked in my project is connecting webpart and web service.

May be this article will give a an Idea of how we can Add a asmx page into sharepoint
and also how to use the existing web service in Share point .


1) Create an ASP.NET Web service in Microsoft Visual Studio 2005.
Create a class library within the Web service that defines the programming logic for the Web service.


Create a strong name for the class library:
add your assembly to the global assembly cache (GAC),
Open TestFiles.asmx page Remove the CodeBehind attribute and Add the class
<%@ WebService Language="C#" Class="Files,clsUploadService, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c741d2e07f0e3abc" %>


where "Files" represents the class name that you provide in Files.cs and " clsUploadService, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c741d2e07f0e3abc" is the one which we get from Reflector.exe ( this procedure is similar to the process of getting assembly name )

2) Generate and edit a static discovery file and a Web Services Description Language (WSDL) file.
To provide discovery and description for your custom Web service, you must create a .disco file and a .wsdl file
In Windows Explorer, copy the TestFiles.asmx file of your Web service to \\ Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS.
Disco.exe at the command promp ( from Microsoft tools - command) disco http: // mytestwebsite:4704 / _layouts/TestFiles.asmx
( mytestwebsite:4704 is the server name ) after this open the wsdl and disco files with this link
http://mytestwebsite:4704/_layouts/TestFiles.asmx?disco
http://mytestwebsite:4704/_layouts/TestFiles.asmx?wsdl
save both file as aspx files TestFilesdisco.aspx and TestFilesWSDL.aspx
In both file replace with
<%@ Page Language="C#" Inherits="System.Web.UI.Page" %>
<%@ Assembly Name="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Import Namespace="Microsoft.SharePoint.Utilities" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<% Response.ContentType = "text/xml"; %>



3) replaces literal paths with code generated paths
in disco file
docRef=<% SPHttpUtility.AddQuote(SPHttpUtility.HtmlEncode(SPWeb.OriginalBaseUrl(Request)),Response.Output); %>
xmlns="http://schemas.xmlsoap.org/disco/scl/" />

xmlns:q1="http://tempuri.org/" binding="q1:HelloWorld" xmlns="http://schemas.xmlsoap.org/disco/soap/" />

xmlns:q2="http://tempuri.org/" binding="q2:ServiceSoap12" xmlns="http://schemas.xmlsoap.org/disco/soap/" />

in WSDL file
/>


4) Copying the Web Service Files to the _vti_bin Directory
The _vti_bin virtual directory maps physically to the Local_Drive:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\ISAPI directory, which contains the default Web service files used in Windows SharePoint Services. Copy the new MyCustomWebServicewsdl.aspx and MyCustomWebServicedisco.aspx files, and also the MyCustomWebService.asmx file, to the ISAPI folder.
To verify navigate to http://mytestwebsite:4704/_vti_bin/TestFiles.asmx.

5 ) Add the New Web Service in spdisco.aspx

To make your Web service discoverable in Visual Studio as a Web service alongside the default Windows SharePoint Services Web services, open the spdisco.aspx file located in \Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\ISAPI and add the following code, specifying the .asmx file for your Web service.

docRef=<% SPHttpUtility.AddQuote(SPHttpUtility.HtmlEncode(spWeb.Url + "/_vti_bin/ TestFiles.asmx"), Response.Output); %>
xmlns=" http://schemas.xmlsoap.org/disco/scl/ " />

xmlns="http://schemas.xmlsoap.org/disco/" />

To create web part which connects to WebService ( TestWebpartServices ) and returns data
add a web reference to http://mytestwebsite:4704/_vti_bin/TestFiles.asmx. and name that has mytestwebsite
public class TestWebpartServices : WebPart
{
private mytestwebsite.Files file = new global::TestWebpartServices.mytestwebsite.Files();
protected override void RenderContents(System.Web.UI.HtmlTextWriter writer)
{

file.PreAuthenticate = true;
file.Credentials = CredentialCache.DefaultCredentials;
writer.Write(file.HelloWorld());
}
}
and after this create web Part from this dll and Import this in application you can see a message "Hello World" .

when I was creating web service application in 2005 we dont have any option to edit the proxy class .i.e reference.cs file will not create .. but if we do this with the class project we can see reference.cs file




MOSS 2007 Training

Microsoft® Office SharePoint® Server 2007

I got a chance to undergo training on MOSS 2007 , since our client Palladiume USA wanted to shift to sharepoint portal .

The Training was conducted by Mr Gurjit , It was about 1 week .

Windows SharePoint Services is a versatile technology included in Microsoft Windows Server 2003 that enables organizations and business units of all sizes to increase the efficiency of business processes and improve team productivity.