Ejemplo n.º 1
0
        public void Run()
        {
            string url = this.url;
            url += "?lastRan=" + ((this.lastRan != null) ? String.Format("{0:MMddyyyyHHmmss}",this.lastRan) : "");

            EcommercePlatformDataContext db = new EcommercePlatformDataContext();
            ScheduledTask t = db.ScheduledTasks.Where(x => x.ID.Equals(this.ID)).FirstOrDefault<ScheduledTask>();
            t.lastRan = DateTime.Now;
            db.SubmitChanges();

            WebClient wc = new WebClient();
            wc.Proxy = null;
            wc.DownloadString(url);
        }
Ejemplo n.º 2
0
 public void runTasks(Object intervalValue) {
     Trace.WriteLine("Running Scheduled Tasks", "Information");
     int interval = (int)intervalValue;
     EcommercePlatformDataContext db = new EcommercePlatformDataContext();
     DateTime now = DateTime.Now.ToUniversalTime();
     DateTime past = DateTime.Now.AddMilliseconds(-interval).ToUniversalTime();
     List<ScheduledTask> tasks = db.ScheduledTasks.Where(x => (x.runtime != null && x.runtime.Value.TimeOfDay > past.TimeOfDay && x.runtime.Value.TimeOfDay <= now.TimeOfDay) || (x.runtime == null && (x.lastRan == null || x.lastRan.Value.AddMinutes(Convert.ToDouble(x.interval)).TimeOfDay <= now.TimeOfDay))).ToList<ScheduledTask>();
     Trace.WriteLine("Running " + tasks.Count + " Tasks", "Information");
     Logger.log("Running " + tasks.Count + " Tasks");
     foreach (ScheduledTask task in tasks) {
         Trace.WriteLine("Running Task: " + task.name, "Information");
         Logger.log("Running Task: " + task.name);
         task.Run();
     }
 }