Exemple #1
0
        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;
            }
        }
Exemple #2
0
        public System.Collections.ArrayList writeTagsStatus()
        {
            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}&mode=verifyEpc", httpUri.AbsoluteUri, cmd, SessionId));

                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;
                if (isCSLResponse(ref doc, "verifyEpc") == 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;
            }
        }
Exemple #3
0
        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;
            }
        }