Upgrading VSeWSS 1.1/1.2/1.3 Projects to target SharePoint 2010

Paul Andrew has just released the VSWeWSS Upgrade Tool to upgrade your existing VSeWSS 1.1 or 1.2 or 1.3 projects to target SharePoint 2010 projects. This tool, extends the Visual Studio 2010 SharePoint projects and allows you to import your VSeWSS project.

 

This tool comes with source, so you get to see all the fun building and extending VS2010 SharePoint Tools :)

 

So, what do you get installing this tool? – A new Visual Studio 2010 SharePoint project template!

 

image

 

The Import VSeWSS Project extends the SharePoint Customization Wizard and gives you this wonderful wizard to import your project:

 

image

 

Select the SharePoint site, trust level and browse to select your VSeWSS project and click Finish to upgrade your project!

 

Please note that this tool supports only importing one project at a time. After import, you may still need to test your project and arrange the SharePoint solutions and SharePoint features.

P.S: Now you know why there were no blog posts recently by me ;)

Toggle SharePoint User Interface between SharePoint 2007 and SharePoint 2010

Just released the SharePoint Toggle UI project to Codeplex: http://sptoggleui.codeplex.com/

 

If you are one of those users who is still getting used to the new SharePoint 2010 user interface, you can now switch between the familiar SharePoint 2007 user interface and the new SharePoint 2010 user interface back and forth!

 

After installing the SharePoint Toggle UI, you get the option in the Site Actions menu

 

toggleui-action

 

Click on Toggle Visual Mode to switch to SharePoint 2007 user interface

 

2007ui

 

Notice you still have the SharePoint 2010 out of the box Visual Upgrade options enabled

 

visual-upgrade

 

Click again on Site Actions | Toggle Visual Mode to switch to SharePoint 2010 user interface!

 

SharePoint Guidance: Developing SharePoint Applications

The patterns & practices SharePoint Guidance team have just released a new Guidance for Developing SharePoint Applications. Whether you are a newbie or an intermediate or an experienced SharePoint developer, this guide is going to help you improve your SharePoint development skills. Many people (at least the newbies) fail to get the SharePoint basics right and this guide explores various application and design patterns to help build a good SharePoint application.

From the guide:

This guidance covers the following subjects in the context of SharePoint applications:

  • It describes how to use application and design patterns to help solve common development challenges.
  • It describes the design and use of the SharePoint Guidance Library, which is a set of reusable components.
  • It describes how to design and secure a site topology.
  • It describes how to design and implement an application that is scalable, manageable, and configurable.
  • It describes how to integrate a SharePoint application with Web services. This includes security options and design tradeoffs.
  • It describes how to develop a SharePoint application that can publish and deploy content.
  • It describes flexible approaches to navigation and branding, including how to implement custom cross-site collection global navigation and custom site navigation.
  • It includes guidance on many of the common decisions that developers encounter, such as choosing between a list and database.
  • It includes implementation examples that are demonstrated in the Partner Portal application, the Training Management application, and in the QuickStarts.
  • It includes guidance on testing. For example, there are discussions on unit tests, build verification tests, and continuous integration tests.
  • It includes a discussion of scale and stress testing that uses the Partner Portal application as an example.
  • It describes how to set up different team build and testing environments.
  • It describes how to manage the application life cycle through development, test, deployment, and upgrading.
  • It describes a team-based application development.

You can download the guide here.

Just for the heads up, the guidance also has the SharePoint Guidance Library logging and tracing component that can be included in your SharePoint applications to log events/error messages.

jQuery Web Parts for SharePoint – Release v1.0.0.0

jQuery Web Parts for SharePoint brings the various jQuery UI elements to SharePoint as web parts. It uses jQuery SmartTools to integrate jQuery in SharePoint.

Installation Instructions

Available Web Parts
- Accordion Web Part for Announcements List
- News Ticker Web Part for Announcements List
- Image Cycle Web Part for Pictures Library

Screenshots

Accordion Web Part

accordion_webpart.png

News Ticker Web Part

newsticker_webpart.png

Image Cycle Web Part

imagecycle_webpart.png

 

To download, visit the CodePlex site.

Item-level Permissions for Document Libraries – Release v1.1.0.0

