<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>Jobs</title><link>https://community.telligent.com/community/11/w/developer-training/65095/jobs</link><description /><dc:language>en-US</dc:language><generator>14.0.0.586 14</generator><item><title>Jobs</title><link>https://community.telligent.com/community/11/w/developer-training/65095/jobs</link><pubDate>Tue, 04 Aug 2020 19:30:28 GMT</pubDate><guid isPermaLink="false">e0f6c661-fe3b-496e-9c7d-7098bd1c6c56</guid><dc:creator>Former Member</dc:creator><comments>https://community.telligent.com/community/11/w/developer-training/65095/jobs#comments</comments><description>Current Revision posted to Developer Training by Former Member on 08/04/2020 19:30:28&lt;br /&gt;
&lt;p&gt;Jobs are used to perform an action based on either a&amp;nbsp;dynamic job that may schedule when an event fires, or based on a recurring schedule which executes based on a specified schedule. &amp;nbsp;When jobs are scheduled, the job server will pick up the jobs and execute them.&lt;/p&gt;
&lt;p&gt;[toc]&lt;/p&gt;
&lt;h2&gt;&lt;a id="When_Would_I_Create_Dynamic_Jobs" name="When_Would_I_Create_Dynamic_Jobs"&gt;&lt;/a&gt;When Would I Create Dynamic Jobs&lt;/h2&gt;
&lt;p&gt;When you have a process that needs to occur based on another action occurring and you need the process to run in the background so it does not slow down the current process. &amp;nbsp;&lt;/p&gt;
&lt;h2&gt;&lt;a id="When_Would_I_Create_Scheduled_Jobs" name="When_Would_I_Create_Scheduled_Jobs"&gt;&lt;/a&gt;When Would I Create Scheduled Jobs&lt;/h2&gt;
&lt;p&gt;When you have a process that needs to occur on a recurring&amp;nbsp;basis. &amp;nbsp;&lt;/p&gt;
&lt;h2&gt;&lt;a id="Creating_dynamic_jobs" name="Creating_dynamic_jobs"&gt;&lt;/a&gt;Creating dynamic&amp;nbsp;jobs&lt;/h2&gt;
&lt;p&gt;To create&amp;nbsp;a dynamic job&amp;nbsp;you will need to implement the [[api-documentation:IEvolutionJob Provider Type|IEvolutionJob]]&amp;nbsp;plugin&amp;nbsp;interface (which requires a reference to Telligent.Evolution.Components.dll). [[api-documentation:IEvolutionJob Provider Type|IEvolutionJob]]&amp;nbsp;extends the [[Plugins|IPlugin]]&amp;nbsp;to add support for executing jobs. &amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;In this sample we create a dynamic job called&amp;nbsp;SampleJob which will&amp;nbsp;parse the jobData data dictionary to extract the Id we will pass in and log an entry into the Event Log using the Id that was passed in.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="csharp"&gt;using System;
using Telligent.Evolution.Extensibility.Api.Version1;
using Telligent.Evolution.Extensibility.Jobs.Version1;

