示例#1
0
        private int setPhonePadData(string type, string account)
        {
            if (AEMSClient == null)
            {
                AEMSClient = new AEMSClient(logwrite, this);
            }


            if (AEMSClient.aemsConnect() != ERRORCODE.SUCCESS)
            {
                logwrite.write("setPhonePadData", "AEMS Cannot Connect");
                isAEMSConnected = false;
                return(ERRORCODE.FAIL);
            }

            Agent       agent       = Agent.getInstance();
            JsonHandler jsonhandler = new JsonHandler(agent.getExtension());

            jsonhandler.setType(type);
            jsonhandler.setCmd("set");
            jsonhandler.setAccount(account);

            string jsonData = jsonhandler.getJsonData();

            jsonData = jsonData.Replace("classType", "@type");
            jsonData = jsonData.Replace("null", "0");
            logwrite.write("setPhonePadData", "AEMS SEND MESSAGE [" + jsonData + "]");

            if (AEMSClient.send(jsonData) != ERRORCODE.SUCCESS)
            {
                logwrite.write("setPhonePadData", "AEMS SEND FAIL!!");
                return(ERRORCODE.FAIL);
            }

            string retStr = AEMSClient.recv();

            logwrite.write("setPhonePadData", "AEMS RECV MESSAGE [" + retStr + "]");

            AEMSClient.disconnect();

            if (retStr == null || retStr.Length <= 0)
            {
                logwrite.write("setPhonePadData", "AEMS RECV MESSAGE IS NULL !!");
                return(ERRORCODE.FAIL);
            }

            phonePadVO = jsonhandler.recvJson(retStr);

            if (!phonePadVO.getRet().Equals("0"))
            {
                return(ERRORCODE.FAIL);
            }

            return(ERRORCODE.SUCCESS);
        }
示例#2
0
        private int getPhonePadInfo()
        {
            if (AEMSClient.aemsConnect() != ERRORCODE.SUCCESS)
            {
                logwrite.write("getPhonePadInfo", "AEMS Cannot Connect");
                isAEMSConnected = false;
                return(ERRORCODE.FAIL);
            }

            Agent       agent       = Agent.getInstance();
            JsonHandler jsonhandler = new JsonHandler(agent.getExtension());

            jsonhandler.setType(phonePadVO.getType());
            jsonhandler.setCmd("get");

            string jsonData = jsonhandler.getJsonData();

            jsonData = jsonData.Replace("classType", "@type");
            logwrite.write("getPhonePadInfo", "AEMS SEND MESSAGE [" + jsonData + "]");

            if (AEMSClient.send(jsonData) != ERRORCODE.SUCCESS)
            {
                logwrite.write("getPhonePadInfo", "AEMS SEND FAIL!!");
                return(ERRORCODE.FAIL);
            }

            string retStr = AEMSClient.recv();

            logwrite.write("getPhonePadInfo", "AEMS RECV MESSAGE [" + retStr + "]");

            AEMSClient.disconnect();

            if (retStr == null || retStr.Length <= 0)
            {
                logwrite.write("getPhonePadInfo", "AEMS RECV MESSAGE IS NULL !!");
                return(ERRORCODE.FAIL);
            }

            phonePadVO = jsonhandler.recvJson(retStr);

            string result = "";

            for (int i = 0; i < phonePadVO.getData().Count; i++)
            {
                result = (string)phonePadVO.getData()[i];
            }

            GetEventOnPassCheck(phonePadVO.getRet(), result);

            logwrite.write("", "");
            logwrite.write("getPhonePadInfo", "::::::::::::::::::::::: Raise Event GetEventOnPassCheck(" + phonePadVO.getRet() + " , " + result + ") ::::::::::::::::::::::: ");

            return(ERRORCODE.SUCCESS);
        }
示例#3
0
        public PhonePad recvJson(string jsonData)
        {
            PhonePad phonePad = new PhonePad();

            stream1 = new MemoryStream(Encoding.UTF8.GetBytes(jsonData));
            //jsonSer = new DataContractJsonSerializer(phonePad.GetType());
            jsonSer  = new DataContractJsonSerializer(typeof(PhonePad));
            phonePad = (PhonePad)jsonSer.ReadObject(stream1);

            stream1.Close();

            return(phonePad);
        }
示例#4
0
 public JsonHandler(string extension)
 {
     phonePadVO     = new PhonePad();
     this.extension = extension;
     phonePadVO.setKey(extension);
 }