Just released Item-level Permission for Document Libraries v1.0.0.0. You can get it here.

ilp_documents_settings_page

Changes in v1.1.0.0

- ILP now uses SharePoint Solution Installer for installation/un-installation

- Fixed a bug with Timer Job & RunWithElevatedPriviliges

- Changed the visibility of the ILP site columns, ILP list instance. They are now visible in the site.

- Added the ability for developers to hook their own event handlers. Read more here >> Info for developers

Known Issues

- If you are using the API to enable ILP & register your custom event handlers, you have to use the API again to disable ILP & un-register your custom event handlers to the corresponding document library or list.

Item Level Permission for Document Libraries – Release v1.0.0.0

 

[There is currently some problem with CodePlex and I am not able to upload my files or source code in my CodePlex project. This project will be eventually moved to CodePlex soon.]

This project is now available at CodePlex – http://ilp.codeplex.com 

--------------------------------------------------------------------------------------------

--------------------------------------------------------------------------------------------

ILP enables item-level permission for document libraries and also allows users to select a set of default permissions that can be applied to the new items and existing items in the document library.

Installation

Execute the install.bat to install. You will be prompted for two Urls – Web Application Url and Web Url.


ILP for Document Libraries will be activated in the Web Url you specify above. So in my above example screenshot, the ILP will be available for the root web / in the http:/sample web application.

How to activate for any other web?

Go to the Site Settings for your web and click on Site Features.


Activate the ILP:Item level permission library settings feature

ilp_feature_activate

Once activated, ILP will be available to that web.

To uninstall, execute the un-install.bat script.

Usage

You can locate the Item-level permissions for the document library in the document library's Settings Page under the Permissions and Management tab

ilp_settings

Click on the Item-level permissions for this document library to open the item-level permissions page


ilp_documents_settings_page

You can now specify your options

  • Require new items to inherit parent permissions?
    • Choosing Yes will enable item-level permission for this document library
    • Choosing No will disable item-level permission for this document library.
  • Default Permission Levels
    • Any additional permissions you might like to give to the new items
    • Choose a Permission Level and then select the groups. Groups == SharePoint Groups.
    • If left empty, nothing happens.
  • Permissions to existing items
    • This helps to update the existing items in the list.
    • If ILP is enabled
      • Choosing Yes will set ILP for existing items in the document library, inherit parent permissions and also apply any default permission levels (chosen in Step 2, if any).
      • Choosing No will not modify existing items in the document library.
    • If ILP is not enabled
      • Choosing Yes will disable ILP for existing items in the document library and copies the parent permissions back.
      • Choosing No will not modify existing items in the document library.

 

 

 

 

Developers, Developers, Developers – ILP API

If you are a devleoper and want to consume the ILP API, you can do so.

Download the latest ilp_api_{version}.zip. Unzip and add reference to the the Chaks.SharePoint.Docs.ILP.dll in your project

You can now use the Extension method EnableItemLevelPermissions on the SPList object.

Below is the declaration of the EnableItemLevelPermissions method:

ilp_enableitemlevelpermissions

It accepts ItemLevelPermissionSettings as the only parameter

ilp_itemlevelpermissionsettings

  • EnableItemLevelPermissions
    • Specify whether to enable ILP or not
  • DefaultGroups
    • List of default SharePoint groups you want to apply to the items
  • DefaultPermissionLevel
    • The default permission level you want to apply to the items
  • ApplyToExistingItems
    • Specify whether to apply the changes to the existing items or not

You can safely ignore EventReceiverAssembly and EventReceiverClass as it is internally used by the ILP to hook to the proper event receiver. From next release onwards, developers will be able to hook up to their own event receivers using these two peoperties.

Using the API

Below are some code samples on using the API

 

 

using Chaks.SharePoint.Docs.ILP;

