//public void OnClientConnect(IAsyncResult asyn) //{ // ////original // //m_socWorker = m_socListener.EndAccept(asyn); // //WaitForData(m_socWorker); // if (!stopClick && asyn.AsyncState == null) // { // //TcpClient client = listener.AcceptTcpClient(); // Get client connection // m_socWorker = m_socListener.EndAccept(asyn); // } // //Begin: send data to client // if (m_socWorker != null && m_socWorker.Connected) // { // DataTable table = GetData(); // int byteSend = m_socWorker.Send(Utilities.SerializeData(table)); // } // WaitForData(m_socWorker); // //End //} //public void WaitForData(Socket socket) //{ // if (pfnWorkerCallBack == null) // { // pfnWorkerCallBack = new AsyncCallback(OnDataReceived); // } // CSocketPacket theSocPkt = new CSocketPacket(); // if (socket != null) // { // theSocPkt.thisSocket = socket; // // now start to listen for any data... // socket.BeginReceive(theSocPkt.dataBuffer, 0, theSocPkt.dataBuffer.Length, SocketFlags.None, pfnWorkerCallBack, theSocPkt); // } //} //public void OnDataReceived(IAsyncResult asyn) //{ // //CSocketPacket theSockId = (CSocketPacket)asyn.AsyncState; // ////end receive... // //int iRx = 0; // //iRx = theSockId.thisSocket.EndReceive(asyn); // //char[] chars = new char[iRx + 1]; // ////Decoder decoder = Encoding.Unicode.GetDecoder(); // //Decoder decoder = Encoding.UTF8.GetDecoder(); // //int charLen = decoder.GetChars(theSockId.dataBuffer, 0, iRx, chars, 0); // //String strData = new System.String(chars); // //txtDataReceive.Invoke(new MethodInvoker(delegate // //{ // // txtDataReceive.Text = txtDataReceive.Text + strData; // //})); // //WaitForData(m_socWorker); // // // CSocketPacket theSockId = (CSocketPacket)asyn.AsyncState; // //end receive... // byte[] data = new byte[1024 * 5000]; // int receivedDataLength = theSockId.thisSocket.Receive(data); // string stringData = Encoding.ASCII.GetString(data, 0, receivedDataLength); // txtDataReceive.Invoke(new MethodInvoker(delegate // { // txtDataReceive.Text = txtDataReceive.Text + stringData; // })); // WaitForData(m_socWorker); // //int bytesRead; // //while ((bytesRead = theSockId.thisSocket.Receive(data)) > 0) // //{ // // //string stringData = Encoding.ASCII.GetString(data, 0, receivedDataLength); // //} // //delete record // bool ret = false; // if (stringData.Contains("DELETE ")) // { // ret = DeleteRecord(stringData); // } // if (ret) // { // txtDataReceive.Invoke(new MethodInvoker(delegate // { // txtDataReceive.Text = txtDataReceive.Text + "One record was deleted..." + Environment.NewLine; // })); // } // //if (theSockId.thisSocket.Available > 0) // .Connected) // //{ // // iRx = theSockId.thisSocket.EndReceive(asyn); // // char[] chars = new char[iRx + 1]; // // System.Text.Decoder d = System.Text.Encoding.UTF8.GetDecoder(); // // int charLen = d.GetChars(theSockId.dataBuffer, 0, iRx, chars, 0); // // String strData = new System.String(chars); // // txtDataReceive.Invoke(new MethodInvoker(delegate // // { // // txtDataReceive.Text = txtDataReceive.Text + strData; // // })); // // WaitForData(m_socWorker); // //} //} private bool DeleteRecord(string query) { bool ret = false; DataInteractor dataUtils = new DataInteractor(); ret = dataUtils.NoneQuery(query); return(ret); }
private DataTable GetData() { DataTable dt = new DataTable(); string query = @"SELECT [IntergerValue] ,[StringValue] ,[DateTimeValue] ,[BooleanValue] FROM Sample"; DataInteractor dataUtils = new DataInteractor(); dt = dataUtils.LoadData(query); return(dt); }