PortalSiteMapProvider provides a nice automatic caching infrastructure for retrieving list data. The class includes a method called GetCachedListItemsByQuery that was used in this test. This method first retrieves data from a list based on an SPQuery object that is provided as a parameter to the method call. The method then looks in its cache to see if the items already exist. If they do, the method returns the cached results, and if not, it queries the list, stores the results in cache and returns them from the method call.
SPQuery strQuery = new SPQuery();
strQuery.RowLimit = 1;
//Retrieve the items for the specified Target location from the Target list
strQuery.Query = "CAML query...";
PortalSiteMapProvider ps = PortalSiteMapProvider.WebSiteMapProvider;
PortalWebSiteMapNode pNode = ps.FindSiteMapNode(web.ServerRelativeUrl) as PortalWebSiteMapNode;
SiteMapNodeCollection pItems = new SiteMapNodeCollection();
pItems = ps.GetCachedListItemsByQuery(pNode, "targetListName", strQuery, web);
//Check if there are items for the specified target location
if (pItems.Count != 0)
{
try
{
//Retrieve the most recently created item for the specified Target location from the list
foreach (PortalListItemSiteMapNode pItem in pItems)
{//TODO}
catch (Exception ex)
{}
}
Friday, March 12, 2010
Tuesday, March 2, 2010
Content types and Site Columns in MOSS 2007
Site column is a reusable component in sharepoint.
Deleting Columns
If a site collection contains lists that contain a site column you want to delete, you cannot delete that site column. If you delete a column from a list, that column is also deleted from any list content type on that list. When you delete a column, all data associated with that column is also deleted.
Site column usage in sharepoint:
There are three ways to use site columns in sharepoint and they are:
1.Using the central administration tool of sharepoint.
2.Using the WSS object model through code snippet.
3.Using features(XML file).
Using features to add site columns in the sharepoint site.
Feature.xml
The feature.xml file is a general description of the feature and looks like this:
Title="MyFields"
Description="Fields added through feature"
Version="12.0.0.0"
Scope="Site"
xmlns="http://schemas.microsoft.com/sharepoint/">http://schemas.microsoft.com/sharepoint/>
Site column feature xml
The file fields.xml looks like this:
Name="RegionFromFeature"
Group="MyColumns"
Type="Choice"
DisplayName="Region"
SourceID=http://schemas.microsoft.com/sharepoint/v3/fields
StaticName="RegionFromFeature"
FillInChoice="FALSE">
Global
Europe
Global
Use STSADM command to install and activate the feature and do an IISRESET.
Commands are:
stsadm -o installfeature -filename fields\feature.xml
stsadm -o activatefeature -filename fields\feature.xml -url “Site Collection URL”
Method for using the WSS object model to add a new site column:
SPSite site=new SPSite(“http://servername/myPortal”)”;
SPWeb web=site.OpenWeb(“/Topics”);
String newFld=web.Fields.Add(“Location”,SPFieldType.Choice,True);
newFld.Choices.Add(“Hyderabad”);
newFld.Choices.Add(“Banglore”);
newFld.Choices.Add(“Jamshedpur”);
newFld.DefaultValue=”Jamshedpur”;
newFld.Update();
Method for using the WSS object model to add a site column to a list:
SPSite site=new SPSite(“http://servername/myPortal”);
SPWeb web=site.OpenWeb(“Topics/MOSS2007”);
SPList list=web.Lists[“Shared Documents”];
SPField myFld=web.AvailableFields[“MyField”];
List.Fields.Add(MyField);
Add site columns to Content type using WSS object model:
SPSite site = new SPSite("http://servername/myPortal");
SPWeb web = site.OpenWeb("/Topics");
// Create new content type
SPContentType documentContentType = web.AvailableContentTypes["Document"];
SPContentType newContentType = new SPContentType(documentContentType, web.ContentTypes, "Address Document");
web.ContentTypes.Add(newContentType);
newContentType = web.ContentTypes[newContentType.Id];
// Add FieldLink to content type
SPField myFld = web.AvailableFields["myField"];
SPFieldLink fieldLink = new SPFieldLink(myFld);
newContentType.FieldLinks.Add(fieldLink);
newContentType.Update(false);
The above code snippet shows how to add site columns to a content Type. Here just add a new SPFieldLink object to the FieldLinks collection of the contenttype.
Deleting Columns
If a site collection contains lists that contain a site column you want to delete, you cannot delete that site column. If you delete a column from a list, that column is also deleted from any list content type on that list. When you delete a column, all data associated with that column is also deleted.
Site column usage in sharepoint:
There are three ways to use site columns in sharepoint and they are:
1.Using the central administration tool of sharepoint.
2.Using the WSS object model through code snippet.
3.Using features(XML file).
Using features to add site columns in the sharepoint site.
Feature.xml
The feature.xml file is a general description of the feature and looks like this:
Description="Fields added through feature"
Version="12.0.0.0"
Scope="Site"
xmlns="http://schemas.microsoft.com/sharepoint/">http://schemas.microsoft.com/sharepoint/>
Site column feature xml
The file fields.xml looks like this:
Group="MyColumns"
Type="Choice"
DisplayName="Region"
SourceID=http://schemas.microsoft.com/sharepoint/v3/fields
StaticName="RegionFromFeature"
FillInChoice="FALSE">
Use STSADM command to install and activate the feature and do an IISRESET.
Commands are:
stsadm -o installfeature -filename fields\feature.xml
stsadm -o activatefeature -filename fields\feature.xml -url “Site Collection URL”
Method for using the WSS object model to add a new site column:
SPSite site=new SPSite(“http://servername/myPortal”)”;
SPWeb web=site.OpenWeb(“/Topics”);
String newFld=web.Fields.Add(“Location”,SPFieldType.Choice,True);
newFld.Choices.Add(“Hyderabad”);
newFld.Choices.Add(“Banglore”);
newFld.Choices.Add(“Jamshedpur”);
newFld.DefaultValue=”Jamshedpur”;
newFld.Update();
Method for using the WSS object model to add a site column to a list:
SPSite site=new SPSite(“http://servername/myPortal”);
SPWeb web=site.OpenWeb(“Topics/MOSS2007”);
SPList list=web.Lists[“Shared Documents”];
SPField myFld=web.AvailableFields[“MyField”];
List.Fields.Add(MyField);
Add site columns to Content type using WSS object model:
SPSite site = new SPSite("http://servername/myPortal");
SPWeb web = site.OpenWeb("/Topics");
// Create new content type
SPContentType documentContentType = web.AvailableContentTypes["Document"];
SPContentType newContentType = new SPContentType(documentContentType, web.ContentTypes, "Address Document");
web.ContentTypes.Add(newContentType);
newContentType = web.ContentTypes[newContentType.Id];
// Add FieldLink to content type
SPField myFld = web.AvailableFields["myField"];
SPFieldLink fieldLink = new SPFieldLink(myFld);
newContentType.FieldLinks.Add(fieldLink);
newContentType.Update(false);
The above code snippet shows how to add site columns to a content Type. Here just add a new SPFieldLink object to the FieldLinks collection of the contenttype.
Monday, November 2, 2009
Creating Publishing Templates in MOSS 2007
In this blog I would explain about how to create a publishing template in MOSS 2007.
Basically a sharepoint page layout comprises content fields and site columns which forms a page layout. First create the content types and then the site columns.
With the help of SPD 2007 open the site and start customizing the aspx page. The layout page is uploaded in the Master Gallery and Page Layouts in sharepoint.
Customize the page using SPD 2007 and then publish the page. Use the site columns created in the SPD for placing the controls as per the requirement. Drag and drop the controls accordingly in the page. Make sure that you give proper name to your page and the content type from which it should be inherited is mapped correctly. Once the page layout is designed completely,publish it.Fill up the details in the page and submit...See your new page layout....I will attach the snapshots as well in the later posts...
Basically a sharepoint page layout comprises content fields and site columns which forms a page layout. First create the content types and then the site columns.
With the help of SPD 2007 open the site and start customizing the aspx page. The layout page is uploaded in the Master Gallery and Page Layouts in sharepoint.
Customize the page using SPD 2007 and then publish the page. Use the site columns created in the SPD for placing the controls as per the requirement. Drag and drop the controls accordingly in the page. Make sure that you give proper name to your page and the content type from which it should be inherited is mapped correctly. Once the page layout is designed completely,publish it.Fill up the details in the page and submit...See your new page layout....I will attach the snapshots as well in the later posts...
Monday, August 31, 2009
Blob Caching mechanism in MOSS 2007
I came across a blog by Steven Gobner where he mentioned about the blob caching mechanism in MOSS 2007. Just check the web.config file for entry
Blob caching allows caching of binary objects like images, style sheets and documents on the MOSS front end server machine which heavily reduces the traffic to the SQL backend server as each file has to be downloaded only once to the blob cache per frontend server.
The benefit is that although the items are now retrieved from the MOSS 2007 frontend server the same security and versioning capabilities exist as if the file would only live in the SQL backend database. The blob cache mechanism also ensures that an item in the cache is invalided as soon as the file changes in the backend database. So that is different from other file caches like proxy servers and browser caches.
To enable blob caching you need to modify only one line in the web.config file:
Just change the false in the enabled attribute to true and update the location attribute to point to a location where sufficient disk space is available. For best performance ensure to set the maxSize attribute to a value that is at least as big as all binary objects in your Web Application.
You can control which file types are cached by modifying the file extension list in the path attribute.
Responsible for the processing of the disk caching logic is the following entry in HttpModules section of the web.config file:
This HttpModule implements the required logic that decides whether a file can be served from the disk cache or if it has to be retrieved from the backend database.
Important to know is that even that this HttpModule is located in the WCM Publishing namespace you its functionality is not limited to publishing sites. Other site collection types like team sites can also use this functionality.
Limitations of Blob Caching
1) Blob caching does not support web gardening
One major limitation is that blob caching should not be used with web gardening. The reason is that each process requires exclusive access to it's instance of the blob cache. That means that only one worker process can access a single instance of the blob cache. Web Gardening means that multiple worker processes serve content for the same application pool. Only the first process of a web garden will then benefit from blob caching which would mean that web gardening would cause negative impact on the overall performance.
2) Blob caching cannot be used with host named site collections
The blob caching engine uses the server relative path to decide if an item in the cache belongs to a URL or not. With host named site collections an additional criteria come into play: the "host" http header. The blob cache engine on the other hand is not aware about host named site collections. That means if you have two site collections with items that have the same server relative URL (e.g. items in the style library) but are different the item that was first hit gets cached and served for all other host named site collections as well.
3) A cached item is only available in one frontend server
The blob cache is a per server cache. That means if an item has been cached on server 1 and the next request for the same item hits server 2 then the item has to downloaded again to the second frontend server. That means the load on a SQL backend server can be higher in the startup phase if multiple frontend servers exist as the same item might have to be downloaded multiple times to the different frontend servers.
I found this blog interesting and thought of sharing to you all.
Blob caching allows caching of binary objects like images, style sheets and documents on the MOSS front end server machine which heavily reduces the traffic to the SQL backend server as each file has to be downloaded only once to the blob cache per frontend server.
The benefit is that although the items are now retrieved from the MOSS 2007 frontend server the same security and versioning capabilities exist as if the file would only live in the SQL backend database. The blob cache mechanism also ensures that an item in the cache is invalided as soon as the file changes in the backend database. So that is different from other file caches like proxy servers and browser caches.
To enable blob caching you need to modify only one line in the web.config file:
Just change the false in the enabled attribute to true and update the location attribute to point to a location where sufficient disk space is available. For best performance ensure to set the maxSize attribute to a value that is at least as big as all binary objects in your Web Application.
You can control which file types are cached by modifying the file extension list in the path attribute.
Responsible for the processing of the disk caching logic is the following entry in HttpModules section of the web.config file:
This HttpModule implements the required logic that decides whether a file can be served from the disk cache or if it has to be retrieved from the backend database.
Important to know is that even that this HttpModule is located in the WCM Publishing namespace you its functionality is not limited to publishing sites. Other site collection types like team sites can also use this functionality.
Limitations of Blob Caching
1) Blob caching does not support web gardening
One major limitation is that blob caching should not be used with web gardening. The reason is that each process requires exclusive access to it's instance of the blob cache. That means that only one worker process can access a single instance of the blob cache. Web Gardening means that multiple worker processes serve content for the same application pool. Only the first process of a web garden will then benefit from blob caching which would mean that web gardening would cause negative impact on the overall performance.
2) Blob caching cannot be used with host named site collections
The blob caching engine uses the server relative path to decide if an item in the cache belongs to a URL or not. With host named site collections an additional criteria come into play: the "host" http header. The blob cache engine on the other hand is not aware about host named site collections. That means if you have two site collections with items that have the same server relative URL (e.g. items in the style library) but are different the item that was first hit gets cached and served for all other host named site collections as well.
3) A cached item is only available in one frontend server
The blob cache is a per server cache. That means if an item has been cached on server 1 and the next request for the same item hits server 2 then the item has to downloaded again to the second frontend server. That means the load on a SQL backend server can be higher in the startup phase if multiple frontend servers exist as the same item might have to be downloaded multiple times to the different frontend servers.
I found this blog interesting and thought of sharing to you all.
Friday, August 21, 2009
Features--- a component for deployment
Let me talk something on features... playing a very good role in Microsoft Office Sharepoint Server. It is a building block for creating sharepoint solutions. Its a unit of design,implementation and deployment. It mainly contains two xml files such as
1.Features.xml
2.Elements.xml
Feature are activated\deactivated at different levels such as
Farm level
Web application level
Site Collection level
Site level
1.Features.xml
2.Elements.xml
Feature are activated\deactivated at different levels such as
Farm level
Web application level
Site Collection level
Site level
Thursday, August 20, 2009
In MOSS 2007 we have two main things and they are
1.Administrative part
2.WSS object model for customizing the sharepoint pages
With administrative previleges one can create(delete) and many more operations. Specially for the customization of sharepoint pages we use Windows Sharepoint Services 3.0 object model.
In the front end web server we have virtual directory which has different folders created under the path as c:\program files\common files\microsoft shared\web server extensions\12\bin known as system directory. Under the system directory inside the bin folder we have stsadm.exe which is a command line utility for creating new site collections and used for activating and deactivating the features. Features provide a mechanism for defining site elements and adding them to a target site or site collection through a process known as "feature activation".
1.Administrative part
2.WSS object model for customizing the sharepoint pages
With administrative previleges one can create(delete) and many more operations. Specially for the customization of sharepoint pages we use Windows Sharepoint Services 3.0 object model.
In the front end web server we have virtual directory which has different folders created under the path as c:\program files\common files\microsoft shared\web server extensions\12\bin known as system directory. Under the system directory inside the bin folder we have stsadm.exe which is a command line utility for creating new site collections and used for activating and deactivating the features. Features provide a mechanism for defining site elements and adding them to a target site or site collection through a process known as "feature activation".
Wednesday, August 19, 2009
Shared Service Provider and Search Database
We have one SSP per farm. SSP is a repository for the data store such as
People Profile
Audience Data
Business Application Data(such as SAP,Siebel etc)
BI Methods
Site Usage data
Infopath Form Services Session state information
Search Database: Each SSP will enable search services per farm.
one search database is created for each SSP
This database doesn't need to be backed up
The Search DB serves as the data store for the following
History Log
Search Data
Search Log
People Profile
Audience Data
Business Application Data(such as SAP,Siebel etc)
BI Methods
Site Usage data
Infopath Form Services Session state information
Search Database: Each SSP will enable search services per farm.
one search database is created for each SSP
This database doesn't need to be backed up
The Search DB serves as the data store for the following
History Log
Search Data
Search Log
Subscribe to:
Posts (Atom)