private Dictionary <int, int> GetQueueList(ISymCommand cmd) { var availableQueues = new Dictionary <int, int>(); while (!(cmd.Get("Action") == "DisplayLine" && cmd.Get("Text").Contains("Batch Queues Available:"))) { cmd = _socket.ReadCommand(); } string line = cmd.Get("Text"); string[] strQueues = line.Substring(line.IndexOf(':') + 1).Split(new[] { ',' }); for (int i = 0; i < strQueues.Length; i++) { strQueues[i] = strQueues[i].Trim(); if (strQueues[i].Contains("-")) { int pos = strQueues[i].IndexOf('-'); int start = int.Parse(strQueues[i].Substring(0, pos)); int end = int.Parse(strQueues[i].Substring(pos + 1)); for (int c = start; c <= end; c++) { availableQueues.Add(c, 0); } } else { availableQueues.Add(int.Parse(strQueues[i]), 0); } } return(availableQueues); }
public SpecfileResult FileCheck(File file) { if (file.Type != FileType.RepGen) { throw new Exception("Cannot check a " + file.FileTypeString() + " file"); } _socket.Write("mm3\u001B"); _socket.ReadCommand(); _socket.Write("7\r"); _socket.ReadCommand(); _socket.ReadCommand(); _socket.Write(file.Name + '\r'); ISymCommand cmd = _socket.ReadCommand(); if (cmd.HasParameter("Warning") || cmd.HasParameter("Error")) { _socket.ReadCommand(); throw new FileNotFoundException(); } if (cmd.Get("Action") == "NoError") { _socket.ReadCommand(); return(SpecfileResult.Success()); } int errRow = 0, errCol = 0; string errFile = "", errText = ""; if (cmd.Get("Action") == "Init") { errFile = cmd.Get("FileName"); cmd = _socket.ReadCommand(); while (cmd.Get("Action") != "DisplayEdit") { if (cmd.Get("Action") == "FileInfo") { errRow = int.Parse(cmd.Get("Line").Replace(",", "")); errCol = int.Parse(cmd.Get("Col").Replace(",", "")); } else if (cmd.Get("Action") == "ErrText") { errText += cmd.Get("Line") + " "; } cmd = _socket.ReadCommand(); } _socket.ReadCommand(); return(new SpecfileResult(file, errFile, errText, errRow, errCol)); } throw new Exception("An unknown error occurred."); }
public ISymCommand ReadCommand() { _data += Read(); if (!string.IsNullOrEmpty(_data)) { string commandStart = Encoding.ASCII.GetString(new byte[] { 0x1b, 0xfe }); string commandEnd = Encoding.ASCII.GetString(new byte[] { 0xfc }); int start = _data.IndexOf(commandStart, StringComparison.Ordinal); int end = _data.IndexOf(commandEnd, start + commandStart.Length, StringComparison.Ordinal); while (start >= 0 && end >= start + commandStart.Length) { int commandLength = end - start - commandStart.Length; string commandString = _data.Substring(start + commandStart.Length, commandLength); SymCommand newCommand = SymCommand.Parse(commandString); _data = _data.Substring(start + commandStart.Length + commandString.Length); int dataLength = _data.Length; if (newCommand.Command == "File") { int nextStart = _data.IndexOf(commandStart, StringComparison.Ordinal); if (nextStart > 2) { newCommand.Data = _data.Substring(0, nextStart - 2); _data = _data.Substring(nextStart); } } _commands.Add(newCommand); start = _data.IndexOf(commandStart, StringComparison.Ordinal); end = _data.IndexOf(commandEnd, start + commandStart.Length, StringComparison.Ordinal); } } if (_commandIndex + 1 == _commands.Count) { _commands.Clear(); _commandIndex = -1; } if (_commands.Count == 0) { return(SymCommand.Parse("")); } ISymCommand cmd = _commands[++_commandIndex]; if ((cmd.Command == "MsgDlg") && (cmd.HasParameter("Text"))) { if (cmd.Get("Text").IndexOf("From PID", StringComparison.Ordinal) != -1) { cmd = ReadCommand(); } } return(cmd); }
private bool SymLogin(int symDir, string userPassword) { _socket.Write("WINDOWSLEVEL=3\r"); int match = _socket.WaitFor("$ ", "SymStart~Global"); if (match == 0) { _socket.Write(String.Format("sym {0}\r", symDir)); } ISymCommand cmd = _socket.ReadCommand(); while (cmd.Command != "Input" || cmd.Get("HelpCode") == "10025") { if (cmd.Command == "Input" && cmd.Get("HelpCode") == "10025") { _socket.Write("$WinHostSync$\r"); break; } if (cmd.Command == "SymLogonError" && cmd.Get("Text").Contains("Too Many Invalid")) { _error = "Too Many Invalid Password Attempts"; return(false); } if (cmd.Command == "SymLogonInvalidUser") { _error = "Invalid Sym User"; return(false); } cmd = _socket.ReadCommand(); } _socket.Write(String.Format("{0}\r", userPassword)); _socket.Write("\r"); _socket.Write("\r"); _socket.Read(); return(true); }
private ISymCommand WaitForPrompt(string prompt) { while (true) { ISymCommand cmd = _socket.ReadCommand(); if (cmd.Get("Prompt").Contains(prompt)) { _socket.Clear(); return(cmd); } } }
private Dictionary<int, int> GetQueueList(ISymCommand cmd) { var availableQueues = new Dictionary<int, int>(); while (!(cmd.Get("Action") == "DisplayLine" && cmd.Get("Text").Contains("Batch Queues Available:"))) { cmd = _socket.ReadCommand(); } string line = cmd.Get("Text"); string[] strQueues = line.Substring(line.IndexOf(':') + 1).Split(new[] {','}); for (int i = 0; i < strQueues.Length; i++) { strQueues[i] = strQueues[i].Trim(); if (strQueues[i].Contains("-")) { int pos = strQueues[i].IndexOf('-'); int start = int.Parse(strQueues[i].Substring(0, pos)); int end = int.Parse(strQueues[i].Substring(pos + 1)); for (int c = start; c <= end; c++) availableQueues.Add(c, 0); } else availableQueues.Add(int.Parse(strQueues[i]), 0); } return availableQueues; }