//private void OnNewCompareSearch(SearchPara searchPara)
        //{
        //    m_isCompareSearch = true;
        //    if (PreNewSearch != null)
        //    {
        //        string[] settings = new string[] { searchPara.Task.TaskName+ " 以图搜车" };
        //        PreNewSearch(settings);
        //    }

        //    if (m_ResultPageInfo != null)
        //    {
        //        m_ResultPageInfo.SelectedPageNumberChanged -= new EventHandler(ResultPageInfo_SelectedPageNumberChanged);
        //    }
        //    m_DTAnalyseResults.Rows.Clear();

        //    m_searchPara = searchPara;
        //    Task = m_searchPara.Task;
        //    // SearchSettings = searchPara.ToString();

        //    //m_FileAccess = FileAccessFactory.GetFileAccess(Task.PictureSource);

        //    if (Framework.Container.Instance.TaskManager.Revisor != null)
        //    {
        //        if (Task.Status == TaskStatus.Finished)
        //        {
        //            m_Records = Framework.Container.Instance.TaskManager.Revisor.GetAllResults(Task);
        //            m_ResultPageInfo = new DataModel.PageInfo(m_Records.Count == 0? 100 : m_Records.Count, searchPara.ResultCount, 0);
        //        }
        //        else
        //        {
        //            m_Records = null;
        //            m_ResultPageInfo = new DataModel.PageInfo(100, 0, 0);
        //        }
        //    }
        //    else
        //    {
        //        m_ResultPageInfo = new DataModel.PageInfo(100, searchPara.ResultCount, 0);
        //        m_ResultPageInfo.SelectedPageNumberChanged += new EventHandler(ResultPageInfo_SelectedPageNumberChanged);
        //        m_SQLQuery = m_searchPara.SqlQuery;
        //        //m_Records = Framework.Container.Instance.TaskManager.SwitchComparePage(m_SQLQuery, m_ResultPageInfo, m_searchPara);
        //    }

        //    FileName = string.Format("{0}: ", m_searchPara.Task.TaskName);
        //    RaisePropertyChangedEvent("FileName");
        //    if (m_Records != null && m_Records.Count > 0)
        //    {
        //        foreach (AnalyseRecord record in m_Records)
        //        {
        //            AddResultRow(m_DTAnalyseResults, record);
        //        }
        //        HasResult = true;
        //    }
        //    else
        //    {
        //        Framework.Container.Instance.InteractionService.ShowMessageBox("没有检索到结果");
        //    }

        //    if (SearchResult != null)
        //    {
        //        SearchResult(this, EventArgs.Empty);
        //    }
        //}
        private void OnSearchFinished(Tuple <List <AnalyseRecord>, long, string> records)
        {
            if (SearchStartTime == null)
            {
                SearchStartTime = DateTime.Now.AddSeconds(-2);
            }
            DateTime searchFinishTime = DateTime.Now;

            Trace.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss,fff") + " OnSearchFinished 1");
            string errorMsg = "";

            if (records != null && records.Item1 != null && records.Item1.Count > 0)
            {
                m_Records = records.Item1;

                m_ResultPageInfo = new DataModel.PageInfo(100, (int)records.Item2, 0);
                m_ResultPageInfo.SelectedPageNumberChanged += new EventHandler(ResultPageInfo_SelectedPageNumberChanged);
                try
                {
                    var detaillist = Framework.Container.Instance.TaskManager.GetDetailResults(m_Records.GetRange(0, Math.Min(100, m_Records.Count)));
                    foreach (AnalyseRecord record in detaillist)
                    {
                        AddResultRow(m_DTAnalyseResults, record);
                        Trace.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss,fff") + " AddResultRow");
                    }
                }
                catch (SDKCallException ex)
                {
                    errorMsg = "无法查询到记录的明细信息,错误信息:" + ex.ToString();
                }
                HasResult = true;
            }
            else
            {
                m_Records        = null;
                m_ResultPageInfo = new DataModel.PageInfo(100, 0, 0);
                errorMsg         = "没有检索到结果" + (string.IsNullOrEmpty(records.Item3) ? "" : ",错误信息:" + records.Item3);
                HasResult        = false;
            }
            Trace.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss,fff") + " OnSearchFinished 2");

            if (SearchResult != null)
            {
                SearchResult(this, EventArgs.Empty);
            }
            Trace.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss,fff") + " OnSearchFinished 3");
            string SearchCastTime1 = searchFinishTime.Subtract(SearchStartTime).TotalSeconds.ToString("0.#") + "秒";
            string SearchCastTime2 = DateTime.Now.Subtract(SearchStartTime).TotalSeconds.ToString("0.#") + "秒";

            FileName = string.Format("检索耗时:{1}: ", m_searchPara.ToString(), SearchCastTime1, SearchCastTime2);
            RaisePropertyChangedEvent("FileName");
            if (!string.IsNullOrEmpty(errorMsg))
            {
                Framework.Container.Instance.InteractionService.ShowMessageBox(errorMsg);
            }
        }
        //private void OnNewCompareSearch(SearchPara searchPara)
        //{
        //    m_isCompareSearch = true;
        //    if (PreNewSearch != null)
        //    {
        //        string[] settings = new string[] { searchPara.Task.TaskName+ " 以图搜车" };
        //        PreNewSearch(settings);
        //    }

        //    if (m_ResultPageInfo != null)
        //    {
        //        m_ResultPageInfo.SelectedPageNumberChanged -= new EventHandler(ResultPageInfo_SelectedPageNumberChanged);
        //    }
        //    m_DTAnalyseResults.Rows.Clear();

        //    m_searchPara = searchPara;
        //    Task = m_searchPara.Task;
        //    // SearchSettings = searchPara.ToString();

        //    //m_FileAccess = FileAccessFactory.GetFileAccess(Task.PictureSource);

        //    if (Framework.Container.Instance.TaskManager.Revisor != null)
        //    {
        //        if (Task.Status == TaskStatus.Finished)
        //        {
        //            m_Records = Framework.Container.Instance.TaskManager.Revisor.GetAllResults(Task);
        //            m_ResultPageInfo = new DataModel.PageInfo(m_Records.Count == 0? 100 : m_Records.Count, searchPara.ResultCount, 0);
        //        }
        //        else
        //        {
        //            m_Records = null;
        //            m_ResultPageInfo = new DataModel.PageInfo(100, 0, 0);
        //        }
        //    }
        //    else
        //    {
        //        m_ResultPageInfo = new DataModel.PageInfo(100, searchPara.ResultCount, 0);
        //        m_ResultPageInfo.SelectedPageNumberChanged += new EventHandler(ResultPageInfo_SelectedPageNumberChanged);
        //        m_SQLQuery = m_searchPara.SqlQuery;
        //        //m_Records = Framework.Container.Instance.TaskManager.SwitchComparePage(m_SQLQuery, m_ResultPageInfo, m_searchPara);
        //    }

        //    FileName = string.Format("{0}: ", m_searchPara.Task.TaskName);
        //    RaisePropertyChangedEvent("FileName");
        //    if (m_Records != null && m_Records.Count > 0)
        //    {
        //        foreach (AnalyseRecord record in m_Records)
        //        {
        //            AddResultRow(m_DTAnalyseResults, record);
        //        }
        //        HasResult = true;
        //    }
        //    else
        //    {
        //        Framework.Container.Instance.InteractionService.ShowMessageBox("没有检索到结果");
        //    }

        //    if (SearchResult != null)
        //    {
        //        SearchResult(this, EventArgs.Empty);
        //    }
        //}
        private void OnSearchFinished(Tuple <List <AnalyseRecord>, long, string> records)
        {
            if (SearchStartTime == null)
            {
                SearchStartTime = DateTime.Now.AddSeconds(-2);
            }
            DateTime searchFinishTime = DateTime.Now;

            Trace.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss,fff") + " OnSearchFinished 1");
            if (records != null && records.Item1 != null && records.Item1.Count > 0)
            {
                m_Records = records.Item1;

                m_ResultPageInfo = new DataModel.PageInfo(24, m_Records.Count, 0);
                m_ResultPageInfo.SelectedPageNumberChanged += new EventHandler(ResultPageInfo_SelectedPageNumberChanged);
                //foreach (AnalyseRecord record in m_Records.GetRange(0, Math.Min(12, m_Records.Count)))
                //{
                //    AddResultRow(m_DTAnalyseResults, record);
                //}
                HasResult = true;
            }
            else
            {
                m_Records        = null;
                m_ResultPageInfo = new DataModel.PageInfo(24, 0, 0);
                Framework.Container.Instance.InteractionService.ShowMessageBox("没有检索到结果" + (string.IsNullOrEmpty(records.Item3)?"":",错误信息:" + records.Item3));
            }
            Trace.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss,fff") + " OnSearchFinished 2");

            if (SearchResult != null)
            {
                SearchResult(true, EventArgs.Empty);
            }
            Trace.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss,fff") + " OnSearchFinished 3");
            string SearchCastTime1 = searchFinishTime.Subtract(SearchStartTime).TotalSeconds.ToString("0.#") + "秒";
            string SearchCastTime2 = DateTime.Now.Subtract(SearchStartTime).TotalSeconds.ToString("0.#") + "秒";

            FileName = string.Format("比对总数:{3}条,检索用时:{1} ", m_searchPara.ToString(), SearchCastTime1, SearchCastTime2, records.Item2);
            RaisePropertyChangedEvent("FileName");
        }