Ejemplo n.º 1
0
        /// <summary>
        /// 検索結果取得
        /// </summary>
        /// <remarks>
        /// 作成者    :  kawana
        /// 作成日    :  2019/10/04
        /// </remarks>
        public void GetSearchResults()
        {
            // 検索条件が正しければ検索実施
            if (Condition.ValidateSearch() == false)
            {
                return;
            }

            DataSet  dtSet    = null;
            DataBase dataBase = null;

            try
            {
                long totalCount = 0;
                SearchResults = new List <SearchResult>();
                List <object> paraList = new List <object>();
                string        queryStr = QueryBuild.GetJushihanSearch(Condition, ref paraList);

                dataBase = new DataBase();
                dataBase.ConnectDB();

                dtSet      = dataBase.GetDataSet(queryStr, paraList.ToArray()); // クエリ実行
                totalCount = dtSet.Tables[0].Rows.Count;                        // 全体件数

                foreach (DataRow row in dtSet.Tables[0].Rows)
                {
                    SearchResult sr = new SearchResult(row);
                    if (Condition.OutPut_Chk || sr.CheckOutPut(Condition.Process))
                    {
                        SearchResults.Add(sr);
                    }
                }

                ResultCount = SearchResults.Count.ToString() + "/" + totalCount.ToString();

                dataBase.DisconnectDB();
            }
            catch (Exception ex)
            {
                SearchErrorMessage = Resources.TextResource.ErrorGetSearchResult;
            }
            finally
            {
                if (dataBase != null)
                {
                    dataBase.DisconnectDB();
                }
                if (dtSet != null)
                {
                    dtSet.Dispose();
                }
            }
        }