private void DownLoadThreadDoWork(object sender, DoWorkEventArgs e) { int handle = DllC0402.setDeviceStringCmd(deviceIP, downLoadCmd, ""); if (handle < 0) { return; } System.Threading.Thread.Sleep(50); DllC0402.disconnectDevice(handle); int FTPHandle1 = DllC0402.connectFTP1(deviceIP); if (FTPHandle1 < 0) { return; } ///发送数据库 FileStream read = new FileStream(filePath, FileMode.Open, FileAccess.Read); byte[] buff = new byte[1024]; long fileLen = read.Length, lenCurrent = 0; int len = 0; isCompletedDownLoad = false; while ((len = read.Read(buff, 0, 1024)) != 0) { lenCurrent += len; DllC0402.setDevicStringData(FTPHandle1, buff, len, ""); backgroundWorker.ReportProgress((int)((lenCurrent * 100 / fileLen))); } DllC0402.setDevicStringData(FTPHandle1, endFlag, ""); ///判断数据库是否发送成功 StringBuilder Buffer = new StringBuilder(1024); int flag = DllC0402.getRTLog(FTPHandle1, Buffer, 25); if (flag <= 0) { return; } else if (Buffer.ToString().Substring(0, flag).Equals(fileLen.ToString())) { isCompletedDownLoad = true; } DllC0402.disconnectDevice(FTPHandle1); }
private void buttonConnect_Click(object sender, EventArgs e) { string ipaddress = kryptonComboBoxControllerIp.Text.Trim(); writeIpAddrToTextFile(ipaddress); int h = DllC0402.testOnline(ipaddress); if (h > 0) { DllC0402.disconnectDevice(h); toolStripStatusLabel2.Text = MyMessageBox.getStringFromRes("textDeviceIsOnline"); } else { DllC0402.disconnectDevice(h); toolStripStatusLabel2.Text = MyMessageBox.getStringFromRes("textDeviceIsNotOnline"); } }
public void closeRealTimeMonitorPort() { isrealwatch = false; DllC0402.disconnectDevice(readTimeMonitorHandle); }