Ejemplo n.º 1
0
        private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
        {
            if (e.Node.Text == "最近看的书")
            {
                SearchResultBookViewControl.Books = BookQuery.RecentReadBooks(DataSettings.Default.User).ToArray();
            }
            else if (e.Node.Text == "看的时间最长的书")
            {
                SearchResultBookViewControl.Books = BookQuery.MostReadBooks(DataSettings.Default.User).ToArray();
            }
            else if (e.Node.Text == "看的次数最多的书")
            {
                SearchResultBookViewControl.Books = BookQuery.MostOpenBooks(DataSettings.Default.User).ToArray();
            }
            else if (e.Node.Text == "非常喜欢")
            {
                SearchResultBookViewControl.Books = BookQuery.RateBooks(DataSettings.Default.User, BookRateEnum.Love).ToArray();
            }
            else if (e.Node.Text == "喜欢")
            {
                SearchResultBookViewControl.Books = BookQuery.RateBooks(DataSettings.Default.User, BookRateEnum.Like).ToArray();
            }
            else if (e.Node.Text == "正规")
            {
                SearchResultBookViewControl.Books = BookQuery.RateBooks(DataSettings.Default.User, BookRateEnum.Regular).ToArray();
            }
            else if (e.Node.Text == "没有感觉")
            {
                SearchResultBookViewControl.Books = BookQuery.RateBooks(DataSettings.Default.User, BookRateEnum.NoFeeling).ToArray();
            }
            else if (e.Node.Text == "不喜欢")
            {
                SearchResultBookViewControl.Books = BookQuery.RateBooks(DataSettings.Default.User, BookRateEnum.NotLike).ToArray();
            }
            else if (e.Node.Text == "孤立的书")
            {
                SearchResultBookViewControl.Books = BookQuery.IsolateBooks().ToArray();
            }
            else if (e.Node.Text == "新添加的书")
            {
                SearchResultBookViewControl.Books = BookQuery.NewBooks().ToArray();
            }
            else if (e.Node.Text == "有新书")
            {
                SearchResultBookViewControl.Books = BookQuery.NewBooks(DataSettings.Default.User).ToArray();

                // update notsee color
                TreeNode tn = FindNode("有新书", treeView1.Nodes);
                tn.ForeColor = Color.Black;

                // update usercheck time
                DataSettings.Default.User.UserLastCheckBookDate = DateTime.Now;
                JianLiLinq.Default.DB.SubmitChanges();
            }
            else if (e.Node.Text == "未定类型的书")
            {
                Book[] bs = BookQuery.TypeBooks(BookTypeEnum.Uncheck).ToArray();
                SearchResultBookViewControl.Books = bs;
            }
        }
Ejemplo n.º 2
0
        public ActionResult QueryBook([FromBody] BookQuery bookQuery)
        {
            if (!BookChecker.existBook(bookQuery))
            {
                return(BadRequest(new { message = "没有此书" }));
            }
            String titledBookName = StringChecker.AddBookTitle(bookQuery.Name);

            using (MySqlConnection conn = SqlProvider.GetMySqlConnection())
            {
                MySqlCommand cmd = new MySqlCommand($"SELECT * from books WHERE name='{titledBookName}'OR GUID='{bookQuery.guid}';", conn);

                MySqlDataAdapter adapter = new MySqlDataAdapter(cmd);
                //创建DataSet类的对象
                DataSet dataset = new DataSet();

                //使用SQLDataAdapter对象sda将查询结果填充到DataTable对象ds中
                adapter.Fill(dataset);

                MySqlCommandBuilder cmdBuilder = new MySqlCommandBuilder(adapter);

                DataRow dataRow = dataset.Tables[0].Rows[0];

                Book book = new Book()
                {
                    GUID         = Guid.Parse(dataRow["GUID"].ToString()),
                    Name         = dataRow["Name"].ToString(),
                    TotalNumber  = (int)dataRow["TotalNumber"],
                    RemainNumber = (int)dataRow["RemainNumber"]
                };
                return(Ok(book));
            }
        }