namespace ConsoleApplication
{
    class Program
    {
        static void Main(string[] args)
        {
            using (SPSite spSite = new SPSite("http://sample"))
            {
                using (SPWeb spWeb = spSite.RootWeb)
                {
                    SPList imagesList = spWeb.Lists["Site Collection Images"];

                    List<SPGroup> spGroups = new List<SPGroup>();
                    spGroups.Add(spWeb.SiteGroups[1]);
                    spGroups.Add(spWeb.SiteGroups[2]);

                    ItemLevelPermissionSettings settings = new ItemLevelPermissionSettings
                                                               {
                                                                   EnableItemLevelPermissions = true,
                                                                   DefaultPermissionLevel = spWeb.RoleDefinitions["Full Control"],
                                                                   DefaultGroups = spGroups,
                                                                   ApplyToExistingItems = true
                                                               };

                    imagesList.EnableItemLevelPermissions(settings);

                    Console.WriteLine("Permissions applied....Press any key to continue");
                }
            }

            Console.ReadKey();
        }
    }
}

You can pass null if you dont intend to apply any default permission level and default groups

ItemLevelPermissionSettings settings = new ItemLevelPermissionSettings
{
     EnableItemLevelPermissions = true,
     DefaultPermissionLevel = null;
     DefaultGroups = null;
     ApplyToExistingItems = true
};

Note

Even though ILP for Document Libraries is meant only for Document Libraries (as the same suggests), using the API, you can also apply it to a SharePoint List.Please note that, it does not override the SharePoint out of the box Permissions settings and thus if you have already set up unique permissions for a SharePoint list, they will also be applied along with the ILP settings.

Downloads

StsAdmin Extension Utility – createsitecolumn

NOTE: As of June 26th, 2009, this utility has a new home - http://csc.codeplex.com/

Feel free to post your feature suggestions or any bugs related to StsAdm 'createsitecolumn' extension here

======================================================= 

Here is my first ever stsadm.exe command extension! – createsitecolumn

stsadm.exe -o createsitecolumn -url http://mysite -name MyTextField -type Text -group Examples

stsadm.exe -o createsitecolumn -url http://mysite -name MyChoiceField -type Choice -group Examples -choices 4,5,3

stsadm.exe -o createsitecolumn -url http://mysite -name MyChoiceField -type MultiChoice -group Examples -choices “Choice A”,”Choice B”

Currently supported column types are as follows:

  • Text
  • Note
  • Choice
  • Boolean
  • Calculated
  • Currency
  • Number
  • User
  • URL
  • DateTime
  • MultiChoice

If there exists a site column already, the command will delete that site column and create again with the supplied values. This is one of the places I require your valuable feedback – whether to delete the site column if its already present

Installation

Extract the stsadm-createsitecolumn-extension.zip and run the Setup.exe. Make sure you deploy the solution only to central administration.

 

Below are the installation screenshots

createsitecolumn-installer-1

createsitecolumn-installer-2

createsitecolumn-installer-3

createsitecolumn-installer-4

createsitecolumn-installer-5

After successful installation, you can check the extension using this command: stsadm –help createsitecolumn 

createsitecolumn-help-message

Feel free to comment or email me if you have find any bugs or any suggestions! I am very happy to get your feedback.

SPVisualDev & MOSS Feature Generator - Must have tools for SharePoint devs

Here is an interesting tool called SPVisualDev. Thought I could share with everyone :)

Without much boring texts, here is what you get with this wonderful tool

First, it creates this lovely folder structure for your project :)

clip_image001

You can easily specify the target for your project

clip_image002

Real time sync files from your local visual studio project with files in the 12-hive

clip_image003

Easy to add new features

clip_image004

Easy to edit feature settings

clip_image005

Easy to add ‘elements’ to your feature

clip_image006

Easy to install / activate SharePoint features from context menu

clip_image007

Integrates well with WSPBuilder

clip_image008

What else a SharePoint dev need! :)

Visit the SPVisualDev project home page for more info and downloads

Another cool project worth mentioning is the MOSS Feature Generator. The MOSS Feature Generator generates features out of existing functionalities on a MOSS 2007 site. This includes Site Columns, Content Types and ListTemplates (including schema.xml and forms). The tool will be expanded in two ways: a build tree will be created to make it possible to create dependant features in an organized way, and the number of supported features will be expanded.

SharePoint Designer is now Free!

Yep! Microsoft Office SharePoint Designer 2007 is now free ! Grab your copy here

MIcrosoft Office SharePoint Designer 2007 Free Download ( c ) Microsoft

SharePoint: Newbie? Unable to find Developer Help?

