Пример #1
0
        private void AutoSuspendJob()
        {
            DateTime?timestamp  = base.TimeTracker.GetTimestamp(RequestJobTimestamp.CompleteAfter);
            DateTime?timestamp2 = base.TimeTracker.GetTimestamp(RequestJobTimestamp.StartAfter);
            TimeSpan incrementalSyncInterval = base.CachedRequestJob.IncrementalSyncInterval;
            DateTime?nextSchedule            = BaseJob.GetNextScheduledTime(timestamp2, timestamp, incrementalSyncInterval);

            if (nextSchedule != null)
            {
                base.Report.Append(MrsStrings.ReportSyncedJob(nextSchedule.Value.ToLocalTime()));
                base.SaveState(SaveStateFlags.Regular, delegate(TransactionalRequestJob mergeRequest)
                {
                    mergeRequest.Status           = RequestStatus.Synced;
                    this.TimeTracker.CurrentState = RequestState.AutoSuspended;
                    this.TimeTracker.SetTimestamp(RequestJobTimestamp.DoNotPickUntil, new DateTime?(nextSchedule.Value));
                    mergeRequest.Message = MrsStrings.MoveRequestMessageInformational(MrsStrings.JobHasBeenSynced);
                });
                return;
            }
            base.SaveState(SaveStateFlags.Regular, delegate(TransactionalRequestJob mergeRequest)
            {
                mergeRequest.Status           = RequestStatus.Completed;
                base.TimeTracker.CurrentState = RequestState.Completed;
                mergeRequest.Message          = MrsStrings.MoveRequestMessageInformational(MrsStrings.ReportRequestCompleted);
            });
        }
Пример #2
0
        protected virtual void AutoSuspendJob()
        {
            if (base.CachedRequestJob.SuspendWhenReadyToComplete || base.CachedRequestJob.PreventCompletion)
            {
                base.Report.Append(MrsStrings.ReportAutoSuspendingJob);
                base.TimeTracker.CurrentState = RequestState.AutoSuspended;
                base.TimeTracker.SetTimestamp(RequestJobTimestamp.Suspended, new DateTime?(DateTime.UtcNow));
                base.SaveState(SaveStateFlags.Regular, delegate(TransactionalRequestJob mergeRequest)
                {
                    mergeRequest.Status  = RequestStatus.AutoSuspended;
                    mergeRequest.Suspend = true;
                    mergeRequest.Message = MrsStrings.MoveRequestMessageInformational(MrsStrings.JobHasBeenAutoSuspended);
                });
                return;
            }
            DateTime?timestamp  = base.TimeTracker.GetTimestamp(RequestJobTimestamp.CompleteAfter);
            DateTime?timestamp2 = base.TimeTracker.GetTimestamp(RequestJobTimestamp.StartAfter);
            TimeSpan incrementalSyncInterval = base.CachedRequestJob.IncrementalSyncInterval;
            DateTime utcNow       = DateTime.UtcNow;
            DateTime?nextSchedule = BaseJob.GetNextScheduledTime(timestamp2, timestamp, incrementalSyncInterval);

            base.Report.Append(MrsStrings.ReportSyncedJob(nextSchedule.Value.ToLocalTime()));
            base.SaveState(SaveStateFlags.Regular, delegate(TransactionalRequestJob mergeRequest)
            {
                mergeRequest.Status           = RequestStatus.Synced;
                this.TimeTracker.CurrentState = RequestState.AutoSuspended;
                this.TimeTracker.SetTimestamp(RequestJobTimestamp.DoNotPickUntil, new DateTime?(nextSchedule.Value));
                mergeRequest.Message = MrsStrings.MoveRequestMessageInformational(MrsStrings.JobHasBeenSynced);
            });
        }