Exemplo n.º 1
0
        /// <summary>
        /// 全部监控的获取
        /// </summary>
        /// <param name="page"></param>
        public void GetCameras(int page = 1)
        {
            string cameraP = "/artemis/api/resource/v2/camera/search";
            string body_c  = "{\"pageNo\":" + page + ",\"pageSize\": 100,\"orderBy\": \"name\",\"orderType\": \"desc\"}";

            java.util.Map path_c = new java.util.HashMap();
            path_c.put("https://", cameraP);
            string result_c = ArtemisHttpUtil.doPostStringArtemis(path_c, body_c, null, "*/*", "application/json", null);
            var    camera   = JsonConvert.DeserializeObject <Camera.Camera>(result_c);

            LogHelper.WriteLog(typeof(string), "监控查询code:" + camera.code);

            //Console.WriteLine("监控查询code:" + camera.code);
            if (camera.data.total == 0)
            {
                return;
            }
            var clist = camera.data.list;

            cameraList.AddRange(clist);
            var camera_total = camera.data.total;

            if ((camera_total - page * 100) % 100 > 0)
            {
                LogHelper.WriteLog(typeof(string), "开始迭代");

                //Console.WriteLine("开始迭代");
                page++;
                GetCameras(page);
            }
        }
Exemplo n.º 2
0
        public object VideoUrl(string indexCode)
        {
            //ArtemisConfig.host = "10.172.33.2"; // 代理API网关nginx服务器ip端口
            //ArtemisConfig.appKey = "27628571";  // 秘钥appkey
            //ArtemisConfig.appSecret = "TJzjgMqgM41EezwD36aV";// 秘钥appSecret
            //获取所有组织
            string videoP = "/artemis/api/video/v1/cameras/previewURLs";
            string body   = "{\"cameraIndexCode\": \"" + indexCode + "\",\"streamType\": 0,\"protocol\": \"hls\",\"transmode\": 1,\"expand\": \"transcode=0\"}";

            java.util.Map path = new java.util.HashMap();
            path.put("https://", videoP);
            string result = ArtemisHttpUtil.doPostStringArtemis(path, body, null, "*/*", "application/json", null);
            var    vdata  = JsonConvert.DeserializeObject <SKVideo>(result);

            return(Ok(new { vdata, indexCode }));
        }
Exemplo n.º 3
0
        public object ToVideoAction(string cameraIndexCode, int number, string command)
        {
            if (string.IsNullOrEmpty(cameraIndexCode) || (number != 1 && number != 0) || string.IsNullOrEmpty(command))
            {
                return("参数有误:cic=" + cameraIndexCode + ";num=" + number + ";comm=" + command);
            }
            string videoA = "/artemis/api/video/v1/ptz/controlling";
            string body   = "{\"cameraIndexCode\": \"" + cameraIndexCode + "\",\"action\":" + number + ",\"command\": \"" + command + "\",\"speed\": 20}";

            java.util.Map path = new java.util.HashMap();
            path.put("https://", videoA);
            string result = ArtemisHttpUtil.doPostStringArtemis(path, body, null, "*/*", "application/json", null);
            var    data   = JsonConvert.DeserializeObject <SKVideoActionResult>(result);



            return(Ok(new { data, cameraIndexCode, number, command, result }));
        }
