Download e-book Microsoft SharePoint 2010 Web Applications The Complete Reference

Free download. Book file PDF easily for everyone and every device. You can download and read online Microsoft SharePoint 2010 Web Applications The Complete Reference file PDF Book only if you are registered here. And also you can download or read online all Book PDF file that related with Microsoft SharePoint 2010 Web Applications The Complete Reference book. Happy reading Microsoft SharePoint 2010 Web Applications The Complete Reference Bookeveryone. Download file Free Book PDF Microsoft SharePoint 2010 Web Applications The Complete Reference at Complete PDF Library. This Book have some digital formats such us :paperbook, ebook, kindle, epub, fb2 and another formats. Here is The CompletePDF Book Library. It's free to register here to get Book file PDF Microsoft SharePoint 2010 Web Applications The Complete Reference Pocket Guide.

SharePoint does not have a mechanism to register a job definition by itself, so it does not have a list of the available job definitions. SharePoint only maintains a list of timer job instances that have been scheduled i. So the Review Job Definitions page is really a list of timer job instances that have been scheduled.

Adding to the confusion, there is also a link from the Review Job Definitions page to Scheduled Jobs. Since a timer job instance needs to be scheduled before it can be used, you would think this page contains a list of timer job instances that have been scheduled. The main difference is that this page displays, and is sorted by, the Next Start Time which informs you when the job will run next instead of by Title.

Timer jobs with schedules that have been disabled will also not appear on this list, so it may have a fewer number of items listed than the Review Job Definitions page. Clicking on the Title from either page takes you to the same timer job instance configuration page that allows you to modify the schedule of the timer job instance. It may also be associated with a server SPServer if you desire, but it is not a requirement.

Without getting into many of the technical details, SharePoint automatically persists state information about SharePoint objects in the farm using a tree-like structure of SPPersistedObject instances. The root of this tree is the SharePoint Farm itself an SPFarm object and includes the various web applications, services, and a myriad of other SharePoint objects that reside in the farm. What this means for you, the developer, is that there are two main constructors for the SPJobDefinition class.

One of the constructors allows you to associate the timer job with a web application, and the other allows you to associate it with a service application. You will need to determine which one is best suited for your situation, a chore that should be relatively simple.

Blog & Events

If you are developing a service application, then it should be associated with that service application. Otherwise, it should be associated with a web application. I recommend associating it with the Central Administration web application, which will be demonstrated later on in this article. You also have the option of associating a timer job with a specific server in the farm SPServer. By doing so, it means that your timer job will only run on that one server. A server can be specified for either one of the constructors. In case you were curious, server association has absolutely nothing to do with the SPPersistedObject hierarchy.

McGraw-Hill EMEA | Transforming The Education Experience | McGraw-Hill Education

You can get a reference to the web application associated with the Central Admin site through the SPWebAdministration. Local property. Just pass this as the web application to the web application constructor and your timer job will be associated with the Central Admin Web Application. It has to be associated with a web application or service application because it must have a parent in the SPPersistedObject hierarchy for the farm.

As mentioned before, the server associated with a timer job instance has nothing to do with that persistence hierarchy.

  • Industrial Boilers and Heat Recovery Steam Generators. Design, Applications, and Calculations!
  • Neural Networks in Finance?
  • SharePoint People Picker 2.x.0.0.
  • Invasion 1914: The Schlieffen Plan to the Battle of the Marne.

Nice try, but no. If you attempt to get around the association by passing null into the constructor for either the web application or service application, it will result in a null object reference exception when that constructor is called in your code. As you would hopefully expect, associating a timer job with any of these items results in these properties being populated with a reference to the associated item.

Writing a timer job definition is extremely easy. All you have to do is create a class that inherits from SPJobDefinition , implement a few constructors , and override the Execute method. You will need to add a reference to the Microsoft.

Your Answer

If you created a SharePoint project, you should not need to manually add any references to your project to write a timer job. If you need to reference an assembly manually, most of the SharePoint assemblies are located in. Administration namespace. You can, of course, inherit from a different class as long as SPJobDefinition is somewhere in the inheritance chain.

You have two requirements when writing the constructor s for your timer job definition:. You are required to implement a default parameter-less constructor for your timer job for deserialization purposes. The SPJobDefinition class inherits directly from the SPPersistedObject class, which means that SharePoint automatically stores the state of your timer job to a permanent store without you having to implement any of that storage logic.

However, the deserialization mechanism expects a default parameter-less constructor to be present in order to operate correctly. Failure to implement the default constructor will result in the following message when you call. Update from your timer job class:. Remember, your timer job must be associated with one of these two entities. The only time that an association can be created is from the constructors on the SPJobDefinition class, so one of your constructors has to be associated with a call down to the appropriate base constructor.

