Exemple #1
0
 private void buttonTestADSL_Click(object sender, EventArgs e)
 {
     if (this.textBoxADSLEntryName.Text == "" || this.textBoxADSLUserName.Text == "")
     {
         MessageBox.Show("请输入ADSL连接名、账号、密码后再按测试钮", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     ADSLFactory.Init(this.textBoxADSLEntryName.Text, this.textBoxADSLUserName.Text, this.textBoxADSLPassword.Text);
     ADSLFactory.Reconnect();
 }
        private const int CONNECTIONOUTOFTIME  = 60000; //连接超时时长 = 60sec

        private static void NCThreadRunner()
        {
            Monitor.Enter(nclockeradsl);
            Monitor.Enter(nclockerbegin);
            Monitor.Enter(nclockerend);

            while (true)
            {
                //IP切换冰封期
                Monitor.Exit(nclockerbegin);
                Monitor.Exit(nclockerend);
                Monitor.Exit(nclockeradsl); //释放ADSL线程
                Monitor.Enter(nclockeradsl);
                Thread.Sleep(CHANGEIPFREEZINGTIME);

                //自由导航模式
                Monitor.Wait(nclockeradsl);

                //IP切换准备模式
                Monitor.Enter(nclockerbegin);
                Monitor.Enter(nclockerend);
                while (ms_navigationcount > 0)
                {
                    if (!Monitor.Wait(nclockerend, CONNECTIONOUTOFTIME))
                    {
                        break;
                    }
                }

                //IP切换模式
                ADSLFactory.Reconnect();
            }

            Monitor.Exit(nclockerbegin);
            Monitor.Exit(nclockerend);
            Monitor.Exit(nclockeradsl);
        }
Exemple #3
0
        protected void ScriptThreadRunner()
        {
            //实现BeforeTask事件
            if (BeforeScript != null)
            {
                BeforeScript(this, null);
            }

            try
            {
                //Log开始
                GetLogger().LogListLog(VBALogLevelFlag.Debug, this.Name + " start...[running time: " + m_runningtime.ToString() + "] [at " + System.Net.Dns.GetHostName() + "]");

                //执行脚本,带空脚本处理
                if (m_script != null && m_script != "")
                {
                    m_engine.Run();
                }

                //关闭引擎
                EngineClose();

                //从VBATask中得到Task状态
                VBATaskStatus ts = (m_vbaobjs["Task"] as VBATask).CurrentVBATaskStatus;
                switch (ts)
                {
                case VBATaskStatus.Failure:
                    GetLogger().LogListLog(VBALogLevelFlag.Debug, this.Name + " fail...");
                    m_taskstatus = TaskStatus.Failure;
                    break;

                case VBATaskStatus.RestartADSL:
                    //重置ADSL(Client)
                    if (ADSLFactory.Reconnect())
                    {
                        GetLogger().LogListLog(VBALogLevelFlag.Debug, this.Name + " restart ADSL...succeed!");
                        m_taskstatus = TaskStatus.Restart;
                    }
                    else
                    {
                        GetLogger().LogListLog(VBALogLevelFlag.Debug, this.Name + " restarting ADSL failed... setting this task failure!");
                        m_taskstatus = TaskStatus.Failure;
                    }
                    break;

                case VBATaskStatus.Ready:
                    m_taskstatus = TaskStatus.Succeed;
                    GetLogger().LogListLog(VBALogLevelFlag.Debug, this.Name + " succeed...");
                    break;

                case VBATaskStatus.Error:
                    m_taskstatus = TaskStatus.Error;
                    GetLogger().LogListLog(VBALogLevelFlag.Error, this.Name + " set error by customer...");
                    break;

                case VBATaskStatus.Close:
                    m_taskstatus = TaskStatus.Succeed;
                    GetLogger().LogListLog(VBALogLevelFlag.Warn, this.Name + " close whole domain!");
                    Domain d = DomainManager.GetDomain(m_domainGUID);
                    if (d.Enable)
                    {
                        d.Enable = false;
                    }
                    break;

                case VBATaskStatus.TurnToNext:
                    m_taskstatus = TaskStatus.Succeed;
                    GetLogger().LogListLog(VBALogLevelFlag.Warn, this.Name + " close and turn to next domain!");
                    Domain dd = DomainManager.GetDomain(m_domainGUID);
                    if (dd.Enable || dd.Priority == DomainPriority.OneTime)
                    {
                        DomainManager.TurnToNextDomain(m_domainGUID);
                    }
                    break;

                default:
                    m_taskstatus = TaskStatus.Succeed;
                    GetLogger().LogListLog(VBALogLevelFlag.Debug, this.Name + " succeed...");
                    break;
                }
            }
            catch (Exception e)
            {
                if (m_IsClosing)
                {
                    log.Warn(this.Name + " closed by force...");
                    GetLogger().LogListLog(VBALogLevelFlag.Warn, this.Name + " closed...");
                    m_taskstatus = TaskStatus.Closing;
                }
                else
                {
                    GetLogger().LogListLog(VBALogLevelFlag.Error, this.Name + " runtime error..." + ParserErrorString(e));
                    log.Error(this.Name + " runtime error: ", e);
                    m_errortime++;
                    m_taskstatus = TaskStatus.Error;
                }
            }
            finally
            {
                //实现AfterTask事件
                if (AfterScript != null)
                {
                    AfterScript(this, null);
                }
            }
        }