Monday, April 23, 2012

Implement your own custom provider to generate unique IDs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Office.DocumentManagement;
  
namespace CustomDocIDProvider
{
    class CustomDocIDProvider :
Microsoft.Office.DocumentManagement.DocumentIdProvider
    {
        public override bool DoCustomSearchBeforeDefaultSearch
        {
           //property used to trigger our custom search first.If false then we will use the SharePoint search when retreiving
            Document IDs
            get
            {
                return false;
            }
        }
  
        //We implement our logic to generate an ID returned as a string
        public override string GenerateDocumentId(Microsoft.SharePoint.SPListItem
        listItem)
        {
            DateTime CurrTime = DateTime.Now;
            return CurrTime.ToString(); 
        }
  
        //Implement our own finder method.Return empty if no results
        public override string[] GetDocumentUrlsById(Microsoft.SharePoint.SPSite
        site, string documentId)
        {
            string[] searchhits = new string[0];
            return new string[0];
        }
  
        //Sample text used in web parts and UI
        public override string GetSampleDocumentIdText(Microsoft.SharePoint.SPSite
        site)
        {
           
            return "Date";
        }
    }
}   

No comments:

Post a Comment

Thank you for Commenting Will reply soon ......

Featured Posts

#Linux Commands Unveiled: #date, #uname, #hostname, #hostid, #arch, #nproc

 #Linux Commands Unveiled: #date, #uname, #hostname, #hostid, #arch, #nproc Linux is an open-source operating system that is loved by millio...