private void btnStart_Click(object sender, EventArgs e) { if (CommonFun.CheckFileExists(txtFilePath.Text.Trim()) == false) { MessageBox.Show(string.Format("{0}不存在.", txtFilePath)); return; } strAccessConnection = string.Format(_deviceElement.ConnectionString, txtFilePath.Text.Trim()); dataTransferAction = new JYNYTestDataTransferAction(strAccessConnection); dataTransferAction.OnDataTransferFinished += new EventHandler <DataTransferFinishedArgs>(DataTransferFinished); int nSecond = 0; if (int.TryParse(txtInterval.Text, out nSecond) == true) { if (nSecond < 5) { MessageBox.Show("时间设置不能小于(5)秒"); return; } } timer1.Interval = nSecond * 1000; timer1.Enabled = true; StartTransfer(); }
private void FrmJYNYDataUpload_Load(object sender, EventArgs e) { timer1.Enabled = false; bool blFound = false; string hostInfo = Dns.GetHostName(); System.Net.IPAddress[] addressList = Dns.GetHostEntry(Dns.GetHostName()).AddressList; //IPAddress ipaddress = addressList[0]; //string ips = ipaddress.ToString(); //MessageBox.Show(ips); //获取配置节信息 this._section = (JYNYTestConfigurationSection)ConfigurationManager.GetSection("mes.JYNYtest"); //增加线程个数。 foreach (JYNYTestDeviceElement element in this._section.Devices) { foreach (IPAddress ipAddress in addressList) { strIP = ipAddress.ToString(); if (strIP == element.Name) { blFound = true; _deviceElement = element; break; } } } if (blFound == false) { MessageBox.Show("此电脑的IP地址没有在配置文件中找到对应的配置,请联系IT"); Application.Exit(); } else { txtFilePath.Text = CommonFun.GetFullFile(_deviceElement.Path, _deviceElement.Format); //txtFilePath.Text = _deviceElement.Path; } string strSql = " select top 1 * from [dbo].[ZWIP_VIR_TEST] where EQUIPMENT_CODE='" + _deviceElement.EqpName + "' order by TEST_TIME desc"; DataTable dt = DatabaseEx.getDbInstance().getDataTable(strSql); if (dt != null && dt.Rows.Count > 0) { txtTestTime.Text = string.Format("{0:yyyy-MM-dd HH:mm:ss}", dt.Rows[0]["TEST_TIME"].ToString()); } else { txtTestTime.Text = "1900-01-01 01:01:01"; } txtEqpName.Text = _deviceElement.EqpName; btnStart.Enabled = true; btnPause.Enabled = false; txtEqpName.ReadOnly = true; txtTestTime.ReadOnly = true; //btnStart_Click(null, null); notifyJYNYData.Visible = false; if (CommonFun.CheckFileExists(txtFilePath.Text.Trim()) == false) { MessageBox.Show(string.Format("{0}不存在.", txtFilePath)); return; } strAccessConnection = string.Format(_deviceElement.ConnectionString, txtFilePath.Text.Trim()); dataTransferAction = new JYNYTestDataTransferAction(strAccessConnection); dataTransferAction.OnDataTransferFinished += new EventHandler <DataTransferFinishedArgs>(DataTransferFinished); int nSecond = 0; if (int.TryParse(txtInterval.Text, out nSecond) == true) { if (nSecond < 10) { MessageBox.Show("时间设置不能小于(10)秒"); return; } } timer1.Interval = nSecond * 1000; timer1.Enabled = true; StartTransfer(); }