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 button3_Click(object sender, EventArgs e) { string ipaddress = kryptonComboBoxControllerIp.Text.Trim(); int ret = DllC0402.setRTLogCMD(ipaddress); if (ret != 0) { return; } StringBuilder Buffer = new StringBuilder(1024); int handle = DllC0402.connectLOG(ipaddress); if (ret != 0) { return; } while (true) { int flag = DllC0402.getRTLog(handle, Buffer, 5); if (flag <= 0) { continue; } string strCount = Buffer.ToString().Substring(0, 4); int intCount = int.Parse(strCount); flag = DllC0402.getRTLog(handle, Buffer, intCount); if (flag <= 0) { continue; } textBox2.Text = Buffer.ToString(); } }
private void realWatch(object h) { int handle = Convert.ToInt32(h); StringBuilder Buffer = new StringBuilder(1024); addReadCardRealWatchData addReadCardRealWatchDataToListView = formRealTimeMoni.addReadCardRealWatchDataToListView; while (isrealwatch == true) { int flag = DllC0402.getRTLog(handle, Buffer, 5); if (flag <= 0) { continue; } string strCount = Buffer.ToString().Substring(0, 4); int intCount = int.Parse(strCount); flag = DllC0402.getRTLog(handle, Buffer, intCount); if (flag <= 0) { continue; } formRealTimeMoni.Invoke(addReadCardRealWatchDataToListView, formRealTimeMoni.listView1, Buffer.ToString()); } }