Beispiel #1
0
        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)
                {
                    DataAngineSet.Model.person_dataset ds = new DataAngineSet.Model.person_dataset();
                    ds = person_datasetbll.GetModel(id);
                    //int num = bll.GetListByTime(searchinfo.StartTime, searchinfo.EndTime, ds.id.ToString()).Tables[0].Rows.Count;
                    HitAlertData[] ha = HitAlertData.CreateInstanceFromDataAngineDataSet(bll.GetListByTime(searchinfo.StartTime, searchinfo.EndTime, searchinfo.StartIndex, searchinfo.PageSize, ds.id.ToString()));

                    HitAlertData[] haALL = HitAlertData.CreateInstanceFromDataAngineDataSet(bll.GetListByTime_TaskId(searchinfo.StartTime, searchinfo.EndTime, ds.id.ToString()));
                    JObject        jo    = new JObject(new JProperty("num", haALL.Length), new JProperty("pageData", JsonConvert.DeserializeObject(JsonConvert.SerializeObject(ha))));

                    response.SetContent(JsonConvert.SerializeObject(jo));
                }
                //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));

                //}
            }
            else
            {
                Log.Debug("轨迹查询");

                Trajectory_Search trajectory_search = Trajectory_Search.CreateInstanceFromJSON(request.PostParams);
                if (trajectory_search != null)
                {
                    HitAlertData_Trajectory_Search[] ha    = HitAlertData_Trajectory_Search.CreateInstanceFromDataAngineDataSet(bll.GetListById(trajectory_search.UserId, trajectory_search.StartTime, trajectory_search.EndTime, trajectory_search.StartIndex, trajectory_search.PageSize));
                    HitAlertData_Trajectory_Search[] haALL = HitAlertData_Trajectory_Search.CreateInstanceFromDataAngineDataSet(bll.GetListById(trajectory_search.UserId, trajectory_search.StartTime, trajectory_search.EndTime));
                    JObject jo = new JObject(new JProperty("num", haALL.Length), new JProperty("pageData", JsonConvert.DeserializeObject(JsonConvert.SerializeObject(ha))));

                    response.SetContent(JsonConvert.SerializeObject(jo));
                }
            }
            response.Send();
        }
        public override void OnPost(HttpRequest request, HttpResponse response)
        {
            hitalert       bll = new hitalert();
            person_dataset person_datasetbll = new person_dataset();

            if (request.RestConvention != null)//根据ID获得数据库
            {
                Log.Debug(string.Format("请求地址无效", request.RestConvention));
                //int id = -1;
                //try
                //{
                //    id = Convert.ToInt32(request.RestConvention);
                //}
                //catch
                //{
                //}

                //SearchInfo searchinfo = SearchInfo.CreateInstanceFromJSON(request.PostParams);
                //if (searchinfo != null)
                //{
                //    DataAngineSet.Model.person_dataset ds = new DataAngineSet.Model.person_dataset();
                //    ds = person_datasetbll.GetModel(id);
                //    //int num = bll.GetListByTime(searchinfo.StartTime, searchinfo.EndTime, ds.id.ToString()).Tables[0].Rows.Count;
                //    HitAlertData[] ha = HitAlertData.CreateInstanceFromDataAngineDataSet(bll.GetListByTime(searchinfo.StartTime, searchinfo.EndTime, searchinfo.StartIndex, searchinfo.PageSize, ds.id.ToString()));

                //    HitAlertData[] haALL = HitAlertData.CreateInstanceFromDataAngineDataSet(bll.GetListByTime_TaskId(searchinfo.StartTime, searchinfo.EndTime, ds.id.ToString()));
                //    JObject jo = new JObject(new JProperty("num", haALL.Length), new JProperty("pageData", JsonConvert.DeserializeObject(JsonConvert.SerializeObject(ha))));

                //    response.SetContent(JsonConvert.SerializeObject(jo));
                //}
            }
            else
            {
                Log.Debug("根据图片的轨迹查询");

                string result = Base64Decode(request.PostParams);
                //string result = request.PostParams;
                Trajectory_Search_ByImg trajectory_search = Trajectory_Search_ByImg.CreateInstanceFromJSON(result);
                if (trajectory_search != null)
                {
                    InitFRS();
                    fa.LoadData();
                    fa.ScoreThresh = (float)0.5;
                    Log.Debug(string.Format("阈值:{0}", fa.ScoreThresh));
                    Log.Debug(string.Format("top值:{0}", fa.TopK));
                    FRS.HitAlert[] hits;

                    if (trajectory_search.PicSrc != null)
                    {
                        Bitmap Bitmapsrc = Base64ToImage(trajectory_search.PicSrc);
                        Bitmap bmpsrc    = new Bitmap(Bitmapsrc.Width, Bitmapsrc.Height, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
                        Graphics.FromImage(bmpsrc).DrawImage(Bitmapsrc, new Rectangle(0, 0, bmpsrc.Width, bmpsrc.Height));
                        hits = fa.Search(bmpsrc);
                        bmpsrc.Dispose();
                    }
                    else
                    {
                        //Image src = Image.FromFile(trajectory_search.PicSrc_Path);
                        Image src = Get_UrlImage(trajectory_search.PicSrc_Path);
                        hits = fa.Search(src);
                    }

                    if (hits == null)
                    {
                        Log.Debug("该图没有人脸");
                        JObject jo = new JObject(new JProperty("num", 0), new JProperty("pageData", null));

                        response.SetContent(JsonConvert.SerializeObject(jo));
                    }
                    else
                    {
                        if (hits[0].Details.Length == 0)
                        {
                            Log.Debug("没有找到该图像对应的人脸");
                            JObject jo = new JObject(new JProperty("num", 0), new JProperty("pageData", null));

                            response.SetContent(JsonConvert.SerializeObject(jo));
                        }
                        else
                        {
                            int UserId = (int)hits[0].Details[0].UserId;
                            Console.WriteLine(UserId);
                            Log.Debug(string.Format("{0}, {1}, {2}, {3}", trajectory_search.StartTime, trajectory_search.EndTime, trajectory_search.StartIndex, trajectory_search.PageSize));

                            System.Data.DataSet a = bll.GetListById(UserId, trajectory_search.StartTime, trajectory_search.EndTime, trajectory_search.StartIndex, trajectory_search.PageSize);

                            Console.WriteLine(a.Tables);

                            HitAlertData_Trajectory_Search[] ha    = HitAlertData_Trajectory_Search.CreateInstanceFromDataAngineDataSet(bll.GetListById(UserId, trajectory_search.StartTime, trajectory_search.EndTime, trajectory_search.StartIndex, trajectory_search.PageSize));
                            HitAlertData_Trajectory_Search[] haALL = HitAlertData_Trajectory_Search.CreateInstanceFromDataAngineDataSet(bll.GetListById(UserId, trajectory_search.StartTime, trajectory_search.EndTime));
                            JObject jo = new JObject(new JProperty("num", haALL.Length), new JProperty("pageData", JsonConvert.DeserializeObject(JsonConvert.SerializeObject(ha))));

                            response.SetContent(JsonConvert.SerializeObject(jo));
                        }
                    }
                }
            }
            response.Send();
        }