namespace Samples
{
    public class SampleJob : IEvolutionJob
    {
        public void Execute(JobData jobData)
        {
            var eventLog = Telligent.Common.Services.Get&amp;lt;IEventLog&amp;gt;();
            Guid id = Guid.Empty;

            Guid.TryParse(jobData.Data[&amp;quot;Id&amp;quot;], out id);

            eventLog.Write(
                string.Format(&amp;quot;SampleJob has successfully run.  The Id {0} was passed into the jobData.&amp;quot;, id), 
                new EventLogEntryWriteOptions 
                { 
                    Category = &amp;quot;Jobs&amp;quot;, 
                    EventType = &amp;quot;Information&amp;quot; 
                });
        }
    }
}&lt;/pre&gt;&lt;/p&gt;
&lt;h3&gt;&lt;a id="Scheduling_your_custom_dynamic_job" name="Scheduling_your_custom_dynamic_job"&gt;&lt;/a&gt;Scheduling&amp;nbsp;your custom dynamic job&lt;/h3&gt;
&lt;p&gt;Dynamic jobs are not scheduled to reoccur, however they do have to be scheduled in order to be picked up by the job server and execute. &amp;nbsp;To schedule the SampleJob you&amp;nbsp;will need to call the [[api-documentation:JobService In-Process API Service|JobService In-Process API]] (which requires a reference to Telligent.Evolution.Api.dll).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The Execute method accepts the jobData parameter which is of the JobData type class. &amp;nbsp;The JobData class has Data property which is of the type&amp;nbsp;Dictionary&amp;lt;string, string&amp;gt;. &amp;nbsp;You can populate the Data dictionary with data your job may need to run.&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;In this sample, we are scheduling&amp;nbsp;the SampleJob and passing in an Id for the SampleJob&amp;nbsp;to use when it executes.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="csharp"&gt;
PublicApi.JobService.Schedule&amp;lt;SampleJob&amp;gt;(
    new Dictionary&amp;lt;string, string&amp;gt;() 
    { 
        { &amp;quot;Id&amp;quot;, Guid.NewGuid().ToString() } 
    });
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;There is also a&amp;nbsp;method overload of the Schedule method to allow for scheduling for a specified time to execute. &amp;nbsp;In the following sample we are scheduling the SampleJob to run in 15 minutes.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="csharp"&gt;
PublicApi.JobService.Schedule&amp;lt;SampleJob&amp;gt;(
    DateTime.UtcNow.AddMinutes(15), 
    new Dictionary&amp;lt;string, string&amp;gt;() 
    { 
        { &amp;quot;Id&amp;quot;, Guid.NewGuid().ToString() }
    });
