// GET: Authorized/Books public ViewResult Index(SearchBook search, int page = 1) { ViewBag.Search = search; var books = repo.GetPageWithBooks(page, search); return(View(books)); }
public IActionResult ViewBook(string ISBN) { logic = new SearchBook(_configuration); Models.BookModel book = logic.ReturnBook(ISBN); return(View("ViewBook", book)); }
public void OnPost() { if (!string.IsNullOrWhiteSpace(SearchBook)) { SearchByBookResults = _context.Book .Where(y => y.Name.ToLower().Contains(SearchBook.ToLower())) .ToList(); SearchCompleted = true; } if (!string.IsNullOrWhiteSpace(SearchGenre)) { SearchByGenreResults = _context.Book .Where(y => y.Genre.Type.ToLower().Contains(SearchGenre.ToLower())) .ToList(); SearchCompleted = true; } if (!string.IsNullOrWhiteSpace(SearchAuthor)) { SearchByAuthorResults = _context.Book .Where(y => y.Author.ToLower().Contains(SearchAuthor.ToLower())) .ToList(); SearchCompleted = true; } //url..https://wallpaperplay.com/walls/full/9/7/e/162410.jpg }
public SearchBookForm(User user) { InitializeComponent(); this.user = user; searchbook = new SearchBook(); searchBookData = new SearchBookDataProvider(); }
private void ssbtnTimkiemDS_Click(object sender, EventArgs e) { SearchBook search = new SearchBook(); search.ShowDialog(); listSach = controller.getListSach(); grcDSDauSach.DataSource = listSach; }
/// <summary> /// 搜索图书 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void searchBook_Click(object sender, RoutedEventArgs e) { this.zhifubao.Visibility = Visibility.Hidden; this.weixin.Visibility = Visibility.Hidden; if (string.IsNullOrWhiteSpace(bookName.Text)) { return; } bookListBox.Dispatcher.InvokeAsync(() => bookListBox.Items.Clear()); //bookListBox.Items.Clear(); bookListBox.Visibility = Visibility.Visible; Task.Run(() => { string name = bookName.Dispatcher.Invoke(() => bookName.Text.ToString().Trim()); string url = " http://api.zhuishushenqi.com/book/fuzzy-search?query='" + name + "'&start=0&limit=5"; string json = common.GetPage(url); var book = new SearchBook(); if (String.IsNullOrEmpty(json)) { MessageBox.Show("网络错误"); return; } book = (SearchBook)common.FromJson("SearchBook", json); if (book.books == null) { bookListBox.Dispatcher.InvokeAsync(() => bookListBox.Items.Clear()); bookListBox.Dispatcher.InvokeAsync(() => bookListBox.Items.Add("没有此图书")); // bookListBox.Items.Add("没有此图书"); return; } List <string> bookList = new List <string>(); foreach (var item in book.books) { bookList.Add(item.title); bookListBox.Dispatcher.InvokeAsync(() => bookListBox.Items.Add(item.title)); // bookListBox.Items.Add(item.title); } if (bookList.Count() != 0) { bookListBox.Dispatcher.InvokeAsync(() => bookListBox.Visibility = Visibility.Visible); // 点击搜索,查询到的书籍列表 Application.Current.Properties["SearchBookList"] = book.books; // 书籍列表 App.Current.Dispatcher.Invoke((Action)(() => { var newWindow = new page.Window1(); newWindow.Show(); })); //bookListBox.Items.Add( bookList); } else { bookListBox.Dispatcher.InvokeAsync(() => bookListBox.Items.Clear()); bookListBox.Dispatcher.InvokeAsync(() => bookListBox.Items.Add("没有此图书")); // bookListBox.Items.Add("没有此图书"); } }); }
public void SearchBookTest() { ExtentTest searchBookTest = extent.CreateTest("SearchBookTest").Info("Search Book Test Started"); SearchBook search = new SearchBook(driver); search.SearchBookPage(); ((ITakesScreenshot)driver).GetScreenshot().SaveAsFile(Path + "Search.png", ScreenshotImageFormat.Png); log.Info("Search Book Test Executed Successfully"); }
public IActionResult Search(int searchKey, string searchInput) { books = new List <BookModel>(); books.Clear(); logic = new SearchBook(_configuration); books = logic.SearchUnfiltered(searchKey, searchInput); return(RedirectToAction("ViewBooks", new { _foundbooks = JsonConvert.SerializeObject(books as List <BookModel>) })); }
/// <summary> /// 搜索 /// </summary> /// <param name="key"></param> /// <param name="type"></param> /// <returns></returns> public List <SearchBook> SearchBook(string key, BookSearchType type, int pageSize, int pageIndex, ResourceFromSite siteType) { var bookCache = MemoryCacheProvider.Cache.Get(key + siteType + pageIndex) as List <SearchBook>; if (bookCache != null) { return(bookCache); } var rst = new List <SearchBook>(); switch (siteType) { case ResourceFromSite.起点: var qRst = SearchQiDian(key, type, pageSize, pageIndex); if (qRst != null) { foreach (var item in qRst) { var temp = new SearchBook() { ResourceId = item.bookid, AuthorName = item.authorname, BookName = item.bookname, BookUrl = item.bookurl, Description = item.description, LastChapter = item.lastchaptername, ImgUrl = item.coverurl }; var vip = "http://vipreader.qidian.com/BookReader/vip,"; var putong = "http://read.qidian.com/BookReader/"; if (item.lastvipchapter == null || item.lastvipchapter == "0" || item.lastvipchapter == "") { temp.LastChapterUrl = putong + item.bookid + "," + item.lastchapter + ".aspx"; } else { temp.LastChapterUrl = vip + item.bookid + "," + item.lastchapter + ".aspx"; } MemoryCacheProvider.Cache.Add(item.bookid + ResourceFromSite.起点.ToString(), temp, DateTimeOffset.Now.AddHours(1)); rst.Add(temp); } } break; case ResourceFromSite.十七K: break; default: break; } MemoryCacheProvider.Cache.Add(key + siteType + pageIndex, rst, DateTimeOffset.Now.AddHours(1)); return(rst); }
public IMainBook GetBookById(int id) { if (id > 0) { ISearchBook search = new SearchBook { Id = id }; return(GetBooks(search).FirstOrDefault()); } throw new ArgumentException("Book ID is not valid. This must be above a zero."); }
public List <SearchBook> GetListBookByTheLoai(string key) { List <SearchBook> list = new List <SearchBook>(); string query = string.Format("Select MaSach , NhanDe, TacGia, SoLuongCon, TenLoai, NhaXuatBan from Sach s , PhanLoai p where s.MaLoai = p.MaLoai and p.TenLoai like N'%{0}%'", key); DataProvider dataP = new DataProvider(); DataTable data = dataP.ExecuteQuery(query); foreach (DataRow item in data.Rows) { SearchBook search = new SearchBook(item); list.Add(search); } return(list); }
public ActionResult _SearchBook(SearchBook searchBook) { if (searchBook.TitleSearch != null) { var result = from i in db.Book where i.Title.Contains(searchBook.TitleSearch) select i; return(PartialView("_SearchBook", result)); } else { return(RedirectToAction("AddBook")); } }
public ActionResult ListBooksSearch(SearchBook form) { IQueryable <Book> books = db.Book; if (!String.IsNullOrEmpty(form.NameSearch)) { books = books.Where(b => b.name.Contains(form.NameSearch)); } //form.BooksList = books.ToList(); int pageSize = 5; int pageNumber = form.Page <= 0 ? 1 : form.Page; form.BooksList = books.OrderBy(b => b.id).ToPagedList(pageNumber, pageSize); return(View(form)); }
/// <summary> /// 搜索按钮点击 /// </summary> private void Search_Click(object sender, RoutedEventArgs e) { SearchBook searchBook = new SearchBook(); //搜索链接拼凑 searchBook.BookUrl = SearchUrl.Text + Tool.EncodingConvert(SearchBookName.Text, Encoding.GetEncoding(GetHtml.GetCode(SearchUrl.Text))); searchBook.AddressRangeRegular = AddressRangeRegular.Text; searchBook.AddressCuttingRegular = AddressCuttingRegular.Text; searchBook.AddressRegular = AddressRegular.Text; Thread td = new Thread(SearchBook); //把线程设置为后台线程 td.IsBackground = true; td.Start(searchBook); }
/// <summary> /// 搜索按钮点击 /// </summary> private void Search_Click(object sender, RoutedEventArgs e) { SearchBook searchBook = new SearchBook(); //搜索链接拼凑 searchBook.BookUrl = SearchUrl.Text + SearchBookName.Text; searchBook.AddressRangeRegular = AddressRangeRegular.Text; searchBook.AddressCuttingRegular = AddressCuttingRegular.Text; searchBook.AddressRegular = AddressRegular.Text; Thread td = new Thread(SearchBook); //把线程设置为后台线程 td.IsBackground = true; td.Start(searchBook); }
public void SearchBookTestMethod() { try { test = extent.CreateTest("SearchBookTestMethod").Info("Search Book Test Started"); SearchBook addwish = new SearchBook(driver); string spanResult = addwish.SearchBookMethod(JsonData.data.BookTitleToSearch); test.Log(Status.Info, "Book is searched"); string expectedSpanResult = "positive thinking"; spanResult.Contains(expectedSpanResult); test.Log(Status.Pass, "Test passed"); } catch (Exception exception) { test.Log(Status.Fail, exception.ToString()); throw; } }
public void Index_NotNullCorrectTypeAndId() { // Arrange pagedBooks = books.ToPagedList <MainBook>(pageNumber, pageSize); SearchBook searchById = new SearchBook(); Mock <IBooksService> mockRepo = new Mock <IBooksService>(); mockRepo.Setup(m => m.GetBookById(It.Is <int>(i => i > 0))) .Returns(pagedBooks[1]); mockRepo.Setup(m => m.GetPageWithBooks(It.Is <int>(i => i > 0), new SearchBook())) .Returns(pagedBooks); BooksController controller = new BooksController(mockRepo.Object); // Act var result = controller.Index(new SearchBook(), pageNumber); // Assert Assert.IsNotNull(result); Assert.IsInstanceOfType(result, typeof(ViewResult)); Assert.AreEqual(searchById.Id, result.ViewBag.Search.Id); }
private void SearchBook(object Search_Book) { SearchBook searchBook = (SearchBook)Search_Book; string html = GetHtml.GetHttpWebRequest(searchBook.BookUrl); List <Book> books = new List <Book>(); //获取搜索书籍范围 string htmlRange = Tool.GetRegexStr(html, searchBook.AddressRangeRegular).Trim(); //分割搜索书籍 string[] bookList = htmlRange.Split(new string[] { searchBook.AddressCuttingRegular }, StringSplitOptions.RemoveEmptyEntries); int i = 0; foreach (string str in bookList) { string url = Tool.GetRegexStr(str, searchBook.AddressRegular).Trim(); if (url.Length > 3) { i++; books.Add(new Book { Id = i, Url = url }); } } //Invoke是同步 BeginInvoke是异步 Dispatcher.Invoke((Action) delegate { SearchList.ItemsSource = books; }); if (books.Count > 0) { state_search = true; } }
public ActionResult Index(SearchBook searchBook, Category category) { //var books; ViewBag.CategoryId = new SelectList(db.Category, "CategoryId", "Name"); if (searchBook.TitleSearch != null) { var books = from i in db.Book where i.CategoryId.Equals(category.CategoryId) || i.Title.Contains(searchBook.TitleSearch) select i; if (books.Count() == 0) return RedirectToAction("Index"); return View(books); } else { var books = from i in db.Book where i.CategoryId.Equals(category.CategoryId) select i; return View(books); } }
public string[] searchBookResultCount(SearchBook bookData) { string[] returnValue = new string[2]; returnValue[0] = "0"; returnValue[1] = "0"; DataBase Base = new DataBase(); string ConditionReturn = this.SearchBookConditionReturn(bookData, "BookDatabase"); using (SqlConnection Sqlconn = new SqlConnection(Base.GetConnString())) { try { StaffDataBase sDB = new StaffDataBase(); List<string> CreateFileName = sDB.getStaffDataName(HttpContext.Current.User.Identity.Name); Sqlconn.Open(); string sql = "SELECT COUNT(*) FROM BookDatabase WHERE isDeleted=0 " + ConditionReturn; SqlCommand cmd = new SqlCommand(sql, Sqlconn); cmd.Parameters.Add("@txtbookNumber", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(bookData.txtbookNumber); cmd.Parameters.Add("@txtbookTitle", SqlDbType.NVarChar).Value = "%" + Chk.CheckStringFunction(bookData.txtbookTitle) + "%"; cmd.Parameters.Add("@txtbookClassification", SqlDbType.Int).Value = Chk.CheckStringtoIntFunction(bookData.txtbookClassification); cmd.Parameters.Add("@txtbookAuthor", SqlDbType.NVarChar).Value = "%" + Chk.CheckStringFunction(bookData.txtbookAuthor) + "%"; cmd.Parameters.Add("@txtbookPress", SqlDbType.NVarChar).Value = "%" + Chk.CheckStringFunction(bookData.txtbookPress) + "%"; returnValue[0] = cmd.ExecuteScalar().ToString(); Sqlconn.Close(); } catch (Exception e) { returnValue[0] = "-1"; returnValue[1] = e.Message.ToString(); } } return returnValue; }
private string SearchBookConditionReturn(SearchBook bookData, string bookDBName) { string ConditionReturn = ""; if (bookData.txtbookNumber != null) { ConditionReturn += " AND BookCodeID=@txtbookNumber "; } if (bookData.txtbookTitle != null) { ConditionReturn += " AND BookName like @txtbookTitle "; } if (bookData.txtbookClassification != null) { ConditionReturn += " AND CategoryID=@txtbookClassification "; } if (bookData.txtbookAuthor != null) { ConditionReturn += " AND Author like @txtbookAuthor "; } if (bookData.txtbookPress != null) { ConditionReturn += " AND Press like @txtbookPress "; } StaffDataBase sDB = new StaffDataBase(); List<string> UserFile = sDB.getStaffDataName(HttpContext.Current.User.Identity.Name); if (int.Parse(_StaffhaveRoles[4]) == 0 && UserFile[1].Length > 0) { ConditionReturn += " AND " + bookDBName + ".Unit =" + UserFile[2] + " "; } return ConditionReturn; }
public ControllerSearch(SearchBook search) { this.search = search; restClient = new RestClient(); }
public List<CreateBookResult> searchBookResult(int indexpage, SearchBook bookData) { List<CreateBookResult> returnValue = new List<CreateBookResult>(); DataBase Base = new DataBase(); string ConditionReturn = this.SearchBookConditionReturn(bookData, "BookDatabase"); using (SqlConnection Sqlconn = new SqlConnection(Base.GetConnString())) { try { StaffDataBase sDB = new StaffDataBase(); List<string> CreateFileName = sDB.getStaffDataName(HttpContext.Current.User.Identity.Name); Sqlconn.Open(); string sql = "SELECT * FROM (SELECT ROW_NUMBER() OVER (ORDER BY BookDatabase.BookID DESC) " + "AS RowNum, BookDatabase.*, BookCategory.CategoryCode, BookCategory.CategoryName FROM BookDatabase " + "RIGHT JOIN BookCategory ON BookDatabase.CategoryID=BookCategory.ID " + "WHERE BookDatabase.isDeleted=0 " + ConditionReturn + " ) " + "AS NewTable " + "WHERE RowNum >= (@indexpage-" + PageMinNumFunction() + ") AND RowNum <= (@indexpage)"; SqlCommand cmd = new SqlCommand(sql, Sqlconn); cmd.Parameters.Add("@indexpage", SqlDbType.Int).Value = indexpage; cmd.Parameters.Add("@txtbookNumber", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(bookData.txtbookNumber); cmd.Parameters.Add("@txtbookTitle", SqlDbType.NVarChar).Value = "%" + Chk.CheckStringFunction(bookData.txtbookTitle) + "%"; cmd.Parameters.Add("@txtbookClassification", SqlDbType.Int).Value = Chk.CheckStringtoIntFunction(bookData.txtbookClassification); cmd.Parameters.Add("@txtbookAuthor", SqlDbType.NVarChar).Value = "%" + Chk.CheckStringFunction(bookData.txtbookAuthor) + "%"; cmd.Parameters.Add("@txtbookPress", SqlDbType.NVarChar).Value = "%" + Chk.CheckStringFunction(bookData.txtbookPress) + "%"; SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { CreateBookResult addValue = new CreateBookResult(); addValue.bID = dr["BookID"].ToString(); addValue.bookNumber = dr["BookCodeID"].ToString(); addValue.bookTitle = dr["BookName"].ToString(); addValue.bookClassificationCode = dr["CategoryCode"].ToString(); addValue.bookClassificationName = dr["CategoryName"].ToString(); addValue.bookAuthor = dr["Author"].ToString(); addValue.bookPress = dr["Press"].ToString(); addValue.checkNo = "1"; returnValue.Add(addValue); } dr.Close(); Sqlconn.Close(); } catch (Exception e) { CreateBookResult addValue = new CreateBookResult(); addValue.checkNo = "-1"; addValue.errorMsg = e.Message.ToString(); returnValue.Add(addValue); } } return returnValue; }
public override bool OnDragDrop(Mobile from, Item dropped) { if (dropped is Gold) { int Coins = dropped.Amount; string sMessage = ""; if (Coins == 10000 || Coins == 9000 || Coins == 8000 || Coins == 7000 || Coins == 6000 || Coins == 5000 ) { int nAllowedForAnotherQuest = SearchPage.ArtifactQuestTimeNew(from); int nServerQuestTimeAllowed = DifficultyLevel.GetTimeBetweenArtifactQuests(); int nWhenForAnotherQuest = nServerQuestTimeAllowed - nAllowedForAnotherQuest; if (nWhenForAnotherQuest > 0) { TimeSpan t = TimeSpan.FromMinutes(nWhenForAnotherQuest); string wait = string.Format("{0:D2} days {1:D2} hours and {2:D2} minutes", t.Days, t.Hours, t.Minutes); sMessage = "I have no artifact encyclopedias at the moment. Check back in " + wait + "."; from.AddToBackpack(dropped); } else { sMessage = "Good luck in your quest."; ArrayList targets = new ArrayList(); foreach (Item item in World.Items.Values) { if (item is SearchBook) { SearchBook searchbook = (SearchBook)item; if (searchbook.owner == from) { targets.Add(item); } } else if (item is SearchPage) { SearchPage searchpage = (SearchPage)item; if (searchpage.owner == from) { targets.Add(item); } } } for (int i = 0; i < targets.Count; ++i) { Item item = ( Item )targets[i]; item.Delete(); } from.AddToBackpack(new SearchBook(from, Coins)); dropped.Delete(); } } else { sMessage = "You look like you need this more than I do."; from.AddToBackpack(dropped); } this.PrivateOverheadMessage(MessageType.Regular, 1153, false, sMessage, from.NetState); } return(base.OnDragDrop(from, dropped)); }
public List<CreateBook> searchBookData(int index, SearchBook bookData) { AdministrationDataBase aDB = new AdministrationDataBase(); aDB.libraryFunction(); return aDB.searchBook(index, bookData); }
public List<CreateBookResult> searchBookDataResult(int index, SearchBook bookData) { AdministrationDataBase aDB = new AdministrationDataBase(); return aDB.searchBookResult(index, bookData); }
public string[] searchBookDataResultCount(SearchBook bookData) { AdministrationDataBase aDB = new AdministrationDataBase(); aDB.libraryFunction(); if (int.Parse(aDB._StaffhaveRoles[3]) == 1) { return aDB.searchBookResultCount(bookData); } else { return new string[2] { _getcheckNo, _errorMsg }; } }
public override bool OnDragDrop(Mobile from, Item dropped) { if (dropped is Gold) { int Coins = dropped.Amount; string sMessage = ""; if (Coins == 500) { if (from.Skills[SkillName.Inscribe].Value >= 30) { if (Server.Misc.Research.AlreadyHasBag(from)) { this.PublicOverheadMessage(MessageType.Regular, 0, false, string.Format("Good luck with your research.")); } else { ResearchBag bag = new ResearchBag(); from.PlaySound(0x2E6); Server.Misc.Research.SetupBag(from, bag); from.AddToBackpack(bag); this.PublicOverheadMessage(MessageType.Regular, 0, false, string.Format("Good luck with your research.")); } dropped.Delete(); } else { sMessage = "You need to be a neophyte scribe before I sell that to you."; from.AddToBackpack(dropped); } } else if (Coins == 10000 || Coins == 9000 || Coins == 8000 || Coins == 7000 || Coins == 6000 || Coins == 5000 ) { int nAllowedForAnotherQuest = SearchPage.ArtifactQuestTimeNew(from); int nServerQuestTimeAllowed = MyServerSettings.GetTimeBetweenArtifactQuests(); int nWhenForAnotherQuest = nServerQuestTimeAllowed - nAllowedForAnotherQuest; if (nWhenForAnotherQuest > 0) { TimeSpan t = TimeSpan.FromMinutes(nWhenForAnotherQuest); string wait = string.Format("{0:D2} days {1:D2} hours and {2:D2} minutes", t.Days, t.Hours, t.Minutes); sMessage = "I have no artifact encyclopedias at the moment. Check back in " + wait + "."; from.AddToBackpack(dropped); } else { sMessage = "Good luck in your quest."; ArrayList targets = new ArrayList(); foreach (Item item in World.Items.Values) { if (item is SearchBook) { SearchBook searchbook = (SearchBook)item; if (searchbook.owner == from) { targets.Add(item); } } else if (item is SearchPage) { SearchPage searchpage = (SearchPage)item; if (searchpage.owner == from) { targets.Add(item); } } } for (int i = 0; i < targets.Count; ++i) { Item item = ( Item )targets[i]; item.Delete(); } from.AddToBackpack(new SearchBook(from, Coins)); dropped.Delete(); } } else { sMessage = "You look like you need this more than I do."; from.AddToBackpack(dropped); } this.PrivateOverheadMessage(MessageType.Regular, 1153, false, sMessage, from.NetState); } return(base.OnDragDrop(from, dropped)); }
private void searchBookBtn_Click(object sender, EventArgs e) { SearchBook searchBookForm = new SearchBook(this); searchBookForm.Show(); }
public IHttpActionResult SearchBooks(SearchBook searchBook) { return(Ok(bookManagement.SearchBooks(searchBook.Title, searchBook.Author, searchBook.PublishYear, searchBook.Category, searchBook.Language, searchBook.Role))); }