Example #1
0
        public string CreateLogger(string address)
        {
            LowLevelParserLib bashParserLib;
            string            listenerAddress = string.Empty;


            if (!address.Contains(":") && !address.StartsWith("COM", StringComparison.OrdinalIgnoreCase))
            {
                if (_bashLevelParserLibs.ContainsKey(address))
                {
                    return(address);
                }

                using (AssetInventoryContext context = DbConnect.AssetInventoryContext())
                {
                    var bashLogCollector = context.BashLogCollectors.FirstOrDefault(n => n.PrinterId == address);
                    if (bashLogCollector == null)
                    {
                        TraceFactory.Logger.Error($@"No BashLog Collector found for: {address}.");
                        throw new Exception($"Unable to create a bash collector for the device: {address}");
                    }
                    if (bashLogCollector.Port == null || bashLogCollector.Port.Value == 0)
                    {
                        listenerAddress = bashLogCollector.Address;
                    }
                    else
                    {
                        if (bashLogCollector.Port != null)
                        {
                            listenerAddress = $"{bashLogCollector.Address}:{bashLogCollector.Port.Value}";
                        }
                    }
                }
            }

            if (string.IsNullOrEmpty(listenerAddress))
            {
                listenerAddress = address;
            }

            if (listenerAddress.StartsWith("COM", StringComparison.OrdinalIgnoreCase))
            {
                bashParserLib = new LowLevelParserLib(listenerAddress, address);
            }
            else
            {
                var telnetAddress = listenerAddress.Split(':');
                bashParserLib = new LowLevelParserLib(IPAddress.Parse(telnetAddress[0]), Convert.ToInt32(telnetAddress[1]));
            }

            _bashLevelParserLibs.AddOrUpdate(address, bashParserLib, (key, lib) => bashParserLib);

            return(address);
        }
Example #2
0
        /// <summary>
        /// Starts the logging for the specified device at the address
        /// </summary>
        public void StartLogging(string key)
        {
            LowLevelParserLib bashLevelParserLib = GetLowLevelParser(key);

            bashLevelParserLib.PollLog = true;
        }
Example #3
0
        public string ReadCommandOutputStream(string key)
        {
            LowLevelParserLib bashLevelParserLib = GetLowLevelParser(key);

            return(bashLevelParserLib.ReadCommandOutputStream());
        }
Example #4
0
        public string WaitForLine(string key, Int32 waitTimeInMSecs, string pattern)
        {
            LowLevelParserLib bashLevelParserLib = GetLowLevelParser(key);

            return(bashLevelParserLib.WaitForLine(waitTimeInMSecs, pattern));
        }
Example #5
0
        public string WaitFor(string key, Int32 waitTimeInMSecs, Regex[] waitTerminatePatterns, Boolean verbose, Func <bool> cancelFunction)
        {
            LowLevelParserLib bashLevelParserLib = GetLowLevelParser(key);

            return(bashLevelParserLib.WaitFor(waitTimeInMSecs, waitTerminatePatterns, verbose, cancelFunction));
        }
Example #6
0
        public string WaitFor(string key, int waitTimeInMilliSeconds, string pattern, bool verbose)
        {
            LowLevelParserLib bashLevelParserLib = GetLowLevelParser(key);

            return(bashLevelParserLib.WaitFor(waitTimeInMilliSeconds, pattern, verbose));
        }
Example #7
0
        public void WriteToEfiShell(string key, string command)
        {
            LowLevelParserLib bashLevelParserLib = GetLowLevelParser(key);

            bashLevelParserLib.WriteToEfiShell(command);
        }
Example #8
0
        public void WriteStream(string key, byte[] data)
        {
            LowLevelParserLib bashLevelParserLib = GetLowLevelParser(key);

            bashLevelParserLib.WriteStream(data);
        }
Example #9
0
        public void WriteStream(string key, string command)
        {
            LowLevelParserLib bashLevelParserLib = GetLowLevelParser(key);

            bashLevelParserLib.WriteStream(command);
        }
Example #10
0
        public void WriteStream(string key, byte value)
        {
            LowLevelParserLib bashLevelParserLib = GetLowLevelParser(key);

            bashLevelParserLib.WriteStream(value);
        }
Example #11
0
        public void StopLogging(string key)
        {
            LowLevelParserLib bashLevelParserLib = GetLowLevelParser(key);

            bashLevelParserLib.PollLog = false;
        }