Ejemplo n.º 3
0
        private async void ButtonSearch_Click(object sender, System.EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(editTextSearchText.Text))
            {
                Toast.MakeText(this, "Bitte geben Sie einen Suchbegriff ein !", ToastLength.Long).Show();
                return;
            }

            ProgressDialog dlg    = ProgressDialog.Show(this, "Loading", "Suche nach Bücher ...");
            BookQuery      result = await ServiceProvider.BookService.FindBooksAsync(editTextSearchText.Text);

            if (result.Count == 0)
            {
                dlg.Dismiss();
                Toast.MakeText(this, "Es wurden leider keine Bücher gefunden !", ToastLength.Long).Show();
                return;
            }

            //LINQ
            //string[] titelArray = result.Books.Select(x => x.Info.Title).ToArray();
            //listViewBooks.Adapter = new ArrayAdapter<string>(this, Android.Resource.Layout.SimpleListItem1, titelArray);

            listViewBooks.Adapter = new BookAdapter(this, result.Books);

            dlg.Dismiss();
        }
Ejemplo n.º 4
0
        async Task <SearchResult <Book> > IBookRepository.SearchAsync(BookQuery query, CancellationToken cancellationToken)
        {
            var results = await SearchAsync <DbBook, Book>(
                (query.Offset, query.Limit),
                _ => _.MultiQuery(q =>
            {
                q.Text(query.Name, b => b.Name)
                .Range(query.Score, b => b.Score);

                if (query.Tags != null)
                {
                    foreach (var(k, v) in query.Tags)
                    {
                        q.Text(v, GetBookTagsPath(k));
                    }
                }

                q.Filter(query.Category, b => b.Category)
                .Filter(query.Rating, b => b.Rating)
                .Range(query.PageCount, b => b.PageCounts)
                .Filter(query.Language, b => b.Languages)
                .Filter(query.IsColor, b => b.IsColor)
                .Filter(query.Source.Project(s => s.ToString()), b => b.Sources);

                return(q);
            })
                .MultiSort(query.Sorting, GetBookSortPath),
                b => b.ToBook(),
                cancellationToken);

            return(results);
        }
Ejemplo n.º 5
0
        private void CountButton_Click(object sender, EventArgs e)
        {
            string amount = "当前资料: " + JianLiLinq.Default.DB.Books.Count().ToString() + " 份,其中:";

            amount += Environment.NewLine;

            amount += "书籍: " + BookQuery.TypeBooks(BookTypeEnum.Book).Count().ToString() + " 册";
            amount += Environment.NewLine;

            amount += "海报: " + BookQuery.TypeBooks(BookTypeEnum.Post).Count().ToString() + " 份";
            amount += Environment.NewLine;

            amount += "论文: " + BookQuery.TypeBooks(BookTypeEnum.Paper).Count().ToString() + " 份";
            amount += Environment.NewLine;

            amount += "杂志/期刊: " + BookQuery.TypeBooks(BookTypeEnum.Magzine).Count().ToString() + " 期";
            amount += Environment.NewLine;

            amount += "Cheet Sheet: " + BookQuery.TypeBooks(BookTypeEnum.CheetSheet).Count().ToString() + " 册";
            amount += Environment.NewLine;

            amount += "其它文档: " + BookQuery.TypeBooks(BookTypeEnum.Doc).Count().ToString() + " 册";
            amount += Environment.NewLine;

            amount += "未归类资料: " + BookQuery.TypeBooks(BookTypeEnum.Uncheck).Count().ToString() + " 份";
            amount += Environment.NewLine;
            amount += Environment.NewLine;

            amount += "文件: " + JianLiLinq.Default.DB.Files.Count().ToString() + " 份";
            amount += Environment.NewLine;
            amount += "关键字: " + JianLiLinq.Default.DB.Keywords.Count().ToString() + " 个";
            amount += Environment.NewLine;
            amount += "类别: " + JianLiLinq.Default.DB.Categories.Count().ToString() + " 个";
            MessageBox.Show(amount);
        }
