Ejemplo n.º 1
0
        protected override IEnumerator OnExecute(JobContext context)
        {
            if (TargetJob.Id.Equals(context.JobId))
            {
                RockLog.WriteLine(this, LogTier.Error, "A currently running job cannot run itself!");
                IsSuccess = false;
                yield break;
            }

            _childSession = JobSession.Create(TargetJob, false);

            _childSession.RootContext.Parent.Parent = context;
            context.Session.ChildSessions.Add(_childSession);

            // modify existing job variables
            foreach (var keyValuePair in TargetJobVariables)
            {
                var customVariable  = keyValuePair.Value;
                var jobVariable     = _childSession.RootContext[keyValuePair.Key];
                var overriddenValue = customVariable.GetValue(context);
                jobVariable.UseFormula = false;
                jobVariable.SetValue(overriddenValue);

                RockLog.WriteLine(LogTier.Info, string.Format("Overridden variable named \"{0}\". New value: \"{1}\"",
                                                              jobVariable.Name, overriddenValue));
            }

            // add new variables
            foreach (var keyValuePair in NewVariables)
            {
                _childSession.RootContext.Add(keyValuePair.Value);
            }

            _childSession.Start();

            while (_childSession.InProgress)
            {
                yield return(null);
            }

            IsSuccess = _childSession.IsSuccess;
        }
Ejemplo n.º 2
0
 /// <inheritdoc />
 protected override void OnPostExecute()
 {
     _childSession = null;
 }
Ejemplo n.º 3
0
 /// <inheritdoc />
 protected override void OnInterrupt()
 {
     _childSession.Stop();
     _childSession = null;
 }