Esempio n. 1
0
 /// <summary>
 ///     Called when the user clicks a command.
 /// </summary>
 /// <remarks>
 ///     Note to inheritors: override OnClick and use this method to
 ///     perform the actual work of the custom command.
 /// </remarks>
 public override void OnClick()
 {
     try
     {
         IMMPxApplication pxApp = this.Application.GetPxApplication();
         IMMPxNode        node  = pxApp.GetCurrentNode();
         IMMPxTask        task  = node.GetTask(this.TaskName, true);
         task.Execute(node);
     }
     catch (Exception ex)
     {
         Log.Error(this.Caption, ex);
     }
 }
Esempio n. 2
0
        /// <summary>
        ///     Executes the task with the given name, if it exists, on the given node.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="taskName">Name of the task.</param>
        /// <returns>
        ///     Returns a <see cref="bool" /> representing <c>true</c> when successfully executed the task.
        /// </returns>
        public static bool ExecuteTask(this IMMPxNode source, string taskName)
        {
            var task = source.GetTask(taskName);

            if (task == null)
            {
                return(false);
            }

            var transition = ((IMMPxTask2)task).Transition;

            if (!transition.FromStates.Contains(source.State))
            {
                return(false);
            }

            return(task.Execute(source));
        }
Esempio n. 3
0
 /// <summary>
 ///     Finds the task using the specified <paramref name="source" /> and <paramref name="taskName" />.
 /// </summary>
 /// <param name="source">The node.</param>
 /// <param name="taskName">Name of the task.</param>
 /// <returns>
 ///     Returns a <see cref="IMMPxTask" /> representing the tasks that matches specified task name for the given node;
 ///     otherwise <c>null</c>.
 /// </returns>
 /// <exception cref="ArgumentNullException">taskName</exception>
 public static IMMPxTask GetTask(this IMMPxNode source, string taskName)
 {
     return(source.GetTask(taskName, false));
 }