/// Client Received data from Server /// </summary> /// <param name="asyn">IAsyncResult</param> public void ClientDataReceived(IAsyncResult asyn) { try { SocketPacket socPacket = (SocketPacket)asyn.AsyncState; int iRx = socPacket.mSocket.EndReceive(asyn); char[] chars = new char[iRx + 1]; System.Text.Decoder d = System.Text.Encoding.ASCII.GetDecoder(); int charLen = d.GetChars(socPacket.mDataBuffer, 0, iRx, chars, 0); string data = new System.String(chars); data = data.Trim(); //Logger.TranferDataLog(" Reciep -" + data + "-" + DateTime.Now.ToString()); if (data.Contains("RECEIVE")) { TransferSaleDataToServer.GetScriptAndFlusToDataBase(); } else if (data.Contains("TRANSFER")) // format : TRANSFER -- ra lenh chuyen so lieu { TransferSaleDataToServer.SaveFileAndLog(); } ClientWaitData(); } catch (SocketException ex) { Logger.TranferDataLog("SocketException " + ex.ToString()); ClearConectSocket(); } catch (Exception ex) { isCallRecieptData = true; Logger.TranferDataLog("Error Data ClientDataReceived: " + ex.ToString()); } }
private void timerTransfer(object sender, ElapsedEventArgs e) { try { // Logger.TranferDataLog("Timmer run" + DateTime.Now.ToString()); ConecServer(); // Logger.TranferDataLog("isTimerTransferRun" + isTimerTransferRun.ToString() + " " + DateTime.Now.ToString()); if (isTimerTransferRun)// && CheckTimerTransfer(DateTime.Now)) { // Logger.TranferDataLog("Timmer run" + DateTime.Now.ToString()); isTimerTransferRun = false; TransferSaleDataToServer.SaveFileAndLog(); isTimerTransferRun = true; } TransferSaleDataToServer.TransferFileDataToServer(); TransferSaleDataToServer.RunScripFile(); } catch (Exception ex) { Logger.TranferDataLog("Timmer run Error" + ex.Message); } }