示例#1
0
        bool  Init(int taskID)
        {
            DataAngine_Set.Model.surveillancetask task = taskBll.GetModel(taskID);
            if (null == task)
            {
                Log.Debug("检索任务失败"); return(false);
            }
            DataAngine_Set.Model.device device = deviceBll.GetModel(task.deviceid);
            if (null == device)
            {
                Log.Debug("检索设备失败"); return(false);
            }
            DataAngine_Set.Model.dataset dataset = datasetBll.GetModel(task.databaseid);
            if (null == dataset)
            {
                Log.Debug("检索库失败"); return(false);
            }

            InitFRS();

            fa.LoadData(dataset.datasetname);
            cap.HitAlertReturnEvent += new Capture.HitAlertCallback(OnHit);


            int id = -1;

            try
            {
                Log.Debug(device.address);
                id = Convert.ToInt32(device.address);
            }
            catch
            {
            }
            if (id == -1)
            {
                if (cap.Start(device.address) != ReturnCode.SUCCESS)
                {
                    Log.Debug("打开摄像头失败");
                    return(false);
                }
            }
            else
            {
                if (cap.Start(id) != ReturnCode.SUCCESS)
                {
                    Log.Debug("打开摄像头失败");
                    return(false);
                }
            }

            return(true);
        }
示例#2
0
        public override void OnGet(HttpRequest request, HttpResponse response)
        {
            if (request.RestConvention != null)
            {
                Console.WriteLine("返回ID:{0}设备信息", request.RestConvention);
                ////根据ID获得 设备
                //Device d = new Device();
                //d.ID = Int32.Parse(request.RestConvention);
                //d.Latitude = 1.0d;
                //d.Latitude = 1.0d;
                //d.Name = "3131";
                //d.Remark = "2131";
                //response.SetContent(d.ToJson());
                //response.Send();
                int id = -1;
                try
                {
                    id = Convert.ToInt32(request.RestConvention);
                }
                catch
                {
                }
                Device da = Device.CreateInstanceFromDataAngineModel(bll.GetModel(id));
                if (null != da)
                {
                    response.SetContent(da.ToJson());
                }
            }
            else if (request.Domain != string.Empty)
            {
                Console.WriteLine("返回所有设备信息");

                List <DataAngine_Set.Model.device> devices = bll.DataTableToList(bll.GetAllList().Tables[0]);
                response.SetContent(JsonConvert.SerializeObject(Device.CreateInstanceFromDataAngineModel(devices.ToArray())));
            }
            response.Send();
        }