예제 #1
0
        private void cmb_Device_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                if (pictureBox1.Image != null)
                {
                    pictureBox1.Image.Dispose();
                    pictureBox1.Image = null;
                }
                if (dataGridView.SelectedRows.Count < 1)
                {
                    return;
                }
                string EnCode = dataGridView.SelectedRows[0].Cells["工号"].Value.ToString();

                MesDeviceBLL MesDeviceBLL = new MesDeviceBLL();
                var          MesDevice    = MesDeviceBLL.GetList_Name(cmb_Device.Text);
                if (MesDevice.Count < 1)
                {
                    return;
                }
                string url = "http://" + MesDevice[0].D_IP + ":8090/face/find";

                string postData = "pass="******"&personId=" + EnCode + "";

                string strtemp = FaceRecognition.Port(url, postData);
                if (!FaceRecognition.json(strtemp))
                {
                    untCommon.InfoMsg("该IP地址不可用!");
                    return;
                }
                JObject joModel = (JObject)JsonConvert.DeserializeObject(strtemp);
                if (!bool.Parse(joModel["success"].ToString()))
                {
                    untCommon.InfoMsg(joModel["msg"].ToString());
                    return;
                }
                else
                {
                    //untCommon.InfoMsg("人脸识别注册成功!");
                    var           jData  = (JArray)joModel["data"];
                    string        strUrl = "";
                    List <string> list   = new List <string>();
                    for (var i = 0; i < jData.Count; i++)
                    {
                        var jObj = (JObject)jData[i];
                        strUrl = (string)jObj["path"].ToString();
                        list.Add(strUrl);
                    }
                    Stream stream = FaceRecognition.Info(list[0].ToString());
                    pictureBox1.Image = Image.FromStream(stream);
                }
            }
            catch (Exception)
            {
                untCommon.InfoMsg("照片显示错误!");
            }
        }