Exemplo n.º 4
0
        /// <summary>
        /// 停车场节点信息
        /// </summary>
        public void Parking(int page = 1)
        {
            //获取停车库节点信息
            string parknodesurl = "/artemis/api/resource/v1/park/search";
            string pnBody       = "{\"pageSize\": 20,\"pageNo\": " + page + "}";

            java.util.Map path_pn = new java.util.HashMap();
            path_pn.put("https://", parknodesurl);
            string result_pn   = ArtemisHttpUtil.doPostStringArtemis(path_pn, pnBody, null, "*/*", "application/json", null);
            var    parknodes_d = JsonConvert.DeserializeObject <ParkNodes>(result_pn);

            Console.WriteLine("停车场节点查询code:" + parknodes_d.code);
            parknodes.AddRange(parknodes_d.data.list);
            var pn_total = parknodes_d.data.total;

            if ((pn_total - page * 20) % 20 > 0)
            {
                Console.WriteLine("开始迭代");
                page++;
                Parking(page);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// 获取监控的在线状态
        /// </summary>
        /// <param name="indexCode"></param>
        /// <returns>1在线,0不在线</returns>
        public string GetOnlineState(string indexCode)
        {
            Console.WriteLine("获取监控状态");
            string onlineP = "/artemis/api/nms/v1/online/camera/get";
            string body_o  = "{\"indexCodes\": [\"" + indexCode + "\"]}";

            java.util.Map path_o = new java.util.HashMap();
            path_o.put("https://", onlineP);
            string result_o = ArtemisHttpUtil.doPostStringArtemis(path_o, body_o, null, "*/*", "application/json", null);
            var    online_d = JsonConvert.DeserializeObject <Online.Online>(result_o);

            //Console.WriteLine(indexCode + "在线状态查询code:" + online_d.code);
            LogHelper.WriteLog(typeof(string), indexCode + "在线状态查询code:" + online_d.code);

            if (online_d.data.list.Count > 0)
            {
                return(online_d.data.list[0].online == 1 ? "在线" : "离线");
            }
            else
            {
                return("未知");
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// 通过海康平台api获取监控在线离线的状态
        /// </summary>
        /// <param name="indexCode"></param>
        /// <returns></returns>
        public string GetJianKState(string indexCode)
        {
            LogHelper.WriteLog(typeof(string), "获取监控状态");
            string onlineP = "/artemis/api/resource/v1/cameras/indexCode";
            string body_o  = "{\"cameraIndexCode\": \"" + indexCode + "\"}";

            java.util.Map path_o = new java.util.HashMap();
            path_o.put("https://", onlineP);
            string result_o =
                ArtemisHttpUtil.doPostStringArtemis(path_o, body_o, null, "*/*", "application/json", null);
            var online_d = JsonConvert.DeserializeObject <JianKongXQ>(result_o);

            LogHelper.WriteLog(typeof(string), online_d.ToString());
            LogHelper.WriteLog(typeof(string), "在线状态查询code:" + online_d.code);
            if (online_d.data != null)
            {
                return(online_d.data.status == 1 ? "在线" : "离线");
            }
            else
            {
                return("未知");
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// 停车场车位信息
        /// </summary>
        /// <param name="indexcode"></param>
        public void ParkingCarport(string indexcode, HaikanSmartTownCockpit.WatchDog.sqjz.model2.List data)
        {
            string carportUrl = "/artemis/api/pms/v1/park/remainSpaceNum";
            string cpbody     = "{\"parkSyscode\": \"" + indexcode + "\"}";

            java.util.Map path_cp = new java.util.HashMap();
            path_cp.put("https://", carportUrl);
            string result_cp      = ArtemisHttpUtil.doPostStringArtemis(path_cp, cpbody, null, "*/*", "application/json", null);
            var    parkcarport_cp = JsonConvert.DeserializeObject <Carport>(result_cp);
            var    carport        = parkcarport_cp.data[0];

            if (_dbContext2.ParkingLot.Any(x => x.ParkingIndexCode == data.indexCode && x.IsDeleted == 0))
            {
                var entity = _dbContext2.ParkingLot.FirstOrDefault(x => x.ParkingIndexCode == data.indexCode && x.IsDeleted == 0);
                entity.Zchewei = carport.totalPlace.ToString();
                entity.Schewei = carport.leftPlace.ToString();
                entity.Ychewei = (carport.totalPlace - carport.leftPlace).ToString();
            }
            else
            {
                ParkingLot lot = new ParkingLot()
                {
                    ParkingLotUuid   = Guid.NewGuid(),
                    ParkingLotName   = data.name,
                    ParkingIndexCode = data.indexCode,
                    IsDeleted        = 0,
                    Zchewei          = carport.totalPlace.ToString(),
                    Schewei          = carport.leftPlace.ToString(),
                    Ychewei          = (carport.totalPlace - carport.leftPlace).ToString(),
                    AddTime          = DateTime.Now.ToString("yyyy-MM-dd"),
                };
                _dbContext2.ParkingLot.Add(lot);
            }
            var num = _dbContext2.SaveChanges();

            Console.WriteLine("添加结果:" + num);
        }
Exemplo n.º 8
0
        /// <summary>
        /// 获取海康平台上所有的监控
        /// </summary>
        /// <param name="page"></param>
        public void Jiankong(int page = 1)
        {
            string regionP = "/artemis/api/resource/v1/cameras";
            string body_r  = "{\"pageNo\":" + page + ",\"pageSize\": 2000}";

            java.util.Map path_r = new java.util.HashMap();
            path_r.put("https://", regionP);
            string result_r =
                ArtemisHttpUtil.doPostStringArtemis(path_r, body_r, null, "*/*", "application/json", null);
            var region_d = JsonConvert.DeserializeObject <JianKong>(result_r);

            LogHelper.WriteLog(typeof(string), "区域查询code:" + region_d.code);

            jiankong.AddRange(region_d.data.list);

            var region_total = region_d.data.total;

            if ((region_total - page * 2000) % 2000 > 0)
            {
                LogHelper.WriteLog(typeof(string), "开始迭代");
                page++;
                Jiankong(page);
            }
        }