/// <summary> /// Perform some kind of control action /// </summary> /// <param name="client"></param> /// <returns></returns> public override bool Execute(SshClient client) { bool success = false; try { var sourcePath = Path.Combine(Globals.CacheFolder, SourceFile); if (!File.Exists(sourcePath)) { Logger.Warn("SourceFile '" + sourcePath + "' does not exist"); return(false); } var sourceText = File.ReadAllText(sourcePath); var displayText = ScriptHelpers.ReplaceVars(sourceText); var displayPath = Path.Combine(Globals.CacheFolder, Globals.CustomerSerialNumber + DateTime.Now.Ticks + ".tmp"); File.WriteAllText(displayPath, displayText); Process.Start(Command, displayPath); success = true; } catch (Exception e) { Logger.Warn("Exception in report command: " + e.Message); } return(success); }
public ModemControlCommand(XmlNode n) : base(n) { if (n.Attributes != null) { foreach (XmlAttribute xa in n.Attributes) { switch (xa.Name) { // Command string to send case "minCSQ": try { MinCSQ = int.Parse(ScriptHelpers.ReplaceVars(xa.Value)); } catch (Exception e) { Logger.Warn("Exception parsing minCSQ: " + e.Message); } break; case "hangUpOnFail": try { HangUpOnFail = xa.Value; } catch (Exception e) { Logger.Warn("Exception parsing hangUpOnFail" + e.Message); } break; } } } }
public ControlCommand(XmlNode n) : base(n) { if (n.Attributes != null) { foreach (XmlAttribute xa in n.Attributes) { switch (xa.Name) { // Command string to send case "send": Send = ScriptHelpers.ReplaceVars(xa.Value); break; // Response should contain this string case "successResponse": SuccessResponse = ScriptHelpers.ReplaceVars(xa.Value); break; case "errorResponse": ErrorResponse = ScriptHelpers.ReplaceVars(xa.Value); break; // Wait for up to x secs case "waitForSecs": try { TimeoutSecs = int.Parse(xa.Value); } catch (Exception e) { Logger.Warn("Problem parsing XML: " + e.Message); } break; case "prompt": Prompt = xa.Value; break; case "setVariable": VariableForOutput = ScriptHelpers.ReplaceVars(xa.Value); break; // Wait for up to x secs } } } }
public Command(XmlNode n) { OutputRegExp = ""; if (n.Attributes != null) { foreach (XmlAttribute xa in n.Attributes) { switch (xa.Name) { case "mode": switch (xa.Value) { case "force": Mode = EnumMode.Force; break; default: Logger.Warn("Unknown attribute value: " + xa.Name + "=" + xa.Value); break; } break; case "source": Source = ScriptHelpers.ReplaceVars(xa.Value); break; case "target": Target = ScriptHelpers.ReplaceVars(xa.Value); break; case "log": Log = ScriptHelpers.ReplaceVars(xa.Value); break; case "failureMode": switch (xa.Value) { case "fail": FailureMode = EnumFailureMode.Fail; break; case "ignore": FailureMode = EnumFailureMode.Ignore; break; case "warn": FailureMode = EnumFailureMode.Warn; break; } break; case "forceStoreOutput": try { ForceStoreOutput = bool.Parse(xa.Value); } catch (Exception e) { Logger.Warn("Problem parsing XML: " + e.Message); } break; case "outputRegExp": OutputRegExp = xa.Value; break; case "initWait": try { InitWaitSecs = int.Parse(xa.Value); } catch (Exception e) { Logger.Warn("Problem parsing XML: " + e.Message); } break; } } } }