There are four key pieces of information for which your timer job definition needs to account in the constructor:. Please understand that the two constructor requirements listed previously are not mutually exclusive — in other words, you are not required to have 2 constructors. If you have static values for these four key pieces of information, then you can implement a single default constructor that calls the appropriate base constructor with your static values, as in the following example:.

Notice that the example above satisfies both requirements: the MyTimerJob class exposes a default constructor, that default constructor is calling down to the web application association constructor of the base class, and all four key pieces of information have been provided. Many timer jobs will, however, require information to be passed in via a constructor.

If this is the case, then you will need to implement two constructors: the default parameter-less constructor, and the constructor with the parameters that need to be passed. If you are implementing a default constructor simply for the sake of having it for deserialization purposes, then you will find the following constructor helpful:. Notice that you do not need to worry about passing any values into the base default constructor. Remember, SharePoint uses this constructor for deserialization, so all of the properties required by your timer job will be populated back into the timer job by SharePoint during that deserialization process.

One of the four key pieces of information that you must provide a timer job is the timer job name. Timer jobs have two properties related to naming: Name and DisplayName. The Name property is used to identify a timer job, so it must be unique for the timer job instances that exist under the parent SPService or SPWebApplication with which the timer job is associated.

In other words, you can have two timer jobs with the same name, as long as they exist under different parents. DisplayName should contain the name of the timer job as it will appear in Central Administration. If you do not provide an explicit DisplayName value, the value will default to the value in the Name property.

Since this name is only used as a display value, it does not have to be unique. You should be aware, however, that the timer job instance lists in Central Administration do not display in a hierarchy — they appear as a flat list.

Download Microsoft SharePoint 2010 Web Applications: The Complete Reference Book

As such, you should take care to distinguish the timer job DisplayName in some way for the sake of users. Since the timer job instances reside under different web applications, they can both have the same Name. If you do not give them different display names, this is what users will see in the timer job instance list in Central Administration:. This can be a bit confusing because it looks like the same timer job is defined twice. Be aware that you can also use these custom properties to set both the Name and the DisplayName values to ensure that the name is unique under a given parent and that the user has some way to distinguish between timer jobs in the timer job instance list.

Another one of the four key pieces of information that you must provide the timer job instance constructor is the SPJobLockType value which helps dictate where and how many times the timer job runs. There are three options for this value:. If you are wondering exactly where a timer job will run, know that lock types play a major role in defining that location.

We will cover in more detail how to determine exactly which machine a timer job will run on later on in this article. The main reason you write a timer job is to run code on a periodic basis.

Types of SharePoint Online site content

All of the code you want to run when your timer job executes should be located in the conveniently named Execute method. Simply override the method and put in whatever code you want to run:. As mentioned before, if your timer job has a lock type value of ContentDatabase , then the targetInstanceId parameter is populated with the ID of the content database for which the timer job is being run. Otherwise, you can disregard this parameter. There is really no limit to what you can do inside of this method, so your timer job process can be as simple or as complicated as you like.

Of course, you can implement a lot more complex timer jobs, but for the sake of demonstration I do not want to have an overly complex scenario that takes a lot of time to setup.

Microsoft SharePoint 2010 Web Applications The Complete Reference by Charlie Holland

Plus, it should make it easy to see that your timer job is actually working. The first thing to notice about this class is that it derives from SPJobDefinition class. As mentioned before, all timer job definitions ultimately derive from this class. Next, we have two constructors. The first constructor is a default, parameter-less constructor that is required for serialization purposes. The second constructor mimics the base constructor from SPJobDefinition that associates a timer job with a SharePoint web application.

After the constructors, you will see the overridden Execute method. This is the method that contains any code that you want executed during the timer job. Making a timer job definition is a pretty simple and straightforward process. Once you have a job definition, all that is left to do is create an instance of that definition, set any applicable properties on the instance, and associate instance with a schedule that defines how often the timer job runs. To do this, you have to create an appropriate SPSchedule object and assign it to the Schedule property on your timer job instance.

Since the SPSchedule class is an abstract base class that defines common functionality required for scheduling a timer job, you will not be creating instances of an SPSchedule object directly. SharePoint ships with a number of classes that derive from the SPSchedule class that offer a variety of scheduling options.

Most of these are fairly self-explanatory, but here is the list none-the-less:. Following is an example demonstrating how to schedule the MyTimerJob timer job to run once per day between the hours of a. First, we create an instance of the timer job class.