+1-888-365-2779
Try Now
More in this section

scheduler

2 posts, 0 answered
  1. Gagandeep
    Gagandeep avatar
    3 posts
    Registered:
    15 Aug 2014
    29 Aug 2014
    Link to this post

    i created one class in dot net that is importing data from excel to site finity. i want to call that function daily 1 am. want to create one scheduler. any suggestion????

  2. Vassil Vassilev
     Vassil Vassilev avatar
    308 posts
    Registered:
    21 Jan 2015
    02 Sep 2014
    Link to this post
    Hello Gagandeep,

    Thank you for using our service.

    Yes, we provide an API functionality to create the scheduled task.

    You need to add the following in your Global.asax file:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.Security;
    using System.Web.SessionState;
    using Telerik.Sitefinity.Abstractions;
    using Telerik.Sitefinity.Data;
    using Telerik.Sitefinity.Scheduling;
      
    namespace SitefinityWebApp
    {
        public class Global : System.Web.HttpApplication
        {
      
            protected void Application_Start(object sender, EventArgs e)
            {
                Bootstrapper.Initialized += new EventHandler<ExecutedEventArgs>(this.OnSitefinityAppInitialized);
            }
       
            private void OnSitefinityAppInitialized(object sender, EventArgs args)
            {
                SchedulingManager manager = SchedulingManager.GetManager();
                string myKey = "239CE594-5613-42EC-AC57-8E2B33B28065";
       
                var count = manager.GetTaskData().Where(i => i.Key == "239CE594-5613-42EC-AC57-8E2B33B28065").ToList().Count;
       
                if (count == 0)
                {
                    PipeScheduledTask newTask = new PipeScheduledTask()
                    {
                        Key = myKey,
                        ExecuteTime = DateTime.UtcNow.AddSeconds(10),
                    };
                    manager.AddTask(newTask);
                    manager.SaveChanges();
                }
            }
        }
    }

    Then you need to create the repeating task as follows:
    using System;
    using System.Linq;
    using Telerik.Sitefinity.Scheduling;
       
    namespace SitefinityWebApp
    {
        public class PipeScheduledTask : ScheduledTask
        {
            public PipeScheduledTask()
            {
            }
        
            public override void ExecuteTask()
            {
                //Your logic here.. e.g. import data
                
                SchedulingManager schedulingManager = SchedulingManager.GetManager();
                PipeScheduledTask newTask = new PipeScheduledTask()
                {
                    Key = this.Key,
                    ExecuteTime = DateTime.UtcNow.AddSeconds(10)
                };
        
                schedulingManager.AddTask(newTask);
                SchedulingManager.RescheduleNextRun();
                schedulingManager.SaveChanges();
            }
        
            public override string TaskName
            {
                get
                {
                    return "SitefinityWebApp.PipeScheduledTask";
                }
            }
        }
    }

    You can use our API  Working with issues and in your case: Sending issues

    Hope this information helps.

    Regards,
    Vassil Vassilev
    Telerik
     
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
     
2 posts, 0 answered