-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from IndicoDataSolutions/meg/timeout2
[CAT-230] Incorporate new UIPath shared code to address timeouts.
- Loading branch information
Showing
88 changed files
with
2,040 additions
and
386 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
...ies/Indico.RPAActivities.Activities.Design/Designers/MarkSubmissionRetrievedDesigner.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<sap:ActivityDesigner x:Class="Indico.RPAActivities.Activities.Design.Designers.MarkSubmissionRetrievedDesigner" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:activity="clr-namespace:Indico.RPAActivities.Activities.Properties;assembly=Indico.RPAActivities.Activities" | ||
xmlns:sap="clr-namespace:System.Activities.Presentation;assembly=System.Activities.Presentation" | ||
xmlns:sapv="clr-namespace:System.Activities.Presentation.View;assembly=System.Activities.Presentation" | ||
xmlns:sapc="clr-namespace:System.Activities.Presentation.Converters;assembly=System.Activities.Presentation" | ||
xmlns:converters="clr-namespace:Indico.UiPath.Shared.Activities.Design.Converters" | ||
xmlns:uip="clr-namespace:Indico.UiPath.Shared.Activities.Design.Controls"> | ||
|
||
<sap:ActivityDesigner.Resources> | ||
<ResourceDictionary> | ||
<ResourceDictionary.MergedDictionaries> | ||
<ResourceDictionary Source="..\Themes\Generic.xaml" /> | ||
</ResourceDictionary.MergedDictionaries> | ||
<sapc:ArgumentToExpressionConverter x:Key="ArgumentToExpressionConverter" /> | ||
<converters:ActivityIconConverter x:Key="ActivityIconConverter" /> | ||
</ResourceDictionary> | ||
</sap:ActivityDesigner.Resources> | ||
|
||
<sap:ActivityDesigner.Icon> | ||
<DrawingBrush Stretch="Uniform" Drawing="{Binding Path=ModelItem, Converter={StaticResource ActivityIconConverter}, ConverterParameter=pack://application:\,\,\,/Indico.RPAActivities.Activities.Design;component/themes/icons.xaml}" /> | ||
</sap:ActivityDesigner.Icon> | ||
|
||
</sap:ActivityDesigner> |
13 changes: 13 additions & 0 deletions
13
.../Indico.RPAActivities.Activities.Design/Designers/MarkSubmissionRetrievedDesigner.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
namespace Indico.RPAActivities.Activities.Design.Designers | ||
{ | ||
/// <summary> | ||
/// Interaction logic for MarkSubmissionRetrievedDesigner.xaml | ||
/// </summary> | ||
public partial class MarkSubmissionRetrievedDesigner | ||
{ | ||
public MarkSubmissionRetrievedDesigner() | ||
{ | ||
InitializeComponent(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
Indico.RPAActivities/Indico.RPAActivities.Activities.Design/Properties/SharedResources.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 53 additions & 7 deletions
60
Indico.RPAActivities/Indico.RPAActivities.Activities/Activities/Common/IndicoActivityBase.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,72 @@ | ||
using System.Activities; | ||
using System; | ||
using System.Activities; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Indico.RPAActivities.Activities.Properties; | ||
using Indico.UiPath.Shared.Activities; | ||
using Indico.UiPath.Shared.Activities.RuntimeSimple; | ||
using Indico.UiPath.Shared.Activities.Localization; | ||
using Indico.UiPath.Shared.Activities.Utilities; | ||
|
||
namespace Indico.RPAActivities.Activities.Activities | ||
{ | ||
public abstract class IndicoActivityBase<TInput, TOutput> : TaskActivity<TInput, TOutput> | ||
public abstract class IndicoActivityBase<TInput, TOutput> : ContinuableAsyncCodeActivity | ||
{ | ||
protected Application Application { get; private set; } | ||
/// <summary> | ||
/// If set, continue executing the remaining activities even if the current activity has failed. | ||
/// </summary> | ||
[LocalizedCategory(nameof(Resources.Common_Category))] | ||
[LocalizedDisplayName(nameof(Resources.ContinueOnError_DisplayName))] | ||
[LocalizedDescription(nameof(Resources.ContinueOnError_Description))] | ||
public override InArgument<bool> ContinueOnError { get; set; } | ||
|
||
[LocalizedCategory(nameof(Resources.Common_Category))] | ||
[LocalizedDisplayName(nameof(Resources.Timeout_DisplayName))] | ||
[LocalizedDescription(nameof(Resources.Timeout_Description))] | ||
public InArgument<int> TimeoutMS { get; set; } = 60000; | ||
|
||
protected IndicoActivityBase() | ||
{ | ||
Constraints.Add(ActivityConstraints.HasParentType<IndicoActivityBase<TInput, TOutput>, IndicoScope>(string.Format(Resources.ValidationScope_Error, Resources.IndicoScope_DisplayName))); | ||
} | ||
|
||
protected override void Init(AsyncCodeActivityContext context) | ||
{ | ||
base.Init(context); | ||
protected abstract TInput GetInputs(AsyncCodeActivityContext ctx); | ||
|
||
var objectContainer = context.GetFromContext<IObjectContainer>(IndicoScope.ParentContainerPropertyTag); | ||
protected override IAsyncResult BeginExecute(AsyncCodeActivityContext context, AsyncCallback callback, object state) | ||
{ | ||
IObjectContainer objectContainer = context.GetFromContext<IObjectContainer>(IndicoScope.ParentContainerPropertyTag); | ||
Application = objectContainer.Get<Application>(); | ||
return base.BeginExecute(context, callback, state); | ||
} | ||
|
||
protected override async Task<Action<AsyncCodeActivityContext>> ExecuteAsync(AsyncCodeActivityContext context, CancellationToken cancellationToken) | ||
{ | ||
// Inputs | ||
int timeout = TimeoutMS.Get(context); | ||
|
||
CancellationTokenSource cts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken); | ||
cts.CancelAfter(timeout); | ||
|
||
// Set a timeout on the execution | ||
Task<TOutput> task = ExecuteWithTimeout(GetInputs(context), cts.Token); | ||
Task timer = Task.Delay(timeout, cts.Token); | ||
Task completedTask = await Task.WhenAny(task, timer); | ||
if (completedTask == task) | ||
{ | ||
// Outputs | ||
return (ctx) => | ||
{ | ||
SetResults(ctx, task.Result); | ||
}; | ||
} | ||
|
||
else | ||
{ | ||
throw new TimeoutException(Resources.Timeout_Error); | ||
} | ||
|
||
} | ||
protected abstract void SetResults(AsyncCodeActivityContext context, TOutput result); | ||
protected abstract Task<TOutput> ExecuteWithTimeout(TInput inputs, CancellationToken cancellationToken = default); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.