public override void ReceivedAllData(string data) { ECString = data; WriteECCommLog("[RECEIVED], " + data); if (data.Trim() == "") { var sendData = new FASendData(); sendData.Result = FAResult.FAIL; sendData.Msg = "EMPTY DATA"; SendCommand(sendData); return; } if (data.Length < 16) { var sendData = new FASendData(); sendData.Result = FAResult.FAIL; sendData.Msg = "NOT FOUND HEADER. DATA LENGTH IS TOO SHORT.(DATA LENGTH < 16)"; SendCommand(sendData); return; } string[] splitData = new string[2]; splitData[0] = data.Substring(0, 16); splitData[1] = data.Substring(16); //if (splitData.Length < 2) return; string head = splitData[0]; string body = splitData[1]; try { bool result = false; string command = GetCommand(body); string errMessage = string.Empty; if (command == "PRODUCT_INFO") { List<string> err = new List<string>(); result = ReceivedDataInfo.ReceiveData.Parsing(body, out err); errMessage = string.Join("\n", err); } ReceivedDataInfo.Error = !result; ReceivedDataInfo.ErrorMessage = string.Join("\n", errMessage); ReceivedDataInfo.Exist = true; FAReceivedDataInfo tempReceiveData = new FAReceivedDataInfo(); ReceivedDataInfo.CopyTo(tempReceiveData); if (OnReceivedData != null) OnReceivedData(this, new FAGenericEventArgs<FAReceivedDataInfo>(tempReceiveData)); var sendData = new FASendData(); if (result) sendData.Result = FAResult.PASS; else { sendData.Result = FAResult.FAIL; sendData.Msg = errMessage; } SendCommand(sendData); } catch { return; } }
public void CopyTo(FAReceivedDataInfo obj) { obj.CommandType = CommandType; obj.Error = Error; obj.ErrorMessage = ErrorMessage; ReceiveData.CopyTo(obj.ReceiveData); obj.Exist = Exist; }