Exemplo n.º 1
0
        /// <summary>
        /// 将临时人员信息上传到海康平台
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="list"></param>
        public AddJurisdictionEntity InsertTempUserHiK(TemporaryUserEntity entity, List <TemporaryUserEntity> list)
        {
            DataItemDetailService data = new DataItemDetailService();
            var    pitem     = data.GetItemValue("Hikappkey");  //密钥
            var    baseurl   = data.GetItemValue("HikBaseUrl"); //海康地址
            string Key       = string.Empty;
            string Signature = string.Empty;
            string no        = new Random().Next(10, 888888).ToString();

            if (!string.IsNullOrEmpty(pitem))
            {
                Key       = pitem.Split('|')[0];
                Signature = pitem.Split('|')[1];
            }
            string Url = "/artemis/api/resource/v1/person/single/add";

            foreach (var item in list)
            {
                //人脸信息(base64必须为jpg格式)
                List <FaceEntity> faces = new List <FaceEntity>();
                FaceEntity        face  = new FaceEntity();
                face.faceData = item.ImgData;
                faces.Add(face);
                string orgcode = "root000000";
                if (item.Istemporary == 0)
                {
                    orgcode = item.Groupsid;
                }
                var model = new
                {
                    personId        = item.USERID,
                    personName      = item.UserName,
                    gender          = "1",
                    orgIndexCode    = orgcode,
                    birthday        = "1990-01-01",
                    phoneNo         = item.Tel,
                    email           = "*****@*****.**",
                    certificateType = "990",
                    certificateNo   = no,
                    jobNo           = item.Tel,
                    faces
                };
                //string msg = SocketHelper.LoadCameraList(model, baseurl, Url, Key, Signature);
                HttpUtillibKbs.SetPlatformInfo(Key, Signature, baseurl, 443, true);
                byte[] result = HttpUtillibKbs.HttpPost(Url, JsonConvert.SerializeObject(model), 20);
                if (result != null)
                {
                    string    msg = System.Text.Encoding.UTF8.GetString(result);
                    parkList1 pl  = JsonConvert.DeserializeObject <parkList1>(msg);
                    if (pl != null && pl.code == "0")
                    {
                        SetLoadUserCarNo(item, baseurl, Key, Signature);
                    }
                }
            }
            //添加权限
            return(UploadUserlimits(list, baseurl, Key, Signature));
        }
Exemplo n.º 2
0
        /// <summary>
        /// 将拜访人员信息上传到海康平台
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="list"></param>
        public void UploadUserHiK(VisitcarEntity entity, List <CarUserFileImgEntity> list)
        {
            DataItemDetailService data = new DataItemDetailService();
            var    pitem     = data.GetItemValue("Hikappkey");
            var    baseurl   = data.GetItemValue("HikBaseUrl");
            string Key       = string.Empty;
            string Signature = string.Empty;

            //string no = new Random().Next(10, 888888).ToString();
            if (!string.IsNullOrEmpty(pitem))
            {
                Key       = pitem.Split('|')[0];
                Signature = pitem.Split('|')[1];
            }
            string Url = "/artemis/api/resource/v1/person/single/add";

            foreach (var item in list)
            {
                string time = DateTime.Now.ToString("yyyyMMddHHmmss");
                var    no   = Str.PinYin(item.Username).ToUpper() + time;//卡号唯一
                //人脸信息(base64必须为jpg格式)
                List <FaceEntity> faces = new List <FaceEntity>();
                FaceEntity        face  = new FaceEntity();
                face.faceData = item.Imgdata;
                faces.Add(face);
                var model = new
                {
                    personId        = item.ID,
                    personName      = item.Username,
                    gender          = "1",
                    orgIndexCode    = "root000000",
                    birthday        = "1990-01-01",
                    phoneNo         = entity.Phone,
                    email           = "*****@*****.**",
                    certificateType = "990",
                    certificateNo   = no,
                    faces
                };

                string    msg = SocketHelper.LoadCameraList(model, baseurl, Url, Key, Signature);
                parkList1 pl  = JsonConvert.DeserializeObject <parkList1>(msg);
                if (pl != null && pl.code == "0")
                {
                    SetLoadUserCarNo(item, baseurl, Key, Signature);
                }
            }
        }