Esempio n. 1
0
 public void ShouldTrackSuccessEvent()
 {
     var context = new JobContext();
     var countOfEventRaised = 0;
     context.JobContextChanged += (obj, args) => countOfEventRaised++;
     context.CountSuccess();
     Assert.AreEqual(1, context.SuccessCount);
     context.CountSuccess();
     Assert.AreEqual(2, context.SuccessCount);
 }
Esempio n. 2
0
        public void ShouldTrackIdenticalObjectEvent()
        {
            var context = new JobContext();

            var countOfEventRaised = 0;
            context.JobContextChanged += (obj, args) => countOfEventRaised++;
            context.CountIdenticalObject();
            Assert.AreEqual(1, context.IdenticalObjectCount);
            context.CountIdenticalObject();
            Assert.AreEqual(2, context.IdenticalObjectCount);
        }
Esempio n. 3
0
        public void ShouldTrackErrorEvent()
        {
            var context = new JobContext();

            var countOfEventRaised = 0;
            context.JobContextChanged += (obj, args) => countOfEventRaised++;
            context.CountError();
            Assert.AreEqual(1, context.ErrorCount);
            context.CountError();
            Assert.AreEqual(2, context.ErrorCount);
        }
Esempio n. 4
0
        public void Run(string sessionRunningFlag)
        {
            InitializeContext(sessionRunningFlag);
            try
            {
                foreach (var job in _jobs)
                {
                    var jobContext = CurrentSessionContext.JobContexts.First(j => j.JobName == job.Name);
                    _currentJobContext = jobContext;
                    if (jobContext.FinishedTime == null)
                        StartJob(jobContext, job);
                }
                UpdateSessionStateToFinished();
            }
            catch (Exception ex)
            {
                var message = String.Format("Encountered error. Sync aborted. Please try to resume this session later. Exception: {0}", ex.Message);
                _notificationService.SendNotification(message);

                CurrentSessionContext.State = SessionState.Aborted;
                SaveContextToDb();
                throw new SyncAbortedException(message, ex);
            }
        }
Esempio n. 5
0
        private void StartJob(JobContext jobContext, ISyncJob job)
        {
            jobContext.JobContextChanged += (obj, arg) => SaveContextToDb();
            if(jobContext.StartTime == null) jobContext.StartTime = DateTime.Now;
            Logger.Info(string.Format("Start job {0} at record {1}", job.Name, jobContext.CurrentRecord));
            SaveContextToDb();

            job.Start(jobContext);
            Logger.Trace("Job finished: " + job.Name);
            jobContext.FinishedTime = DateTime.Now;
            SaveContextToDb();
        }