/// <summary> /// Searches for download links on multiple services asynchronously. /// </summary> /// <param name="query">The name of the release to search for.</param> /// <returns>List of search tasks.</returns> public List <Task> SearchAsync(string query) { if (Filter) { if (ShowNames.Regexes.Numbering.IsMatch(query)) { var tmp = ShowNames.Parser.Split(query); _titleRegex = Database.GetReleaseName(tmp[0]); _episodeRegex = ShowNames.Parser.GenerateEpisodeRegexes(tmp[1]); } else { _titleRegex = Database.GetReleaseName(query); _episodeRegex = null; } } _done = new ConcurrentBag <DownloadSearchEngine>(); query = ShowNames.Parser.CleanTitleWithEp(query, false); Log.Debug("Starting async search for " + query + "..."); _start = DateTime.Now; var tlist = new List <Task>(); foreach (var engine in SearchEngines.OrderBy(e => AutoDownloader.Parsers.IndexOf(e.Name))) { tlist.Add(engine.SearchAsync(query)); } return(tlist); }
/// <summary> /// Searches for subtitles on multiple services asynchronously. /// </summary> /// <param name="query">The name of the release to search for.</param> public void SearchAsync(string query) { if (Filter) { if (ShowNames.Regexes.Numbering.IsMatch(query)) { var tmp = ShowNames.Parser.Split(query); _titleRegex = Database.GetReleaseName(tmp[0]); _episodeRegex = ShowNames.Parser.GenerateEpisodeRegexes(tmp[1]); } else { _titleRegex = Database.GetReleaseName(query); _episodeRegex = null; } } _done = new ConcurrentBag <SubtitleSearchEngine>(); Log.Debug("Starting async search for " + query + "..."); _start = DateTime.Now; foreach (var engine in SearchEngines.OrderBy(e => SubtitlesPage.Actives.IndexOf(e.Name))) { engine.SearchAsync(query); } }
/// <summary> /// Calls the InvalidateSetting method to get the values. /// </summary> public static void InitializeValues() { manager = new GFS(); string settingsDirectory = Application.StartupPath + @"\Settings\"; if (!Directory.Exists(settingsDirectory)) { Directory.CreateDirectory(settingsDirectory); } string SettingFile = settingsDirectory + "applicationSettings.set"; manager.SettingsDirectory = SettingFile; UniversalUsername = InvalidateSetting(_Username, ""); UniversalPassword = InvalidateSetting(_Password, ""); BrowserEngine = BrowserEngineFromString(InvalidateSetting(_BrowserEngine, _cefSharp)); SearchEngine = SearchEngineFromString(InvalidateSetting(_SearchEngine, _google)); HistorySettings = HistoryEngineFromString(InvalidateSetting(_HistoryEngine, _SyncAll)); UserAgent = UserAgentFromString(InvalidateSetting(_UserAgent, _default)); BuildVersion = BuildVersionFromString(InvalidateSetting(_BuildVersion, _Public)); SyncHistory = bool.Parse(InvalidateSetting(_SyncHistory, true.ToString())); SyncBookmarks = bool.Parse(InvalidateSetting(_SyncBookmarks, true.ToString())); SyncInterval = int.Parse(InvalidateSetting(_SyncInterval, 10000.ToString())); }
/// <summary> /// Initializes a new instance of the <see cref="DownloadSearch"/> class. /// </summary> /// <param name="engines">The engines to use for searching.</param> /// <param name="filter">if set to <c>true</c> the search results will be filtered.</param> public DownloadSearch(IEnumerable <DownloadSearchEngine> engines = null, bool filter = false) { Log.Debug("Initializing search engines..."); SearchEngines = (engines ?? AutoDownloader.ActiveSearchEngines).ToList(); Filter = filter; var remove = new List <DownloadSearchEngine>(); foreach (var engine in SearchEngines) { engine.DownloadSearchNewLink += SingleDownloadSearchNewLink; engine.DownloadSearchDone += SingleDownloadSearchDone; engine.DownloadSearchError += SingleDownloadSearchError; if (engine.Private) { engine.Cookies = Utils.Decrypt(engine, Settings.Get(engine.Name + " Cookies"))[0]; // if requires authentication and no cookies or login information were provided, ignore the engine if (string.IsNullOrWhiteSpace(engine.Cookies) && string.IsNullOrWhiteSpace(Settings.Get(engine.Name + " Login"))) { remove.Add(engine); Log.Warn(engine.Name + " is private and no login info specified."); } } } // now remove them. if we remove it directly in the previous loop, an exception will be thrown that the enumeration was modified foreach (var engine in remove) { SearchEngines.Remove(engine); } }
public AirportController() { indexName = ConfigurationManager.AppSettings["SearchServiceIndexName"]; suggesterName = ConfigurationManager.AppSettings["SearchServiceSuggesterName"]; var engines = new SearchEngines("SearchServiceName", "SearchServiceApiKey"); azureSearchEngine = engines.AzureSearchEngine; }
public Occurences Clone() { lock (this) return new Occurences { Keywords = Keywords.Select(x => x), SearchEngines = SearchEngines.Select(x => x), }; }
public void Initialize() { indexName = ConfigurationManager.AppSettings["SearchServiceIndexName"]; suggesterName = ConfigurationManager.AppSettings["SearchServiceSuggesterName"]; var engines = new SearchEngines("SearchServiceName", "SearchServiceApiKey"); azureSearchEngine = engines.AzureSearchEngine; csvFile = GetTestCsvFile(); }
private static bool StartSearches(string imgUrl, SearchEngines engines, SearchResults res) { ISearchEngine[] available = GetAvailableEngines() .Where(e => engines.HasFlag(e.Engine)) .ToArray(); int i = 0; res.Results = new SearchResult[available.Length + 1]; res.Results[i] = new SearchResult(imgUrl, "(Original image)"); i++; foreach (var idx in available) { string wait = String.Format("{0}: ...", idx.Engine); CliOutput.WithColor(ConsoleColor.Blue, () => { // Console.Write(wait); }); // Run search var result = idx.GetResult(imgUrl); if (result != null) { string url = result.Url; if (url != null) { CliOutput.OnCurrentLine(ConsoleColor.Green, "{0}: Done\n", result.Name); if (RuntimeInfo.Config.PriorityEngines.HasFlag(idx.Engine)) { WebAgent.OpenUrl(result.Url); } } else { CliOutput.OnCurrentLine(ConsoleColor.Yellow, "{0}: Done (url is null!)\n", result.Name); } res.Results[i] = result; } // todo i++; } return(true); }
/// <summary> /// Cancels the active asynchronous searches on all services. /// </summary> public void CancelAsync() { SearchEngines.ForEach(engine => { engine.SubtitleSearchNewLink -= SingleSubtitleSearchNewLink; engine.SubtitleSearchDone -= SingleSubtitleSearchDone; engine.SubtitleSearchError -= SingleSubtitleSearchError; engine.CancelAsync(); }); }
private IDictionary <string, string> ToMap() { var m = new Dictionary <string, string> { { CFG_SEARCH_ENGINES, SearchEngines.ToString() }, { CFG_PRIORITY_ENGINES, PriorityEngines.ToString() }, { CFG_IMGUR_APIKEY, ImgurAuth }, { CFG_SAUCENAO_APIKEY, SauceNaoAuth } }; return(m); }
public ISearchStrategy GetStrategy(SearchEngines searchEngine) { switch (searchEngine) { default: case SearchEngines.GOOGLE: return(new GoogleSearchStrategy()); case SearchEngines.BING: return(new BingSearchStrategy()); } }
/// <summary> /// Loads the parsers. /// </summary> public static void LoadParsers() { Actives = Settings.Get <List <string> >("Active Trackers"); AutoActives = Settings.Get <List <string> >("Auto-Download Trackers"); Parsers = Settings.Get <List <string> >("Tracker Order"); Parsers.AddRange(SearchEngines .Where(engine => Parsers.IndexOf(engine.Name) == -1) .Select(engine => engine.Name)); WaitForPreferred = TimeSpan.FromSeconds(Settings.Get("Wait for Preferred Quality", TimeSpan.FromDays(2).TotalSeconds)); PreferredQuality = (Qualities)Enum.Parse(typeof(Qualities), Settings.Get("Preferred Download Quality", Qualities.WebDL1080p.ToString())); SecondPreferredQuality = (Qualities)Enum.Parse(typeof(Qualities), Settings.Get("Second Preferred Download Quality", Qualities.HDTV720p.ToString())); }
/// <summary> /// Cancels the active asynchronous searches on all services. /// </summary> public void CancelAsync() { Log.Debug("Cancelling search after " + (DateTime.Now - _start).TotalSeconds + "s."); SearchEngines.ForEach(engine => { engine.DownloadSearchNewLink -= SingleDownloadSearchNewLink; engine.DownloadSearchDone -= SingleDownloadSearchDone; engine.DownloadSearchError -= SingleDownloadSearchError; engine.CancelAsync(); }); }
/// <summary> /// Initializes a new instance of RankCheckerViewModel class. /// </summary> /// <param name="searchersLoader">Searchers loader to use to get all available searchers</param> public RankCheckerViewModel(ISearchersLoader searchersLoader) { ConfigureCommands(); // Setup available search engines for selection this.searchersLoader = searchersLoader; SearchEngines = GetSearchEngines(); SelectedSearchEngine = SearchEngines.FirstOrDefault(); // Setup number of search results selection NumberOfSearchResults = new List <int> { 10, 50, 100 }; SelectedNumberOfResults = NumberOfSearchResults.FirstOrDefault(); }
/// <summary> /// Called when a download link search is done. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> private void SingleDownloadSearchDone(object sender, EventArgs e) { _done.Add(sender as DownloadSearchEngine); (sender as DownloadSearchEngine).DownloadSearchNewLink -= SingleDownloadSearchNewLink; (sender as DownloadSearchEngine).DownloadSearchDone -= SingleDownloadSearchDone; (sender as DownloadSearchEngine).DownloadSearchError -= SingleDownloadSearchError; DownloadSearchEngineDone.Fire(this, SearchEngines.Except(_done).ToList()); if (_done.Count == SearchEngines.Count) { Log.Debug("Search finished in " + (DateTime.Now - _start).TotalSeconds + "s."); DownloadSearchDone.Fire(this); } }
/// <summary> /// Called when a subtitle search is done. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> private void SingleSubtitleSearchDone(object sender, EventArgs e) { _done.Add((SubtitleSearchEngine)sender); (sender as SubtitleSearchEngine).SubtitleSearchNewLink += SingleSubtitleSearchNewLink; (sender as SubtitleSearchEngine).SubtitleSearchDone += SingleSubtitleSearchDone; (sender as SubtitleSearchEngine).SubtitleSearchError += SingleSubtitleSearchError; SubtitleSearchEngineDone.Fire(this, SearchEngines.Except(_done).ToList()); if (_done.Count == SearchEngines.Count) { Log.Debug("Search finished in " + (DateTime.Now - _start).TotalSeconds + "s."); SubtitleSearchDone.Fire(this); } }
/// <summary> /// Public constructor. /// </summary> /// <param name="query">Query to be processed.</param> /// <param name="engine">Search engine to be used.</param> /// <param name="pageCount">Pages count to be processed (50 is a maximum).</param> /// <param name="proxy">WebProxy object if needed (use null if not).</param> public LinksExtractor(string query, SearchEngines engine, int pageCount = 1, WebProxy proxy = null) { if (pageCount < 1) { throw new ArgumentOutOfRangeException("pageCount"); } if (pageCount > 50) { pageCount = 50; } if (query == null) { throw new ArgumentNullException("query"); } _links = new List <DomElement>(); query = GetEngineReadyQuery(query); _engine = engine; _proxy = proxy; string url = string.Empty; for (int i = 0; i < pageCount; i++) { switch (engine) { case SearchEngines.Google: url = string.Format("http://www.google.com/search?hl=en&q={0}&start={1}", query, (i + 1) * 10); break; case SearchEngines.Yandex: url = string.Format("http://yandex.ru/yandsearch?p={1}&lr=187&text={0}", query, i); break; case SearchEngines.Bing: url = string.Format("http://www.bing.com/search?q={0}&first={1}", query, i * 10 + 1); break; default: throw new ArgumentException("Not supported search engine."); } _links.AddRange(this.GetExtractedLinks(new Uri(url))); } }
/// <summary> /// Get a String from a Search Engine /// </summary> /// <param name="searchString">A string value to convert</param> /// <returns>A SearchEngine refers to String</returns> public static string SearchEngineToString(SearchEngines searchEng) { switch (searchEng) { case SearchEngines.Google: return(_google); case SearchEngines.Yahoo: return(_yahoo); case SearchEngines.Bing: return(_bing); } //if values null, return default searchengine return(_google); }
/// <summary> /// Called when a download link search has encountered an error. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> private void SingleDownloadSearchError(object sender, EventArgs <string, Exception> e) { _done.Add(sender as DownloadSearchEngine); (sender as DownloadSearchEngine).DownloadSearchNewLink -= SingleDownloadSearchNewLink; (sender as DownloadSearchEngine).DownloadSearchDone -= SingleDownloadSearchDone; (sender as DownloadSearchEngine).DownloadSearchError -= SingleDownloadSearchError; Log.Warn("Error while searching on " + ((DownloadSearchEngine)sender).Name + ".", e.Second); DownloadSearchEngineError.Fire(this, e.First, e.Second); DownloadSearchEngineDone.Fire(this, SearchEngines.Except(_done).ToList()); if (_done.Count == SearchEngines.Count) { Log.Debug("Search finished in " + (DateTime.Now - _start).TotalSeconds + "s."); DownloadSearchDone.Fire(this); } }
/// <summary> /// Do a search of the selected text with Google. /// </summary> private void OnContextMenuClick(object sender, EventArgs eventArgs) { string textToSearch = GetSelection(); // Remove any trailing '.' at the end of the string while (textToSearch.Length > 0 && textToSearch.EndsWith(".", StringComparison.Ordinal)) { textToSearch = textToSearch.Remove(textToSearch.Length - 1, 1); } // Double up any quotes in the string textToSearch = textToSearch.Replace("\"", "\"\""); // Escape spaces textToSearch = textToSearch.Replace(" ", "%20"); string linkTemplate = SearchEngines.LinkForSearchEngine(Preferences.StandardPreferences.DefaultSearchEngine); string searchUrl = string.Format(linkTemplate, textToSearch.Trim()); Process.Start(searchUrl); }
public List<JobListing> GetListFor(SearchEngines engine, string url) { List<JobListing> jobListings = new List<JobListing>(); switch (engine) { case SearchEngines.Monster: { AddMonsterJobs(url, jobListings); break; } case SearchEngines.Indeed: { AddIndeedJobs(url, jobListings); break; } case SearchEngines.Dice: { AddDiceJobs(url, jobListings); break; } case SearchEngines.GitHub: { AddGithubJobs(url, jobListings); break; } case SearchEngines.RobertHalf: { AddRoberthalfJobs(url, jobListings); break; } case SearchEngines.StackExchange: { AddStackExchangeJobs(url, jobListings); break; } } return jobListings; }
public IActionResult OnPost() { //create the search engines and add them //normally this is done separetely, but this is a test searchEngines = new List <SearchEngines>(); SearchEngines Google = new SearchEngines("Google", "http://google.com/search?q=", "/url?q=", "//a[@href]"); SearchEngines Bing = new SearchEngines("Bing", "http://bing.com/search?q=", "", "//a[@href]"); SearchEngines Yahoo = new SearchEngines("Yahoo", "https://search.yahoo.com/search?p=", "", "//a[@href]"); searchEngines.Add(Google); searchEngines.Add(Yahoo); searchEngines.Add(Bing); //get the value of the search term SearchTerm = Request.Form["searchTerm"].ToString().Trim(); UseSearchTerm(SearchTerm); return(Page()); }
/*--------------------------------------------------------------------------------------------------- * Created by: Marco Antonio García León * Country : Perú * Date of build: 2018.05.16-0216hrs * Notes: This is a coding assesstment test for a job. *---------------------------------------------------------------------------------------------------*/ static void Main(string[] args) { List <Result> lstResults = new List <Result>(); Console.WriteLine("SearchFight: Utility to compare results in the three most popular search engines."); string sResultOk = "\n"; sResultOk = "┌──────────────────────────────┬────────────────────┬────────────────────┬────────────────────┐\n"; sResultOk += "│ Programming language │ Google Results │ Bing Results │ Yandex Results │\n"; sResultOk += "├──────────────────────────────┼────────────────────┼────────────────────┼────────────────────┤\n"; for (int i = 0; i < args.Count(); i++) { string sParameter = args[i].Trim(); Console.WriteLine("Querying for: " + sParameter); float iGoogleResult = SearchEngines.SearchUsingGoogle(sParameter); if (iGoogleResult < 0) { Console.WriteLine("Error found in Google search: " + SearchEngines.LastErrorMessage); } float iBingResult = SearchEngines.SearchUsingBing(sParameter); if (iBingResult < 0) { Console.WriteLine("Error found in Bing search: " + SearchEngines.LastErrorMessage); } float iYandexResult = SearchEngines.SearchUsingYandex(sParameter); if (iYandexResult < 0) { Console.WriteLine("Error found in Yandex search: " + SearchEngines.LastErrorMessage); } lstResults.Add(new Result { Word = sParameter, Google = iGoogleResult, Bing = iBingResult, Yandex = iYandexResult }); sResultOk += "│" + sParameter.PadRight(30, ' ') + "│" + iGoogleResult.ToString("###,###,###,##0").PadLeft(20, ' ') + "│" + iBingResult.ToString("###,###,###,##0").PadLeft(20, ' ') + "│" + iYandexResult.ToString("###,###,###,##0").PadLeft(20, ' ') + "│\n"; Console.WriteLine("\n"); } // Now, query to see the best one for each column Console.WriteLine("Searching for the best results"); string sBestForGoogle = lstResults.Where(w => w.Google > 0).OrderByDescending(o => o.Google).Select(s => s.Word).FirstOrDefault(); string sBestForBing = lstResults.Where(w => w.Bing > 0).OrderByDescending(o => o.Bing).Select(s => s.Word).FirstOrDefault(); string sBestForYandex = lstResults.Where(w => w.Yandex > 0).OrderByDescending(o => o.Yandex).Select(s => s.Word).FirstOrDefault(); sBestForGoogle = sBestForGoogle ?? "### ERROR ###".PadLeft(20, ' '); sBestForBing = sBestForBing ?? "### ERROR ###".PadLeft(20, ' '); sBestForYandex = sBestForYandex ?? "### ERRROR ###".PadLeft(20, ' '); sResultOk += "├──────────────────────────────┼────────────────────┼────────────────────┼────────────────────┤\n"; sResultOk += "| Best result by search engine │" + sBestForGoogle.PadRight(20, ' ') + "│" + sBestForBing.PadRight(20, ' ') + "│" + sBestForYandex.PadRight(20, ' ') + "│\n"; sResultOk += "└──────────────────────────────┴────────────────────┴────────────────────┴────────────────────┘\n"; Console.WriteLine(sResultOk); Console.WriteLine("Press [ENTER] to exit"); Console.ReadLine(); }
public ActionResult Index(string filter, int pageIndex) { #region 控制搜索引擎访问频率(目前设置的十秒钟内最多可以访问10次) string SearchEngines = Public.IsSearchEnginesGet(); if (SearchEngines != null) { SOSOshop.BLL.SearchEngines blls = new SearchEngines(); if (!blls.isPower(SearchEngines)) { Response.StatusCode = 503; return(Content("")); } blls.created = DateTime.Now; blls.Engines = SearchEngines; blls.ip = Request.UserHostAddress; blls.insert(); } #endregion ViewBag.Title = ConfigurationManager.AppSettings["List_Title"]; ViewBag.description = ConfigurationManager.AppSettings["List_Description"]; ViewBag.keywords = ConfigurationManager.AppSettings["List_Key"]; ViewBag.ActuationValue = "查看所有商品"; SOSOshop.BLL.Db db = new Db(); int showpic = 0;//用户对列表状态无选择则为0,大图为1,列表为2. string isshow = Request["show"]; isshow = Library.Lang.Input.Filter(isshow); if (!string.IsNullOrEmpty(isshow)) { if (int.Parse(isshow) == 1) { showpic = 1; } else { showpic = 2; } } //设置是否是大图列表 ViewBag.Show = showpic; //设置排序 string sort = Request["sort"]; sort = Library.Lang.Input.Filter(sort); ViewBag.Sort = 0; string order = " order by Product_ID desc"; if (!string.IsNullOrEmpty(sort)) { switch (int.Parse(sort)) { case 1: order = " order by Product_ClickNum desc"; ViewBag.Sort = 1; break; case 2: ViewBag.Sort = 2; order = " order by Price_01 asc"; #region 买家类型判断 int UID = BaseController.GetUserId(); if (UID > 0) { int Member_Class = 0; //批发 object objMC = db.ExecuteScalarForCache("SELECT Member_Class FROM memberinfo WHERE UID=" + UID); if (objMC != null) { Member_Class = int.Parse(objMC.ToString()); } if (Member_Class == 1) { order = " order by Price_02 desc"; //OTC } } #endregion break; case 3: ViewBag.Sort = 3; order = " order by Product_SaleNum desc"; break; case 4: ViewBag.Sort = 4; order = " order by price_03 asc"; break; } } //定义分页信息 PageInfo pg = new PageInfo(); pg.pageSize = 24; if (pageIndex == 0) { pageIndex = 1; } //设置分类固定长度,增加新的分类后要将长度调整为对应的长度 string SearchUrl = HomeController.SearchUrl(0, 0); int[] keyIds = new int[filter.Split('-').Length]; if (keyIds.Length < 10) { return(Redirect(HomeController.SearchUrl(0, 0))); } int[] akeyIds = (from a in filter.Split('-') select int.Parse(a)).ToArray(); for (int x = 0; x < akeyIds.Length && akeyIds.Length <= keyIds.Length; x++) { keyIds[x] = akeyIds[x]; } // url_filter = string.Join("-", keyIds);//filter; List <string> keywords = new List <string>(); //选择的条件 List <int> keyposit = new List <int>(); //选择条件的位置 #region 拼接sql条件 StringBuilder filterExpression = new StringBuilder(177); filterExpression.Append(" 1=1"); int index = 0; string type = null; //药理药效 if (keyIds[index] != 0) { filterExpression.Append(" and DrugsBase_ID in (select DrugsBase_ID from [DrugsBase_PharmMediNameLink] where [Pharm_ID] in (select [Pharm_ID] from [DrugsBase_Pharm] where [Pharm_ID_Path] like '%\\" + keyIds[index].ToString() + "%'))"); if (keyIds[index] == 1) { keywords.Add("西药"); } else if (keyIds[index] == 583) { keywords.Add("中成药"); } else { if (SearchModel.GetList(SearchModelEnum.药理二级).Where(x => x.id == keyIds[index]).Count() > 0) { keywords.Add(SearchModel.GetList(SearchModelEnum.药理二级).Where(x => x.id == keyIds[index]).First().name); } } keyposit.Add(0); type = "药理药效"; //分类热销品种 SelectPharmById(keyIds[index]); } //适应症 index = 1; if (keyIds[index] != 0) { //filterExpression.AppendFormat(" and DrugsBase_id in(SELECT product_id FROM Tag_PharmProduct WHERE product_key='d' and Tag_PharmAttribute_id={0})", keyIds[index]); string sql_syz = string.Format(" and DrugsBase_id in(SELECT product_id FROM Tag_PharmProduct WHERE Tag_PharmAttribute_id in (select id from Tag_PharmAttribute where fullPath like '%/{0}/%'))", keyIds[index]); filterExpression.Append(sql_syz); var blltag = new SOSOshop.BLL.DrugsBase.Tag_PharmAttribute(); string syz = blltag.GetTagName(keyIds[index]); keywords.Add(blltag.GetKeyWord(keyIds[index])); keyposit.Add(1); type = "适应症"; //列出适应症的二级分类 string syzsql = string.Format("select id,name from Tag_PharmAttribute where fullPath like '%/'+convert(varchar,(select case when ParentId=0 then id else ParentId end from Tag_PharmAttribute where id={0}))+'/%' order by ParentId", keyIds[index]); ViewBag.SyzList = db.ExecuteTableForCache(syzsql); ViewBag.SelectMenuId = keyIds[index]; //分类热销品种 SelectSYZById(keyIds[index], syz, sql_syz); } //厂家数量 index = 2; if (keyIds[index] != 0) { var list = SearchModel.GetList(SearchModelEnum.厂家数量); if (list.Exists(x => x.id == keyIds[index])) { var model = list.Where(x => x.id == keyIds[index]).First(); filterExpression.Append(model.condition); keywords.Add(model.name); keyposit.Add(index); type = "厂家数量"; } } //价格区间 index = 3; if (keyIds[index] != 0) { var list = SearchModel.GetList(SearchModelEnum.价格区间); if (list.Exists(x => x.id == keyIds[index])) { var model = list.Where(x => x.id == keyIds[index]).First(); filterExpression.Append(model.condition); keywords.Add(model.name); keyposit.Add(index); type = "价格区间"; } } //剂型 index = 4; if (keyIds[index] != 0) { var list = SearchModel.GetList(SearchModelEnum.剂型二级); if (list.Exists(x => x.id == keyIds[index])) { var model = list.Where(x => x.id == keyIds[index]).First(); filterExpression.AppendFormat(model.condition == null ? " and DrugsBase_DrugName like('%{0}%')" : model.condition, model.name); keywords.Add(model.name); keyposit.Add(index); type = "剂型"; } } //热门标签 index = 5; if (keyIds[index] != 0) { var list = SearchModel.GetList(SearchModelEnum.热门标签); if (list.Exists(x => x.id == keyIds[index])) { var model = list.Where(x => x.id == keyIds[index]).First(); filterExpression.Append(model.condition); keywords.Add(model.name); keyposit.Add(index); type = "热门标签"; } } //品牌厂家 index = 6; if (keyIds[index] != 0) { var list = SearchModel.GetList(SearchModelEnum.品牌厂家); if (list.Exists(x => x.id == keyIds[index])) { var model = list.Where(x => x.id == keyIds[index]).First(); filterExpression.Append(model.condition); keywords.Add(model.name); keyposit.Add(index); type = "品牌厂家"; } } //中药饮片 index = 8; if (keyIds[index] != 0) { var list = SearchModel.GetList(SearchModelEnum.中药饮片); if (list.Exists(x => x.id == keyIds[index])) { var model = list.Where(x => x.id == keyIds[index]).First(); filterExpression.Append(model.condition); keywords.Add(model.name); keyposit.Add(index); type = "中药饮片"; } } //进口药品 index = 9; if (keyIds[index] != 0) { var list = SearchModel.GetList(SearchModelEnum.进口药品); if (list.Exists(x => x.id == keyIds[index])) { var model = list.Where(x => x.id == keyIds[index]).First(); filterExpression.Append(model.condition); keywords.Add(model.name); keyposit.Add(index); type = "进口药品"; } } #endregion //新品上架的品种必须有库存 if ("1".Equals(Request.QueryString["new"])) { filterExpression.Append(" and Product_ID in (SELECT a.Product_ID FROM dbo.Product a LEFT OUTER JOIN dbo.Stock_Lock b ON a.Product_ID = b.Product_ID WHERE a.Stock-ISNULL(b.Stock,0)>0)"); } //折扣商品列表 if ("2".Equals(Request.QueryString["new"])) { filterExpression.Append(" and Product_ID in (SELECT a.Product_ID FROM dbo.Product a where Discount>0 AND Discount<>1 AND GETDATE() BETWEEN BeginDate AND EndDate )"); } //促销商品列表 if ("3".Equals(Request.QueryString["new"])) { filterExpression.Append(" and Product_ID in (SELECT a.Product_ID FROM dbo.Product a where (CuPrice>0 or (discount>0 and discount<>1)) AND GETDATE() BETWEEN BeginDate AND EndDate )"); } //产品搜索 string search = Request["q"]; if (search != null) { search = search.Trim().Trim('+'); } search = Library.Lang.Input.Filter(search); if (!string.IsNullOrEmpty(search)) { filterExpression.Append(string.Format(" and ([Product_Name] like '%{0}%' or DrugsBase_SimpeCode like '%{0}%' or [DrugsBase_DrugName] like '%{0}%' or [DrugsBase_ProName] like '%{0}%' or [DrugsBase_Manufacturer] like '%{0}%' or [DrugsBase_ApprovalNumber] like '%{0}%' )", search)); type = "搜索"; ViewBag.ActuationValue = string.Format("搜索:" + search); ViewBag.Search = search; ViewBag.Title = search + ConfigurationManager.AppSettings["List_Search_Title"]; ViewBag.description = search + ConfigurationManager.AppSettings["List_Search_Description"]; ViewBag.keywords = search + ConfigurationManager.AppSettings["List_Search_Key"]; } string ypmc = Request["ypmc"]; if (ypmc != null) { ypmc = ypmc.Trim().Trim('+'); } ypmc = Library.Lang.Input.Filter(ypmc); if (!string.IsNullOrEmpty(ypmc)) { filterExpression.Append(string.Format(" and ([Product_Name] like '%{0}%' or DrugsBase_SimpeCode like '%{0}%' or [DrugsBase_DrugName] like '%{0}%' or [DrugsBase_ProName] like '%{0}%' or [DrugsBase_Manufacturer] like '%{0}%' or [DrugsBase_ApprovalNumber] like '%{0}%' )", ypmc)); type = "搜索"; ViewBag.Search = search + " " + ypmc; } string sccj = Request["sccj"]; if (sccj != null) { sccj = sccj.Trim().Trim('+'); } sccj = Library.Lang.Input.Filter(sccj); if (!string.IsNullOrEmpty(sccj)) { filterExpression.Append(string.Format(" and ([DrugsBase_Manufacturer] like '%{0}%')", sccj)); type = "搜索"; ViewBag.Search = search + " " + ypmc + " " + sccj; } //参数限定 string stop = "[Product_bShelves] =1"; //and [DrugsBase_bStop]=0 and [Product_bStop]=0"; filterExpression.Append(" and " + stop); //显示的字段列表 string fields = SOSOshop.BLL.Product.Product._PriceTableColumns + "[Product_ID],[Product_Name],[Product_ClickNum],[Product_SaleNum] ,[Product_State] ," + "DrugsBase_ProName,DrugsBase_Manufacturer,DrugsBase_Specification," + "Goods_ID,Goods_Pcs,Goods_Pcs_Small,Goods_ConveRatio,Goods_Unit,Image,drug_sensitive," + "Goods_ConveRatio_Unit,Goods_ConveRatio_Unit_Name,is_cl," + "stock-ISNULL((select stock from stock_lock where [Product_ID]=pt.[Product_ID]),0) stock_lock," //袋装量 + @"ISNULL(( SELECT ISNULL(BagCapacity, 1.00) AS BagCapacity FROM dbo.DrugsBase_ZYC WHERE DrugsBase_ID = pt.DrugsBase_ID ), 1) AS BagCapacity"; string stock = "case when Stock<=0 or (sellType=2 and Stock<Goods_Pcs_Small) or (sellType=3 and Stock<Goods_Pcs) then '可预订' else '现货' end as stock1"; fields = string.Format("{0},{1} ", fields, stock); //药品列表 string sql = "SELECT TOP " + pg.pageSize + " " + fields + " FROM product_online_v pt WHERE ([Product_ID] NOT IN(SELECT TOP (" + pg.pageSize + " * " + (pageIndex - 1) + ") [Product_ID] FROM product_online_v where " + filterExpression + " " + order + ")) and " + filterExpression + " " + order; //Response.Write(sql); //Response.End(); ViewBag.List = db.ExecuteTableForCache(string.Format(sql, filter), DateTime.Now.AddHours(1)).GetPriceTable(); ViewBag.url = filter; //列表总数 string countsql = "select count(Product_ID) as pagecount from product_online_v where " + filterExpression; //计算总数 DataTable page = db.ExecuteTableForCache(countsql, DateTime.Now.AddHours(1)); double cs = ((int)page.Rows[0]["pagecount"]) / pg.pageSize; //页总数 try { //Response.Write(((int)page.Rows[0]["pagecount"]) / pg.pageSize +" "+ Math.Ceiling((double)(((int)page.Rows[0][0]) / pg.pageSize)) + " " + cs + " " + page.Rows[0]["pagecount"] + " " + pg.pageSize); //Response.End(); ViewBag.PageCount = int.Parse(Math.Ceiling(cs).ToString()); } catch { ViewBag.PageCount = 1; } //当前页 ViewBag.CurrentPage = pageIndex; //记录总数 ViewBag.RecordSize = (int)page.Rows[0]["pagecount"]; //文件url ViewBag.PageURL = filter; ViewBag.Selected = keywords; ViewBag.Posit = keyposit; ViewBag.Type = type; PagedList <DataRow> pl = null; if (ViewBag.List != null) { ViewBag.List = ViewBag.List; pl = new PagedList <DataRow>(ViewBag.List.Select(), pageIndex, pg.pageSize, (int)page.Rows[0]["pagecount"]); } //SEO 复合条件选择 if (keywords.Count > 0 && string.IsNullOrEmpty(search)) { ViewBag.ActuationValue = string.Format("筛选条件:{0}", string.Join("-", keywords)); ViewBag.Title = string.Join("-", keywords) + ConfigurationManager.AppSettings["List_Search2_Title"]; string[] descriptions = ConfigurationManager.AppSettings["List_Search2_Description"].Split('|'); ViewBag.description = string.Format("{0}为您找到 " + string.Join(",", keywords) + " 的药品信息" + page.Rows[0]["pagecount"] + "条;更多网上药品批发,药品采购,药品价格信息登录{1},随时查询,方便快捷,采购就这么简单!", descriptions[0], descriptions[0]); ViewBag.keywords = string.Join(",", keywords) + ConfigurationManager.AppSettings["List_Search2_Key"]; } MemberInfo member = new MemberInfo(); int uid = BaseController.GetUserId(); int member_Class = -1;//客户未登录 if (uid > 0) { member_Class = member.GetModel(uid).Member_Class;//用户类型 0 批发客户,1 OTC批零客户 } ViewBag.Memberclass = member_Class; ViewBag.UID = uid; SOSOshop.BLL.Product.Product bll = new SOSOshop.BLL.Product.Product(); //最近浏览过的商品 if (uid != 0) { ViewBag.History_Of_ProductList = bll.Get_History_Of_ProductList(10, uid).GetPriceTable(); } //热销榜 string sqlhot = string.Empty; if (member_Class == 1) { sqlhot = "SELECT TOP 9 " + SOSOshop.BLL.Product.Product._PriceTableColumns + "Product_SellingPoint,Product_Advertisement,maid1,ggy1,drug_sensitive,Product_ID,DrugsBase_Specification,DrugsBase_Manufacturer,Product_Name,Product_Advertisement,Image," + "Product_SaleNum as SaleNum,Goods_ConveRatio_Unit_Name,Goods_ConveRatio_Unit,Goods_ConveRatio,Goods_Unit,Goods_Unit Goods_Unit1, DrugsBase_ID " + "FROM product_online_v p " + "ORDER BY SaleNum DESC"; } else { sqlhot = "SELECT TOP 9 " + SOSOshop.BLL.Product.Product._PriceTableColumns + "Product_SellingPoint,Product_Advertisement,maid1,ggy1,Product_ID,DrugsBase_Specification,DrugsBase_Manufacturer,Product_Advertisement,Product_Name, Image, " + "( " + "SELECT SUM(Product_SaleNum/Goods_pcs) " + "FROM product_online_v " + "WHERE DrugsBase_ID=p.DrugsBase_ID " + ")SaleNum,'件' Goods_Unit1,Goods_ConveRatio_Unit_Name,Goods_ConveRatio_Unit,Goods_ConveRatio,Goods_Unit,drug_sensitive,Product_SaleNum " + "FROM product_online_v p " + "where (Price_01 is not null and Price_01!=0.000000) " + "AND p.Goods_Pcs != 1 " + "ORDER BY SaleNum DESC"; } try { ViewBag.Hot = db.ExecuteTableForCache(sqlhot).GetPriceTable(); } catch (Exception) { ViewBag.Hot = new DataTable(); } //热门推荐 string sqltj = "select top 2 " + SOSOshop.BLL.Product.Product._PriceTableColumns + "Product_SellingPoint,Product_Advertisement,maid1,ggy1,Product_ID,product_name,DrugsBase_Specification as gg,DrugsBase_Manufacturer,Product_SaleNum/Goods_Pcs as jian,Image,[Goods_ConveRatio] ,[Goods_ConveRatio_Unit] ,[Goods_ConveRatio_Unit_Name],[Goods_Pcs],[Goods_Unit],drug_sensitive,minsell,maxsell from product_online_v where product_id=24 or product_id=37 order by Product_SaleNum desc"; ViewBag.HotTj = db.ExecuteTableForCache(sqltj).GetPriceTable(); ViewBag.ActuationValue += ":pageIndex-" + pageIndex; return(View(pl)); }
//this function take a search engine and get all the links public void SearchEngine(SearchEngines searchEngine, string searchTerm) { try { StringBuilder sb = new StringBuilder(); byte[] ResultsBuffer = new byte[8192]; //create the search url using the engine url and search term string SearchResults = searchEngine.Url + searchTerm.Trim(); HttpWebRequest request = (HttpWebRequest)WebRequest.Create(SearchResults); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); //read the response and transform into a string Stream resStream = response.GetResponseStream(); string tempString; int count; do { count = resStream.Read(ResultsBuffer, 0, ResultsBuffer.Length); if (count != 0) { tempString = Encoding.ASCII.GetString(ResultsBuffer, 0, count); sb.Append(tempString); } }while (count > 0); string sbb = sb.ToString(); //convert the response into a html document with the help of HTMLAgilityPack HtmlDocument html = new HtmlDocument(); html.OptionOutputAsXml = true; html.LoadHtml(sbb); HtmlNode doc = html.DocumentNode; //doc.InnerHtml= HttpUtility.HtmlDecode(doc.InnerHtml); //find each link href inside the document foreach (HtmlNode link in doc.SelectNodes(searchEngine.NodeSelector)) { // string hrefValue = link.GetAttributeValue("href", string.Empty); //try to eliminate the ones which are adds or similar if (!hrefValue.ToString().ToUpper().Contains(searchEngine.Name.ToUpper()) && hrefValue.ToString().Contains(searchEngine.EscapeString) && (hrefValue.ToString().ToUpper().Contains("HTTP://") || hrefValue.ToString().ToUpper().Contains("HTTPS://"))) { int index = hrefValue.IndexOf("&"); //check if there are additional parameters added by the engine, like google //and remove them if needed, otherwise keep the url if (index > 0) { hrefValue = hrefValue.Substring(0, index); //use the function which will open each link and search for the term inside LinkResults currentLink = SearchLink(hrefValue, searchTerm, searchEngine.Name); if (currentLink != null) { _results.Add(currentLink); } } else { LinkResults currentLink = SearchLink(hrefValue, searchTerm, searchEngine.Name); if (currentLink != null) { _results.Add(currentLink); } } } } } catch (Exception ex) { throw ex; } }
private static searchResult searchInEngine(SearchEngines engine, string query) { searchResult respResult = null; System.IO.Stream newStream = null; System.Net.WebResponse response = null; System.IO.StreamReader reader = null; try { /* * An example to call to the search engine directly * * string url = String.Format("{0}?q={1}", engine.url, query); * * System.Net.WebRequest wr = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(url); * * wr.Method = "GET"; * wr.ContentType = "application/x-www-form-urlencoded"; * * response = wr.GetResponse(); * newStream = response.GetResponseStream(); * * reader = new System.IO.StreamReader(newStream); * string responseFromServer = reader.ReadToEnd(); */ /*This is for test purpose*/ respResult = new searchResult(); respResult.engine = engine.name; switch (engine.name) { case "google": respResult.resultsCount = RandomNumberBetween(1000, 5000); respResult.search = query; break; case "yahoo": respResult.resultsCount = RandomNumberBetween(1000, 5000); respResult.search = query; break; case "bing": respResult.resultsCount = RandomNumberBetween(1000, 5000); respResult.search = query; break; default: respResult.resultsCount = 0; respResult.search = query; break; } } catch (Exception ex) { //Log error } finally { if (reader != null) { reader.Close(); } if (newStream != null) { newStream.Close(); } if (response != null) { response.Close(); } } return(respResult); }
public void TestInitialize() { var engines = new SearchEngines("SearchServiceName", "SearchServiceApiKey"); azureSearchEngine = engines.AzureSearchEngine; }
// Display Results internal static void DisplayResults(ResultFormatting resultFormatting) { var resultsList = new[] { Results.BingResults, Results.GoogleResults }; switch (resultFormatting) { case ResultFormatting.Html: // WebBrowser // Save the palette image to temp directory. // My.Resources.RGB.Save(Palette_Image); // Write the header title. File.WriteAllText(ResultsFileHtml, HtmlHeader); // Write the document back color. File.WriteAllText(ResultsFileHtml, string.Format(HtmlDocumentBackColor, HtmlBackColor)); // Loop over each list. for (var i = 0; i < resultsList.Length; i++) { List <Result> list = resultsList[i]; SearchEngines engine = (SearchEngines)(i + 1); if (list.Count != 0) { // Get the lowest and greatest result numbers to calculate the rule of 3. _ruleOf3Lowest = Tuple.Create(list.OrderBy(tuple => tuple.Count).First().Count, list.OrderBy(tuple => tuple.Count).First().Term); _ruleOf3Greatest = Tuple.Create(list.OrderBy(tuple => tuple.Count).Last().Count, list.OrderBy(tuple => tuple.Count).Last().Term); // Write the Search Engine title. File.AppendAllText(ResultsFileHtml, string.Format(HtmlSearchEngineTitle, HtmlForeColor, engine)); // Loop over each result in list. foreach (var result in list) { // Calculate the rule of 3. _ruleOf3 = (result.Count - _ruleOf3Lowest.Item1) / (double)(_ruleOf3Greatest.Item1 - _ruleOf3Lowest.Item1) * 100; // Set the result colors. if (_ruleOf3 > 50) { _green = (short)(255 - Math.Round(_ruleOf3 * 2.55)); _red = 255; } else if (_ruleOf3 <= 50) { _red = (short)Math.Round(_ruleOf3 * 5.1); _green = 255; } // Write the search pattern and result quantity. File.AppendAllText(ResultsFileHtml, string.Format(HtmlResultFormat, HtmlForeColor, result.Term, RgbToHtml(_red, _green, 0), FormatNumber(result.Count))); } // Write the minimum and maximum stats. File.AppendAllText(ResultsFileHtml, string.Format(HtmlPaletteString, HtmlForeColor, NumberAbbreviation(_ruleOf3Greatest.Item1.ToString(), false), FormatNumber(_ruleOf3Greatest.Item1), PaletteImage, NumberAbbreviation(_ruleOf3Lowest.Item1.ToString(), false), FormatNumber(_ruleOf3Lowest.Item1))); } } // Write the EndOfFile. File.AppendAllText(ResultsFileHtml, HtmlEnd); // Start the file using Shell Execute. Process.Start(ResultsFileHtml); break; case ResultFormatting.Txt: // Notepad // Write the header title. File.WriteAllText(ResultsFileTxt, TxtHeader); // Loop over each list. for (var i = 0; i < resultsList.Length; i++) { List <Result> list = resultsList[i]; SearchEngines engine = (SearchEngines)(i + 1); if (list.Count != 0) { // Write the Search Engine title. File.AppendAllText(ResultsFileTxt, string.Format(TxtSearchEngineTitle, engine)); // Get the lowest and greatest result numbers to calculate the rule of 3. _ruleOf3Lowest = Tuple.Create(list.OrderBy(tuple => tuple.Count).First().Count, list.OrderBy(tuple => tuple.Count).First().Term); _ruleOf3Greatest = Tuple.Create(list.OrderBy(tuple => tuple.Count).Last().Count, list.OrderBy(tuple => tuple.Count).Last().Term); // Loop over each result in list. foreach (var result in list) { // Write the search pattern and result quantity. File.AppendAllText(ResultsFileTxt, string.Format(TxtResultFormat, result.Term, FormatNumber(result.Count))); } // Write the minimum and maximum stats. File.AppendAllText(ResultsFileTxt, string.Format(TxtPaletteString, NumberAbbreviation(_ruleOf3Greatest.Item1.ToString(), false), FormatNumber(_ruleOf3Greatest.Item1), _ruleOf3Greatest.Item2, NumberAbbreviation(_ruleOf3Lowest.Item1.ToString(), false), FormatNumber(_ruleOf3Lowest.Item1), _ruleOf3Lowest.Item2)); } } // Start the file using Shell Execute. Process.Start(ResultsFileTxt); break; } }
private static bool StartSearches(string imgUrl, SearchEngines engines, ref SearchResult[] res) { // todo: improve // todo: use tasks var availableEngines = GetAvailableEngines() .Where(e => engines.HasFlag(e.Engine)) .ToArray(); int i = 0; res = new SearchResult[availableEngines.Length + 1]; res[i] = new SearchResult(imgUrl, "(Original image)"); i++; foreach (var currentEngine in availableEngines) { string wait = String.Format("{0}: ...", currentEngine.Engine); CliOutput.WithColor(ConsoleColor.Blue, () => { // Console.Write(wait); }); var sw = Stopwatch.StartNew(); // Run search var result = currentEngine.GetResult(imgUrl); sw.Stop(); if (result != null) { string url = result.Url; var sb = new StringBuilder(); double t = sw.Elapsed.TotalSeconds; double t2 = Math.Round(t, 3); sb.AppendFormat("{0}: Done ({1:F3} sec)\n", result.Name, t2); //todo bool ok = url != null; string sz = sb.ToString(); if (ok) { CliOutput.OnCurrentLine(ConsoleColor.Green, sz); if (SearchConfig.Config.PriorityEngines.HasFlag(currentEngine.Engine)) { WebAgent.OpenUrl(result.Url); } } else { CliOutput.OnCurrentLine(ConsoleColor.Yellow, sz); } res[i] = result; } // todo i++; } return(true); }
//internal const string ResultStatsId = "result-stats"; // Get URL SourceCode internal static async Task <PageSource> GetUrlSourceCode(IWebDriver web, SearchEngines engine, string url, string term, bool doSearch) { string engineUrl = ""; switch (engine) { case SearchEngines.Bing: break; case SearchEngines.Google: engineUrl = "https://www.google.com/"; break; default: throw new InvalidOperationException("Unsupported engine type."); } //Console.WriteLine($"Searching on URL: {url}"); if (Uri.TryCreate(url, UriKind.Absolute, out var uri) && (uri.Scheme == Uri.UriSchemeHttp || uri.Scheme == Uri.UriSchemeHttps)) { //Do something with your validated Absolute URI... } else { uri = new Uri(engineUrl + url); } var task = Task.Run(() => { if (doSearch) { var curUrl = web.Url; bool search = true; if (engine == SearchEngines.Bing && !curUrl.Contains("bing") || engine == SearchEngines.Google && !curUrl.Contains("google")) { web.Navigate().GoToUrl(uri); search = false; } if (search) { var element = web.WaitForElement(By.XPath(SearchBarXPath)); var text = element.GetAttribute("value"); var action = new Actions(web); for (int i = 0; i < text.Length; i++) { action = action.SendKeys(element, Keys.Backspace); } action.Build().Perform(); element.SendKeys(term); } var button = web.WaitForElement(By.XPath(SearchButtonXPath)); button.Click(); Thread.Sleep(200); } // TODO: Check for bot confirmation IWebElement spellOrig = web.FindElementOrDefault(By.XPath(SpellOrigXPath)); var pageSource = spellOrig != null ? new PageSource(spellOrig, web.PageSource) : new PageSource(web.PageSource); return(pageSource); }); await task; return(task.Result); }
static void Main(string[] args) { Console.WriteLine(@"輸入範例: 5 NSYSU NC CT NS NM NTU BC NC CT NS NCCU BC NL HL Providence BC NC NTHU BC NS 2 BC NS + CT HL NM + BC NL + BC NC "); SearchEngines search = new SearchEngines(); #region 大學個數 { Console.WriteLine("請輸入查詢學校條件:"); bool result = false; do { string data = Console.ReadLine(); result = search.SetNData(data); } while (!result); } #endregion #region 學校資料 { Console.WriteLine(string.Format("請輸入{0}筆學校資料!", search.GetN())); for (int i = 0; i < search.GetN(); i++) { string data = Console.ReadLine(); search.SetSchools(data); } } #endregion #region 查詢個數 { Console.WriteLine("請輸入查詢個數!"); bool result = false; do { string data = Console.ReadLine(); result = search.SetMData(data); } while (!result); } #endregion #region 查詢條件 { Console.WriteLine(string.Format("請輸入{0}筆查詢條件!", search.GetM())); for (int i = 0; i < search.GetM(); i++) { string data = Console.ReadLine(); search.SetCondition(data); } } #endregion #region 結果 { Dictionary <int, List <string> > dicResult = search.GetResult(); foreach (int i in dicResult.Keys) { string result = ""; foreach (string schoolName in dicResult[i]) { result += " " + schoolName; } Console.WriteLine(result); } } #endregion Console.Read(); }