Skip to content

Commit

Permalink
Merge remote-tracking branch 'obones/Issue46'
Browse files Browse the repository at this point in the history
  • Loading branch information
dhommel committed Jan 9, 2012
2 parents ec16481 + fc30ded commit fe4801b
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 3 deletions.
44 changes: 41 additions & 3 deletions project/core/tasks/SequentialTask.cs
Expand Up @@ -68,6 +68,38 @@ public override ITask[] Tasks
#endregion
#endregion

private class _RunningSubTaskDetails
{
private int _Index;
private IIntegrationResult _ParentResult;

public _RunningSubTaskDetails(int Index, IIntegrationResult ParentResult)
{
_Index = Index;
_ParentResult = ParentResult;
}

public int Index { get { return _Index; } }
public IIntegrationResult ParentResult { get { return _ParentResult; } }
}

private string _getStatusInformation(string runningSubTaskStartupInfo, _RunningSubTaskDetails Details)
{
string Value = !string.IsNullOrEmpty(Description)
? Description
: string.Format("Running sequential tasks ({0} task(s))", Tasks.Length);

if (Details != null)
Value += string.Format(": [{0}] {1}",
Details.Index,
!string.IsNullOrEmpty(runningSubTaskStartupInfo)
? runningSubTaskStartupInfo
: "No information");

return Value;
}


#region Protected methods
#region Execute()
/// <summary>
Expand All @@ -79,9 +111,7 @@ protected override bool Execute(IIntegrationResult result)
// Initialise the task
var logger = Logger ?? new DefaultLogger();
var numberOfTasks = Tasks.Length;
result.BuildProgressInformation.SignalStartRunTask(!string.IsNullOrEmpty(Description)
? Description
: string.Format(System.Globalization.CultureInfo.CurrentCulture,"Running sequential tasks ({0} task(s))", numberOfTasks));
result.BuildProgressInformation.SignalStartRunTask(_getStatusInformation("", null));
logger.Info("Starting sequential task with {0} sub-task(s)", numberOfTasks);

// Launch each task
Expand All @@ -95,6 +125,8 @@ protected override bool Execute(IIntegrationResult result)
{
// Start the actual task
var taskResult = result.Clone();
taskResult.BuildProgressInformation.OnStartupInformationUpdatedUserObject = new _RunningSubTaskDetails(loop, result);
taskResult.BuildProgressInformation.OnStartupInformationUpdated = SubTaskStartupInformationUpdated;
var task = Tasks[loop];
RunTask(task, taskResult);
result.Merge(taskResult);
Expand Down Expand Up @@ -126,5 +158,11 @@ protected override bool Execute(IIntegrationResult result)
}
#endregion
#endregion

private void SubTaskStartupInformationUpdated(string information, object UserObject)
{
_RunningSubTaskDetails Details = (_RunningSubTaskDetails)UserObject;
Details.ParentResult.BuildProgressInformation.UpdateStartupInformation(_getStatusInformation(information, Details));
}
}
}
20 changes: 20 additions & 0 deletions project/core/util/BuildProgressInformation.cs
Expand Up @@ -18,6 +18,15 @@ public class BuildProgressInformation
private readonly object lockObject = new object();
private System.Collections.Generic.List<BuildProgressInformationData> Progress;
private const Int32 MaxItemsInQueue = 10;
private OnStartupInformationUpdatedDelegate _OnStartupInformationUpdated = null;


private void DoStartupInformationUpdated(string information)
{
this._lastTimeQueried = DateTime.Now.AddYears(-10);
if (_OnStartupInformationUpdated != null)
OnStartupInformationUpdated(information, OnStartupInformationUpdatedUserObject);
}


/// <summary>
Expand Down Expand Up @@ -56,9 +65,13 @@ public virtual void SignalStartRunTask(string information)
this._buildInformation = GetQueueDataAsXml();
this._lastTimeQueried = DateTime.Now.AddYears(-10);

DoStartupInformationUpdated(information);
}
}

public delegate void OnStartupInformationUpdatedDelegate(string information, object UserObject);
public OnStartupInformationUpdatedDelegate OnStartupInformationUpdated { get { return _OnStartupInformationUpdated; } set { _OnStartupInformationUpdated += value; } }
public object OnStartupInformationUpdatedUserObject { get; set; }

/// <summary>
/// Adds the task information.
Expand All @@ -74,6 +87,13 @@ public virtual void AddTaskInformation(string information)
}


public void UpdateStartupInformation(string information)
{
Progress[0] = new BuildProgressInformationData(information);

DoStartupInformationUpdated(information);
}

/// <summary>
/// Gets the build progress information.
/// </summary>
Expand Down

0 comments on commit fe4801b

Please sign in to comment.