コード例 #1
0
        /// <summary>
        /// 拜访人员删除对应设备中出入权限配置
        /// </summary>
        public void DeleteUserlimits(List <CarUserFileImgEntity> list, string baseUrl, string Key, string Signature)
        {
            string msg = string.Empty;

            if (list.Count > 0)
            {
                var url = "/artemis/api/acps/v1/auth_config/delete";
                List <personDatas1> personDatas = new List <personDatas1>();
                personDatas1        entity      = new personDatas1();
                List <string>       codes       = new List <string>();
                foreach (var Item in list)
                {
                    codes.Add(Item.ID);//人员Id
                }
                entity.indexCodes     = codes;
                entity.personDataType = "person";
                personDatas.Add(entity);
                string sql = string.Format("select t.itemname,t.itemvalue,t.itemcode from base_dataitem d join BASE_DATAITEMDETAIL t on d.itemid=t.itemid  where d.itemcode='equipment1' order by t.sortcode asc");
                //出入权限
                DataTable dt = this.BaseRepository().FindTable(sql);
                if (dt.Rows.Count > 0)
                {
                    List <resourceInfos1> resourceInfos = new List <resourceInfos1>();//设备信息集合
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        List <int> nos = new List <int>();
                        if (dt.Rows[i][2].ToString() == "1")
                        {//门禁通道
                            nos.Add(1);
                            nos.Add(2);
                        }
                        else
                        {//门禁
                            nos.Add(1);
                        }
                        resourceInfos1 entity1 = new resourceInfos1();
                        entity1.resourceIndexCode = dt.Rows[i][1].ToString();//设备唯一编号
                        entity1.resourceType      = "acsDevice";
                        entity1.channelNos        = nos;
                        resourceInfos.Add(entity1);
                    }
                    var model = new
                    {
                        personDatas,
                        resourceInfos
                    };
                    //配置删除权限
                    msg = SocketHelper.LoadCameraList(model, baseUrl, url, Key, Signature);
                    JurisdictionEntity ps = JsonConvert.DeserializeObject <JurisdictionEntity>(msg);
                    if (ps.code == "0")
                    {
                        //下发删除配置到硬件设备上
                        downloadUserlimits(resourceInfos, baseUrl, Key, Signature);
                    }
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// 出入权限配置
        /// </summary>
        private void UploadUserlimits(List <CarUserFileImgEntity> list, string baseUrl, string Key, string Signature)
        {
            if (list.Count > 0)
            {
                var url = "/artemis/api/acps/v1/auth_config/add";
                List <personDatas1> personDatas = new List <personDatas1>();
                personDatas1        entity      = new personDatas1();
                List <string>       codes       = new List <string>();
                foreach (var item in list)
                {
                    codes.Add(item.ID);//人员Id
                }
                entity.indexCodes     = codes;
                entity.personDataType = "person";
                personDatas.Add(entity);

                string    Qres = string.Empty;//临时人员默认一号岗
                string    sql  = string.Format("select t.itemname,t.itemvalue,t.itemcode from base_dataitem d join BASE_DATAITEMDETAIL t on d.itemid=t.itemid  where d.itemcode='equipment1' order by t.sortcode asc");
                DataTable dt   = this.BaseRepository().FindTable(sql);
                if (dt.Rows.Count > 0)
                {
                    List <resourceInfos1> resourceInfos = new List <resourceInfos1>();//设备信息集合
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        List <int> nos = new List <int>();
                        if (dt.Rows[i][2].ToString() == "1")
                        {//门禁通道
                            nos.Add(1);
                            nos.Add(2);
                        }
                        else
                        {//门禁
                            nos.Add(1);
                        }
                        resourceInfos1 entity1 = new resourceInfos1();
                        entity1.resourceIndexCode = dt.Rows[i][1].ToString();//设备唯一编号
                        entity1.resourceType      = "acsDevice";
                        entity1.channelNos        = nos;
                        resourceInfos.Add(entity1);
                    }
                    string stime = Convert.ToDateTime(list[0].CreateDate).ToString("yyyy-MM-ddTHH:mm:ss+08:00", DateTimeFormatInfo.InvariantInfo);//ISO8601时间格式
                    string etime = Convert.ToDateTime(list[0].CreateDate).AddDays(1).ToString("yyyy-MM-ddTHH:mm:ss+08:00", DateTimeFormatInfo.InvariantInfo);
                    var    model = new
                    {
                        personDatas,
                        resourceInfos,
                        startTime = stime,
                        endTime   = etime
                    };
                    string msg = SocketHelper.LoadCameraList(model, baseUrl, url, Key, Signature);
                    downloadUserlimits(resourceInfos, baseUrl, Key, Signature);
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// 出入权限配置
        /// </summary>
        /// <param name="codes">用户或组织id集合</param>
        /// <param name="ParentAccess">控制器id集合</param>
        /// <param name="Access">门禁点id集合</param>
        /// <param name="StartTime">开始时间</param>
        /// <param name="EndTime">结束时间</param>
        /// <param name="Type">0组织 1人员</param>
        /// <param name="baseUrl"></param>
        /// <param name="Key"></param>
        /// <param name="Signature"></param>
        private void DeleteUserlimits(List <string> codes, List <HikAccessNo> ParentAccess, List <HikAccessNo> Access, int Type, string baseUrl, string Key, string Signature)
        {
            var url = "/artemis/api/acps/v1/auth_config/delete";
            List <personDatas1> personDatas = new List <personDatas1>();
            personDatas1        entity      = new personDatas1();

            entity.indexCodes = codes;
            if (Type == 0)
            {
                entity.personDataType = "org";
            }
            else
            {
                entity.personDataType = "person";
            }
            personDatas.Add(entity);

            List <resourceInfos1> AllresourceInfos = new List <resourceInfos1>();//设备信息集合

            for (int i = 0; i < ParentAccess.Count; i++)
            {
                //List<int> nos = new List<int>();
                //nos.Add(1);
                //nos.Add(2);


                resourceInfos1 entity1 = new resourceInfos1();
                entity1.resourceIndexCode = ParentAccess[i].AccId;//设备唯一编号
                entity1.resourceType      = "acsDevice";
                entity1.channelNos        = ParentAccess[i].No;
                AllresourceInfos.Add(entity1);
            }
            //这里门禁控制器固定为设备类型门禁点类型采取数据编码配置
            DataItemDetailService itemBll = new DataItemDetailService();
            string doorType = itemBll.GetItemValue("doorType");

            foreach (var item in Access)
            {
                //List<int> nos = new List<int>();
                //nos.Add(1);
                resourceInfos1 entity1 = new resourceInfos1();
                entity1.resourceIndexCode = item.AccId;//设备唯一编号
                entity1.resourceType      = doorType;
                entity1.channelNos        = item.No;
                AllresourceInfos.Add(entity1);
            }
            var model = new
            {
                personDatas,
                resourceInfos = AllresourceInfos
            };
            string msg  = SocketHelper.LoadCameraList(model, baseUrl, url, Key, Signature);
            var    tsk  = JsonConvert.DeserializeObject <JurisdictionEntity>(msg);
            bool   flag = QuerySpeedofprogress(tsk.data.taskId, baseUrl, Key, Signature);

            if (flag)
            {
                //将删除卡号下发到所有设备
                downloadUserlimits(AllresourceInfos, 1, baseUrl, Key, Signature);
            }
        }
コード例 #4
0
        /// <summary>
        /// 出入权限配置
        /// </summary>
        /// <param name="codes">用户或组织id集合</param>
        /// <param name="ParentAccess">控制器id集合</param>
        /// <param name="Access">门禁点id集合</param>
        /// <param name="StartTime">开始时间</param>
        /// <param name="EndTime">结束时间</param>
        /// <param name="Type">0组织 1人员</param>
        /// <param name="baseUrl"></param>
        /// <param name="Key"></param>
        /// <param name="Signature"></param>
        private void UploadUserlimits(List <string> codes, List <HikAccessNo> ParentAccess, List <HikAccessNo> Access, string StartTime, string EndTime, int Type, string baseUrl, string Key, string Signature)
        {
            var url = "/artemis/api/acps/v1/auth_config/add";
            List <personDatas1> personDatas = new List <personDatas1>();
            personDatas1        entity      = new personDatas1();

            entity.indexCodes = codes;
            if (Type == 0)
            {
                entity.personDataType = "org";
            }
            else
            {
                entity.personDataType = "person";
            }
            personDatas.Add(entity);

            List <resourceInfos1> AllresourceInfos = new List <resourceInfos1>(); //设备信息集合
            List <resourceInfos1> resourceInfos    = new List <resourceInfos1>(); //设备信息集合

            for (int i = 0; i < ParentAccess.Count; i++)
            {
                resourceInfos1 entity1 = new resourceInfos1();
                entity1.resourceIndexCode = ParentAccess[i].AccId;//设备唯一编号
                entity1.resourceType      = "acsDevice";
                entity1.channelNos        = ParentAccess[i].No;
                AllresourceInfos.Add(entity1);
            }
            //这里门禁控制器固定为设备类型门禁点类型采取数据编码配置
            DataItemDetailService itemBll = new DataItemDetailService();
            string doorType = itemBll.GetItemValue("doorType");

            foreach (var item in Access)
            {
                resourceInfos1 entity1 = new resourceInfos1();
                entity1.resourceIndexCode = item.AccId;//设备唯一编号
                entity1.resourceType      = doorType;
                entity1.channelNos        = item.No;
                AllresourceInfos.Add(entity1);
                resourceInfos.Add(entity1);
            }
            string stime = Convert.ToDateTime(StartTime).ToString("yyyy-MM-ddTHH:mm:ss+08:00", DateTimeFormatInfo.InvariantInfo);//ISO8601时间格式
            string etime = Convert.ToDateTime(EndTime).ToString("yyyy-MM-ddTHH:mm:ss+08:00", DateTimeFormatInfo.InvariantInfo);
            var    model = new
            {
                personDatas,
                resourceInfos = AllresourceInfos,
                startTime     = stime, // "2019-12-01T17:30:08+08:00",
                endTime       = etime  //"2019-12-19T17:30:08+08:00"
            };
            string msg  = SocketHelper.LoadCameraList(model, baseUrl, url, Key, Signature);
            var    tsk  = JsonConvert.DeserializeObject <JurisdictionEntity>(msg);
            bool   flag = QuerySpeedofprogress(tsk.data.taskId, baseUrl, Key, Signature);

            if (flag)
            {
                //先将卡号下发到所有设备
                downloadUserlimits(AllresourceInfos, 1, baseUrl, Key, Signature);
                //再讲指纹单独下发到设备
                downloadUserlimits(resourceInfos, 2, baseUrl, Key, Signature);
            }
        }
コード例 #5
0
        /// <summary>
        /// 添加出入权限配置
        /// </summary>
        private AddJurisdictionEntity UploadUserlimits(List <TemporaryUserEntity> list, string baseUrl, string Key, string Signature)
        {
            AddJurisdictionEntity Juentity = new AddJurisdictionEntity();

            if (list.Count > 0)
            {
                var url = "/artemis/api/acps/v1/auth_config/add";
                List <personDatas1> personDatas = new List <personDatas1>();
                personDatas1        entity      = new personDatas1();
                List <string>       codes       = new List <string>();
                foreach (var item in list)
                {                           //将所有人放集合做一次任务下发
                    codes.Add(item.USERID); //人员Id
                }
                entity.indexCodes     = codes;
                entity.personDataType = "person";
                personDatas.Add(entity);
                #region  查询设备唯一编号
                string Qres   = list[0].PassPostId == null ? "" : list[0].PassPostId;
                string qc     = string.Empty;
                var    qclist = Qres.Split(',');
                for (int i = 0; i < qclist.Length; i++)
                {
                    if (string.IsNullOrEmpty(qclist[i]))
                    {
                        continue;
                    }
                    qc += "'" + qclist[i] + "'" + ",";
                }
                string sql = string.Format("select t.itemname,t.itemvalue,t.itemcode from base_dataitem d join BASE_DATAITEMDETAIL t on d.itemid=t.itemid  where d.itemcode in ({0}) order by t.sortcode asc", qc.TrimEnd(','));
                #endregion
                if (!string.IsNullOrEmpty(Qres))
                {//授权门岗不能为空
                    DataTable dt = this.BaseRepository().FindTable(sql);
                    if (dt.Rows.Count > 0)
                    {
                        List <resourceInfos1> resourceInfos = new List <resourceInfos1>();//设备信息集合
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            List <int> nos = new List <int>();
                            if (dt.Rows[i][2].ToString() == "1")
                            {//门禁通道
                                nos.Add(1);
                                nos.Add(2);
                            }
                            else
                            {//门禁
                                nos.Add(1);
                            }
                            resourceInfos1 entity1 = new resourceInfos1();
                            entity1.resourceIndexCode = dt.Rows[i][1].ToString();//设备唯一编号
                            entity1.resourceType      = "acsDevice";
                            entity1.channelNos        = nos;
                            resourceInfos.Add(entity1);
                        }
                        string stime = Convert.ToDateTime(list[0].startTime).ToString("yyyy-MM-ddTHH:mm:ss+08:00", DateTimeFormatInfo.InvariantInfo);//ISO8601时间格式
                        string etime = Convert.ToDateTime(list[0].EndTime).ToString("yyyy-MM-ddTHH:mm:ss+08:00", DateTimeFormatInfo.InvariantInfo);
                        var    model = new
                        {
                            personDatas,
                            resourceInfos,
                            startTime = stime,  // "2019-12-01T17:30:08+08:00",
                            endTime   = etime   //"2019-12-19T17:30:08+08:00"
                        };
                        HttpUtillibKbs.SetPlatformInfo(Key, Signature, baseUrl, 443, true);
                        byte[] result = HttpUtillibKbs.HttpPost(url, JsonConvert.SerializeObject(model), 20);
                        if (result != null)
                        {
                            string             msgs = System.Text.Encoding.UTF8.GetString(result);
                            JurisdictionEntity p1   = JsonConvert.DeserializeObject <JurisdictionEntity>(msgs);
                            if (p1 != null && p1.code == "0")
                            {
                                Juentity.taskId        = p1.data.taskId;
                                Juentity.resourceInfos = resourceInfos;
                                Juentity.type          = "add";
                            }
                        }
                    }
                }
            }
            return(Juentity);
        }
コード例 #6
0
        /// <summary>
        /// 删除对应设备中出入权限配置记录
        /// </summary>
        public AddJurisdictionEntity DelEquipmentRecord(List <TemporaryUserEntity> list, string baseUrl, string Key, string Signature)
        {
            AddJurisdictionEntity Juentity = new AddJurisdictionEntity();

            if (list.Count > 0)
            {
                var url = "/artemis/api/acps/v1/auth_config/delete";
                List <personDatas1> personDatas = new List <personDatas1>();
                personDatas1        entity      = new personDatas1();
                List <string>       codes       = new List <string>();
                foreach (var Item in list)
                {
                    codes.Add(Item.USERID);//人员Id
                }
                entity.indexCodes     = codes;
                entity.personDataType = "person";
                personDatas.Add(entity);

                #region  查询设备唯一编号
                string Qres   = list[0].PassPostId == null ? "" : list[0].PassPostId;
                string qc     = string.Empty;
                var    qclist = Qres.Split(',');
                for (int i = 0; i < qclist.Length; i++)
                {
                    if (string.IsNullOrEmpty(qclist[i]))
                    {
                        continue;
                    }
                    qc += "'" + qclist[i] + "'" + ",";
                }
                string sql = string.Format("select t.itemname,t.itemvalue,t.itemcode from base_dataitem d join BASE_DATAITEMDETAIL t on d.itemid=t.itemid  where d.itemcode in ({0}) order by t.sortcode asc", qc.TrimEnd(','));
                #endregion
                if (!string.IsNullOrEmpty(qc))
                {
                    //出入权限
                    DataTable dt = this.BaseRepository().FindTable(sql);
                    if (dt.Rows.Count > 0)
                    {
                        List <resourceInfos1> resourceInfos = new List <resourceInfos1>();//设备信息集合
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            List <int> nos = new List <int>();
                            if (dt.Rows[i][2].ToString() == "1")
                            {//门禁通道
                                nos.Add(1);
                                nos.Add(2);
                            }
                            else
                            {//门禁
                                nos.Add(1);
                            }
                            resourceInfos1 entity1 = new resourceInfos1();
                            entity1.resourceIndexCode = dt.Rows[i][1].ToString();//设备唯一编号
                            entity1.resourceType      = "acsDevice";
                            entity1.channelNos        = nos;
                            resourceInfos.Add(entity1);
                        }
                        var model = new
                        {
                            personDatas,
                            resourceInfos
                        };
                        // string msgs = 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             msgs = System.Text.Encoding.UTF8.GetString(result);
                            JurisdictionEntity p1   = JsonConvert.DeserializeObject <JurisdictionEntity>(msgs);
                            if (p1 != null && p1.code == "0")
                            {
                                Juentity.taskId        = p1.data.taskId;
                                Juentity.resourceInfos = resourceInfos;
                                Juentity.type          = "del";
                            }
                        }
                    }
                }
            }
            return(Juentity);
        }