public bool writeTags(WRITETAG_INFO wti) { string cmd = "writeTag"; ErrorCode = ERR_CODE_UNKNOWN_RESPONSE; ErrorMsg = ERR_MSG_UNKNOWN_RESPONSE; //default error message try { StringBuilder sbReq = new StringBuilder(); sbReq.Append(String.Format("{0}API?command={1}&session_id={2}", httpUri.AbsoluteUri, cmd, SessionId)); sbReq.Append(String.Format("&filterOp1={0}&filter1={1}&filterLogic={2}", wti.filter_op_1, wti.filter1, wti.filter_logic)); sbReq.Append(String.Format("&filterOp2={0}&filter2={1}", wti.filter_op_2, wti.filter2)); sbReq.Append(String.Format("&writeFixedNo={0}&useActiveProfile={1}", wti.writeFixedNo, wti.useActiveProfile)); if (wti.useActiveProfile.Equals("false")) { sbReq.Append(String.Format("&antennaPort={0}modulationProfile={1}&mode={2}", wti.antennas, wti.modulation_profile, wti.mode)); sbReq.Append(String.Format("&transmitPower={0}&populationEst={1}&sessionNo={2}", wti.transmit_power, wti.population, wti.session_no)); sbReq.Append(String.Format("&epc={0}&autoInc={1}", wti.epc, wti.auto_inc)); } if (wti.mode.Equals("writeAllBanksFilterManyHexBased") || wti.mode.Equals("writeAllBanksFilterFixedNumberHexBased")) { sbReq.Append(String.Format("&tag_model={0}&bank3_hex={1}&bank1_enable={2}&bank3_enable={3}", wti.tag_model, wti.user_memory, wti.bank1_enable, wti.bank3_enable)); sbReq.Append(String.Format("&bank1Lock={0}&bank1Unlock={1}", wti.bank1Lock, wti.bank1Unlock)); sbReq.Append(String.Format("&bank3Lock={0}&bank3Unlock={1}", wti.bank3Lock, wti.bank3Unlock)); } string resp = sendHTTPRequest(sbReq.ToString()); if (resp == null) return false; XmlDocument doc = new XmlDocument(); doc.LoadXml(resp); if (isCSLResponse(ref doc, cmd) == false) return false; XmlNode node = doc.SelectSingleNode("CSL/Ack"); if (node != null) { if (node.InnerXml.StartsWith("OK", StringComparison.OrdinalIgnoreCase)) { ErrorCode = ERR_CODE_NO_ERROR; ErrorMsg = ""; return true; } } parseErrorCode(ref doc); return false; } catch { ErrorCode = ERR_CODE_UNKNOWN_ERROR; ErrorMsg = ERR_MSG_UNKNOWN_ERROR; return false; } }
public System.Collections.ArrayList syncModifyKillPassword(WRITETAG_INFO wti) { string cmd = "writeTag"; ErrorCode = ERR_CODE_UNKNOWN_RESPONSE; ErrorMsg = ERR_MSG_UNKNOWN_RESPONSE; //default error message System.Collections.ArrayList list = new System.Collections.ArrayList(); try { StringBuilder sbReq = new StringBuilder(); sbReq.Append(String.Format("{0}API?command={1}&session_id={2}", httpUri.AbsoluteUri, cmd, SessionId)); sbReq.Append(String.Format("&mode=syncModifyKillPassword&killPassword={0}&unlockPassword={1}", wti.killPassword, wti.unlockPassword)); sbReq.Append(String.Format("&filterOp1={0}&filter1={1}&filterLogic={2}", wti.filter_op_1, wti.filter1, wti.filter_logic)); sbReq.Append(String.Format("&filterOp2={0}&filter2={1}", wti.filter_op_2, wti.filter2)); sbReq.Append(String.Format("&writeFixedNo={0}&timeOut=5000", wti.writeFixedNo)); string resp = sendHTTPRequest(sbReq.ToString()); if (resp == null) return null; XmlDocument doc = new XmlDocument(); doc.LoadXml(resp); if (isCSLResponse(ref doc, cmd) == false) return null; XmlNode node = doc.SelectSingleNode("CSL/EpcValue"); if (node != null) { while (node != null) { WRITETAG_STATUS wts = new WRITETAG_STATUS(); XmlAttributeCollection atts = node.Attributes; wts.after = atts.GetNamedItem("after").Value; wts.before = atts.GetNamedItem("before").Value; wts.status = atts.GetNamedItem("status").Value; list.Add(wts); node = node.NextSibling; } ErrorCode = ERR_CODE_NO_ERROR; ErrorMsg = ""; return list; } parseErrorCode(ref doc); return null; } catch { ErrorCode = ERR_CODE_UNKNOWN_ERROR; ErrorMsg = ERR_MSG_UNKNOWN_ERROR; return null; } }
public System.Collections.ArrayList syncWriteTags(WRITETAG_INFO wti) { string cmd = "writeTag"; ErrorCode = ERR_CODE_UNKNOWN_RESPONSE; ErrorMsg = ERR_MSG_UNKNOWN_RESPONSE; //default error message System.Collections.ArrayList list = new System.Collections.ArrayList(); try { StringBuilder sbReq = new StringBuilder(); sbReq.Append(String.Format("{0}API?command={1}&session_id={2}", httpUri.AbsoluteUri, cmd, SessionId)); sbReq.Append(String.Format("&filterOp1={0}&filter1={1}&filterLogic={2}", wti.filter_op_1, wti.filter1, wti.filter_logic)); sbReq.Append(String.Format("&filterOp2={0}&filter2={1}", wti.filter_op_2, wti.filter2)); sbReq.Append(String.Format("&writeFixedNo={0}&autoInc={1}", wti.writeFixedNo, wti.auto_inc)); sbReq.Append(String.Format("&mode={0}&timeOut={1}", wti.mode, wti.timeOut)); if (wti.passwordEnable.Equals("true")) { //Need password sbReq.Append(String.Format("&unlockPassword={0}&passwordEnable=true", wti.unlockPassword)); } if (wti.bank1_enable.Equals("true") == true) { sbReq.Append(String.Format("&epc={0}&bank1_enable=true", wti.epc)); if (wti.passwordEnable.Equals("true")) { sbReq.Append(String.Format("bank1Lock={0}&bank1Unlock={1}", wti.bank1Lock, wti.bank1Unlock)); } } else if (wti.bank3_enable.Equals("true") == true) { sbReq.Append(String.Format("&bank3_hex={0}&bank3_enable=true&tag_model={1}", wti.user_memory, wti.tag_model)); if (wti.passwordEnable.Equals("true")) { sbReq.Append(String.Format("bank3Lock={0}&bank3Unlock={1}", wti.bank3Lock, wti.bank3Unlock)); } //work around for a bug that must have EPC field. sbReq.Append(String.Format("&epc=000000000000000000000001")); } string resp = sendHTTPRequest(sbReq.ToString()); if (resp == null) return null; XmlDocument doc = new XmlDocument(); doc.LoadXml(resp); if (isCSLResponse(ref doc, cmd) == false) return null; XmlNode node = doc.SelectSingleNode("CSL/EpcValue"); if (node != null) { while (node != null) { WRITETAG_STATUS wts = new WRITETAG_STATUS(); XmlAttributeCollection atts = node.Attributes; wts.after = atts.GetNamedItem("after").Value; wts.before = atts.GetNamedItem("before").Value; wts.status = atts.GetNamedItem("status").Value; list.Add(wts); node = node.NextSibling; } ErrorCode = ERR_CODE_NO_ERROR; ErrorMsg = ""; return list; } parseErrorCode(ref doc); return null; } catch { ErrorCode = ERR_CODE_UNKNOWN_ERROR; ErrorMsg = ERR_MSG_UNKNOWN_ERROR; return null; } }
public bool killTags(WRITETAG_INFO wti) { string cmd = "writeTag"; ErrorCode = ERR_CODE_UNKNOWN_RESPONSE; ErrorMsg = ERR_MSG_UNKNOWN_RESPONSE; //default error message try { StringBuilder sbReq = new StringBuilder(); sbReq.Append(String.Format("{0}API?command={1}&session_id={2}&mode=killTagFixedNumber", httpUri.AbsoluteUri, cmd, SessionId)); sbReq.Append(String.Format("&filterOp1={0}&filter1={1}&filterLogic={2}", wti.filter_op_1, wti.filter1, wti.filter_logic)); sbReq.Append(String.Format("&filterOp2={0}&filter2={1}&timeOut={2}", wti.filter_op_2, wti.filter2,wti.timeOut)); sbReq.Append(String.Format("&killFixedNo={0}&killPassword={1}&useActiveProfile={2}", wti.killFixedNo, wti.killPassword, wti.useActiveProfile)); if (wti.useActiveProfile.Equals("false")) { sbReq.Append(String.Format("&antennaPort={0}modulationProfile={1}&mode={2}", wti.antennas, wti.modulation_profile, wti.mode)); sbReq.Append(String.Format("&transmitPower={0}&populationEst={1}&sessionNo={2}", wti.transmit_power, wti.population, wti.session_no)); } string resp = sendHTTPRequest(sbReq.ToString()); if (resp == null) return false; XmlDocument doc = new XmlDocument(); doc.LoadXml(resp); if (isCSLResponse(ref doc, cmd) == false) return false; XmlNode node = doc.SelectSingleNode("CSL/Ack"); if (node != null) { if (node.InnerXml.StartsWith("OK", StringComparison.OrdinalIgnoreCase)) { ErrorCode = ERR_CODE_NO_ERROR; ErrorMsg = ""; return true; } } parseErrorCode(ref doc); return false; } catch { ErrorCode = ERR_CODE_UNKNOWN_ERROR; ErrorMsg = ERR_MSG_UNKNOWN_ERROR; return false; } }