Example #1
0
 public void Start(IJobContext jobContext)
 {
     for (int batchCount = 1; ; batchCount++)
     {
         Logger.Debug(string.Format("Running batch {0} of {1} with batch size: {2} starting at {3} ", batchCount, Name, _batchSize, jobContext.CurrentRecord));
         var currentBatch = _source.GetBatchOfObjects(_objectType,
                                                  _batchSize,
                                                  jobContext.CurrentRecord,
                                                  jobContext.MinimumModificationDate).ToList();
         currentBatch.ForEach(syncObject => Enqueue(syncObject, jobContext));
         if (currentBatch.Any())
             jobContext.SetCurrentRecord(currentBatch.Last().SalsaKey);
         else
             break;
     };
 }
Example #2
0
 public void Start(IJobContext jobContext)
 {
     for (int batchCount = 1; ; batchCount++)
     {
         if(!Config.SalsaWritable) throw new AccessViolationException(String.Format("Cannot export objects to Salsa. {0} is in read-only mode.", Config.Environment));
         Logger.Debug("Dequeue in batch " + batchCount + " with batch size:" + _batchSize + " " + Name);
         var currentBatch = _source.GetBatchOfObjects(_objectType,
                                                  _queueName,
                                                  _batchSize,
                                                  jobContext.CurrentRecord).ToList();
         var tasks = currentBatch.Select(syncObject => Task.Factory.StartNew(arg => ExportSyncObject(syncObject, jobContext), null));
         Task.WaitAll(tasks.ToArray());
         Logger.Trace("Updating current record...");
         if (currentBatch.Any())
             jobContext.SetCurrentRecord(currentBatch.Last().QueueId);
         else
             break;
     };
 }