예제 #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
        public int AddJurisdiction(JurisdictionEntity jurisdiction)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into tbtype (jurisdition_name)");
            strSql.Append("values");
            strSql.Append("(@JurisdictionName)");
            strSql.Append(";SELECT @@IDENTITY");
            SqlParameter[] paras =
            {
                new SqlParameter("@JurisdictionName", jurisdiction.JurisdictionName)
            };
            return(Convert.ToInt32(SqlHelper.ExecuteScalar(SqlHelper.connStr, CommandType.Text, strSql.ToString(), paras)));
        }
예제 #3
0
        public bool EditJurisdiction(JurisdictionEntity jurisdiction)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update tbjurisdiction set");
            strSql.Append("(jurisdition_name=@JurisdictionName)");
            strSql.Append("where id=@JurisdictionID");
            SqlParameter[] paras =
            {
                new SqlParameter("@JurisdictionName", jurisdiction.JurisdictionName),
                new SqlParameter("@JurisdictionID",   jurisdiction.JurisdictionID)
            };
            object obj = SqlHelper.ExecuteNonQuery(SqlHelper.connStr, CommandType.Text, strSql.ToString(), paras);

            if (Convert.ToInt32(obj) > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #4
0
        /// <summary>
        /// 出入权限配置
        /// </summary>
        private AddJurisdictionEntity UploadUserlimits(List <CarUserFileImgEntity> list, string baseUrl, string Key, string Signature)
        {
            AddJurisdictionEntity Juentity = new AddJurisdictionEntity();

            try
            {
                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);

                        JurisdictionEntity p1 = JsonConvert.DeserializeObject <JurisdictionEntity>(msg);
                        //Juentity.taskId = "54654646465465464654";
                        //Juentity.type = "add";
                        //Juentity.resourceInfos = resourceInfos;
                        if (p1 != null && p1.code == "0")
                        {
                            Juentity.taskId        = p1.data.taskId;
                            Juentity.resourceInfos = resourceInfos;
                            Juentity.type          = "add";
                        }
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(Juentity);
        }
예제 #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);
        }