Esempio n. 1
0
        private void btnStart_Click(object sender, EventArgs e)
        {
            while (true)
            {
                try{
                    //test connection
                    lblStatus.Text = String.Format("DB Server : [{0}]", DBConfig.getDBUrl());
                    lblStatus.Refresh();
                    if (m_tu.conn.State == ConnectionState.Closed)
                    {
                        m_tu.conn.Open();
                    }
                    GrabAgent.trace_log("Mysql connection established.");
                    break;
                }catch (Exception ex) {
                    DialogResult dr = MessageBox.Show(ex.Message + "\r\nPlease check config.xml file or contact DB Admin.\r\n Exit and reconfigure.",
                                                      "Mysql connection error.", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                    if (dr == DialogResult.Abort)
                    {
                        Application.Exit(); return;
                    }
                    else if (dr == DialogResult.Ignore)
                    {
                        break;
                    }
                    else
                    {
                        continue;
                    }
                }
            }

            try
            {
                retryInterval = Convert.ToInt32(txtInterval.Text);
            }
            catch (Exception)
            {
                txtInterval.Text = "10";
                retryInterval    = 10;
            }

            try
            {
                connectionTimeout = Convert.ToInt32(txtTimeout.Text);
            }
            catch (Exception)
            {
                txtTimeout.Text   = "3";
                connectionTimeout = 3;
            }

            btnStart.Enabled  = false;
            btnStop.Enabled   = true;
            groupBox1.Enabled = false;

            m_tu.start();
        }
Esempio n. 2
0
        //public static StreamWriter logFile;
        public GrabAgent(string agentName, int uInterval)
        {
            this.AgentName      = agentName;
            this.updateInterval = uInterval;
            this.conn           = DBConfig.getConnection();
            //this.dbAdapter = new MySqlDataAdapter();

            theThread = new Thread(new ThreadStart(this.runUpdate));
        }