예제 #1
0
 /// <summary>
 /// Handle child task completed eveent
 /// </summary>
 /// <param name="tce"></param>
 private void HandleChildTaskCompleted(TaskCompleted tce)
 {
     lock (this)
     {
         if (tce.ParentTaskInstanceId != this.InstanceId)
             throw new TaskRuntimeException("Parent task correlation id is incorrect").SetInstanceId(InstanceId);
         TransitionInfo ti = GetTransitionInfo(tce.FromTaskInstanceId);
         if (ti == null)
             throw new TaskRuntimeException("Child task not found: " + tce.FromTaskInstanceId).SetInstanceId(InstanceId);
         if (ti.Status == TransitionStatus.Completed)
             return;
         if (ti.IsTransitionActive)
         {
             OnChildTaskCompleted(tce);
         }
         else
         {
             log.Warn("Child task {0} ({1}) completed, but current transition status is {2}. Ignoring the notification - status inconsistent.", tce.FromTaskInstanceId, ti.TaskId, ti.Status);
             return;
         }
         //else throw new Exception("Invalid transition status");
     }
 }
예제 #2
0
        /// <summary>
        /// Invoked when a child task completes. Executes task output data bindings
        /// and moves the tokens.
        /// TODO: handle a case when the transition is 'cancelling' but the task fails or completes
        /// before nginn cancels it
        /// </summary>
        /// <param name="tce"></param>
        private void OnChildTaskCompleted(TaskCompleted tce)
        {
            log.Debug("Child task completed: {0}", tce.FromTaskInstanceId);
            TransitionInfo ti = GetTransitionInfo(tce.FromTaskInstanceId);
            TaskDef tsk = MyTask.GetTask(ti.TaskId);
            if (ti.Status == TransitionStatus.Enabling)
                ti.Status = TransitionStatus.Enabled;

            if (ti.Status == TransitionStatus.Enabled || ti.Status == TransitionStatus.Started)
            {
                ConsumeTaskInputTokens(tce.FromTaskInstanceId);
                if (tce is MultiTaskCompleted)
                {
                    MultiTaskCompleted mce = (MultiTaskCompleted)tce;
                    if (!string.IsNullOrEmpty(tsk.MultiInstanceResultsBinding) && mce.MultiOutputData != null)
                    {
                        TaskData[tsk.MultiInstanceResultsBinding] = mce.MultiOutputData;
                    }
                }
                else
                {
                    if (tce.OutputData != null)
                    {
                        ScriptRuntime.ExecuteChildTaskOutputDataBinding(this, tsk, tce.OutputData, Context);
                    }
                }
                ti.Status = TransitionStatus.Completed;
                ProduceTaskOutputTokens(ti.InstanceId);
            }
            else
            {
                ti.Status = TransitionStatus.Completed;
                log.Warn("Task {0} has completed, but the transition status was {1} and it did not produce output tokens or execute data bindings", ti.InstanceId, ti.Status);
            }
        }
예제 #3
0
 private void Handle(TaskCompleted message)
 {
     HandleChildTaskCompleted(message);
 }
예제 #4
0
 private void Handle(TaskCompleted message)
 {
     RequireActivation(true);
     if (message.ParentTaskInstanceId != this.InstanceId) throw new Exception();
     if (message is MultiTaskCompleted) throw new Exception();
     TransitionInfo ti = GetTransition(message.FromTaskInstanceId);
     if (ti == null) throw new Exception();
     log.Info("MT Child task {0} has completed", ti.InstanceId);
     if (ti.Status == TransitionStatus.Completed)
         return;
     if (!ti.IsTransitionActive)
     {
         log.Warn("Transition {0} ({1}) is not active: {2}", ti.InstanceId, ti.TaskId, ti.Status);
         return;
     }
     ti.Status = TransitionStatus.Completed;
     ti.OutputData = message.OutputData;
     if (ti.OutputData == null)
     {
         log.Info("No output data returned from child task {0}", ti.InstanceId);
         ti.OutputData = new Dictionary<string, object>();
     }
     OnTransitionStatusChanged(ti.InstanceId);
     return;
     
 }