コード例 #1
0
        public static SearchableWebsite QuerySearchableWebsite(int ID = -1)
        {
            SearchableWebsite searchableWebsite = new SearchableWebsite();
            string            intID;

            if (ID == -1)
            {
                intID = "null";
            }
            else
            {
                intID = ID.ToString();
            }

            SqliteConnection conn    = OpenDatabase();
            SqliteCommand    command = conn.CreateCommand();

            command.CommandText = $"Select TSearchableWebsites.searchableWebsitesID, TSearchableWebsites.searchableWebsiteName, TSearchableWebsites.searchableWebsiteBaseURL, TSearchableWebsites.searchableWebsiteQueryString, TSearchableWebsites.spaceReplacement From TSearchableWebsites Where TSearchableWebsites.searchableWebsitesID = COALESCE({intID}, TSearchableWebsites.searchableWebsitesID);";
            using (SqliteDataReader reader = command.ExecuteReader())
            {
                while (reader.Read())
                {
                    int intSearchableWebsitesID = int.Parse(reader["searchableWebsitesID"].ToString());
                    searchableWebsite.SearchableWebsiteID = intSearchableWebsitesID;
                    searchableWebsite.Name        = reader["searchableWebsiteName"].ToString();
                    searchableWebsite.BaseURL     = reader["searchableWebsiteBaseURL"].ToString();
                    searchableWebsite.QueryString = reader["searchableWebsiteQueryString"].ToString();
                }
            }
            conn.Close();
            return(searchableWebsite);
        }
コード例 #2
0
        public static List <SearchableWebsite> QueryAllSearchableWebsites()
        {
            List <SearchableWebsite> searchableWebsites = new List <SearchableWebsite>();
            string query = @"Select searchableWebsitesID, searchableWebsiteName, searchableWebsiteBaseURL, searchableWebsiteQueryString, spaceReplacement From TSearchableWebsites;";

            using (SqliteConnection connection = OpenDatabase())
            {
                SqliteCommand command = connection.CreateCommand();
                command.CommandText = query;
                using (SqliteDataReader reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        searchableWebsites.Add(SearchableWebsite.FromDataRow(reader));
                    }
                }
            }
            return(searchableWebsites);
        }
コード例 #3
0
ファイル: WebsiteSearchAction.cs プロジェクト: ploiu/Bob
        //put together base url, query search, and the search parameters
        private string BuildSearchQuery(SearchableWebsite websiteSearch, string toSearch)
        {
            string searchQuery = websiteSearch.BaseURL + websiteSearch.QueryString + WebUtility.UrlEncode(toSearch).Replace("+", websiteSearch.SpaceReplacement);

            return(searchQuery);
        }