/// <summary> /// run all automation /// </summary> private void RunAll() { if (Data != null) { // create new report IReporter reporter = Reporter.NewInstance; reporter.BeginReport(Name, Data.Name); while (Data.MoveNext() && !IsStopped) { reporter.BeginDataRow(Data.CurrentRowId); StartScript.Restart(); Scripts.Push(StartScript); Run(reporter); reporter.EndDataRow(Data.CurrentRowId); } reporter.EndReport(); } else { // create new report IReporter reporter = Reporter.NewInstance; reporter.BeginReport(Name + Constants.ReportText.ReportNameSuffix, null); StartScript.Restart(); Scripts.Push(StartScript); Run(reporter); reporter.EndReport(); } if (IsStopped && Interupted != null) { Interupted(this); } if (Ended != null) { Ended(this); } }
/// <summary> /// execute the script /// </summary> private void Run() { IReporter reporter = Reporter.NewInstance; reporter.BeginReport("path"); while (Scripts.Count > 0) { CurrentScript = Scripts.Pop(); // begin new section in report if (CurrentScript.CurrentLineNumber == 0) { reporter.BeginScript(CurrentScript.Name); } // loop for each line of current script while (CurrentScript.HasNextLine) { ActionLine actLine = CurrentScript.Next(); if (actLine.ActionName == Constants.ActionUseInterface) { Interface newInterface = new Interface(Parser); newInterface.PathFile = actLine.Arguments[Constants.KeywordInterface] + Parser.FileExtension; Interfaces.Add(newInterface.Name, newInterface); } else if (actLine.ActionName == Constants.ActionStartScript) { Script newScript = new Script(Parser); newScript.PathFile = actLine.Arguments[Constants.KeywordScript] + Parser.FileExtension; Scripts.Push(CurrentScript); CurrentScript = newScript; // begin new section in report reporter.BeginScript(CurrentScript.Name); } else { Action action = getAction(actLine); if (action == null) { throw new InvalidOperationException("No action named '" + actLine.ActionName + "'"); } if (!action.IsValid()) { throw new InvalidOperationException("Invalid arguments for action named '" + actLine.ActionName + "'"); } int ret = action.Execute(); action.Reset(); // write result of executing to report reporter.WriteLine(); } } // end section in report if (CurrentScript.CurrentLineNumber > 0) { reporter.EndScript(); } } }