Skip to content

Commit

Permalink
Merge pull request UiPath#57 from UiPath/issue55
Browse files Browse the repository at this point in the history
Allows resuming Wf at correct point after persistence
  • Loading branch information
lbargaoanu authored Jun 18, 2019
2 parents 86c97d4 + f4d1b82 commit 66da71b
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 5 deletions.
2 changes: 2 additions & 0 deletions src/CoreWf/Bookmark.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ namespace System.Activities
using System.Runtime.Serialization;
using System.Globalization;
using System.Activities.Internals;
using System.ComponentModel;

[DataContract]
[Fx.Tag.XamlVisible(false)]
[TypeConverter(typeof(BookmarkConverter))]
public class Bookmark : IEquatable<Bookmark>
{
private static readonly Bookmark asyncOperationCompletionBookmark = new Bookmark(-1);
Expand Down
34 changes: 34 additions & 0 deletions src/CoreWf/BookmarkConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// This file is part of Core WF which is licensed under the MIT license.
// See LICENSE file in the project root for full license information.

namespace System.Activities
{
using System;
using System.Globalization;
using System.ComponentModel;

public class BookmarkConverter : TypeConverter
{
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
{
return sourceType == typeof(string) || sourceType == typeof(long);
}

public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
{

if (value is string stringValue && !String.IsNullOrEmpty(stringValue))
{
return new Bookmark(stringValue);
}

if (value is long longValue && longValue != 0)
{
return Bookmark.Create(longValue);
}

return base.ConvertFrom(context, culture, value);
}

}
}
2 changes: 2 additions & 0 deletions src/CoreWf/Hosting/WorkflowInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,8 @@ protected void Initialize(object deserializedRuntimeState)
this.executor.ThrowIfNonSerializable();

EnsureDefinitionReady();

InitializeCore(null, null);
}
#endif

Expand Down
6 changes: 3 additions & 3 deletions src/test/TestCases.Activities/Flowchart/Execution.cs
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ public void FlowchartWithOnlyFlowConditionalWithoutStartEvent()
/// <summary>
/// Unload and load flowchart while executing condition of flow conditional.
/// </summary>
[Fact(Skip = "Duplicate activities found in validation")]
[Fact()]
public void UnloadFlowchartWhileExecutingFlowConditionalCondition()
{
TestFlowchart flowchart = new TestFlowchart();
Expand Down Expand Up @@ -578,7 +578,7 @@ public void UnloadFlowchartWhileExecutingFlowConditionalCondition()
/// <summary>
/// Unload and load flowchart while executing flow switch's expression.
/// </summary>
[Fact(Skip = "Duplicate activities found in validation")]
[Fact()]
public void UnloadFlowchartWhileExecutingFlowSwitchExpression()
{
TestFlowchart flowchart = new TestFlowchart();
Expand Down Expand Up @@ -684,7 +684,7 @@ public void UseVariableInFlowchart()
/// <summary>
/// Unload and load flowchart while executing flow step
/// </summary>
[Fact(Skip = "Duplicate activities found in validation")]
[Fact()]
public void UnloadFlowchartWhileExecutingFlowStep()
{
TestFlowchart flowchart = new TestFlowchart();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ private static void TestInstanceOperationFromResumeBookmarkCallback(int operatio
}
}

[Fact(Skip = "Test is flaky, fails after 60 seconds")]
[Fact()]
public static void TestPersistDuringResumeBookmark()
{
bool isSync = true;
Expand Down
2 changes: 1 addition & 1 deletion src/test/TestCases.Runtime/WorkflowInstanceAbortTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ void AbortParallel(bool isTestCancel)
runtime.WaitForAborted(out Exception excepion, expectedTrace);
}

[Fact(Skip = "Test is flaky, fails after 60 seconds")]
[Fact()]
public void TestAbortLoad()
{
Variable<int> value = VariableHelper.Create<int>("value");
Expand Down

0 comments on commit 66da71b

Please sign in to comment.