Exemple #1
0
        public override void OnGet(HttpRequest request, HttpResponse response)
        {
            if (request.RestConvention != null)
            {
                Log.Debug(string.Format("返回ID:{0}人员库", request.RestConvention));

                int id = -1;
                try
                {
                    id = Convert.ToInt32(request.RestConvention);
                }
                catch
                {
                }

                Dataset da = Dataset.CreateInstanceFromDataAngineModel(bll.GetModel(id));
                if (null != da)
                {
                    response.SetContent(da.ToJson());
                }
            }
            else if (request.Domain != string.Empty)
            {
                Log.Debug(string.Format("返回所有库信息"));
                List <DataAngine_Set.Model.dataset> datasets = bll.DataTableToList(bll.GetAllList().Tables[0]);
                response.SetContent(JsonConvert.SerializeObject(Dataset.CreateInstanceFromDataAngineModel(datasets.ToArray())));
            }
            response.Send();
        }
Exemple #2
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);
        }
        /// <summary>
        /// Post时调用
        /// </summary>
        public override void OnPost(HttpRequest request, HttpResponse response)
        {
            bool status = false;

            if (request.Operation == "verify")//添加一条数据
            {
                Log.Debug("比较图片");

                //OneVsOne
                if (request.RestConvention == "0")
                {
                    VerifyOneVsOne verify = VerifyOneVsOne.CreateInstanceFromJSON(request.PostParams);
                    if (verify != null)
                    {
                        Bitmap Bitmapsrc = BytesToBitmap(verify.PicSrc);
                        Bitmap Bitmapdst = BytesToBitmap(verify.PicDst);
                        double score     = fa.Compare(Bitmapsrc, Bitmapdst);

                        response.SetContent(JsonConvert.SerializeObject(score));
                    }
                }
                else
                {
                    VerifyOneVsN verify = VerifyOneVsN.CreateInstanceFromJSON(request.PostParams);
                    if (verify != null)
                    {
                        int DatasetId = Convert.ToInt32(request.RestConvention);
                        DataAngine_Set.Model.dataset ds = new DataAngine_Set.Model.dataset();
                        ds = bll.GetModel(DatasetId);

                        Bitmap Bitmapsrc = BytesToBitmap(verify.PicSrc);
                        fa.LoadData(ds.datasetname);
                        FRS.HitAlert[] hits = fa.Search(Bitmapsrc);
                        string         msg  = JsonConvert.SerializeObject(Model.HitAlert.CreateInstanceFromFRSHitAlert(hits));
                        response.SetContent(msg);
                    }
                }
            }
            response.Send();
        }
        public override void OnPost(HttpRequest request, HttpResponse response)
        {
            if (request.RestConvention != null)//根据ID获得数据库
            {
                Log.Debug(string.Format("返回数据库{0}的信息", request.RestConvention));
                int id = -1;
                try
                {
                    id = Convert.ToInt32(request.RestConvention);
                }
                catch
                {
                }

                SearchInfo searchinfo = SearchInfo.CreateInstanceFromJSON(request.PostParams);
                if (searchinfo != null)
                {
                    DataAngine_Set.Model.dataset ds = new DataAngine_Set.Model.dataset();
                    ds = datasetbll.GetModel(id);
                    HitAlertData[] ha = HitAlertData.CreateInstanceFromDataAngineDataSet(bll.GetListByTime(searchinfo.StartTime, searchinfo.EndTime, searchinfo.StartIndex, searchinfo.PageSize, ds.datasetname));
                    response.SetContent(JsonConvert.SerializeObject(ha));
                }
                //if(request.GetParams!=null)
                //{
                //    DateTime starttime=new DateTime();
                //    DateTime endtime=new DateTime();
                //    int startindex = 0;
                //    int pagesize = 30;
                //    starttime = Convert.ToDateTime(request.GetParams["starttime"]);
                //    endtime = Convert.ToDateTime(request.GetParams["endtime"]);
                //    startindex = Convert.ToInt32(request.GetParams["startindex"]);
                //    pagesize = Convert.ToInt32(request.GetParams["pagesize"]);
                //    HitAlertData[] ha = HitAlertData.CreateInstanceFromDataAngineDataSet(bll.GetListByTime(starttime, endtime, startindex, pagesize, library));
                //     response.SetContent(JsonConvert.SerializeObject(ha));

                //}
            }
            response.Send();
        }
Exemple #5
0
 public override void OnGet(HttpRequest request, HttpResponse response)
 {
     if (request.RestConvention != null)//根据ID获得数据库
     {
         Console.WriteLine("返回ID{0}的数据库信息", request.RestConvention);
         int id = -1;
         try{
             id = Convert.ToInt32(request.RestConvention);
         }
         catch {
         }
         Dataset da = Dataset.CreateInstanceFromDataAngineModel(bll.GetModel(id));
         if (null != da)
         {
             response.SetContent(da.ToJson());
         }
     }
     else if (request.Domain != null)//获得所有数据库
     {
         List <DataAngine_Set.Model.dataset> datasets = bll.DataTableToList(bll.GetAllList().Tables[0]);
         response.SetContent(JsonConvert.SerializeObject(Dataset.CreateInstanceFromDataAngineModel(datasets.ToArray())));
     }
     response.Send();
 }