Execute() public method

public Execute ( ) : bool
return bool
Exemplo n.º 1
0
        public bool Execute()
        {
            TaskEngine taskEngine;

            LogTaskStarted();
            ITask task;

            try {
                task = InitializeTask();
            } catch (Exception e) {
                LogError("Error initializing task {0}: {1}", taskElement.LocalName, e.Message);
                LogMessage(MessageImportance.Low, "Error initializing task {0}: {1}",
                           taskElement.LocalName, e.ToString());
                return(false);
            }

            try {
                taskEngine = new TaskEngine(parentTarget.Project, task, Type);
                taskEngine.Prepare(GetParameters());
                var result = taskEngine.Execute();
                if (result)
                {
                    taskEngine.PublishOutput(taskElement, taskEngine.ValueFromExecution);
                }

                LogTaskFinished(result);
                return(result);
            } catch (Exception e) {
                task_logger.LogError("Error executing task {0}: {1}", taskElement.LocalName, e.Message);
                task_logger.LogMessage(MessageImportance.Low,
                                       "Error executing task {0}: {1}", taskElement.LocalName, e.ToString());
                return(false);
            }
        }
Exemplo n.º 2
0
		public bool Execute ()
		{
			bool		result = false;
			TaskEngine	taskEngine;

			LogTaskStarted ();
			ITask task = null;

			try {
				try {
					task = InitializeTask ();
				} catch (Exception e) {
					LogError ("Error initializing task {0}: {1}", taskElement.LocalName, e.Message);
					LogMessage (MessageImportance.Low, "Error initializing task {0}: {1}",
							taskElement.LocalName, e.ToString ());
					return false;
				}

				try {
					taskEngine = new TaskEngine (parentTarget.Project);
					taskEngine.Prepare (task, this.taskElement, GetParameters (), this.Type);
					result = taskEngine.Execute ();
					if (result)
						taskEngine.PublishOutput ();
				} catch (Exception e) {
					task_logger.LogError ("Error executing task {0}: {1}", taskElement.LocalName, e.Message);
					task_logger.LogMessage (MessageImportance.Low,
							"Error executing task {0}: {1}", taskElement.LocalName, e.ToString ());
					result = false;
				}
			} finally {
				LogTaskFinished (result);
			}

			return result;
		}