private void WaitForAllSwitchStatusTransmited(Telnet.Terminal telnetSwitch, DisableGetObjects.Setting_SwitchType whatTypeOfSwitch)
        {
            //大量交换机显示==more==信息,因此需要等待命令行
            //added @ 2012 05 20 by sc
            for (int counter = 0; counter < 20; ++counter)
            {
                if (!telnetSwitch.SendResponse(" ", false))
                {
                    lock (nowUsingItem)
                    { nowUsingItem.FlushResult = "发送等待命令行参数的请求失败"; }
                    throw new Exception();
                }
            }

            ///最大尝试次数
            const int MAXIMUM_TRY_COUNT = 20;

            for (int currectTry = 0; currectTry <= MAXIMUM_TRY_COUNT; ++currectTry)
            {
                telnetSwitch.WaitForChangedScreen();

                //若是屏幕上没有出现命令提示符
                try
                {
                    if (telnetSwitch.VirtualScreen.FindOnScreen(whatTypeOfSwitch.PromptForCommandAfterEnable, false) != null)
                    {
                        break;
                    }
                }
                catch (NullReferenceException)
                {
                    lock (nowUsingItem)
                    { nowUsingItem.FlushResult = "发送请求命令行参数的请求中,连接断开"; }
                    throw new Exception();
                }
                catch (Exception)
                {
                    lock (nowUsingItem)
                    { nowUsingItem.FlushResult = "发送请求命令行参数的请求失败"; }
                    throw new Exception();
                }

                if (currectTry == MAXIMUM_TRY_COUNT)
                {
                    //到达最大重试门限
                    lock (nowUsingItem)
                    {
                        nowUsingItem.LastFlushLog += "\n到达取得数据最大门限\n";
                    }
                }
                else
                {

                    //发送空格以及两个回车
                    if (!telnetSwitch.SendResponse(" ", true))
                    {
                        lock (nowUsingItem)
                        { nowUsingItem.FlushResult = "发送等待命令行参数的请求失败-1"; }
                        throw new Exception();
                    }
                }

            }
        }
        private void SendLoginUserNameIfNeeded(Telnet.Terminal telnetSwitch, DisableGetObjects.Setting_SwitchType whatTypeOfSwitch)
        {
            if (whatTypeOfSwitch.IsThisSwitchNeedsOfUserName)
            {
                LogInToEvent.WriteDebug(nowUsingItem.Name + "/" + nowUsingItem.IpAddress + "-" + "要求登录用户名");
                lock (nowUsingItem)
                {
                    nowUsingItem.LastFlushLog += "\n" + nowUsingItem.Name + "/" + nowUsingItem.IpAddress + "-" + "要求登录用户名\n";
                }
                try
                {
                    telnetSwitch.WaitForString(whatTypeOfSwitch.PromptForUserName);

                }
                catch (Exception e)
                {
                    lock (nowUsingItem)
                    {
                        nowUsingItem.FlushResult = "要求用户名时遇到异常-" + e.ToString();
                    }
                    LogInToEvent.WriteDebug(nowUsingItem.Name + "/" + nowUsingItem.IpAddress + "-" + e.ToString());
                    throw new Exception();
                }

                if (!telnetSwitch.SendResponse(nowUsingItem.UserName, true))
                {
                    lock (nowUsingItem)
                    {
                        nowUsingItem.FlushResult = "未发送用户名";
                    }

                    throw new Exception();
                }

                if (!telnetSwitch.WaitForChangedScreen())
                {
                    lock (nowUsingItem)
                    {
                        nowUsingItem.FlushResult = "等待用户名结果失败";
                    }
                    throw new Exception();
                }

            }
        }
        private void SendLoginPassword_LowPriv(Telnet.Terminal telnetSwitch, DisableGetObjects.Setting_SwitchType whatTypeOfSwitch)
        {
            LogInToEvent.WriteDebug(nowUsingItem.Name + "/" + nowUsingItem.IpAddress + "-" + "要求登录密码");
            lock (nowUsingItem)
            {
                nowUsingItem.LastFlushLog += "\n" + nowUsingItem.Name + "/" + nowUsingItem.IpAddress + "-" + "要求登录密码\n";
            }
            try
            {
                telnetSwitch.WaitForString(whatTypeOfSwitch.PromptForPassword);

            }
            catch (Exception e)
            {
                LogInToEvent.WriteDebug(nowUsingItem.Name + "/" + nowUsingItem.IpAddress + "-" + e.ToString());
                lock (nowUsingItem)
                {
                    nowUsingItem.FlushResult = "没有要求密码或密码请求字符串不正确";
                }
                throw new Exception();
            }
            LogInToEvent.WriteDebug(nowUsingItem.Name + "/" + nowUsingItem.IpAddress + "-" + "发送登录密码");
            lock (nowUsingItem)
            {
                nowUsingItem.LastFlushLog += "\n" + nowUsingItem.Name + "/" + nowUsingItem.IpAddress + "-" + "发送登录密码\n";
            }
            if (!telnetSwitch.SendResponse(nowUsingItem.Password, true))
            {
                lock (nowUsingItem)
                {
                    nowUsingItem.FlushResult = "发送密码失败";
                }
                throw new Exception();
            }
            if (!telnetSwitch.WaitForChangedScreen())
            {
                lock (nowUsingItem)
                {
                    nowUsingItem.FlushResult = "发送密码后没有响应";
                }
                throw new Exception();
            }
        }
        private void SendLoginPassword_HighPriv(Telnet.Terminal telnetSwitch, DisableGetObjects.Setting_SwitchType whatTypeOfSwitch)
        {
            //enable密码
            LogInToEvent.WriteDebug(nowUsingItem.Name + "/" + nowUsingItem.IpAddress + "-" + "等待要求enable密码");
            lock (nowUsingItem)
            {
                nowUsingItem.LastFlushLog += "\n" + nowUsingItem.Name + "/" + nowUsingItem.IpAddress + "-" + "等待要求enable密码\n";
            }
            try
            {
                telnetSwitch.WaitForString(whatTypeOfSwitch.PromptForEnablePassword);
            }
            catch (Exception e)
            {
                LogInToEvent.WriteDebug(nowUsingItem.Name + "/" + nowUsingItem.IpAddress + "-" + e.ToString());
                lock (nowUsingItem)
                { nowUsingItem.FlushResult = "没有提示输入enable密码/enable用户名错误?"; }
                throw new Exception();
            }
            lock (nowUsingItem)
            { nowUsingItem.LastFlushLog += "\n" + nowUsingItem.Name + "/" + nowUsingItem.IpAddress + "-" + "发送enable密码\n"; }
            if (!telnetSwitch.SendResponse(nowUsingItem.EnablePassword, true))
            {
                lock (nowUsingItem)
                { nowUsingItem.FlushResult = "错误:发送enable密码失败"; }
                throw new Exception();
            }

            if (!telnetSwitch.WaitForChangedScreen())
            {
                lock (nowUsingItem)
                { nowUsingItem.FlushResult = "错误:WaitForChangedScreen返回false"; }
                throw new Exception();
            }
        }
        private void SendEnableUserNameIfNeeded(Telnet.Terminal telnetSwitch, DisableGetObjects.Setting_SwitchType whatTypeOfSwitch)
        {
            //enable登录过程
            if (whatTypeOfSwitch.IsThisSwitchNeedsOfEnableUserName)
            {
                LogInToEvent.WriteDebug(nowUsingItem.Name + "/" + nowUsingItem.IpAddress + "-" + "等待要求enable用户名登录");
                nowUsingItem.LastFlushLog += "\n" + nowUsingItem.Name + "/" + nowUsingItem.IpAddress + "-" + "等待要求enable用户名登录\n";
                try
                {
                    telnetSwitch.WaitForString(whatTypeOfSwitch.PromptForEnableUserName);

                }
                catch (Exception e)
                {
                    LogInToEvent.WriteDebug(nowUsingItem.Name + "/" + nowUsingItem.IpAddress + "-" + e.ToString());
                    lock (nowUsingItem)
                    {
                        nowUsingItem.FlushResult = "没有提示输入enable用户名";
                    }
                    throw new Exception();
                }
                lock (nowUsingItem)
                {
                    nowUsingItem.LastFlushLog += "\n" + nowUsingItem.Name + "/" + nowUsingItem.IpAddress + "-" + "发送enable用户名\n";
                }
                if (!telnetSwitch.SendResponse(nowUsingItem.EnableUsername, true))
                {
                    lock (nowUsingItem)
                    {
                        nowUsingItem.FlushResult = "发送enable用户名失败";
                    }
                    throw new Exception();
                }
                if (!telnetSwitch.WaitForChangedScreen())
                {
                    lock (nowUsingItem)
                    {
                        nowUsingItem.FlushResult = "发送enable用户名后没有响应";
                    }
                    throw new Exception();
                }
            }
        }
 private void SendEnableCommand(Telnet.Terminal telnetSwitch)
 {
     if (!telnetSwitch.SendResponse("enable", true))
     {
         lock (nowUsingItem)
         {
             nowUsingItem.FlushResult = "发送enable指令失败";
         }
         throw new Exception();
     }
     if (!telnetSwitch.WaitForChangedScreen())
     {
         lock (nowUsingItem)
         {
             nowUsingItem.FlushResult = "发送enable指令后没有响应";
         }
         throw new Exception();
     }
 }