forked from SharePoint/PnP-Partner-Pack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPnPPartnerPackProvisioningJob.cs
More file actions
48 lines (41 loc) · 1.63 KB
/
Copy pathPnPPartnerPackProvisioningJob.cs
File metadata and controls
48 lines (41 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
using Microsoft.SharePoint.Client;
using OfficeDevPnP.Core.Framework.TimerJobs;
using OfficeDevPnP.PartnerPack.Infrastructure;
using OfficeDevPnP.PartnerPack.Infrastructure.Jobs;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OfficeDevPnP.PartnerPack.ScheduledJob
{
public class PnPPartnerPackProvisioningJob : TimerJob
{
public PnPPartnerPackProvisioningJob(): base("PnP Partner Pack Provisioning Job")
{
TimerJobRun += ExecuteProvisioningJobs;
}
private void ExecuteProvisioningJobs(object sender, TimerJobRunEventArgs e)
{
Console.WriteLine("Starting job");
// Show the current context
Web web = e.SiteClientContext.Web;
web.EnsureProperty(w => w.Title);
Console.WriteLine("Processing jobs in Site: {0}", web.Title);
// Retrieve the list of pending jobs
var provisioningJobs = ProvisioningRepositoryFactory.Current.GetTypedProvisioningJobs<ProvisioningJob>(
ProvisioningJobStatus.Pending);
foreach (var job in provisioningJobs)
{
Console.WriteLine("Processing job: {0} - Owner: {1} - Title: {2}",
job.JobId, job.Owner, job.Title);
Type jobType = job.GetType();
if (PnPPartnerPackSettings.ScheduledJobHandlers.ContainsKey(jobType))
{
PnPPartnerPackSettings.ScheduledJobHandlers[jobType].RunJob(job);
}
}
Console.WriteLine("Ending job");
}
}
}