Ejemplo n.º 6
0
        public void FindBooksAsyncTest_ResultCountIsZeroWhenNoBooksFound(string searchText)
        {
            BookQuery result = service.FindBooksAsync(searchText).Result;

            Assert.NotNull(result);
            Assert.Zero(result.Count);
        }
Ejemplo n.º 7
0
        public void FindBooksAsyncTest_getValidBookQueryWithValidInput(string searchText)
        {
            BookQuery result = service.FindBooksAsync(searchText).Result;

            Assert.NotNull(result);
            Assert.GreaterOrEqual(result.Count, 1);
        }
Ejemplo n.º 8
0
        public void FindBooksAsyncTest_getExceptionWhenInputIsNotValid(string searchText)
        {
            AsyncTestDelegate del = new AsyncTestDelegate(async() =>
            {
                BookQuery result = await service.FindBooksAsync(searchText);
            });

            Assert.ThrowsAsync <ArgumentException>(del);
        }
Ejemplo n.º 9
0
        public void FindBooksTest_getExceptionWhenInputIsNotValid(string searchText)
        {
            TestDelegate del = new TestDelegate(() =>
            {
                BookQuery result = service.FindBooks(searchText);
            });

            Assert.Throws <ArgumentException>(del);
        }
        public Book RemoveBook(BookQuery bookQuery)
        {
            using (var context = new ApplicationContext())
            {
                var book = context.Books.Find(bookQuery.Id) ?? new Book();

                context.Books.Remove(book);
                context.SaveChanges();
                return(book);
            }
        }
Ejemplo n.º 11
0
        public async Task <IActionResult> Book(int bookId)
        {
            var query       = new BookQuery(bookId);
            var queryResult = await _mediator.Send(query);

            var model = new BookViewModel()
            {
                Book = queryResult.Book
            };

            return(View(model));
        }
Ejemplo n.º 12
0
        public PageResult <BookDto> GetAll(int bookShopId, BookQuery bookQuery)
        {
            _bookServiceGuard.CheckBookShopExistsById(bookShopId);

            var(books, booksTotalCount) = GetBooksByQuery(bookShopId, bookQuery);

            var booksDto = _mapper.Map <IEnumerable <BookDto> >(books);

            var bookPageResult = new PageResult <BookDto>(booksDto, booksTotalCount, bookQuery.PageSize, bookQuery.PageNumber);

            return(bookPageResult);
        }
Ejemplo n.º 13
0
        public override void OpenView()
        {
            this.book_view = this.book.GetBookView(BookQuery.AnyFieldContains(""),
                                                   new object [0],
                                                   -1);

            this.book_view.ContactsAdded    += OnContactsAdded;
            this.book_view.ContactsRemoved  += OnContactsRemoved;
            this.book_view.ContactsChanged  += OnContactsChanged;
            this.book_view.SequenceComplete += OnSequenceComplete;

            this.book_view.Start();
        }
