Index: Core/Common/src/Core.Common.Base/Core.Common.Base.csproj
===================================================================
diff -u -r95837098c8fbc25212797c64431f6f16496814b3 -r358f5af627a563dd5b6903b94ba6abb16df8084e
--- Core/Common/src/Core.Common.Base/Core.Common.Base.csproj (.../Core.Common.Base.csproj) (revision 95837098c8fbc25212797c64431f6f16496814b3)
+++ Core/Common/src/Core.Common.Base/Core.Common.Base.csproj (.../Core.Common.Base.csproj) (revision 358f5af627a563dd5b6903b94ba6abb16df8084e)
@@ -100,7 +100,7 @@
Resources.resx
-
+
Index: Core/Common/src/Core.Common.Base/Service/Activity.cs
===================================================================
diff -u -rbb3a4dbfa4e43123f5b101034e90b89e8712bd41 -r358f5af627a563dd5b6903b94ba6abb16df8084e
--- Core/Common/src/Core.Common.Base/Service/Activity.cs (.../Activity.cs) (revision bb3a4dbfa4e43123f5b101034e90b89e8712bd41)
+++ Core/Common/src/Core.Common.Base/Service/Activity.cs (.../Activity.cs) (revision 358f5af627a563dd5b6903b94ba6abb16df8084e)
@@ -6,15 +6,22 @@
namespace Core.Common.Base.Service
{
///
- /// Abstract class that can be used for performing activies (like calculations, data imports, data exports, etc.).
+ /// Abstract class that can be derived for performing activities (like calculations, data imports, data exports, etc.).
/// The regular workflow for completely performing an is: -> .
/// can be called for cancelling a running .
///
+ ///
+ /// By convention, only should contain UI thread related logic.
+ ///
public abstract class Activity
{
+ ///
+ /// Event handler for notifying progress changes.
+ ///
public event EventHandler ProgressChanged;
private readonly ILog log = LogManager.GetLogger(typeof(Activity));
+
private string progressText;
///
@@ -31,9 +38,9 @@
public virtual string Name { get; set; }
///
- /// Gets or sets the of the .
+ /// Gets or sets the of the .
///
- public ActivityStatus Status { get; protected set; }
+ public ActivityState State { get; protected set; }
///
/// Gets or sets the progress text of the .
@@ -54,66 +61,79 @@
}
///
- /// Gets or sets the collection of log messages of the (which is appended while performing the ).
+ /// Gets or sets the collection of log messages of the (which can be appended while performing the ).
///
+ ///
+ /// Derived classes themselves are responsible for clearing the collection of log messages.
+ ///
public IList LogMessages { get; private set; }
///
- /// This method runs the .
+ /// This method resets to and then runs the .
+ /// The of a successfully run will become .
+ /// When the run fails, the will become .
///
public void Run()
{
- ChangeState(OnExecute, ActivityStatus.Executed);
+ State = ActivityState.None;
- if (Status == ActivityStatus.Failed)
+ ChangeState(OnRun, ActivityState.Executed);
+
+ if (State == ActivityState.Failed)
{
log.ErrorFormat(Resources.Activity_Run_Execution_of_0_has_failed, Name);
}
}
///
/// This method cancels a running .
+ /// The of a successfully cancelled will become .
+ /// When the cancel action fails, the will become .
///
public void Cancel()
{
- ChangeState(OnCancel, ActivityStatus.Cancelled);
+ ChangeState(OnCancel, ActivityState.Cancelled);
log.WarnFormat(Resources.Activity_Run_Execution_of_0_has_been_canceled, Name);
}
///
/// This method finishes an that successfully ran.
- /// Successfully ran activities can be identified by a not equal to or .
+ /// Successfully ran activities can be identified by a equal to .
+ /// The of a successfully finished will become .
+ /// When the finish action fails, the will become .
///
public void Finish()
{
- if (Status != ActivityStatus.Failed && Status != ActivityStatus.Cancelled)
+ if (State == ActivityState.Executed)
{
- ChangeState(OnFinish, ActivityStatus.Finished);
+ ChangeState(OnFinish, ActivityState.Finished);
}
}
///
- /// Executes one step. This method will be called multiple times to allow for multiple
- /// execution steps. After calling this method, will be set to
- /// if no error has occurred.
+ /// This template method provides the actual run logic (it is called within ).
///
///
- /// Set to
- /// when an error has occurred while executing.
+ /// The should be set to when one or more errors occur.
+ /// By convention, the implementation of this method should not contain UI thread related logic.
///
- protected abstract void OnExecute();
+ protected abstract void OnRun();
///
- /// Cancels current run. will change to
- /// after this method has been called.
+ /// This template method provides the actual cancel logic (it is called within ).
///
+ ///
+ /// By convention, the implementation of this method should not contain UI thread related logic.
+ ///
protected abstract void OnCancel();
///
- /// Activity has finished successfully. After calling this method,
- /// will be set to if no error has occurred.
+ /// This template method provides the actual finish logic (it is called within ).
///
+ ///
+ /// By convention, only the implementation of this method might contain UI thread related logic.
+ ///
protected abstract void OnFinish();
private void OnProgressChanged()
@@ -124,26 +144,26 @@
}
}
- private void ChangeState(Action transitionAction, ActivityStatus statusAfter)
+ private void ChangeState(Action transitionAction, ActivityState stateAfter)
{
try
{
transitionAction();
- if (Status == ActivityStatus.Failed || Status == ActivityStatus.Cancelled)
+ if (State == ActivityState.Failed || State == ActivityState.Cancelled)
{
return;
}
}
catch (Exception e)
{
- Status = ActivityStatus.Failed;
+ State = ActivityState.Failed;
log.Error(e.Message);
return;
}
- Status = statusAfter;
+ State = stateAfter;
}
}
}
\ No newline at end of file
Index: Core/Common/src/Core.Common.Base/Service/ActivityState.cs
===================================================================
diff -u
--- Core/Common/src/Core.Common.Base/Service/ActivityState.cs (revision 0)
+++ Core/Common/src/Core.Common.Base/Service/ActivityState.cs (revision 358f5af627a563dd5b6903b94ba6abb16df8084e)
@@ -0,0 +1,38 @@
+namespace Core.Common.Base.Service
+{
+ ///
+ /// Enumeration that defines the possible states of an .
+ ///
+ public enum ActivityState
+ {
+ ///
+ /// The state of an that is about to be run.
+ ///
+ ///
+ None,
+
+ ///
+ /// The state of an that is successfully ran.
+ ///
+ ///
+ Executed,
+
+ ///
+ /// The state of an that is not successfully ran.
+ ///
+ ///
+ Failed,
+
+ ///
+ /// The state of an that is successfully cancelled.
+ ///
+ ///
+ Cancelled,
+
+ ///
+ /// The state of an that is successfully finished.
+ ///
+ ///
+ Finished
+ }
+}
\ No newline at end of file
Fisheye: Tag 358f5af627a563dd5b6903b94ba6abb16df8084e refers to a dead (removed) revision in file `Core/Common/src/Core.Common.Base/Service/ActivityStatus.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Core/Common/src/Core.Common.Base/Service/FileImportActivity.cs
===================================================================
diff -u -r5e6503b31c813b6f1c4d4dfbab28092bcf4809a6 -r358f5af627a563dd5b6903b94ba6abb16df8084e
--- Core/Common/src/Core.Common.Base/Service/FileImportActivity.cs (.../FileImportActivity.cs) (revision 5e6503b31c813b6f1c4d4dfbab28092bcf4809a6)
+++ Core/Common/src/Core.Common.Base/Service/FileImportActivity.cs (.../FileImportActivity.cs) (revision 358f5af627a563dd5b6903b94ba6abb16df8084e)
@@ -44,7 +44,7 @@
}
}
- protected override void OnExecute()
+ protected override void OnRun()
{
foreach (var fileName in files)
{
Index: Core/Common/test/Core.Common.Base.Test/Service/ActivityTest.cs
===================================================================
diff -u -r5e6503b31c813b6f1c4d4dfbab28092bcf4809a6 -r358f5af627a563dd5b6903b94ba6abb16df8084e
--- Core/Common/test/Core.Common.Base.Test/Service/ActivityTest.cs (.../ActivityTest.cs) (revision 5e6503b31c813b6f1c4d4dfbab28092bcf4809a6)
+++ Core/Common/test/Core.Common.Base.Test/Service/ActivityTest.cs (.../ActivityTest.cs) (revision 358f5af627a563dd5b6903b94ba6abb16df8084e)
@@ -14,7 +14,7 @@
// assert
Assert.IsNull(activity.Name);
- Assert.AreEqual(ActivityStatus.None, activity.Status);
+ Assert.AreEqual(ActivityState.None, activity.State);
Assert.IsNull(activity.ProgressText);
}
@@ -35,7 +35,7 @@
private class SimpleActivity : Activity
{
- protected override void OnExecute()
+ protected override void OnRun()
{
}
Index: Ringtoets/Piping/src/Ringtoets.Piping.Service/PipingCalculationActivity.cs
===================================================================
diff -u -r5e6503b31c813b6f1c4d4dfbab28092bcf4809a6 -r358f5af627a563dd5b6903b94ba6abb16df8084e
--- Ringtoets/Piping/src/Ringtoets.Piping.Service/PipingCalculationActivity.cs (.../PipingCalculationActivity.cs) (revision 5e6503b31c813b6f1c4d4dfbab28092bcf4809a6)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Service/PipingCalculationActivity.cs (.../PipingCalculationActivity.cs) (revision 358f5af627a563dd5b6903b94ba6abb16df8084e)
@@ -27,11 +27,11 @@
}
}
- protected override void OnExecute()
+ protected override void OnRun()
{
if (!PipingCalculationService.Validate(calculation))
{
- Status = ActivityStatus.Failed;
+ State = ActivityState.Failed;
return;
}
Index: Ringtoets/Piping/test/Ringtoets.Piping.Service.Test/PipingCalculationActivityTest.cs
===================================================================
diff -u -rbb3a4dbfa4e43123f5b101034e90b89e8712bd41 -r358f5af627a563dd5b6903b94ba6abb16df8084e
--- Ringtoets/Piping/test/Ringtoets.Piping.Service.Test/PipingCalculationActivityTest.cs (.../PipingCalculationActivityTest.cs) (revision bb3a4dbfa4e43123f5b101034e90b89e8712bd41)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Service.Test/PipingCalculationActivityTest.cs (.../PipingCalculationActivityTest.cs) (revision 358f5af627a563dd5b6903b94ba6abb16df8084e)
@@ -29,7 +29,7 @@
Assert.IsInstanceOf(activity);
Assert.AreEqual(calculation.Name, activity.Name);
Assert.IsNull(activity.ProgressText);
- Assert.AreEqual(ActivityStatus.None, activity.Status);
+ Assert.AreEqual(ActivityState.None, activity.State);
}
[Test]
@@ -57,7 +57,7 @@
StringAssert.StartsWith(String.Format("Validatie van '{0}' beƫindigd om: ", invalidPipingCalculation.Name), msgs[3]);
StringAssert.StartsWith(String.Format("Uitvoering van '{0}' is mislukt.", invalidPipingCalculation.Name), msgs[4]);
});
- Assert.AreEqual(ActivityStatus.Failed, activity.Status);
+ Assert.AreEqual(ActivityState.Failed, activity.State);
Assert.AreEqual(originalOutput, invalidPipingCalculation.Output);
}
@@ -84,7 +84,7 @@
StringAssert.StartsWith(String.Format("Berekening van '{0}' gestart om: ", validPipingCalculation.Name), msgs[2]);
StringAssert.StartsWith(String.Format("Berekening van '{0}' beƫindigd om: ", validPipingCalculation.Name), msgs[3]);
});
- Assert.AreEqual(ActivityStatus.Executed, activity.Status);
+ Assert.AreEqual(ActivityState.Executed, activity.State);
Assert.IsNotNull(validPipingCalculation.Output);
}