Thursday, 12 October 2017

SharePoint Interview Questions and Answers

26. Difference between SharePoint-hosted apps, Provider-hosted apps and Auto-hosted apps:

SharePoint-hosted apps (SharePoint Add-ins)

SharePoint-hosted apps are installed on a SharePoint 2013 website, called the host web. They have their resources hosted on an isolated subsite of a host web, called the app web.

In SharePoint Hosted Apps , No Server Side is allowed, you need to write all business logic in Javascript

A SharePoint-hosted app may provision basic resources into its app web such as HTML/CSS/JS files, site column/content type/list definitions, etc. Under no circumstances can server-side code run within a SharePoint-hosted app.

Provider-hosted apps

Provider-hosted apps for SharePoint include components that are deployed and hosted outside the SharePoint server. They are installed to the host web, but their remote components are hosted on another server.

In Provider Hosted Apps you can write code in CSOM and  even take advantage of frameworks like ASP.NET MVC (or  Java, PHP, or other non-Microsoft technologies as well), but you are also responsible for things like tenant isolation.

Auto-hosted apps:

Auto hosted apps are currently available only on Office 365. They differ from provider-hosted apps by fact that they are deployed fully to cloud.

27. What is  Remote event receiver in SharePoint 2013 ?

In SharePoint 2013, a new concept, Remote Event Receivers, has been introduced, where the event generated by a SharePoint app could be listened to and handled by the SharePoint Server. .

28 . What is Timer Job in  SharePoint 2013 ?

A Timer Job is a periodically executed task inside SharePoint Server. It provides us a task execution environment. For example, we can execute tasks like: sending emails every hour, data updating every day, creating reports every week, etc.

Default Timer Jobs inside SharePoint:

There are many timer jobs inside SharePoint which do internal tasks like:

Send emails

Validate sites

Delete unused sites

Health analysis

Product versioning

Diagnostics

These tasks will having execution periods like:

Minute

Hour

Day

Week

Month.

29.  What is SPJobDefinition class  ?

Derive CustomTimerJob Class from SPJobDefinition

Add the three Constructors of the derived class : Whenever we create the object of CustomTimerJob  class, corresponding constructor will execute.

Override the Execute method: Whenever the timer job start running then the code inside the Execute method will run.

We need to create a Feature and Feature Receiver so on activation of this feature we are going the add our timer job to SharePoint farm.

Create a Custom Timer Job in SharePoint is very simple, you can declare a class which inherits from SPJobDefinition and overrides the Execute method as shown in the following example :

        public class SampleTimerJob : SPJobDefinition

    {

        public const string JOBNAME = "SAMPLETIMERJOB";

        public const string JOBTITLE = "Sample Timer Job";

 

        public SampleTimerJob()

        {

            this.Title = JOBTITLE;

        }

 

        public SampleTimerJob(SPWebApplication webApplication)

            : base(JOBNAME, webApplication, null, SPJobLockType.Job)

        {

            Title = JOBTITLE;

        }

 

        public override void Execute(Guid targetInstanceId)

        {

            // write your code here

        }

    }

.

30.  What is SPJobLockType class ?

All timer jobs in SharePoint have scope, on which they need to be run, and this can be a farm level, a server level and a content database level,

SPJobLockType is a enum, having three value that is Job, None and Content Database

Job means this timer job will run only once per server per iteration.

None means this timer job will run once per server.

Content Database means this job will run once for each content database.

You can see these times job by Powershell script

To retrieve all farm-scoped jobs

Get-SPTimerJob | ? {$_.LockType -eq “Job”}

To retrieve all server-scoped job

Get-SPTimerJob | ? {$_.LockType -eq “None”}

To retrieve content database-scoped jobs

Get-SPTimerJob | ? {$_.LockType -eq “ContentDatabase”} | Select-Object -Unique | Sort-Object Name | Format-Table Name


SPJobLockType is a  enumeration and namespace for this is Microsoft.SharePoint.Administration and assembly is Microsoft.SharePoint


 

Thank you very much

          Fahadullah Karimi

         SharePoint Specialist


Previous SharePoint Interview Questions And AnswersNext SharePoint Interview Questions and Answers

No comments:

Post a Comment