From d861184be57895488ea7e3b786d0ed7607086f8d Mon Sep 17 00:00:00 2001 From: Jason Bayldon Date: Sat, 11 Jan 2020 01:01:48 -0500 Subject: [PATCH] Added Command to skip to next loop iteration https://github.com/saucepleez/taskt/issues/184 --- .../Commands/BeginContinousLoopCommand.cs | 7 ++++ .../Automation/Commands/BeginIfCommand.cs | 2 +- .../Commands/BeginListLoopCommand.cs | 7 ++++ .../Commands/BeginNumberOfTimesLoopCommand.cs | 8 ++++ .../Automation/Commands/NextLoopCommand.cs | 39 ++++++++++++++++++ .../Core/Automation/Commands/ScriptCommand.cs | 3 +- .../Engine/AutomationEngineInstance.cs | 5 +++ taskt/Properties/Resources.Designer.cs | 10 +++++ taskt/Properties/Resources.resx | 3 ++ taskt/Resources/command-nextloop.png | Bin 0 -> 11678 bytes taskt/UI/CustomControls/CustomControls.cs | 1 + taskt/taskt.csproj | 2 + 12 files changed, 85 insertions(+), 2 deletions(-) create mode 100644 taskt/Core/Automation/Commands/NextLoopCommand.cs create mode 100644 taskt/Resources/command-nextloop.png diff --git a/taskt/Core/Automation/Commands/BeginContinousLoopCommand.cs b/taskt/Core/Automation/Commands/BeginContinousLoopCommand.cs index c55466ad5..9410184c5 100644 --- a/taskt/Core/Automation/Commands/BeginContinousLoopCommand.cs +++ b/taskt/Core/Automation/Commands/BeginContinousLoopCommand.cs @@ -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; + } } } } diff --git a/taskt/Core/Automation/Commands/BeginIfCommand.cs b/taskt/Core/Automation/Commands/BeginIfCommand.cs index 79ffaede4..3796642a5 100644 --- a/taskt/Core/Automation/Commands/BeginIfCommand.cs +++ b/taskt/Core/Automation/Commands/BeginIfCommand.cs @@ -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]); diff --git a/taskt/Core/Automation/Commands/BeginListLoopCommand.cs b/taskt/Core/Automation/Commands/BeginListLoopCommand.cs index eeeeff3b7..05129ad1c 100644 --- a/taskt/Core/Automation/Commands/BeginListLoopCommand.cs +++ b/taskt/Core/Automation/Commands/BeginListLoopCommand.cs @@ -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); diff --git a/taskt/Core/Automation/Commands/BeginNumberOfTimesLoopCommand.cs b/taskt/Core/Automation/Commands/BeginNumberOfTimesLoopCommand.cs index dc47ebd2e..460dffbde 100644 --- a/taskt/Core/Automation/Commands/BeginNumberOfTimesLoopCommand.cs +++ b/taskt/Core/Automation/Commands/BeginNumberOfTimesLoopCommand.cs @@ -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; + } + + } diff --git a/taskt/Core/Automation/Commands/NextLoopCommand.cs b/taskt/Core/Automation/Commands/NextLoopCommand.cs new file mode 100644 index 000000000..85e038ba4 --- /dev/null +++ b/taskt/Core/Automation/Commands/NextLoopCommand.cs @@ -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 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(); + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/ScriptCommand.cs b/taskt/Core/Automation/Commands/ScriptCommand.cs index 2fe75473a..debd44f89 100644 --- a/taskt/Core/Automation/Commands/ScriptCommand.cs +++ b/taskt/Core/Automation/Commands/ScriptCommand.cs @@ -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))] diff --git a/taskt/Core/Automation/Engine/AutomationEngineInstance.cs b/taskt/Core/Automation/Engine/AutomationEngineInstance.cs index 82c121942..9bb3a2b06 100644 --- a/taskt/Core/Automation/Engine/AutomationEngineInstance.cs +++ b/taskt/Core/Automation/Engine/AutomationEngineInstance.cs @@ -20,6 +20,7 @@ public class AutomationEngineInstance public List 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; } @@ -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 diff --git a/taskt/Properties/Resources.Designer.cs b/taskt/Properties/Resources.Designer.cs index a069697d1..097f071e1 100644 --- a/taskt/Properties/Resources.Designer.cs +++ b/taskt/Properties/Resources.Designer.cs @@ -330,6 +330,16 @@ internal static System.Drawing.Bitmap command_input { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap command_nextloop { + get { + object obj = ResourceManager.GetObject("command_nextloop", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// diff --git a/taskt/Properties/Resources.resx b/taskt/Properties/Resources.resx index 498120989..85f09df71 100644 --- a/taskt/Properties/Resources.resx +++ b/taskt/Properties/Resources.resx @@ -316,4 +316,7 @@ ..\Resources\command-begin-multi-if.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\command-nextloop.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file diff --git a/taskt/Resources/command-nextloop.png b/taskt/Resources/command-nextloop.png new file mode 100644 index 0000000000000000000000000000000000000000..b5a2c80962a402952360dd303dd720b66e6b5a14 GIT binary patch literal 11678 zcmeHNX;f2Zw>}IC+6s<%t;Zk|pjHZ&$Pgt!i!B~0L}dzs7^{FS2!zNK8KSnOmKyZL z3Bf?MicJuLIG_mPfN3NQ6@#cuk{E47AZP@X;qI6A-uv(V`|i4HeX^DyZ%+2R=jYj* z>|5vWGh_Nk(=iO2L9AK50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m#-~?=20wm(*v0O{_Uh+hE~x5Gq8AoIw324VJ}m>TB^Kh+nV} zjOu>ouy*jGcGj|9rW3+nKAN&I)-ly~l193(XGBiPu%U#R^ulHo>z=Pkb(8;!2w}+q zI}&#vH!|bzKykhH2zRwh+pPa(9xR&|(q!h)Hzg?N6PENd2S-4B_w{W8M;Jj{QMkK9 z(4OFQpLsCz+um11=5??Zg&WP&|14S8dYjwOcaEAYzQ-N|$F4&IK5zVt?WA^)z zAho8_R-UA!eU#<{dlzsHTB~6Gb!kMOnDS?>os%pGY|^8sqG1|Xwfu>8=?^t0)Ic}+ zXp+XrPt^Iq% z3Y{lN7=;}x#!gY_5-pBi^<*)g8jpMA7`?)t@@KXsw@`ii(Xt{U~*0kdj`w&`I`G>1fd%hmNKp zt$2IdumEvmul@AQLtp+j5j(%;EzH6+8BOUpr#ld3ly-8{`toK-W|(GJrafvhIcH-^ zj{@}_o6PEoBXp05v6I;3m|fJ0hlRE;%j}w6^Jo#_P?AYtk5Pr3b%mwMyNb$`^r}oS zP?K8z_9+&Nu(T+fUUOL8zGM8abJS?GY27@vHW^*}_Lyo8QTpgk;V2uJuRfiB0{MUE zD_FG_-szv%Kn?}wPHjV(>kjVg1Bm*jTEtBPbo4AK;GBoZsJh zmklfXZAXUkwn})E$#EOw<*Ve>cS5+FD&LI|*`oIRr0V&q7lZ?hi3pI*YU76W=;KNW zYZ2o%tc@F-_WlD)|N1|zqK^Il_?CefrBQIBPvIl62=w%I&UWBWP2cnW!)xz9y9a&f v{YMv}@xK4$CV=?=^1)Sj?f>>Gxo5&)x$^$^N5i*wqML~?{a2TM!QS(qh33H< literal 0 HcmV?d00001 diff --git a/taskt/UI/CustomControls/CustomControls.cs b/taskt/UI/CustomControls/CustomControls.cs index 5a514fb90..4e486591e 100644 --- a/taskt/UI/CustomControls/CustomControls.cs +++ b/taskt/UI/CustomControls/CustomControls.cs @@ -511,6 +511,7 @@ public static Dictionary 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); diff --git a/taskt/taskt.csproj b/taskt/taskt.csproj index d2ad39aec..1074dcee8 100644 --- a/taskt/taskt.csproj +++ b/taskt/taskt.csproj @@ -165,6 +165,7 @@ + @@ -734,6 +735,7 @@ + Always