Wednesday, 14 October 2009

Composit Control Tips

Came across this useful link about Composite Control.

http://skysigal.xact-solutions.com/Articles/tabid/434/ctl/ArticleView/mid/1024/articleId/36/Default.aspx

Friday, 18 September 2009

Read RSS and Atom feed in C#

I had a requirement to read RSS/Atom feeds from blogs and store in SharePoint List.
I remember we had to go for separate framework to read the feeds and parse it. In that case we need to refer the framework in our project and install that assembly in Bin or GAC.

Now with .Net 3.5, life has become much easier.

Yes, with the namespace 'System.ServiceModel.Syndication' it is just few lines of code to read and parse the feeds either RSS or Atom.

Just add reference to 'System.ServiceModel.Web' to your project and include above namespace in your class, thats it.

Below is the code i used.

XmlReader reader = XmlReader.Create(curUrl);
SyndicationFeed feed = SyndicationFeed.Load(reader);
string title = String.Empty;
string link = String.Emplty;
DateTime dateTime = null;
foreach (var feeditem in feed.Items)
{
title = feeditem.Title.Text;
dateTime = feeditem.PublishDate.LocalDateTime;
link = feeditem.Links[feeditem.Links.Count -1].Uri.OriginalString;

//Do your tasks here
}

East to deploy and maintain too.

Happy Coding

வாழ்க வளமுடன் :)

Useful SharePoint Links

Some Useful SharePoint links


Accessing Data from Workflow Association and Initiation Forms in Windows SharePoint Services 3.0
Best Practices: Common Coding Issues When Using the SharePoint Object Model
Best Practices: Using Disposable Windows SharePoint Services Objects
Checklist for Creating SharePoint Web Parts
Creating Custom Timer Jobs in Windows SharePoint Services 3.0
Creating a Windows SharePoint Services 3.0 Custom Field by Using the EntityPicker
Creating a Windows SharePoint Services 3.0 Web Part Using Visual Studio 2005 Extensions
Development Tools and Techniques for Working with Code in Windows SharePoint Services 3.0 (Part 1 of 2)
Development Tools and Techniques for Working with Code in Windows SharePoint Services 3.0 (Part 2 of 2)
Securing Application Pages in Windows SharePoint Services 3.0
Selective Content Migration in Windows SharePoint Services 3.0
Understanding and Creating Customized and Uncustomized Files in Windows SharePoint Services 3.0
Understanding the Administrative Object Model of Windows SharePoint Services 3.0
Usage Event Logging in Windows SharePoint Services 3.0
Using Solution Packages to Deploy Features and Content in Windows SharePoint Services 3.0
Workflow Scalability and Performance in Windows SharePoint Services 3.0
Working with ASP.NET 2.0 Web Parts and Windows SharePoint Services 3.0

Wednesday, 22 July 2009

Building CAML Query

Found this useful site details about building CAML query.

http://sharepointmagazine.net/technical/development/writing-caml-queries-for-retrieving-list-items-from-a-sharepoint-list

Thanks Boske.

Thursday, 18 December 2008

SharePoint Tools

Ok friends, its very long since my last post. I will make sure that i update this blog regularly. To start with, here are the tools often used during SharePoint development.

1. SharePoint Tips Utility Pack - Developed by my ex-colleague Ishai.
This tool has many functions. Setting the properties of a field and managing Event Listeners were we largely used among them.
Mate, you are champion. I am really proud that I was your team member. You have answer for all SharePoint questions.

2. Stramit SharePoint 2007 Caml Viewer
This tool can be used to see the GUIDs of any lists and views very easily. Also all the fields and its internal names can be easily seen using this tool.

3. U2U CAML Query Builder
Last but not least, the most useful tool for building CAML queries to use in SharePoint object model coding.

Tuesday, 26 June 2007

"Trying to use SPWeb object that has been closed.." Error

We were getting “Trying to use an SPWeb object that has been closed or disposed and is no longer valid.” in our MOSS -Workflow project.

After investigating all the source codes, I found the error causing statement in WebPart class.

The best practice is to dispose objects either by calling Dispose() in finally block or with using clause.

The snippet causing problem in our project was

SPGroup group;
using (SPWeb web = SPContext.Current.Web)
{
group = web.Groups[“Administrators”];
this.DisplayText = "Submit for Approval";
:
:
}

Here, the object is not really created in the memory, only the reference to the exisiting object is got and used. We should not dispose the current context web object manually in our code.

More information about best practice can be found at
http://msdn2.microsoft.com/en-us/library/ms778813.aspx

Happy Coding :)

Tuesday, 19 June 2007

Extending stsadm.exe with custom actions

Stsadm.exe command can be extended by inheriting
Microsoft.SharePoint.StsAdmin.ISPStsadmCommand interface.

The actual process involves two steps.
  1. Creating the configuration xml file.
  2. Creating a class that implements ISPStsadmCommand interface.
Configuration file
The configuration xml file indicates to stsadm.exe which operations are available. This configuration file must follow well known naming convention stsadmcommands.<customcommands>.xml where <customcommands> can be any meaningful name but must be unique. Through this naming convention for configuration files, stsadm.exe implements a pluggable architecture for declaring custom operations.


<?xml version="1.0" encoding="utf-8"?>

<commands>

<command name="<name for command>" class="<namespace>,<class>,Version=<version>,

Culture=neutral,PublicKeyToken=<token>">

</command>

</commands>


The configuration file itself is a simple XML document with a root element containing one or more sub-elements. These sub-elements are where we declare custom operations and include two attributes name and class. The name attribute indicates the name of the operation to be executed by stsadm.exe. Note that the exact value of the name attribute will be specified by an administrator at runtime using the -o named parameter in order to execute the declared custom operation. The second attribute class specifies the class and .NET Assembly name where our classes that implement the ISPStsadmCommand interface.

.Net assembly
The .Net assembly containing the classes has to be placed in GAC. Each operation requires separate class inheriting ISPStsadmCommand interface. The ISPStsadmCommand interface has two methods to implement.
1. GetHelpMessage – this method returns help and usage information.
2. Run – this method actually does the custom operation.



class CustomActivateFeature : ISPStsadmCommand
{
//method to return help message
public string GetHelpMessage(string command)
{
//named parameters expected
return "-url ";
}

//method called to perform the action
public int Run(string command,
System.Collections.Specialized.StringDictionary keyValues,
out string output)
{

//assign value to variables
if (keyValues.ContainsKey("url"))
{
url = keyValues["url"];
if ((url == null) (url.Length == 0)) output += "url cannot be empty";
:
:


Deployment
The deployment process involves two steps.
1. Copy the configuration file (stsadmcommands.feature.xml) to [12 Hive]\CONFIG folder.
2. Copy the DLL file to GAC.

Now we can perform our custom actions using stsadm.exe by typing

stsadm.exe –o <name we have specified in xml file> <named
parameters> at command prompt.

It can be very useful to include in script/batch file for actions like backup, restore or some other automated actions.