Thanks for any help.. here's what I'm doing with the scheduler.
public override void DoWork()
{
try
{
this.Progressing();
this.ScheduleHistoryItem.AddLogNote("Starting Import");
this.ScheduleHistoryItem.AddLogNote("Getting AllClients");
foreach (int portalId in _Data.getAllClients())
{
_Data = new Data();
_portalId = portalId;
//_portalId = 0;
// The Process Feeds call the Data() class as well to retrieve data from a web service call.
_cursors = _Data.getCursors(_portalId);
//process catalog feed
this.ScheduleHistoryItem.AddLogNote("Processing Catalogs for Portal " + _portalId);
processCatalogFeed(_cursors[0]);
this.ScheduleHistoryItem.AddLogNote("Processing Products for Portal " + _portalId);
processProductFeed(_cursors[1]);
//Also not that the LogNotes only show up when the scheduler fails to complete (ie throws an exception)
}
this.ScheduleHistoryItem.AddLogNote("Ending Import");
this.ScheduleHistoryItem.Succeeded = true;
this.Completed();
//I added this to ensure the next start time is not set to some time in the past
if (this.ScheduleHistoryItem.NextStart < DateTime.Now)
this.ScheduleHistoryItem.NextStart = DateTime.Now.AddMinutes(15);
}
catch(Exception e)
{
this.Errored(ref e);
this.ScheduleHistoryItem.Succeeded = false;
this.ScheduleHistoryItem.AddLogNote("Unexpected Error:" + e.ToString());
//add a log entry
LogInfo li = new LogInfo("<Feeds>Do Work</Feeds");
LogDetailInfo ldi = new LogDetailInfo("Exception", e.ToString());
li.LogProperties.Add(ldi);
li.LogCreateDate = DateTime.Now;
li.LogTypeKey = "DEBUG";
li.LogPortalID = 0;
_log.AddLog(li);
}
}