Thursday, July 7, 2011

SharePoint : Connected Webparts

Creating connected webparts involves the below steps.
 
Create an Interface  
 
         public interface ITextBoxString
Create a property which would be returning a reference to the interface.
         public interface ITextBoxString
        {
            string TextBoxString { get; set; }
        }

Provider Webpart
 Implement the interface.

         public class StringProvider : WebPart, ITextBoxString

 
create a property which would be returning the interface reference decorate it with ConnectionProvider

         [ConnectionProvider("Provider for Text Value", "TextBoxStringProvider")]
         public ITextBoxString TextBoxStringProvider()
        {
            return this;
        }
 
Consumer web part
     It should contain the method which would receive the interface.The method should be decorated with ConnectionConsumer attribute.
     
          [ConnectionConsumer("String Consumer", "StringConsumer")]
          public void TextBoxStringConsumer(ITextBoxString Provider)
         {
            _myProvider = Provider;
         }


YOU ARE ALL SET!

SharePoint : SPJOBLockType

Specifies the lock type for a given timer job definition.


There are 3 Locks available..
  1. SPJobLockType.None -- if you set it none, the instance will run in all the available servers in the Farm (e.g. Application Server Timer Job)
  2. SPJobLockType.ContentDatabase – this will cause 3 instances to be running in each of the Web-Frontends.in short, it’s almost the same as the Job one, meaning that it only runs one server.
  3. SPJobLockType.Job – this will cause only one instance of the job to run on any of the front-end servers. (Note: it is possible to see multiple instances listed in the Job Status .. but if you look at the time it was last run.. only one would have run lately.