&lt;/pre&gt;&lt;/p&gt;
&lt;h2&gt;&lt;a id="Creating_recurring_scheduled_jobs" name="Creating_recurring_scheduled_jobs"&gt;&lt;/a&gt;Creating recurring scheduled jobs&lt;/h2&gt;
&lt;p&gt;To recreate a custom scheduled job&amp;nbsp;you will need to implement the [[api-documentation:IRecurringEvolutionJobPlugin Plugin Type|IRecurringEvolutionJobPlugin]] plugin interface (which requires a reference to Telligent.Evolution.Components.dll). &amp;nbsp;The [[api-documentation:IRecurringEvolutionJobPlugin Plugin Type|IRecurringEvolutionJobPlugin]]&amp;nbsp;interface extends the [[api-documentation:IEvolutionJob Provider Type|IEvolutionJob]] interface to add support for scheduling jobs assigning a unique JobTypeId and specifying the context in which the job should run.&lt;/p&gt;
&lt;p&gt;Jobs can be run in a background thread in the website or in the job service background process. &amp;nbsp;A job defines where it should be run by setting the SupportedContext property. &amp;nbsp;The value of the SupportedContext is a&amp;nbsp;JobContext. &amp;nbsp;&lt;/p&gt;
&lt;p&gt;The options for JobContext are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Service: The job will be run from the background job service.&lt;/li&gt;
&lt;li&gt;InProcess: The job will be run on each web node.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Here we set the SupportedContext property as JobContext.Service&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="csharp"&gt;public JobContext SupportedContext
{
    get { return JobContext.Service; }
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;A recurring job defines its default schedule using the DefaultSchedule property. &amp;nbsp;The schedule can be in intervals of seconds, minutes, hours, or on certain days at a specific time. &amp;nbsp;The JobSchedule class exposes various static methods that should be used to create a valid job schedule.&lt;/p&gt;
&lt;p&gt;Here we set the DefaultSchedule to run every three minutes.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="csharp"&gt;public JobSchedule DefaultSchedule
{
    get { return JobSchedule.EveryMinutes(3); }
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;In this complete sample of a recurring job the job will log an entry into the Event Log every time it runs.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="csharp"&gt;using System;
using Telligent.Evolution.Extensibility.Api.Version1;
using Telligent.Evolution.Extensibility.Jobs.Version1;

namespace Samples
{
    public class SamplemRecurringJob : IRecurringEvolutionJobPlugin
    {
        public JobSchedule DefaultSchedule
        {
            get { return JobSchedule.EveryMinutes(3); }
        }

        public Guid JobTypeId
        {
            get { return new Guid(&amp;quot;A5F40BA8-7D11-4429-AFE9-8238CE450B73&amp;quot;); }
        }

        public JobContext SupportedContext
        {
            get { return JobContext.Service; }
        }

        public void Execute(JobData jobData)
        {
            var eventLog = Telligent.Common.Services.Get&amp;lt;IEventLog&amp;gt;();

            eventLog.Write(
                &amp;quot;SampleRecurringJob has successfully run&amp;quot;, 
                new EventLogEntryWriteOptions 
                { 
                    Category = &amp;quot;Jobs&amp;quot;, 
                    EventType = &amp;quot;Information&amp;quot; 
                });
        }

        public string Description
        {
            get { return &amp;quot;This is a sample recurring job to demonstratoe how the IRecurringEvolutionJobPlugin works&amp;quot;; }
        }

        public void Initialize()
        {
        }

        public string Name
        {
            get { return &amp;quot;Sample Recurring Job&amp;quot;; }
        }
    }
}
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Once this sample is deployed to Verint Community, the plugin will show in &lt;strong&gt;Administration &amp;gt; Jobs &amp;gt; Jobs. &amp;nbsp;&lt;/strong&gt;On the Schedule tab, you have the option to change the default schedule.&lt;/p&gt;
&lt;p&gt;&lt;a href="/cfs-file/__key/communityserver-wikis-components-files/00-00-00-12-83/3527.png"&gt;&lt;img alt=" " src="/resized-image/__size/1040x0/__key/communityserver-wikis-components-files/00-00-00-12-83/3527.png" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;

&lt;div style="font-size: 90%;"&gt;Tags: Jobs&lt;/div&gt;
</description></item><item><title>Jobs</title><link>https://community.telligent.com/community/11/w/developer-training/65095/jobs/revision/1</link><pubDate>Thu, 13 Jun 2019 19:28:15 GMT</pubDate><guid isPermaLink="false">e0f6c661-fe3b-496e-9c7d-7098bd1c6c56</guid><dc:creator>Ben Tiedt</dc:creator><comments>https://community.telligent.com/community/11/w/developer-training/65095/jobs#comments</comments><description>Revision 1 posted to Developer Training by Ben Tiedt on 06/13/2019 19:28:15&lt;br /&gt;
&lt;p&gt;Jobs are used to perform an action based on either a&amp;nbsp;dynamic job that may schedule when an event fires, or based on a recurring schedule which executes based on a specified schedule. &amp;nbsp;When jobs are scheduled, the job server will pick up the jobs and execute them.&lt;/p&gt;
&lt;p&gt;[toc]&lt;/p&gt;
&lt;h2&gt;&lt;a id="When_Would_I_Create_Dynamic_Jobs" name="When_Would_I_Create_Dynamic_Jobs"&gt;&lt;/a&gt;When Would I Create Dynamic Jobs&lt;/h2&gt;
&lt;p&gt;When you have a process that needs to occur based on another action occurring and you need the process to run in the background so it does not slow down the current process. &amp;nbsp;&lt;/p&gt;
&lt;h2&gt;&lt;a id="When_Would_I_Create_Scheduled_Jobs" name="When_Would_I_Create_Scheduled_Jobs"&gt;&lt;/a&gt;When Would I Create Scheduled Jobs&lt;/h2&gt;
&lt;p&gt;When you have a process that needs to occur on a recurring&amp;nbsp;basis. &amp;nbsp;&lt;/p&gt;
&lt;h2&gt;&lt;a id="Creating_dynamic_jobs" name="Creating_dynamic_jobs"&gt;&lt;/a&gt;Creating dynamic&amp;nbsp;jobs&lt;/h2&gt;
&lt;p&gt;To create&amp;nbsp;a dynamic job&amp;nbsp;you will need to implement the [[api-documentation:IEvolutionJob Provider Type|IEvolutionJob]]&amp;nbsp;plugin&amp;nbsp;interface (which requires a reference to Telligent.Evolution.Components.dll). [[api-documentation:IEvolutionJob Provider Type|IEvolutionJob]]&amp;nbsp;extends the [[Plugins|IPlugin]]&amp;nbsp;to add support for executing jobs. &amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;In this sample we create a dynamic job called&amp;nbsp;SampleJob which will&amp;nbsp;parse the jobData data dictionary to extract the Id we will pass in and log an entry into the Event Log using the Id that was passed in.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="csharp"&gt;using System;
using Telligent.Evolution.Extensibility.Api.Version1;
using Telligent.Evolution.Extensibility.Jobs.Version1;

namespace Samples
{
    public class SampleJob : IEvolutionJob
    {
        public void Execute(JobData jobData)
        {
            var eventLog = Telligent.Common.Services.Get&amp;lt;IEventLog&amp;gt;();
            Guid id = Guid.Empty;

            Guid.TryParse(jobData.Data[&amp;quot;Id&amp;quot;], out id);

            eventLog.Write(
                string.Format(&amp;quot;SampleJob has successfully run.  The Id {0} was passed into the jobData.&amp;quot;, id), 
                new EventLogEntryWriteOptions 
                { 
                    Category = &amp;quot;Jobs&amp;quot;, 
                    EventType = &amp;quot;Information&amp;quot; 
                });
        }
    }
}&lt;/pre&gt;&lt;/p&gt;
&lt;h3&gt;&lt;a id="Scheduling_your_custom_dynamic_job" name="Scheduling_your_custom_dynamic_job"&gt;&lt;/a&gt;Scheduling&amp;nbsp;your custom dynamic job&lt;/h3&gt;
&lt;p&gt;Dynamic jobs are not scheduled to reoccur, however they do have to be scheduled in order to be picked up by the job server and execute. &amp;nbsp;To schedule the SampleJob you&amp;nbsp;will need to call the [[api-documentation:JobService In-Process API Service|JobService In-Process API]] (which requires a reference to Telligent.Evolution.Api.dll).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The Execute method accepts the jobData parameter which is of the JobData type class. &amp;nbsp;The JobData class has Data property which is of the type&amp;nbsp;Dictionary&amp;lt;string, string&amp;gt;. &amp;nbsp;You can populate the Data dictionary with data your job may need to run.&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;In this sample, we are scheduling&amp;nbsp;the SampleJob and passing in an Id for the SampleJob&amp;nbsp;to use when it executes.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="csharp"&gt;
PublicApi.JobService.Schedule&amp;lt;SampleJob&amp;gt;(
    new Dictionary&amp;lt;string, string&amp;gt;() 
    { 
        { &amp;quot;Id&amp;quot;, Guid.NewGuid().ToString() } 
    });
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;There is also a&amp;nbsp;method overload of the Schedule method to allow for scheduling for a specified time to execute. &amp;nbsp;In the following sample we are scheduling the SampleJob to run in 15 minutes.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="csharp"&gt;
PublicApi.JobService.Schedule&amp;lt;SampleJob&amp;gt;(
    DateTime.UtcNow.AddMinutes(15), 
    new Dictionary&amp;lt;string, string&amp;gt;() 
    { 
        { &amp;quot;Id&amp;quot;, Guid.NewGuid().ToString() }
    });
&lt;/pre&gt;&lt;/p&gt;
&lt;h2&gt;&lt;a id="Creating_recurring_scheduled_jobs" name="Creating_recurring_scheduled_jobs"&gt;&lt;/a&gt;Creating recurring scheduled jobs&lt;/h2&gt;
&lt;p&gt;To recreate a custom scheduled job&amp;nbsp;you will need to implement the [[api-documentation:IRecurringEvolutionJobPlugin Plugin Type|IRecurringEvolutionJobPlugin]] plugin interface (which requires a reference to Telligent.Evolution.Components.dll). &amp;nbsp;The [[api-documentation:IRecurringEvolutionJobPlugin Plugin Type|IRecurringEvolutionJobPlugin]]&amp;nbsp;interface extends the [[api-documentation:IEvolutionJob Provider Type|IEvolutionJob]] interface to add support for scheduling jobs assigning a unique JobTypeId and specifying the context in which the job should run.&lt;/p&gt;
&lt;p&gt;Jobs can be run in a background thread in the website or in the job service background process. &amp;nbsp;A job defines where it should be run by setting the SupportedContext property. &amp;nbsp;The value of the SupportedContext is a&amp;nbsp;JobContext. &amp;nbsp;&lt;/p&gt;
&lt;p&gt;The options for JobContext are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Service: The job will be run from the background job service.&lt;/li&gt;
&lt;li&gt;InProcess: The job will be run on each web node.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Here we set the SupportedContext property as JobContext.Service&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="csharp"&gt;public JobContext SupportedContext
{
    get { return JobContext.Service; }
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;A recurring job defines its default schedule using the DefaultSchedule property. &amp;nbsp;The schedule can be in intervals of seconds, minutes, hours, or on certain days at a specific time. &amp;nbsp;The JobSchedule class exposes various static methods that should be used to create a valid job schedule.&lt;/p&gt;
&lt;p&gt;Here we set the DefaultSchedule to run every three minutes.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="csharp"&gt;public JobSchedule DefaultSchedule
{
    get { return JobSchedule.EveryMinutes(3); }
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;In this complete sample of a recurring job the job will log an entry into the Event Log every time it runs.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="csharp"&gt;using System;
using Telligent.Evolution.Extensibility.Api.Version1;
using Telligent.Evolution.Extensibility.Jobs.Version1;

namespace Samples
{
    public class SamplemRecurringJob : IRecurringEvolutionJobPlugin
    {
        public JobSchedule DefaultSchedule
        {
            get { return JobSchedule.EveryMinutes(3); }
        }

        public Guid JobTypeId
        {
            get { return new Guid(&amp;quot;A5F40BA8-7D11-4429-AFE9-8238CE450B73&amp;quot;); }
        }

        public JobContext SupportedContext
        {
            get { return JobContext.Service; }
        }

        public void Execute(JobData jobData)
        {
            var eventLog = Telligent.Common.Services.Get&amp;lt;IEventLog&amp;gt;();

            eventLog.Write(
                &amp;quot;SampleRecurringJob has successfully run&amp;quot;, 
                new EventLogEntryWriteOptions 
                { 
                    Category = &amp;quot;Jobs&amp;quot;, 
                    EventType = &amp;quot;Information&amp;quot; 
                });
        }

        public string Description
        {
            get { return &amp;quot;This is a sample recurring job to demonstratoe how the IRecurringEvolutionJobPlugin works&amp;quot;; }
        }

        public void Initialize()
        {
        }

        public string Name
        {
            get { return &amp;quot;Sample Recurring Job&amp;quot;; }
        }
    }
}
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Once this sample is deployed to Telligent Community, the plugin will show in &lt;strong&gt;Administration &amp;gt; Jobs &amp;gt; Jobs. &amp;nbsp;&lt;/strong&gt;On the Schedule tab, you have the option to change the default schedule.&lt;/p&gt;
&lt;p&gt;&lt;a href="/cfs-file/__key/communityserver-wikis-components-files/00-00-00-12-83/3527.png"&gt;&lt;img src="/resized-image/__size/1040x0/__key/communityserver-wikis-components-files/00-00-00-12-83/3527.png" alt=" " /&gt;&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;
</description></item></channel></rss>