Skip to content

Commit

Permalink
Fix index/Total updates in BreakableLoop
Browse files Browse the repository at this point in the history
  • Loading branch information
skadefro committed Apr 23, 2024
1 parent 33cf282 commit 0934913
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 64 deletions.
92 changes: 29 additions & 63 deletions OpenRPA.Interfaces/BreakableLoop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,93 +41,59 @@ private void OnContinue(NativeActivityContext context, Bookmark bookmark, object
context.ResumeBookmark(_bookmark, value);
}
}
public void SetTotal(NativeActivityContext context, int Value)
{
var input = GetDescriptor<int>(context, "Total");
if (input == null) return;
input.SetValue(context.DataContext, Value);
}
public void IncIndex(NativeActivityContext context)
{
var input = GetTotalDescriptor(context);
var input = GetDescriptor<int>(context, "Index");
if (input == null) return;
if (input != null)
try
{
try
var _index = 0;
var value = input.GetValue(context.DataContext);
if (value != null)
{
var _index = 0;
var value = input.GetValue(context.DataContext);
if (value != null)
if (value is int wfview)
{
if (value is int wfview)
{
_index = (int)value;
}
else if(int.TryParse(value.ToString(), out int current))
{
_index = current;
}
_index = (int)value;
}
_index++;
input.SetValue(context.DataContext, _index);
}
catch (Exception ex)
{
Log.Warning("Updating loop Index failed with " + ex.ToString());
}
}
}
public Variable GetTotalVariable(NativeActivityContext context)
{
if (Variables.Count < 1) return null;
for (var i = 0; i < Variables.Count; i++)
{
var variable = Variables[i];
if (variable.Name == "Total" && variable.Type == typeof(int))
{
return variable;
else if(int.TryParse(value.ToString(), out int current))
{
_index = current;
}
}
_index++;
input.SetValue(context.DataContext, _index);
}
return null;
}
public PropertyDescriptor GetTotalDescriptor(NativeActivityContext context)
{
if (Variables.Count < 1) return null;
for (var i = 0; i < Variables.Count; i++)
catch (Exception ex)
{
var variable = Variables[i];
if (variable.Name == "Total" && variable.Type == typeof(int))
{
return context.DataContext.GetProperties()[variable.Name];
}
Log.Warning("Updating loop Index failed with " + ex.ToString());
}
return null;
}
public Variable GetIndexVariable(NativeActivityContext context)
public Variable GetVariable<T>(NativeActivityContext context, string Name)
{
if (Variables.Count < 1) return null;
if(context == null) return null;
if (string.IsNullOrEmpty(Name)) return null;
for (var i = 0; i < Variables.Count; i++)
{
var variable = Variables[i];
if (variable.Name == "Index" && variable.Type == typeof(int))
if (variable.Name.ToLower() == Name.ToLower() && variable.Type == typeof(T))
{
return variable;
}
}
return null;
}
public PropertyDescriptor GetIndexDescriptor(NativeActivityContext context)
{
if (Variables.Count < 1) return null;
for (var i = 0; i < Variables.Count; i++)
{
var variable = Variables[i];
if (variable.Name == "Index" && variable.Type == typeof(int))
{
return context.DataContext.GetProperties()[variable.Name];
}
}
return null;
}
public void SetTotal(NativeActivityContext context, int Value)
public PropertyDescriptor GetDescriptor<T>(NativeActivityContext context, string Name)
{
var input = GetTotalDescriptor(context);
if (input == null) return;
input.SetValue(context.DataContext, Value);
var v = GetVariable<T>(context, Name);
if(v == null) return null;
return context.DataContext.GetProperties()[v.Name];
}
[System.ComponentModel.Browsable(false)]
public System.Collections.ObjectModel.Collection<Variable> Variables { get; set; } = new System.Collections.ObjectModel.Collection<Variable>();
Expand Down
2 changes: 1 addition & 1 deletion OpenRPA/OpenRPA.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<Description>Base UI of OpenRPA, used as part of OpenRPA robot</Description>
<PackageLicenseExpression>MPL-2.0</PackageLicenseExpression>
<PackageProjectUrl>https://github.com/open-rpa/openrpa</PackageProjectUrl>
<Version>1.4.57.3</Version>
<Version>1.4.57.4</Version>
<PackageReleaseNotes></PackageReleaseNotes>
<PackageIcon>openrpa.png</PackageIcon>
<Configurations>Debug;Release;ReleaseNuget;PrepInstaller</Configurations>
Expand Down

0 comments on commit 0934913

Please sign in to comment.