Ejemplo n.º 1
0
        public void relationships_work()
        {
            var cover = new BookCover
            {
                BookID   = "123",
                BookName = "test book " + Guid.NewGuid().ToString()
            };

            cover.Save();

            var mark = new BookMark
            {
                BookCover = cover.ToReference(),
                BookName  = cover.BookName,
            };

            mark.Save();

            cover.BookMarks.Add(mark);

            var res = cover.BookMarks.ChildrenQueryable().First();

            Assert.AreEqual(cover.BookName, res.BookName);

            Assert.AreEqual(res.BookCover.ToEntity().ID, cover.ID);
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,BookId,ModifiedDate,ModifiedBy")] BookCover bookCover)
        {
            if (id != bookCover.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(bookCover);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BookCoverExists(bookCover.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["BookId"] = new SelectList(_context.Books, "Id", "Id", bookCover.BookId);
            return(View(bookCover));
        }
            static BookCover()
            {
                TitleProperty  = DomainProperty.Register <string, BookCover>("Title");
                NumberProperty = DomainProperty.Register <string, BookCover>("Number");

                Empty = new BookCoverEmpty();
            }
Ejemplo n.º 4
0
        public async Task relationships_work()
        {
            await DB.InitAsync(dbName);

            DB.DatabaseFor <BookCover>(dbName);
            DB.DatabaseFor <BookMark>(dbName);

            var cover = new BookCover
            {
                BookID   = "123",
                BookName = "test book " + Guid.NewGuid().ToString()
            };
            await cover.SaveAsync();

            var mark = new BookMark
            {
                BookCover = cover.ToReference(),
                BookName  = cover.BookName,
            };

            await mark.SaveAsync();

            await cover.BookMarks.AddAsync(mark);

            var res = await cover.BookMarks.ChildrenQueryable().FirstAsync();

            Assert.AreEqual(cover.BookName, res.BookName);

            Assert.AreEqual((await res.BookCover.ToEntityAsync()).ID, cover.ID);
        }
        public void ValueObjectHashCode()
        {
            var cover1 = new BookCover("照片1", "1");
            var cover2 = new BookCover("照片1", "1");

            Assert.IsTrue(cover1.GetHashCode() == cover2.GetHashCode());
            Assert.IsTrue(cover1.Equals(cover2));
        }
Ejemplo n.º 6
0
 public Promotion(string pID, string pModelNumber, BookCover pSelfCover)
 {
     ID = pID;
     str_ModelNumber = pModelNumber;
     SelfCover       = pSelfCover;
     IDList          = new List <BookInfo>();
     PageList        = new List <Page>();
     IdDictionary    = new Dictionary <string, int>();
     maxPageCode     = 0;
 }
Ejemplo n.º 7
0
 public void ChangeCover(Image image, string text)
 {
     try
     {
         BookCover cover = new BookCover(image, text);
         book.AddCover(cover);
     }
     catch
     {
     }
 }
Ejemplo n.º 8
0
        public async Task <IActionResult> Create([Bind("Id,BookId,ModifiedDate,ModifiedBy")] BookCover bookCover)
        {
            if (ModelState.IsValid)
            {
                _context.Add(bookCover);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["BookId"] = new SelectList(_context.Books, "Id", "Id", bookCover.BookId);
            return(View(bookCover));
        }
Ejemplo n.º 9
0
 public Promotion(BookCover pSelfCover, List <Page> pPageList, int pDecorativeNumber)
 {
     ModelNumber      = 0;
     DecorativeNumber = 0;
     SelfCover        = pSelfCover;
     PageList         = pPageList;
     DecorativeNumber = pDecorativeNumber;
     IDList           = new List <BookInfo>();
     IdDictionary     = new Dictionary <string, int>();
     ID          = null;
     CataTempNum = 0;
     maxPageCode = 0;
 }
Ejemplo n.º 10
0
 public void AddCover(Image image, string coverId)
 {
     try
     {
         BookCover cover = new BookCover(image, coverId);
         book.AddCover(cover);
         libraryPresenter.Container.books.Add(book);
         libraryPresenter.Container.Save();
         MessageBox.Show("Done");
     }
     catch
     {
     }
 }
Ejemplo n.º 11
0
    /// <summary>
    /// 添加一本书
    /// </summary>
    /// <param name="cover"></param>
    public BookProfebSc AddLastToBookrack(BookCover cover)
    {
        GameObject   obj = Instantiate(BookPrefab, BookPrefab.transform.position, BookPrefab.transform.rotation) as GameObject;
        BookProfebSc sc  = obj.GetComponent <BookProfebSc>();

        sc.Index          = _bookList.Count - 1;
        sc.DefaultTexture = DefaultCoverTexture1;
        AllBookImgs.Add(obj.GetComponent <Image>());
        sc.selfCover = cover;
        //Imgs.Add(ri, _bookList[_bookList.Count - 1].SelfCover.PictureUrl);
        obj.transform.parent = BookContent.transform;
        obj.SetActive(true);
        obj.transform.GetChild(0).gameObject.SetActive(true);
        return(sc);
    }
Ejemplo n.º 12
0
 /// <summary>
 /// 添加书
 /// </summary>
 public void AddBook()
 {
     if (!_loadImgFlg && !UpService.UpInstance.IsAddingBook())
     {
         BookCover   SelfCover = new BookCover();
         List <Page> bop       = new List <Page>();
         Promotion   boo       = new Promotion(SelfCover, bop, 0);
         _bookList.Add(boo);
         UpService.UpInstance.AddBook(boo, AddLastToBookrack(SelfCover));
     }
     else if (UpService.UpInstance.IsAddingBook())
     {
         AddBtn.interactable = false;
     }
 }
Ejemplo n.º 13
0
        public void save_entity_works()
        {
            var cover = new BookCover
            {
                BookID   = "123",
                BookName = "test book " + Guid.NewGuid().ToString()
            };

            cover.Save();
            Assert.IsNotNull(cover.ID);

            var res = db.Find <BookCover>().One(cover.ID);

            Assert.AreEqual(cover.ID, res.ID);
            Assert.AreEqual(cover.BookName, res.BookName);
        }
Ejemplo n.º 14
0
    /// <summary>
    /// Insert a new book cover
    /// </summary>
    /// <param name="bookInstanceID"></param>
    /// <param name="productID"></param>
    /// <param name="sDropFolder"></param>
    /// <param name="sCoverFileName"></param>
    /// <returns></returns>
    public BookCover AddBookCover(decimal bookInstanceID, decimal productID, string sDropFolder, string
                                  sCoverFileName)
    {
        SDSPortalApplication app        = new SDSPortalApplication();
        BookCover            _bookcover = new BookCover();

        _bookcover.DATE_ADDED       = DateTime.Now;
        _bookcover.BOOK_INSTANCE_ID = bookInstanceID;
        _bookcover.COVER_FILE_PATH  = string.Format(sDropFolder + "{0}" + "Product_" + productID.ToString() + "{1}", "\\", "\\Cover");
        _bookcover.COVER_FILE_NAME  = sCoverFileName;
        _bookcover.COVER_FILE_TYPE  = "PDF";
        _bookcover.COVER_FILE_DATE  = DateTime.Now;
        _bookcover.DATE_ADDED       = DateTime.Now;

        _bookcover.Add(app.SDSConnection);
        return(_bookcover);
    }
Ejemplo n.º 15
0
        public async Task <int> UpdateBookAsync(BookServiceModel book)
        {
            _logger.LogInformation("UpdateBookAsync");
            var bookDto = await _unitOfWork.Books.GetByIdAsync(book.Id);

            bookDto.Name       = book.Name;
            bookDto.Author     = book.Author;
            bookDto.Isbn       = book.Isbn;
            bookDto.Price      = book.Price;
            bookDto.Quantity   = book.Quantity;
            bookDto.LanguageId = book.LanguageId;

            _unitOfWork.Books.Update(bookDto);

            if (book.imageOfCover.LengthOfFile > 0)
            {
                var coverDto = await Task.Run(() => _unitOfWork.BookCovers.Get(bc => bc.BookId == book.Id).FirstOrDefault());

                if (coverDto != null)
                {
                    coverDto.BodyOfFile   = book.imageOfCover.BodyOfFile;
                    coverDto.NameOfFile   = book.imageOfCover.NameOfFile;
                    coverDto.LengthOfFile = book.imageOfCover.LengthOfFile;
                    coverDto.TypeOfFile   = book.imageOfCover.TypeOfFile;
                    _unitOfWork.BookCovers.Update(coverDto);
                }
                else
                {
                    coverDto = new BookCover
                    {
                        BodyOfFile   = book.imageOfCover.BodyOfFile,
                        NameOfFile   = book.imageOfCover.NameOfFile,
                        LengthOfFile = book.imageOfCover.LengthOfFile,
                        TypeOfFile   = book.imageOfCover.TypeOfFile,
                        BookId       = book.Id
                    };
                    await _unitOfWork.BookCovers.CreateAsync(coverDto);
                }
            }
            await _unitOfWork.SaveAsync();

            return(book.Id);
        }
Ejemplo n.º 16
0
        public void AddBookCover(string sourceFilePath, int bookId)
        {
            var bookCovers = "BookCovers";

            var fileType = Path.GetExtension(sourceFilePath);
            var fileName = Path.GetFileName(sourceFilePath);

            var sp       = new StoredProcedure();
            var fileGuid = sp.GetBookCoverGuid(fileName);

            using ApplicationContext ctx = new ApplicationContext();
            var dbFile = new DbFile(fileGuid, bookCovers, fileName, fileType);

            ctx.DbFiles.Add(dbFile);
            ctx.SaveChanges();

            var bookCover = new BookCover(dbFile.Id, bookId);

            ctx.BookCovers.Add(bookCover);
            ctx.SaveChanges();
        }
Ejemplo n.º 17
0
 /// <summary>
 /// 刷新封面模板的显示
 /// </summary>
 public void RefreshCoverModel(BookCover pCover, bool isDisplay)
 {
     //Debug.Log((pCover == null) + ";" + ";");
     if (ModelNumDic.ContainsKey(pCover.ModelNumber))
     {
         foreach (int key in ModelNumDic.Keys)
         {
             if (pCover.ModelNumber != key)
             {
                 ModelNumDic[key].gameObject.SetActive(false);
             }
             else
             {
                 ModelNumDic[key].gameObject.SetActive(true);
             }
         }
         BookCoverParams bcp = new BookCoverParams(pCover, ModelNumDic[pCover.ModelNumber], isDisplay ? BookRoot : null);
         //Debug.Log("bcp.items == null ? " + bcp.Items == null);
         InitializeModel(bcp);
     }
 }
Ejemplo n.º 18
0
        public async Task save_entity_works()
        {
            DB.DatabaseFor <BookCover>(dbName);
            DB.DatabaseFor <BookMark>(dbName);

            await DB.InitAsync(dbName);

            var cover = new BookCover
            {
                BookID   = "123",
                BookName = "test book " + Guid.NewGuid().ToString()
            };

            await cover.SaveAsync();

            Assert.IsNotNull(cover.ID);

            var res = await DB.Find <BookCover>().OneAsync(cover.ID);

            Assert.AreEqual(cover.ID, res.ID);
            Assert.AreEqual(cover.BookName, res.BookName);
        }
Ejemplo n.º 19
0
        public IActionResult PostBook([FromForm] BookCover bcover)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            // Getting Name
            Book book = bcover.book;

            // Getting Image
            var image = bcover.image;

            //Determine the next ID
            var newID = _context.Books.Select(x => x.Id).Max() + 1;

            book.Id = newID;

            // Saving Image on Server
            if (image != null && image.Length > 0)
            {
                string path = "CoverImage/" + image.FileName;
                book.CoverImage = path;

                using (var fileStream = new FileStream(path, FileMode.Create))
                {
                    image.CopyTo(fileStream);
                }
            }


            _context.Books.Add(book);
            _context.SaveChanges();

            //return CreatedAtAction("GetBook", new { id = book.Id }, book);
            return(Ok(new { status = true, message = "Book added successfully." }));
        }
Ejemplo n.º 20
0
        private void BuildWidgets ()
        {
            var hbox = new HBox () { Spacing = 12 };

            // Left box - cover art, title, etc
            var left_box = new VBox () { BorderWidth = 12, Spacing = 12 };

            // Cover art
            cover = new BookCover (this) {
                WidthRequest = 300,
                HeightRequest = 300
            };

            var editable_cover = CoverArtEditor.For (
                cover, (x, y) => true,
                () => library.TrackModel[0],
                UpdateCover
            );

            // Title
            title_label = new WrapLabel ();

            resume_button = new ImageButton ("", null, IconSize.LargeToolbar);
            resume_button.ImageWidget.Stock = Stock.MediaPlay;
            resume_button.LabelWidget.Xalign = 0;
            resume_button.Spacing = 6;

            // FIXME the left padding on this is not right
            rating_entry = new RatingEntry () {
                AlwaysShowEmptyStars = true,
                HasFrame = false
            };
            var rating = new HBox ();
            rating.PackStart (rating_entry, false, false, 0);

            // Packing
            left_box.PackStart (editable_cover, false, false,  0);
            left_box.PackStart (title_label, false, false,  0);
            left_box.PackStart (resume_button, false, false,  0);
            //left_box.PackStart (rating, false, false,  0);

            hbox.PackStart (left_box, false, false, 0);

            // Right box - track list
            track_list = new BaseTrackListView () {
                HeaderVisible = true,
                IsEverReorderable = false
            };

            var columns = new DefaultColumnController ();
            var file_columns = new ColumnController ();
            var disc_column = DefaultColumnController.Create (
                    BansheeQuery.DiscNumberField, 0.02, false, new ColumnCellPositiveInt (null, false, 2, 2));

            file_columns.AddRange (
                columns.IndicatorColumn,
                disc_column,
                columns.TitleColumn,
                columns.DurationColumn
            );
            file_columns.SortColumn = columns.DiscNumberAndCountColumn;

            foreach (var col in file_columns) {
                col.Visible = true;
            }

            var track_sw = new Gtk.ScrolledWindow () {
                Child = track_list,
                ShadowType = ShadowType.None
            };

            track_list.ColumnController = file_columns;

            hbox.PackEnd (track_sw, true, true, 0);

            Child = hbox;
        }
Ejemplo n.º 21
0
        public override void Dispose ()
        {
            if (cover != null) {
                cover.Dispose ();
                cover = null;
            }

            base.Dispose ();
        }
Ejemplo n.º 22
0
        public IActionResult PutBook(int id, [FromForm] BookCover bcover)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            // Getting Name
            Book book = bcover.book;

            // Getting Image
            var image = bcover.image;

            if (id != book.Id)
            {
                return(BadRequest());
            }

            // Saving Image on Server
            if (image != null && image.Length > 0)
            {
                //Delete old file
                if (System.IO.File.Exists(book.CoverImage))
                {
                    try
                    {
                        System.IO.File.Delete(book.CoverImage);
                    }
                    catch
                    {
                    }
                }

                string path = "CoverImage/" + image.FileName;
                book.CoverImage = path;

                using (var fileStream = new FileStream(path, FileMode.Create))
                {
                    image.CopyTo(fileStream);
                }
            }

            _context.Entry(book).State = EntityState.Modified;

            try
            {
                _context.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!BookExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            //return NoContent();
            return(Ok(new { status = true, message = "Book updated successfully." }));
        }
Ejemplo n.º 23
0
 public BookCoverParams(BookCover pbookCover, Content pcoverModelSc)
 {
     bookCover    = pbookCover;
     coverModelSc = pcoverModelSc;
 }
Ejemplo n.º 24
0
 public BookCoverParams(BookCover pbookCover, Content pcoverModelSc, GameObject pSetActiveObj)
 {
     bookCover    = pbookCover;
     coverModelSc = pcoverModelSc;
     SetActiveObj = pSetActiveObj;
 }
Ejemplo n.º 25
0
    public void Init(XmlParam param)
    {
        string xmlStr = param.xmlStr;

        Camera.main.GetComponent <MsgCenter_h>().TestText.text += "\nInit(XmlParam param)";

        if (xmlStr != null && xmlStr != string.Empty && xmlStr != "")
        {
            Debug.Log("Init : " + param.xmlStr);
            List <Promotion> pros    = new List <Promotion>();
            XmlElement       xmlRoot = GetXmlElement(param.xmlStr);
            BookCover        cover;
            Promotion        pro = null;
            maxCode = 0;
            int     tmp     = 0;
            XmlNode xmlNode = null;
            //Camera.main.GetComponent<MsgCenter_h>().TestText.text += param.xmlStr + "\n";
            if (xmlRoot["brochure_list"] != null)
            {
                //Debug.Log("if");
                foreach (XmlNode node in xmlRoot["brochure_list"].ChildNodes)
                {
                    pro   = null;
                    cover = null;
                    if (node.Attributes["brochure_code"] != null)
                    {
                        tmp = int.Parse(node.Attributes["brochure_code"].Value);
                    }
                    else
                    {
                        tmp = -1;
                    }
                    try
                    {
                        pro = new Promotion(node.Attributes["brochure_id"].Value,
                                            node.Attributes["brochure_templet_id"].Value);

                        cover = new BookCover(node.Attributes["brochure_file_url"].Value);
                    }
                    catch (Exception exc)
                    {
                        Debug.Log(exc.Message);
                        //throw;
                    }
                    finally
                    {
                        if (tmp > maxCode)
                        {
                            maxCode = tmp;
                        }
                        if (pro != null)
                        {
                            pros.Add(pro);
                            if (cover != null)
                            {
                                pro.SelfCover = cover;
                            }
                            else
                            {
                                pro.SelfCover = new BookCover();
                            }
                        }
                        if (xmlNode == null)
                        {
                            xmlNode = node;
                        }
                    }
                }
                //Debug.Log("if_after");
            }
            else
            {
                Camera.main.GetComponent <MsgCenter_h>().TestText.text += "\nerr : xmlRoot[\"brochure_list\"] == null !\n";
                Debug.Log("err : xmlRoot[\"brochure_list\"] == null");
            }
            Debug.Log("---------------->>>>>>>>>>>>>>>>>>>>" + maxCode);
            if (!string.IsNullOrEmpty(Bookrack.Instance.GetAttribute(xmlNode)))
            {
                _book = pros;
                Camera.main.GetComponent <MsgCenter_h>().TestText.text += "\nbook.Count = " + _book.Count.ToString() + "\n";
                XmlParam xmlParam;
                //Camera.main.GetComponent<MsgCenter_h>().TestText.text += "     _book.Count" + _book.Count;//
                //Debug.Log(_book.Count);
                for (int i = 0; i < _book.Count; i++)
                {
                    xmlParam = new XmlParam("3D404767", "page", "brochure_id=\"" + _book[i].ID + "\" " + "layout_kind = \"1\"", AnalysisCoverLeyout, _book[i]);
                    GetTarXml(xmlParam);
                }
            }
        }

        Camera.main.GetComponent <MsgCenter_h>().TestText.text += "\nOverInit(XmlParam param)";
    }
Ejemplo n.º 26
0
        static async Task Main(string[] args)
        {
            var assembly = Assembly.GetExecutingAssembly();

            var configuration = ConsoleConfigurationBuilder.BuildConfiguration(args, assembly);

            var serviceRegistry = new ServiceRegistry();

            serviceRegistry.Scan(s =>
            {
                // Look for any registry in a DLL we built.
                s.AssembliesAndExecutablesFromApplicationBaseDirectory(f => f?.FullName?.StartsWith("Fulgoribus.", StringComparison.OrdinalIgnoreCase) ?? false);

                s.LookForRegistries();
            });
            serviceRegistry.AddHttpClient();
            // Need to use a lamba to resolve the SqlConnection because trying to bind by type was going off into setter injection land.
            serviceRegistry.For <IDbConnection>().Use(_ => new SqlConnection(configuration.GetConnectionString("DefaultConnection"))).Scoped();
            using var container = new Container(serviceRegistry);

            var bookRepo    = container.GetInstance <IBookRepository>();
            var regexVolume = new Regex("[0-9]+[0-9.]*", RegexOptions.Compiled);
            var regexCover  = new Regex(@"""https:\/\/c\.bookwalker\.jp\/([0-9]+)\/.*\.jpg""", RegexOptions.Compiled);

            Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
            var httpClientFactory = container.GetInstance <IHttpClientFactory>();

            using (var sqlConnection = new SqlConnection(configuration.GetConnectionString("DefaultConnection")))
                using (var reader = new StreamReader(configuration["BookwalkerImport:ImportPath"], Encoding.GetEncoding(932)))
                    using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture))
                    {
                        csv.Configuration.RegisterClassMap <BookwalkerBookMap>();
                        await foreach (var record in csv.EnumerateRecordsAsync(new BookwalkerBook()))
                        {
                            if (record.Url?.StartsWith("https://global.bookwalker.jp") ?? false)
                            {
                                if (record.Category == Categories.ArtBook ||
                                    record.Category == Categories.BookshelfSkin ||
                                    record.Category == Categories.LiteratureAndNovels ||
                                    record.Category == Categories.Manga ||
                                    record.Category == Categories.NonFiction)
                                {
                                    // Do nothing.
                                }
                                else if (record.Category == Categories.LightNovel)
                                {
                                    var bookId = record.Url.Replace("https://global.bookwalker.jp/", string.Empty).Replace("/", string.Empty);

                                    var book = await bookRepo.GetBookByRetailerAsync("BW", bookId);

                                    if (book == null)
                                    {
                                        book = new Book
                                        {
                                            Title       = record.Title,
                                            ReleaseDate = record.ReleaseDate,
                                            Label       = record.Label
                                        };
                                        await bookRepo.SaveBookAsync(book);

                                        var seriesTitle = record.Series.GetValueOrNull();
                                        if (seriesTitle != null)
                                        {
                                            var series = await bookRepo.GetSeriesAsync(seriesTitle);

                                            if (series == null)
                                            {
                                                series = new Series
                                                {
                                                    Title = seriesTitle
                                                };
                                                await bookRepo.SaveSeriesAsync(series);
                                            }

                                            // Try to get the sort order as the first number in the title (to handle Kokoro Connect Volumes 9/10) that is not
                                            // part of the series (to handle 86).
                                            decimal?sortOrder        = null;
                                            var     titleForParsing  = book.Title.Replace(seriesTitle, string.Empty);
                                            var     volumeCandidates = regexVolume.Matches(titleForParsing);
                                            var     books            = await bookRepo.GetSeriesBooksAsync(series.SeriesId !.Value);

                                            if (volumeCandidates.Any())
                                            {
                                                // Take the first one.
                                                sortOrder = Convert.ToDecimal(volumeCandidates.First().Value);

                                                // Make sure this doesn't collide with an existing volume. (e.g. Ascendance of a Bookworm)
                                                if (books.Any(b => b.SortOrder == sortOrder))
                                                {
                                                    sortOrder = null;
                                                }
                                            }

                                            if (!sortOrder.HasValue)
                                            {
                                                Console.WriteLine($"Unknown series order for series {seriesTitle}, book {book.Title}. Picking next available integer.");
                                                if (books.Any())
                                                {
                                                    var lastSortOrder = books.Last().SortOrder !.Value;
                                                    sortOrder = Math.Ceiling(lastSortOrder);
                                                    if (sortOrder == lastSortOrder)
                                                    {
                                                        sortOrder += 1;
                                                    }
                                                }
                                                else
                                                {
                                                    sortOrder = 1;
                                                }
                                            }
                                            var seriesBook = new SeriesBook
                                            {
                                                Series    = series,
                                                Book      = book,
                                                SortOrder = sortOrder,
                                                Volume    = sortOrder.ToString()
                                            };
                                            await bookRepo.SaveSeriesBookAsync(seriesBook);
                                        }

                                        var bookRetailer = new BookRetailer
                                        {
                                            BookId      = book.BookId,
                                            RetailerId  = "BW",
                                            RetailerKey = bookId
                                        };
                                        await bookRepo.SaveBookRetailerAsync(bookRetailer);
                                    }

                                    if (book.BookId.HasValue)
                                    {
                                        var cover = await bookRepo.GetBookCoverAsync(book.BookId.Value);

                                        if (cover == null)
                                        {
                                            cover = new BookCover
                                            {
                                                BookId = book.BookId.Value
                                            };

                                            try
                                            {
                                                var client = httpClientFactory.CreateClient();
                                                var body   = await client.GetStringAsync(record.Url);

                                                var matches = regexCover.Matches(body);
                                                if (matches.Any() && int.TryParse(new string(matches.First().Groups[1].Value.Reverse().ToArray()), out var id))
                                                {
                                                    var imageUrl = "http://c.bookwalker.jp/coverImage_" + (id - 1) + ".jpg";
                                                    var result   = await client.GetAsync(imageUrl);

                                                    if (result.StatusCode == HttpStatusCode.Forbidden)
                                                    {
                                                        // Try using the URL as-is. Not as good as the full-fat cover but it will do.
                                                        var quotedUrl = matches.First().Value;
                                                        var url       = quotedUrl[1..^ 1];
Ejemplo n.º 27
0
 public void Init()
 {
     SelfCover = new BookCover();
     PageList  = new List <Page>();
 }
Ejemplo n.º 28
0
        protected override void Dispose(bool disposing)
        {
            if (disposing) {
                if (cover != null) {
                    cover.Dispose ();
                    cover = null;
                }
            }

            base.Dispose (disposing);
        }