Ejemplo n.º 14
0
        public async Task <IActionResult> GetBooks(BookQuery query)
        {
            try
            {
                var books = await bookRepository.GetBooksAsync(query);

                return(Ok(mapper.Map <QueryResult <Book>, QueryResultResource <BookResource> >(books)));
            }
            catch (System.Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Ejemplo n.º 15
0
        // Find bøger ud fra søgkriterier
        public async Task <List <BookDTO> > GetBooksAsync(BookQuery query)
        {
            string relativeURL = "api/books/?title=" + query.Title + "&author=" + query.Author
                                 + "&id=" + query.Id + "&onlyOnShelf=" + query.OnlyOnShelf + "&publisher=" + query.Publisher
                                 + "&yearpublished=" + query.YearPublished;

            HttpResponseMessage response = await client.GetAsync(relativeURL);

            if (response.IsSuccessStatusCode)
            {
                var items = JsonConvert.DeserializeObject <List <BookDTO> >(await response.Content.ReadAsStringAsync());

                return(items);
            }
            return(null);
        }
Ejemplo n.º 16
0
        public IEnumerable<Book> Read(BookQuery query)
        {
            var books = from b in EBooks
                        where b.PublishedAt >= query.After
                        where b.PublishedAt < query.Before
                        where query.Author == null || b.Authors.Any(a => a.Name.Contains(query.Author))
                        where query.Title == null || b.Title.Contains(query.Title)
                        orderby b.PublishedAt descending
                        select b;

            return books
                .Skip((query.Page - 1) * query.PageSize)
                .Take(query.PageSize)
                .AsEnumerable()
                .Select(Book);
        }
Ejemplo n.º 17
0
        public IEnumerable <Book> Read(BookQuery query)
        {
            var books = from b in EBooks
                        where b.PublishedAt >= query.After
                        where b.PublishedAt < query.Before
                        where query.Author == null || b.Authors.Any(a => a.Name.Contains(query.Author))
                        where query.Title == null || b.Title.Contains(query.Title)
                        orderby b.PublishedAt descending
                        select b;

            return(books
                   .Skip((query.Page - 1) * query.PageSize)
                   .Take(query.PageSize)
                   .AsEnumerable()
                   .Select(Book));
        }
Ejemplo n.º 18
0
        /// <summary>
        /// 分页信息
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public PageList <BookQueryInfo> GetList(BookQuery query)
        {
            var barList = new PageList <BookQueryInfo>(query.PageIndex, query.PageSize);

            var queryString        = @"
                                  select * from ( SELECT ROW_NUMBER() OVER(ORDER BY CreateTime DESC ) as RowID,* FROM Books where 1=1 {0}) r
                                where RowID between @StartIndex  and @EndIndex;

                                select Count(*) as RecordTotal from Books
                                where 1=1  {0} ";
            DynamicParameters para = new DynamicParameters();

            para.Add("@StartIndex", query.StartIndex);
            para.Add("@EndIndex", query.EndIndex);

            string whereStr = string.Empty;

            if (query.ParentType > 0)
            {
                whereStr += " and  ParentType=@ParentType ";
                para.Add("@ParentType", query.ParentType);
            }

            if (query.SubType > 0)
            {
                whereStr += " and  SubType=@SubType ";
                para.Add("@SubType", query.SubType);
            }

            if (query.PublishHouseId > 0)
            {
                whereStr += " and  PublishHouseId=@PublishHouseId ";
                para.Add("@PublishHouseId", query.PublishHouseId);
            }
            queryString = string.Format(queryString, whereStr);

            using (IDbConnection conn = DataBaseConfig.GetSqlConnection())
            {
                using (var multi = conn.QueryMultiple(queryString, para))
                {
                    barList.List        = multi.Read <BookQueryInfo>().ToList();
                    barList.RecordTotal = multi.ReadSingle <int>();
                }
            }

            return(barList);
        }
Ejemplo n.º 19
0
        private void UserViewControl_Load(object sender, EventArgs e)
        {
            if (this.Site != null)
            {
                if (this.Site.DesignMode == true)
                {
                    return;
                }
            }
            var bs = BookQuery.NewBooks(DataSettings.Default.User);

            if (bs.Count() > 0)
            {
                TreeNode tn = FindNode("有新书", treeView1.Nodes);
                tn.ForeColor = Color.Red;
            }
        }
Ejemplo n.º 20
0
        /// <summary>
        /// 网站首页数据源
        /// </summary>
        /// <param name="query">查询条件</param>
        /// <returns></returns>
        public HomeUI Home(BookQuery query)
        {
            var list = book.GetList(query);

            HomeUI home = new HomeUI()
            {
                PublishHouseId = query.PublishHouseId,
                ParentType     = query.ParentType,
                SubType        = query.SubType,
                HoustList      = publishHouseRepository.GetList(),
                Parent         = bookTypeRepository.GetParentList(),
                Children       = query.ParentType > 0? bookTypeRepository.GetChildList(query.ParentType):null,
                QueryList      = list
            };

            return(home);
        }
Ejemplo n.º 21
0
        public PageResult <BookDto> GetAllBySQL(int bookShopId, BookQuery bookQuery)
        {
            bookQuery.SortBy ??= SqlConstants.DefaultSortedColumn;

            var books = _dbContext.Books.FromSqlRaw($"SelectBooks '{bookQuery.PageNumber}'" +
                                                    $", '{bookQuery.PageSize}'" +
                                                    $", '{bookQuery.SortBy}'" +
                                                    $", '{bookQuery.SortDirection}'" +
                                                    $", '{bookQuery.SearchAuthor}'").ToList();


            var booksDto = _mapper.Map <IEnumerable <BookDto> >(books);

            var bookPageResult = new PageResult <BookDto>(booksDto, 1000, bookQuery.PageSize, bookQuery.PageNumber);

            return(bookPageResult);
        }
Ejemplo n.º 22
0
 public static bool existBook(BookQuery bookQuery)
 {
     using (MySqlConnection conn = SqlProvider.GetMySqlConnection())
     {
         String titledBookName = StringChecker.AddBookTitle(bookQuery.Name);
         conn.Open();
         var          cmdstr = $"SELECT * from books WHERE Name='{titledBookName}'OR GUID='{bookQuery.guid}';";
         MySqlCommand cmd1   = new MySqlCommand(cmdstr, conn);
         var          reader = cmd1.ExecuteReader();
         if (reader.HasRows)
         {
             conn.Close();
             return(true);
         }
         conn.Close();
         return(false);
     }
 }
Ejemplo n.º 23
0
        public async Task <BookResult> GetBooksAsync(BookQuery bookQuery)
        {
            var books = _context.Books
                        .Include(b => b.Author)
                        .Include(b => b.Genres)
                        .ThenInclude(bg => bg.Genre)
                        .AsQueryable();

            if (!string.IsNullOrWhiteSpace(bookQuery.SearchKey))
            {
                books = books.Where(b => b.Title.Contains(bookQuery.SearchKey));
            }

            if (bookQuery.AuthorId != null)
            {
                books = books.Where(b => b.AuthorId == bookQuery.AuthorId);
            }

            if (bookQuery.GenreId != null)
            {
                books = books.Where(b => b.Genres.Any(bg => bg.GenreId == bookQuery.GenreId));
            }

            var columnsMap = new Dictionary <string, Expression <Func <Book, object> > >()
            {
                ["Title"]        = book => book.Title,
                ["Price"]        = book => book.Price,
                ["YearReleased"] = book => book.YearReleased,
                ["Author"]       = book => book.Author.Name
            };

            books = books.ApplyOrdering(bookQuery, columnsMap);

            var totalCount = await books.CountAsync();

            books = books.ApplyPaging(bookQuery);

            return(new BookResult
            {
                Books = await books.ToListAsync(),
                TotalCount = totalCount
            });
        }
Ejemplo n.º 24
0
        public async Task <QueryResult <Book> > GetBooksAsync(BookQuery queryObj)
        {
            var result = new QueryResult <Book>();

            var query = context.Books.OrderBy(B => B.Id)
                        .Include(B => B.Categories)
                        .ThenInclude(bc => bc.Category)
                        .Include(B => B.Author).AsQueryable();

            query = query.ApplyFiltering(queryObj);

            query = query.ApplyPaging(queryObj);

            result.TotalItems = await query.CountAsync();

            result.Items = await query.ToListAsync();

            return(result);
        }
Ejemplo n.º 25
0
        public static IQueryable <Book> ApplyFiltering(this IQueryable <Book> query, BookQuery queryObj)
        {
            if (queryObj.BookName != null)
            {
                query = query.Where(b => b.Name == queryObj.BookName);
            }

            if (queryObj.AuthorName != null)
            {
                query = query.Where(b => b.Author.Name == queryObj.AuthorName);
            }

            if (queryObj.CategoryName != null)
            {
                query = query.Where(b => b.Categories.Any(bc => bc.Category.Name == queryObj.CategoryName));
            }


            return(query);
        }
Ejemplo n.º 26
0
        private Tuple <IEnumerable <Book>, int> GetBooksByQuery(int bookShopId, BookQuery bookQuery)
        {
            var filteredBooks = _dbContext.Books
                                .Where(b => bookQuery.SearchAuthor == null ||
                                       b.Author.ToUpper().Contains(bookQuery.SearchAuthor.ToUpper()));

            if (!string.IsNullOrEmpty(bookQuery.SortBy))
            {
                filteredBooks = filteredBooks.OrderBy(bookQuery.SortBy, bookQuery.SortDirection);
            }

            var books = filteredBooks
                        .Skip(bookQuery.PageSize * (bookQuery.PageNumber - 1))
                        .Take(bookQuery.PageSize)
                        .ToList();

            var totalCount = filteredBooks.Count();
            var result     = new Tuple <IEnumerable <Book>, int>(books, totalCount);

            return(result);
        }
Ejemplo n.º 27
0
        public ActionResult deleteBook(BookQuery bookQuery)
        {
            if (!BookChecker.existBook(bookQuery))
            {
                return(BadRequest(new { message = "没有此书" }));
            }
            String titledBookName = StringChecker.AddBookTitle(bookQuery.Name);

            using (MySqlConnection conn = SqlProvider.GetMySqlConnection())
            {
                conn.Open();
                MySqlCommand cmd       = new MySqlCommand($"DELETE  from books WHERE name='{titledBookName}'OR GUID='{bookQuery.guid}';", conn);
                var          rowsCount = cmd.ExecuteNonQuery();
                if (rowsCount != 0)
                {
                    conn.Close();
                    return(Ok(new { message = "删除成功" }));
                }
                conn.Close();
                return(BadRequest(new { message = "删除失败" }));
            }
        }
Ejemplo n.º 28
0
        public ArrayList GetContacts(string bookName)
        {
            string    contact_fax = null;
            ArrayList ebooks      = new ArrayList();
            ArrayList records     = new ArrayList();

            SourceList slist = new SourceList("/apps/evolution/addressbook/sources");

            if (slist != null)
            {
                SList group_list = slist.Groups;
                foreach (SourceGroup group in group_list)
                {
                    //Only get phone books on this machine.
                    if (group.Name == "On This Computer")
                    {
                        SList src_list = group.Sources;

                        foreach (Evolution.Source src in src_list)
                        {
                            if (src.Name == bookName)
                            {
                                //Book bk = Book.NewSystemAddressbook ();
                                Book bk = new Book(src);
                                bk.Open(true);

                                BookQuery q           = BookQuery.AnyFieldContains("");
                                Contact[] contactlist = bk.GetContacts(q);
                                //Console.WriteLine ("Contact count (range) : {0}", contactlist.Length);

                                if (contactlist != null)
                                {
                                    foreach (Contact comp in contactlist)
                                    {
                                        contact_fax = null;

                                        if (comp.BusinessFax != null && comp.BusinessFax != String.Empty)
                                        {
                                            contact_fax = comp.BusinessFax;
                                        }
                                        else if (comp.OtherFax != null && comp.OtherFax != String.Empty)
                                        {
                                            contact_fax = comp.OtherFax;
                                        }
                                        else if (comp.HomeFax != null && comp.HomeFax != String.Empty)
                                        {
                                            contact_fax = comp.HomeFax;
                                        }

                                        if (contact_fax != null)
                                        {
                                            GfaxContact gc = new GfaxContact();
                                            //Console.WriteLine ("Id: {0}", comp.Id);
                                            gc.PhoneNumber   = contact_fax;
                                            gc.ContactPerson = comp.FullName;
                                            gc.Organization  = comp.Org;
                                            records.Add(gc);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(records);
        }
Ejemplo n.º 29
0
        public ActionResult <IEnumerable <BookDto> > GetBooks([FromRoute] int bookShopId, [FromQuery] BookQuery bookQuery)
        {
            var bookDtos = _bookService.GetAllBySQL(bookShopId, bookQuery);

            return(Ok(bookDtos));
        }
Ejemplo n.º 30
0
 public async Task <SearchResult <Book> > SearchAsync(BookQuery query)
 => (await _books.SearchAsync(query)).Project(b => b.Convert(_services));
Ejemplo n.º 31
0
        public IActionResult Index(BookQuery query)
        {
            var list = book.GetList(query);

            return(View(list));
        }