Skip to content

Commit

Permalink
Added Command to skip to next loop iteration saucepleez#184
Browse files Browse the repository at this point in the history
  • Loading branch information
saucepleez committed Jan 11, 2020
1 parent 2095b2b commit d861184
Show file tree
Hide file tree
Showing 12 changed files with 85 additions and 2 deletions.
7 changes: 7 additions & 0 deletions taskt/Core/Automation/Commands/BeginContinousLoopCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ public override void RunCommand(object sender, Core.Script.ScriptAction parentCo
engine.CurrentLoopCancelled = false;
return;
}

if (engine.CurrentLoopContinuing)
{
engine.ReportProgress("Continuing Next Loop From Line " + loopCommand.LineNumber);
engine.CurrentLoopContinuing = false;
break;
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion taskt/Core/Automation/Commands/BeginIfCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public override void RunCommand(object sender, Core.Script.ScriptAction parentCo

for (int i = startIndex; i < endIndex; i++)
{
if ((engine.IsCancellationPending) || (engine.CurrentLoopCancelled))
if ((engine.IsCancellationPending) || (engine.CurrentLoopCancelled) || (engine.CurrentLoopContinuing))
return;

engine.ExecuteCommand(parentCommand.AdditionalScriptCommands[i]);
Expand Down
7 changes: 7 additions & 0 deletions taskt/Core/Automation/Commands/BeginListLoopCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,13 @@ public override void RunCommand(object sender, Core.Script.ScriptAction parentCo
engine.CurrentLoopCancelled = false;
return;
}

if (engine.CurrentLoopContinuing)
{
engine.ReportProgress("Continuing Next Loop From Line " + loopCommand.LineNumber);
engine.CurrentLoopContinuing = false;
break;
}
}

engine.ReportProgress("Finished Loop From Line " + loopCommand.LineNumber);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,14 @@ public override void RunCommand(object sender, Core.Script.ScriptAction parentCo
return;
}

if (engine.CurrentLoopContinuing)
{
engine.ReportProgress("Continuing Next Loop From Line " + loopCommand.LineNumber);
engine.CurrentLoopContinuing = false;
break;
}


}


Expand Down
39 changes: 39 additions & 0 deletions taskt/Core/Automation/Commands/NextLoopCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using taskt.UI.CustomControls;
using taskt.UI.Forms;

namespace taskt.Core.Automation.Commands
{
[Serializable]
[Attributes.ClassAttributes.Group("Loop Commands")]
[Attributes.ClassAttributes.Description("This command enables user to break and exit from the current loop")]
[Attributes.ClassAttributes.UsesDescription("Use this command when you want to break from the current loop")]
[Attributes.ClassAttributes.ImplementationDescription("")]
public class NextLoopCommand : ScriptCommand
{
public NextLoopCommand()
{
this.DefaultPause = 0;
this.CommandName = "NextLoopCommand";
this.SelectionName = "Next Loop";
this.CommandEnabled = true;
this.CustomRendering = true;
}
public override List<Control> Render(frmCommandEditor editor)
{
base.Render(editor);

RenderedControls.Add(CommandControls.CreateDefaultLabelFor("v_Comment", this));
RenderedControls.Add(CommandControls.CreateDefaultInputFor("v_Comment", this, 100, 300));

return RenderedControls;
}

public override string GetDisplayValue()
{
return base.GetDisplayValue();
}
}
}
3 changes: 2 additions & 1 deletion taskt/Core/Automation/Commands/ScriptCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ namespace taskt.Core.Automation.Commands
[XmlInclude(typeof(ExcelCreateDataSetCommand))]
[XmlInclude(typeof(DatabaseRunQueryCommand))]
[XmlInclude(typeof(BeginNumberOfTimesLoopCommand))]
[XmlInclude(typeof(BeginListLoopCommand))]
[XmlInclude(typeof(BeginListLoopCommand))]
[XmlInclude(typeof(NextLoopCommand))]
[XmlInclude(typeof(BeginContinousLoopCommand))]
[XmlInclude(typeof(SequenceCommand))]
[XmlInclude(typeof(StopTaskCommand))]
Expand Down
5 changes: 5 additions & 0 deletions taskt/Core/Automation/Engine/AutomationEngineInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public class AutomationEngineInstance
public List<ScriptError> ErrorsOccured { get; set; }
public bool IsCancellationPending { get; set; }
public bool CurrentLoopCancelled { get; set; }
public bool CurrentLoopContinuing { get; set; }
private bool IsScriptPaused { get; set; }
[JsonIgnore]
public UI.Forms.frmScriptEngine tasktEngineUI { get; set; }
Expand Down Expand Up @@ -290,6 +291,10 @@ public void ExecuteCommand(Core.Script.ScriptAction command)
{
CurrentLoopCancelled = true;
}
else if (parentCommand is Core.Automation.Commands.NextLoopCommand)
{
CurrentLoopContinuing = true;
}
else if(parentCommand is Core.Automation.Commands.SetEngineDelayCommand)
{
//get variable
Expand Down
10 changes: 10 additions & 0 deletions taskt/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions taskt/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -316,4 +316,7 @@
<data name="command_begin_multi_if" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\command-begin-multi-if.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="command_nextloop" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\command-nextloop.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>
Binary file added taskt/Resources/command-nextloop.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions taskt/UI/CustomControls/CustomControls.cs
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,7 @@ public static Dictionary<string, Image> UIImageDictionary()
uiImages.Add("StringSplitCommand", taskt.Properties.Resources.command_string);
uiImages.Add("StringReplaceCommand", taskt.Properties.Resources.command_string);
uiImages.Add("BeginIfCommand", taskt.Properties.Resources.command_begin_if);
uiImages.Add("NextLoopCommand", taskt.Properties.Resources.command_nextloop);
uiImages.Add("BeginMultiIfCommand", taskt.Properties.Resources.command_begin_multi_if);
uiImages.Add("EndIfCommand", taskt.Properties.Resources.command_end_if);
uiImages.Add("ElseCommand", taskt.Properties.Resources.command_else);
Expand Down
2 changes: 2 additions & 0 deletions taskt/taskt.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@
<Compile Include="Core\ApplicationUpdate.cs" />
<Compile Include="Core\ApplicationSettings.cs" />
<Compile Include="Core\Automation\Commands\BeginMutliIfCommand.cs" />
<Compile Include="Core\Automation\Commands\NextLoopCommand.cs" />
<Compile Include="Core\Automation\Commands\OutlookEmailCommand.cs" />
<Compile Include="Core\Automation\Commands\GetRegexMatchesCommand.cs" />
<Compile Include="Core\Automation\Commands\GetDictionaryValueCommand.cs" />
Expand Down Expand Up @@ -734,6 +735,7 @@
<None Include="Resources\command-try.png" />
<None Include="Resources\command-remote.png" />
<None Include="Resources\command-begin-multi-if.png" />
<None Include="Resources\command-nextloop.png" />
<Content Include="Resources\IEDriverServer.exe">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
Expand Down

0 comments on commit d861184

Please sign in to comment.