private void parseRC(string sRC) { Regex rg = new Regex(@"Microsoft.*\n.*All rights reserved."); sRC = rg.Replace(sRC, ""); string GingerRCStart = "~~~GINGER_RC_START~~~"; string GingerRCEnd = "~~~GINGER_RC_END~~~"; int i = sRC.IndexOf(GingerRCStart); int i2 = -1; if (i > 0) { i2 = sRC.IndexOf(GingerRCEnd, i); if (i2 > 0) { sRC = sRC.Substring(i + GingerRCStart.Length, i2 - i - GingerRCEnd.Length - 2); } } if (i > 0 && i2 > 0) { string[] RCValues = sRC.Split('\n'); foreach (string RCValue in RCValues) { if (RCValue.Length > 0) // Ignore empty lines { string Param; string Value; i = RCValue.IndexOf('='); if (i > 0) { Param = RCValue.Substring(0, i); //the rest is the value Value = RCValue.Substring(Param.Length + 1); } else { // in case of bad RC not per Ginger style we show it as "?" with value Param = "???"; Value = RCValue; } AddOrUpdateReturnParamActual(Param, Value); } } } else { //No params found so return the full output AddOrUpdateReturnParamActual("???", sRC); } }
public override void RunAction(Act act) { //TODO: add func to Act + Enum for switch string actClass = act.GetType().ToString(); //TODO: avoid hard coded string... actClass = actClass.Replace("GingerCore.Actions.", ""); switch (actClass) { case "ActConsoleCommand": mWait = ((ActConsoleCommand)act).WaitTime; ValueExpression VE = new ValueExpression(this.Environment, this.BusinessFlow); string ExpString = ((ActConsoleCommand)act).ExpString; VE.Value = ExpString; mExpString = VE.ValueCalculated; ActConsoleCommand ACC = (ActConsoleCommand)act; string command = GetCommandText(ACC); act.ExInfo = command; taskFinished = false; if (command.StartsWith("GINGER_RC=")) { //This is FTP command and we already have the result act.AddOrUpdateReturnParamActual("GINGER_RC", command.Replace("GINGER_RC=", "")); } else { string sRC; //Send the command via driver if (ACC.ConsoleCommand == ActConsoleCommand.eConsoleCommand.Script) { //TODO: externalize static const for ~~~GINGER_RC_END~~~ and all hard coded multi use strings sRC = mConsoleDriverWindow.RunConsoleCommand(command, "~~~GINGER_RC_END~~~"); } else { sRC = mConsoleDriverWindow.RunConsoleCommand(command); } if (mExpString != null && sRC.Contains(mExpString) == false) { act.Error = @"Expected String """ + mExpString + @""" not found in command output"; act.Status = Amdocs.Ginger.CoreNET.Execution.eRunStatus.Failed; return; } act.AddOrUpdateReturnParamActual("Result", sRC); sRC = sRC.Replace("\r", ""); sRC = sRC.Replace("\t", ""); string[] RCValues = sRC.Split('\n'); foreach (string RCValue in RCValues) { if (RCValue.Trim().Length > 0) { string Param; string Value; int i = -1; if (!string.IsNullOrEmpty(ACC.Delimiter)) { i = RCValue.IndexOf(ACC.Delimiter); } else { i = RCValue.IndexOf('='); } if ((i > 0) && (i != RCValue.IndexOf("==")) && (i != RCValue.IndexOf("!=") + 1)) { Param = (RCValue.Substring(0, i)).Trim(); //the rest is the value Value = RCValue.Substring(Param.Length + 1); Value = new string(Value.Where(ch => !char.IsControl(ch)).ToArray()); act.AddOrUpdateReturnParamActual(Param, Value); } } } } break; case "ActScreenShot": TakeScreenShot(act); break; default: throw new Exception("Action unknown/Not Impl in Driver - " + this.GetType().ToString()); } }
public override void RunAction(Act act) { //TODO: add func to Act + Enum for switch string actClass = act.GetType().ToString(); //TODO: avoid hard coded string... actClass = actClass.Replace("GingerCore.Actions.", ""); switch (actClass) { case "ActVBScript": ActScript ACC = (ActScript)act; mActVBS = (ActScript)act; string command = GetCommandText(ACC); act.ExInfo = command; if (command.StartsWith("GINGER_RC=")) { //This is FTP command and we already have the result act.AddOrUpdateReturnParamActual("GINGER_RC", command.Replace("GINGER_RC=", "")); } else { string sRC = ""; //Send the command via driver if (ACC.ScriptCommand == ActScript.eScriptAct.Script) { //TODO: externalize static const for ~~~GINGER_RC_END~~~ and all hard coded multi use strings sRC = RunScript(command); } else { sRC = RunScript(command); } sRC = sRC.Replace("\r", ""); string[] RCValues = sRC.Split('\n'); foreach (string RCValue in RCValues) { if (RCValue.Length > 0) // Ignore empty lines { string Param; string Value; int i = RCValue.IndexOf('='); if (i > 0) { Param = RCValue.Substring(0, i); //the rest is the value Value = RCValue.Substring(Param.Length + 1); } else { // in case of bad RC not per Ginger style we show it as "?" with value Param = "???"; Value = RCValue; } act.AddOrUpdateReturnParamActual(Param, Value); } } } break; default: throw new Exception("Action unknown/not implemented for the Driver: " + this.GetType().ToString()); } }