Are you a newbie to SharePoint development? (or) Are you looking for a one place where you can find information about help in SharePoint products and technologies?

Andrew Connell has written an excellent article regarding finding developer help for SharePoint products and technologies. Discover where to find the SDKs, peer-to-peer forums, MSDN developer centers, and Microsoft TechNet resources you need as you develop with Microsoft SharePoint Products and Technologies.

Even if you know SharePoint, the article is quite helpful and worth to be bookmarked ;)

Code Snippets: Upload and Download a file from Sharepoint Document Library

Here are sample code snippets to upload and download a file from Sharepoint Document Library

Upload a File:

   1: public static void UploadDocument(string siteCollectionUrl, 
   2:                             string siteUrl,string libraryName)
   3: {
   4:     using (SPSite hostSite = new SPSite(siteCollectionUrl))
   5:     {
   6:         #region Reading a file
   7:  
   8:         string filename = "C:\\TFS.doc";
   9:         FileInfo fInfo = new FileInfo(filename);
  10:         long numBytes = fInfo.Length;
  11:         FileStream fStream = 
  12:             new FileStream(filename, 
  13:                            FileMode.Open, 
  14:                            FileAccess.Read);
  15:         BinaryReader br = new BinaryReader(fStream);
  16:         byte[] fileBuffer = br.ReadBytes((int)numBytes);
  17:         br.Close();
  18:         fStream.Close();
  19:  
  20:         #endregion
  21:  
  22:         #region Fields
  23:  
  24:         Dictionary<string, string> DocumentFields = 
  25:                           new Dictionary<string, string>();
  26:         DocumentFields.Add("Status", "Received");
  27:  
  28:         #endregion
  29:  
  30:         #region Upload File into the Document Library
  31:  
  32:         using (SPWeb targetWeb = hostSite.OpenWeb(siteUrl))
  33:         {
  34:             DateTime submissionDate = DateTime.Now;
  35:             SPList submissionsList = targetWeb.Lists[libraryName];
  36:             SPFolder folder = submissionsList.RootFolder;
  37:  
  38:             string fileName = "Sample.doc";
  39:  
  40:             SPFile newSubmissionFile = folder.Files.Add(fileName,fileBuffer);
  41:  
  42:             SPListItem submissionItem = newSubmissionFile.Item;
  43:  
  44:             foreach (KeyValuePair<string, string> documentField in DocumentFields)
  45:             {
  46:                 submissionItem[documentField.Key] = documentField.Value;
  47:             }
  48:  
  49:             submissionItem.Update();
  50:         }
  51:  
  52:         #endregion
  53:     }
  54:  
  55:     Console.WriteLine("File Uploaded Successfully!");
  56: }

Download a File:

   1: public static void DownloadDocument(string siteCollectionUrl, 
   2:                     string siteUrl, string libraryName, string fileName)
   3: {
   4:     using (SPSite hostSite = new SPSite(siteCollectionUrl))
   5:     {
   6:         #region Download the File from the Document Library
   7:  
   8:         using (SPWeb targetWeb = hostSite.OpenWeb(siteUrl))
   9:         {
  10:             DateTime submissionDate = DateTime.Now;
  11:             SPList submissionsList = targetWeb.Lists[libraryName];
  12:             SPFolder folder = submissionsList.RootFolder;
  13:             SPFile targetFile=targetWeb.GetFile(folder.Url + "/" + fileName);
  14:  
  15:             if (targetFile.Exists)
  16:             {
  17:                 byte[] fileContents = targetFile.OpenBinary();
  18:  
  19:                 if (!File.Exists(fileName))
  20:                 {
  21:                     File.Create(fileName)
  22:                         .Write(fileContents, 0, 
  23:                                fileContents.Count());
  24:  
  25:                     Console.WriteLine("File saved successfully");
  26:                 }
  27:                 else
  28:                 {
  29:                     Console.WriteLine("File Already Exists");
  30:                 }
  31:             }
  32:         }
  33:  
  34:         #endregion
  35:     }
  36: }

Creative Commons License
Chaks' Corner Blog by Chakkaradeep Chandran is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License.
Based on a work at www.chakkaradeep.com.
Permissions beyond the scope of this license may be available at http://www.chakkaradeep.com.