Loading...

Wednesday, November 23, 2011

EnterPrise Content Types:Download Document Sets in Zip Format

What are the Document Sets?
 Its a Content type which  groups documents with a single work item and wrap them into a single version or workflow.
To add a new custom button to the Manage tab of the Document sets ribbon,
To export document sets so that they can be downloaded as a single ZIP file.

1) Create the Empty SharePoint Project.
 Add the reference of  C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\ISAPI\Microsoft.Office.DocumentManagement.dll
C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Web.dll

2) Create the Delegate Control with Site Scope Feature

i) Add the empty element in solution Right click ProjectAdd new Item Add empty element name as RibbonZipDelegateControl. And Delegate Control xml as shown in Image

ii) In Page load event write the logic to export Document Sets to zip file

iii) Add the Safe Control entry in web.config

SafeControl Assembly="DocsetRibbonDelegate, Version=1.0.0.0, Culture=neutral, PublicKeyToken=492efe3bf2c2f2b0" Namespace="DocsetRibbonDelegate" TypeName="DocsetRibbonDelegate"
3) Create Web Scoped Feature for the Custom Action Which Raise DownloadZipDelegateEvent Event (In Manage Tab Of Document Sets)

i) Add the empty element in solution Right click ProjectAdd new Item Add empty elementname it as RibbonDelegateCustomAction. And Delegate Control xml as shown in Image

ii) Create Image Mapped folder to display Icon of Image and Provide its Path in Custom Action
using System;
using Microsoft. SharePoint;
using Microsoft.Office.DocumentManagement.DocumentSets;
using System.Web.UI.WebControls;

namespace DocsetRibbonDeleagate

{

public class DocsetRibbonDelegate : WebControl

{

const string EVENT_NAME = "DownloadZipDelegateEvent";
const string MIME_TYPE = "application/zip";
protected override void OnLoad(EventArgs e)

{

this.EnsureChildControls();
base.OnLoad(e);
if (this.Page.Request["__EVENTTARGET"] == EVENT_NAME)

{

SPListItem currentItem = SPContext.Current.ListItem;

DocumentSet currentDocset = DocumentSet.GetDocumentSet(currentItem.Folder);

this.Page.Response.ContentType = MIME_TYPE;

currentDocset.Export(this.Page.Response.OutputStream, 1024);

this.Page.Response.End();

}

}

}

}

4) Create Web Scoped Feature for the Custom Action Which Raise DownloadZipDelegateEvent Event (In Manage Tab Of Document Sets)
i) Add the empty element in solution Right click ProjectAdd new Item Add empty elementname it as RibbonDelegateCustomAction. And Delegate Control xml as shown in Image

ii) Create Image Mapped folder to display Icon of Image and Provide its Path in Custom Action
 
5) Enable the Document Set Content Type
i) Site Settings Site Collection FeatureEnable Document Sets Feature
ii) In any Document Library Setting Advance SettingsEnable Management of Content types.
iii) Add from existing Content TypesSelect Document Set Content Type
iv) In Document Library, Create new Document Set and Deploy the solution as stated in step 1 and3 Go to Managed tab Export document Set in zip file

msdn References