/// <summary> /// Entry point called when trigger fires. /// </summary> /// <param name="context"></param> public void Execute(JobExecutionContext context) { var settings = Load(context); try { foreach (var mdn in ExpiredMdns(settings)) { using (TransactionScope scope = new TransactionScope()) { var message = CreateNotificationMessage(mdn, settings); string filePath = Path.Combine(settings.PickupFolder, UniqueFileName()); MDNManager.TimeOut(mdn); message.Save(filePath); scope.Complete(); } } } catch (Exception e) { Logger.Error("Error in job!"); Logger.Error(e.Message); var je = new JobExecutionException(e); throw je; } }
/// <summary> /// Retrieve expired records. /// Records without processed notification and older than the <c>ExpiredMinutes</c> /// Load a limited amount of record set by <c>BulkCount</c> /// </summary> /// <param name="settings"></param> /// <returns></returns> protected override IList <Mdn> ExpiredMdns(TimeoutSettings settings) { IList <Mdn> mdns; mdns = MDNManager.GetExpiredProcessed(settings.ExpiredMinutes, settings.BulkCount).ToList(); if (mdns.Count() > 0) { Logger.Debug("Processing {0} expired processed mdns", mdns.Count()); } return(mdns); }