Exemplo n.º 1
0
        private SearchSession Search(SearchSession searchSession)
        {
            MyLog4Net.Container.Instance.Log.InfoFormat("VideoSearchService entering Search: session {0}, searchType {1}, result display mode {2} ...",
                                                        searchSession.GetHashCode(), searchSession.SearchPara.SearchType, searchSession.SearchPara.DisplayMode);
            lock (this.m_SyncObjSearch)
            {
                CloseSearch(searchSession.SearchPara.SearchType);

                try
                {
                    LogSearchItems(searchSession.SearchPara);

                    if (searchSession.SearchPara.SearchType == SearchType.Normal)
                    {
                        searchSession.SearchId = Framework.Container.Instance.IVXProtocol.StartMoveObjectSearchByTaskUnit(searchSession.SearchPara);
                    }
                    else if (searchSession.SearchPara.SearchType == SearchType.Compare)
                    {
                        searchSession.SearchId = Framework.Container.Instance.IVXProtocol.StartCompareSearchByTaskUnit(searchSession.SearchPara);
                    }

                    else if (searchSession.SearchPara.SearchType == SearchType.Face)
                    {
                        searchSession.SearchId = Framework.Container.Instance.IVXProtocol.StartFaceSearchByTaskUnit(searchSession.SearchPara);
                    }

                    else if (searchSession.SearchPara.SearchType == SearchType.Vehicle)
                    {
                        searchSession.SearchId = Framework.Container.Instance.IVXProtocol.StartVehicleSearchByTaskUnit(searchSession.SearchPara);
                    }

                    m_DTSearchType2SearchSession.Add(searchSession.SearchPara.SearchType, searchSession);
                    m_DTSearchType2InQueue[searchSession.SearchPara.SearchType] = false;
                }
                catch (Exception ex)
                {
                    searchSession.Exception = ex;
                    SDKCallExceptionHandler.Handle(ex, "Search", false);
                }
                MyLog4Net.Container.Instance.Log.InfoFormat("VideoSearchService exited Search: session {0}, searchType {1}, seachID {2}",
                                                            searchSession.GetHashCode(), searchSession.SearchPara.SearchType, searchSession.SearchId);
            }
            return(searchSession);
        }
Exemplo n.º 2
0
        public bool StartSearch(SearchPara para)
        {
            if (!Framework.Environment.CheckMemeryUse())
            {
                throw new SDKCallException(0, "内存占用过大,请关闭视频播放或取消检索后再试。");
            }

            MyLog4Net.Container.Instance.Log.Info("VideoSearchService entering StartSearch ...");
            bool bRet = true;

            lock (m_SyncObjSearch)
            {
                // 先停掉当前的检索
                //if (m_SearchSession != null)
                //{
                //    Framework.Container.Instance.IVXProtocol.CloseSearchSession(m_SearchSession.SearchId);
                //    m_SearchSession = null;
                //}
                try
                {
                    CloseSearch(para.SearchType);
                }
                catch (SDKCallException ex)
                {
                    SDKCallExceptionHandler.Handle(ex, "CloseSearchSession", false);
                }

                // 放入任务队列
                SearchSession searchSession = new SearchSession(para)
                {
                };
                // 状态复位
                para.ResetSearchItemStatus();

                para.DisplayMode = Framework.Environment.GetDisplayMode(para.SearchType);

                // m_DTSearchType2SearchSession.Add(para.SearchType, searchSession);
                m_DTSearchType2InQueue[para.SearchType] = true;

                TaskItem <SearchSession, SearchSession> taskItem =
                    new TaskItem <SearchSession, SearchSession> {
                    FuncToRun = Search, Callback = OnSearchResult, Para = searchSession
                };

                MyLog4Net.Container.Instance.Log.InfoFormat("VideoSearchService: Insert task item session {0}", searchSession.GetHashCode());
                m_taskRunner.AddTask(taskItem);

                MyLog4Net.Container.Instance.Log.Info("VideoSearchService leave StartSearch");
            }
            return(bRet);
        }