Windows SharePoint Services v3 Features:
33 Features in WSS v3
|
|
Microsoft Office SharePoint Services 2007 Features:
107 Features Added in MOSS 2007*
|
|
probing 'DEEP' to discover the truth
|
|
|
|
Upon successful verification of solution, we move forward on how to deploy solution in SharePoint 2007.
Deploying the solution file to SharePoint is a two-step process: First, register the solution in the database. Registration is accomplished from the STSADM command-line utility. To add the test.wsp file, run the utility like this:
STSADM –o addsolution –filename test.wsp
Second, once the solution has been added to the solution store you can deploy it from the command line, or you can deploy it using the Central Administration user interface. Find the Solutions Management page by going to Start-->Administrative Tools-->SharePoint 3.0 Central Administration-->Operations, and in the Global Configuration section clicking Solution management. From there, click one of the listed solutions to see its status and to take action on it—like deploying it. Alternatively, you can deploy the solution from the command line with the STSADM command deploysolution. If you want to deploy the test.wsp solution to the local system, issue this command:
STSADM –o deploysolution –name test.wsp –allcontenturls –local –allowgacdeployment –allowcaspolicies
The –allowgacdeployment and –allocaspolicies options are necessary only if you have indicated deploying an assembly to the GAC, or you have provided a CAS policy as a part of the solution file, respectively.private System.Web.UI.WebControls.WebParts.WebPart
FetchWebPart(SPWeb web, String webPartName)
{
SPQuery query = new SPQuery();
// CAML query fetch list item with name equal to webPartName
query.Query = "<Where><Eq><FieldRef Name='FileLeafRef'/><Value Type='File'>" +webPartName + "</Value></Eq></Where>";
SPList webPartGallery = null;
// webpart gallery is available at root web only
if (null == web.ParentWeb)
{
// This is the root web.
webPartGallery = web.GetCatalog(
SPListTemplateType.WebPartCatalog);
}
else
{
SPWeb fetchRootWeb = web;
// fetch root web
while(fetchRootWeb.ParentWeb!=null)
{
fetchRootWeb = fetchRootWeb.ParentWeb;
}
webPartGallery = fetchRootWeb.GetCatalog(
SPListTemplateType.WebPartCatalog);
}
// pass query object to item collection
SPListItemCollection webParts = webPartGallery.GetItems(query);
String typeName = webParts[0].GetFormattedValue("WebPartTypeName");
String assemblyName = webParts[0].GetFormattedValue("WebPartAssembly");
ObjectHandle webPartHandle = Activator.CreateInstance(
assemblyName, typeName);
System.Web.UI.WebControls.WebParts.WebPart webPart =
(System.Web.UI.WebControls.WebParts.WebPart)webPartHandle.Unwrap();
return webPart;
}
public string AddWebPart(
SPWeb web,
String pageUrl,
String webPartName,
String zoneID,
int zoneIndex)
{
using (System.Web.UI.WebControls.WebParts.WebPart webPart =
FetchWebPart(web, webPartName))
{
using (SPLimitedWebPartManager manager = web.GetLimitedWebPartManager(
pageUrl, PersonalizationScope.Shared))
{
manager.AddWebPart(webPart, zoneID, zoneIndex);
return webPart.ID;
}
}
}
[/code]
public void AddWebPartConnection(
SPWeb web,
string pageUrl,
string providerWebPartID,
string consumerWebPartID,
string providerConnectionPointName,
string consumerConnectionPointName)
{
using (SPLimitedWebPartManager manager = web.GetLimitedWebPartManager(
pageUrl, PersonalizationScope.Shared))
{
System.Web.UI.WebControls.WebParts.WebPart provider =
manager.WebParts[providerWebPartID];
System.Web.UI.WebControls.WebParts.WebPart consumer =
manager.WebParts[consumerWebPartID];
ProviderConnectionPointCollection providerPoints =
manager.GetProviderConnectionPoints(provider);
ConsumerConnectionPointCollection consumerPoints =
manager.GetConsumerConnectionPoints(consumer);
ProviderConnectionPoint providerPoint = null;
foreach (ProviderConnectionPoint point in providerPoints)
{
if (String.Equals(
providerConnectionPointName,
point.DisplayName,
StringComparison.OrdinalIgnoreCase))
{
providerPoint = point;
break;
}
}
ConsumerConnectionPoint consumerPoint = null;
foreach (ConsumerConnectionPoint point in consumerPoints)
{
if (String.Equals(
consumerConnectionPointName,
point.DisplayName,
StringComparison.OrdinalIgnoreCase))
{
consumerPoint = point;
break;
}
}
manager.SPConnectWebParts(
provider,
providerPoint,
consumer,
consumerPoint);
}
}