예제 #1
0
        public List <STRUCT_COMPONENT> GetComponent()
        {
            try
            {
                JObject jsonState = new JObject();
                jsonState["state"] = STATE_GET_COMP_LIST;
                client.Send(Utility.CreateJsonObject(CMD_STATE, Convert.ToString(jsonState)));
                Thread.Sleep(10);
                JObject jsonObject = new JObject();
                client.Send(Utility.CreateJsonObject(CMD_GET_COMP, Convert.ToString(jsonObject)));
                //Thread.Sleep(2000);
                string data = ParseReceivedData(true, Convert.ToString(jsonObject), 200);

                List <STRUCT_COMPONENT> structComponentList = new List <STRUCT_COMPONENT>();
                if (data != string.Empty)
                {
                    JArray jsonArray = JArray.Parse(data);
                    for (int i = 0; i < jsonArray.Count; i++)
                    {
                        JObject          componentData   = JObject.Parse(jsonArray[i].ToString());
                        STRUCT_COMPONENT structComponent = new STRUCT_COMPONENT();
                        structComponent.ComponentName  = componentData["name"].ToString();
                        structComponent.ComponentCode  = componentData["code"].ToString();
                        structComponent.ComponentId    = (uint)componentData["id"];
                        structComponent.ComponentImage = Utility.ByteArrayToImage((byte[])(componentData["image"]));
                        structComponentList.Add(structComponent);
                    }
                    return(structComponentList);
                }
            }
            catch (Exception ex)
            {
            }
            return(new List <STRUCT_COMPONENT>());
        }
예제 #2
0
        public List <STRUCT_COMPONENT> GetComponent(string searchVal, int start_idx, int display_cnt)
        {
            try
            {
                JObject jsonState = new JObject();
                jsonState["state"] = STATE_GET_COMP_LIST;
                client.Send(Utility.CreateJsonObject(CMD_STATE, Convert.ToString(jsonState)));
                Thread.Sleep(10);
                JObject jsonObject = new JObject();
                jsonObject["start_idx"]   = start_idx;
                jsonObject["display_cnt"] = display_cnt;
                jsonObject["search_val"]  = searchVal;
                //jsonObject["is_asc"] = isSort;
                client.Send(Utility.CreateJsonObject(CMD_GET_COMP, Convert.ToString(jsonObject)));
                //Thread.Sleep(2000);
                string data = ParseReceivedData(true, Convert.ToString(jsonObject), 200);

                List <STRUCT_COMPONENT> structComponentList = new List <STRUCT_COMPONENT>();
                if (data != string.Empty)
                {
                    JArray jsonArray = JArray.Parse(data);
                    for (int i = 0; i < jsonArray.Count; i++)
                    {
                        JObject          componentData   = JObject.Parse(jsonArray[i].ToString());
                        STRUCT_COMPONENT structComponent = new STRUCT_COMPONENT();
                        structComponent.ComponentName  = componentData["name"].ToString();
                        structComponent.ComponentCode  = componentData["code"].ToString();
                        structComponent.ComponentId    = (uint)componentData["id"];
                        structComponent.ComponentImage = Utility.ByteArrayToImage((byte[])(componentData["image"]));
                        structComponent.TestLength     = (int)componentData["test_len"];
                        if (Utility.CheckForJsonKeyPresence(componentData, "comp_start_count"))
                        {
                            GlobalVar.COMPONENT_START_INDEX = (int)componentData["comp_start_count"];
                        }
                        structComponentList.Add(structComponent);
                    }
                    return(structComponentList);
                }
            }
            catch (Exception ex)
            {
            }
            return(new List <STRUCT_COMPONENT>());
        }
예제 #3
0
 public STRUCT_COMPONENT GetBarcode(string barcodeVal, bool isManualEntry)
 {
     try
     {
         if (isManualEntry)
         {
             JObject jsonState = new JObject();
             jsonState["state"] = STATE_BARCODE_ENTRY;
             client.Send(Utility.CreateJsonObject(CMD_STATE, Convert.ToString(jsonState)));
         }
         else
         {
             JObject jsonState = new JObject();
             jsonState["state"] = STATE_BARCODE_SCANNING;
             client.Send(Utility.CreateJsonObject(CMD_STATE, Convert.ToString(jsonState)));
         }
         Thread.Sleep(10);
         JObject jsonObject = new JObject();
         jsonObject["barcode"] = barcodeVal;
         client.Send(Utility.CreateJsonObject(CMD_BARCODE, Convert.ToString(jsonObject)));
         string data = ParseReceivedData(true, Convert.ToString(jsonObject), 50);
         if (data != string.Empty)
         {
             JObject          componentData   = JObject.Parse(data);
             STRUCT_COMPONENT structComponent = new STRUCT_COMPONENT();
             structComponent.ComponentName = componentData["name"].ToString();
             structComponent.ComponentCode = componentData["code"].ToString();
             structComponent.ComponentId   = (uint)componentData["id"];
             return(structComponent);
         }
         return(new STRUCT_COMPONENT());
     }
     catch (Exception)
     {
         return(new STRUCT_COMPONENT());
     }
 }