public async Task <IActionResult> ReparseRawBookData([FromBody] BookLoader request) { try { if (request == null) { throw new ArgumentException("Missing request"); } if (string.IsNullOrEmpty(request.Isbn)) { throw new ArgumentException("Missing ISBN"); } if (request.Isbn.Any(c => !char.IsLetterOrDigit(c))) { throw new ArgumentException("Invalid ISBN"); } var rawData = await _bookRepo.GetRawData(request.Isbn) ?? throw new ArgumentException("Invalid ISBN"); DataScraperFactory.ReparseBookData(rawData); await _bookRepo.StoreRawData(rawData); var bookId = await _bookRepo.GetOne(request.Isbn, x => x.Id); var newBook = await DataScraperFactory.CreateBook(rawData); await _bookRepo.Update(bookId, newBook); return(Ok()); } catch (ArgumentException ex) { _log.LogWarning(ex, ex.Message); return(BadRequest(ex.Message)); } catch (Exception ex) { _log.LogError(ex, ex.Message); return(StatusCode(500, ex.Message)); } }
private async Task PinRecord(PinRecord Record) { BookItem Book = await ItemProcessor.GetBookFromId(Record.Id); if (Book == null) { return; } TaskCompletionSource <bool> TCS = new TaskCompletionSource <bool>(); BookLoader BL = new BookLoader(async(b) => { if (b != null) { string TileId = await PageProcessor.PinToStart(Book); if (!string.IsNullOrEmpty(TileId)) { PM.RegPin(b, TileId, false); } } TCS.SetResult(true); }); BL.Load(Book); await TCS.Task; }
public void UpdateInterface(UpdateInterfaceParams pars) { switch (pars.Type) { case TurnType.TurnFromRight: { UpdateLeftRightPage(BookLoader.Instance().PreviousPageLeftPart, BookLoader.Instance().PreviousPageRightPart, BookLoader.Instance().CurrentPageLeftPage, BookLoader.Instance().CurrentPageRightPage, BookLoader.Instance().NextPageLeftPart, BookLoader.Instance().NextPageRightPart); this.AnimateToNextPage(500); break; } case TurnType.TurnFromLeft: { UpdateLeftRightPage(BookLoader.Instance().PreviousPageLeftPart, BookLoader.Instance().PreviousPageRightPart, BookLoader.Instance().CurrentPageLeftPage, BookLoader.Instance().CurrentPageRightPage, BookLoader.Instance().NextPageLeftPart, BookLoader.Instance().NextPageRightPart); this.AnimateToPreviousPage(500); break; } case TurnType.NoTurn: { UpdateLeftRightPage(BookLoader.Instance().PreviousPageLeftPart, BookLoader.Instance().PreviousPageRightPart, BookLoader.Instance().CurrentPageLeftPage, BookLoader.Instance().CurrentPageRightPage, BookLoader.Instance().NextPageLeftPart, BookLoader.Instance().NextPageRightPart); break; } default: { break; } } }
public void OnCompleteAnimation() { try { if (!BookLoader.Instance().CanTurnLeft) { leftPage.IsBottomLeftCornerEnabled = false; leftPage.IsTopLeftCornerEnabled = false; } else { leftPage.IsBottomLeftCornerEnabled = true; leftPage.IsTopLeftCornerEnabled = true; } if (!BookLoader.Instance().CanTurnRight) { rightPage.IsBottomRightCornerEnabled = false; rightPage.IsTopRightCornerEnabled = false; } else { rightPage.IsBottomRightCornerEnabled = true; rightPage.IsTopRightCornerEnabled = true; } BookLoader.Instance().UpdatePrePageToCurrentPage(); UpdateLeftRightPage(BookLoader.Instance().PreviousPageLeftPart, BookLoader.Instance().PreviousPageRightPart, BookLoader.Instance().CurrentPageLeftPage, BookLoader.Instance().CurrentPageRightPage, BookLoader.Instance().NextPageLeftPart, BookLoader.Instance().NextPageRightPart); } catch (Exception ex) { MessageBox.Show("OnCompleteAnimation: " + ex.Message); } }
private void OpenBook(BookItem Book) { ThisBook = Book; Shared.CurrentBook = Book; PageProcessor.ReadSecondaryTile(Book); CacheStateStory.Begin(); BookLoading = true; if (Book.IsEx()) { Book.XSetProp("Mode", X.Const <string>(XProto.WProtocols, "ACTION_BOOK_META")); } BookLoader BL = new BookLoader(BookLoadComplete); BL.Load(Book, true); BL.LoadIntro(Book, true); BL.LoadCover(Book, true); SyncAnchors(); SetContext(); }
private void ImageReloadCover() { BookLoader BL = new BookLoader(); ThisBook.Info.CoverSrcUrl = null; BL.LoadCover(ThisBook, false); }
public void ParserShouldReadAllMarkdown() { var loader = new BookLoader("SupportedMarkdown.md"); var book = loader.Load(); Assert.Single(book.Chapters); }
private void setupUI() { mainMask.Visibility = Visibility.Collapsed; Page1Sheet.curlShadow.Visibility = Visibility.Collapsed; //BookData = new BookLoader(); BookLoader.Instance();//force init data, and download menudata.xml BookLoader.Instance().Attach(this); this.pageWidth = 1200;// 900; this.pageHeight = 600; this.pageHalfWidth = this.pageWidth * 0.5; this.pageHalfHeight = this.pageHeight * 0.5; BookSizes bs = new BookSizes() { layoutRootW = pageWidth, layoutRootH = pageHeight, layoutRootHalfH = pageHeight / 2, layoutRootHalfW = pageHalfWidth }; this.LayoutRoot.DataContext = bs; this.rutieow.SetValue(Canvas.LeftProperty, this.pageHalfWidth); this.rutieow.SetValue(Canvas.TopProperty, this.pageHalfHeight); this.PageCorner.SetValue(Canvas.LeftProperty, this.pageHalfWidth - 100.0); this.PageCorner.SetValue(Canvas.TopProperty, this.pageHalfHeight - 100.0); this.spineTop = new Point(0.0, -this.pageHalfHeight); this.spineBottom = new Point(0.0, this.pageHalfHeight); this.fixedRadius = this.pageHalfWidth; this.maskSize.X = this.pageHalfWidth; this.maskSize.Y = this.pageHeight * 1.6; this.mainMask.Width = this.maskSize.X; this.mainMask.Height = this.maskSize.Y; this.mainMask.SetValue(Canvas.TopProperty, this.pageHeight - (this.maskSize.Y * 0.8)); this.mouse.X = this.pageHalfWidth - 1.0; this.mouse.Y = this.pageHalfHeight - 1.0; this.follow.X = this.mouse.X; this.follow.Y = this.mouse.Y; this.corner.X = this.mouse.X; this.corner.Y = this.mouse.Y; this.PageCorner.MouseLeftButtonDown += new MouseButtonEventHandler(this.PageCorner_MouseLeftButtonDown); this.PageCorner.MouseMove += new MouseEventHandler(this.PageCorner_MouseMove); this.PageCorner.MouseLeftButtonUp += new MouseButtonEventHandler(this.PageCorner_MouseLeftButtonUp); this.PageCorner.MouseLeave += new MouseEventHandler(this.PageCorner_MouseLeave); this.Page1Sheet.Effect = new CustomPixelShader.Effects.GutterBookEffect(); this.Page2SheetSection2.Effect = new CustomPixelShader.Effects.GutterBookEffect(); this.Page1TraceSheet.Effect = new CustomPixelShader.Effects.GutterBookEffect(); }
public CatalogueController(BusinessService businessService, CatalogueService catService, SignInManager <ApplicationUser> signInManager, UserManager <ApplicationUser> userManager) { _businessService = businessService; _catalogueService = catService; _signInManager = signInManager; _userManager = userManager; _bookLoader = new BookLoader(businessService); }
public MasterPage() { InitializeComponent(); _timer.Duration = TimeSpan.FromMilliseconds(30); _timer.Completed += new EventHandler(_timer_Completed); _timer.Begin(); BookLoader.Instance().Attach(this); }
public UCBook() { InitializeComponent(); leftPage.Attach(this); rightPage.Attach(this); BookLoader.Instance();//force init data, and download menudata.xml BookLoader.Instance().Attach(this); this.Loaded += new RoutedEventHandler(UCBook_Loaded); }
public HtmlRendererTests() { var loader = new BookLoader("SupportedMarkdown.md"); var book = loader.Load(); var renderer = new HtmlRenderer(new RenderOptions()); _html = renderer.RenderBook(book).ToString(); File.WriteAllText("SupportedMarkdown.html", _html); }
public static async Task <AsyncTryOut <Chapter> > TryGetAutoAnchor(BookItem Book, bool Sync = true) { StringResources stx = StringResources.Load("LoadingMessage"); if (Sync) { MessageBus.SendUI(typeof(PageProcessor), stx.Str("SyncingAnchors"), Book.ZItemId); await new AutoAnchor(Book).SyncSettings(); } MessageBus.SendUI(typeof(PageProcessor), stx.Str("ProgressIndicator_Message"), Book.ZItemId); TaskCompletionSource <TOCSection> TCS = new TaskCompletionSource <TOCSection>(); BookLoader BLoader = new BookLoader(b => { if (b == null) { TCS.TrySetResult(null); } else { MessageBus.SendUI(typeof(PageProcessor), stx.Str("LoadingVolumes"), Book.ZItemId); new VolumeLoader(b2 => { if (b2 == null) { TCS.TrySetResult(null); } else { TCS.TrySetResult(new TOCSection(b2)); } }).Load(b); } }); BLoader.Load(Book, true); TOCSection TOCData = await TCS.Task; if (TOCData == null) { return(new AsyncTryOut <Chapter>(false, null)); } if (TOCData.AnchorAvailable) { return(new AsyncTryOut <Chapter>(true, TOCData.AutoAnchor)); } else { return(new AsyncTryOut <Chapter>(false, TOCData.FirstChapter)); } }
public MainWindow() { InitializeComponent(); GroupBox newGroupBox = FormCreator.CreateGroupBox("MainGroup", "Book", new Thickness(0, 0, 0, 0), 887, 384); Grid g = new BookLoader().Load(new Book()); g.Children.Add(new BookLoader().CreateButtonsGroup("Book")); newGroupBox.Content = g; MainGrid.Children.Add(newGroupBox); }
void LoadBookList() { _container = new BookContainer(); var idList = BookLoader.LoadBookIdList(); foreach (var id in idList) { if (!id.Equals(String.Empty)) { AddBook(id); } } }
public void OnCompleteAnimation() { try { BookLoader.Instance().UpdatePrePageToCurrentPage(); UpdateLeftRightPage(BookLoader.Instance().PreviousPageLeftPart, BookLoader.Instance().PreviousPageRightPart, BookLoader.Instance().CurrentPageLeftPage, BookLoader.Instance().CurrentPageRightPage, BookLoader.Instance().NextPageLeftPart, BookLoader.Instance().NextPageRightPart); } catch (Exception ex) { MessageBox.Show("OnCompleteAnimation: " + ex.Message); } }
public async Task <IActionResult> SearchForBookData([FromBody] BookLoader request) { try { if (request == null) { throw new ArgumentException("Missing request"); } if (string.IsNullOrEmpty(request.Isbn)) { throw new ArgumentException("Missing ISBN"); } if (request.Isbn.Any(c => !char.IsLetterOrDigit(c))) { throw new ArgumentException("Invalid ISBN"); } var chk = await _bookRepo.GetOne(request.Isbn, x => x.Id); if (chk != ObjectId.Empty) { throw new ArgumentException($"Book already loaded for '{request.Isbn}'") { HelpLink = chk.ToString() } } ; var extnData = await DataScraperFactory.GetBookDataFromWeb(request.Isbn); await _bookRepo.StoreRawData(extnData); var bk = await DataScraperFactory.CreateBook(extnData); var newId = await _bookRepo.Insert(bk); return(Ok(newId.ToString())); } catch (ArgumentException ex) { _log.LogWarning(ex, ex.Message); if (ex.HelpLink != null) { return(BadRequest(new ErrorMessageModel { Message = ex.Message, BookId = ex.HelpLink })); } return(BadRequest(ex.Message)); } catch (SearchFailedException ex) { _log.LogWarning(ex, ex.Message); return(BadRequest(ex.Message)); } catch (Exception ex) { _log.LogError(ex, ex.Message); return(StatusCode(500, ex.Message)); } }
private void ReloadBtn_Click(object sender, RoutedEventArgs e) { if (BookLoading) { return; } BookLoading = true; CacheStateStory.Begin(); BookLoader BL = new BookLoader(BookLoadComplete); BL.Load(ThisBook); BL.LoadIntro(ThisBook); }
public object Convert(object value, Type targetType, object parameter, string language) { if (value is BookDisplay BkDisplay) { BookItem BItem = ItemProcessor.GetBookItem(BkDisplay.Entry); if (!BItem.CoverExist) { BookLoader Loader = new BookLoader(); Loader.LoadCover(BItem, true); } return(BItem); } return(null); }
public void AddBook(string id) { if (_container.IsTitleOverlapped(id)) { Viewer.Instance.DrawError(error_titleOverlapped); } else if (_container.IsStorgaeLimit()) { Viewer.Instance.DrawError(error_bookShelf); } else { Book newBook = new Book(id); Viewer.Instance.DrawBook(newBook); _container.AddBook(newBook); BookLoader.SaveBookIdList(_container.GetBookIdList()); } }
static void Main(string[] args) { Configuration programConfiguration; programConfiguration = ConfigurationMenager.ReadConfiguration(); var optionsBuilder = new DbContextOptionsBuilder <TestAppContext>(); optionsBuilder.UseSqlServer(programConfiguration.Connection.ConnectionString); using (var context = new TestAppContext(optionsBuilder.Options)) { AuthorLoader authorLoader = new AuthorLoader(context); authorLoader.LoadMethod(programConfiguration.AuthorsPath); BookLoader bookLoader = new BookLoader(context); bookLoader.LoadMethod(authorLoader.authorsCount, programConfiguration.BooksPath); } }
void _timer_Completed(object sender, EventArgs e) { if (pbar.Value < pbar.Maximum) { //pbar.Value++; pbar.Value += 10; _timer.Begin(); } else { containerContent.RenderTransform = new CompositeTransform(); VisualStateManager.GoToState(this, "Right", true); pbar.Opacity = 0; /*MessageBox.Show("asdf"); * MainPage2 page = FindControl<MainPage2>(containerContent, typeof(MainPage2),""); * page.MoveRight();*/ BookLoader.Instance().GoToFirstMenuPage(); } }
private void ChangePageBeforeTransition(object sender, EventArgs e) { try { this.Page2SheetSection2.sheetImage.Children.Clear(); this.Page1TraceSheet.sheetImage.Children.Clear(); if (BookLoader.Instance().NextPageLeftPart != null) { this.Page2SheetSection2.sheetImage.Children.Add(BookLoader.Instance().NextPageLeftPart); } if (BookLoader.Instance().NextPageRightPart != null) { this.Page1TraceSheet.sheetImage.Children.Add(BookLoader.Instance().NextPageRightPart); } } catch (Exception ex) { MessageBox.Show("ChangePageBeforeTransition: " + ex.Message); } }
public static async Task <string> PinToStart(BookItem Book) { BookLoader BL = new BookLoader(); await BL.LoadCoverAsync(Book, true); string TilePath = await Resources.Image.CreateTileImage(Book); (string Args, string TileId) = TileParams(Book.Entry); SecondaryTile S = new SecondaryTile() { TileId = TileId, DisplayName = Book.Title, Arguments = Args }; S.VisualElements.Square150x150Logo = new Uri(TilePath); S.VisualElements.ShowNameOnSquare150x150Logo = true; if (await S.RequestCreateAsync()) { return(TileId); } return(null); }
private void ChangePageAfterTransition(object sender, EventArgs e) { try { BookLoader.Instance().UpdatePrePageToCurrentPage(); //bCanTransitionRight = BookLoader.Instance().IsCanTransitionRight(); this.Page1Sheet.sheetImage.Children.Clear(); this.Page2SheetSection2.sheetImage.Children.Clear(); this.Page1TraceSheet.sheetImage.Children.Clear(); if (BookLoader.Instance().CurrentPageRightPage != null) { this.Page1Sheet.sheetImage.Children.Add(BookLoader.Instance().CurrentPageRightPage); } if (BookLoader.Instance().NextPageLeftPart != null) { this.Page2SheetSection2.sheetImage.Children.Add(BookLoader.Instance().NextPageLeftPart); } if (BookLoader.Instance().NextPageRightPart != null) { this.Page1TraceSheet.sheetImage.Children.Add(BookLoader.Instance().NextPageRightPart); } //TypeTransition = UpdatePageTransition.Default; this.mouse = new Point(this.pageHalfWidth - 1.0, this.pageHalfHeight - 1.0); this.follow = new Point(this.pageHalfWidth - 1.0, this.pageHalfHeight - 1.0); mainMask.Visibility = Visibility.Collapsed; Page1Sheet.curlShadow.Visibility = Visibility.Collapsed; } catch (Exception ex) { MessageBox.Show("ChangePageAfterTransition: " + ex.Message); } }
private void btPrevious_Click(object sender, RoutedEventArgs e) { BookLoader.Instance().OnPreviousPage(); }
private void btNext_Click(object sender, RoutedEventArgs e) { BookLoader.Instance().OnNextPage(); }
private void btBack_Click(object sender, RoutedEventArgs e) { BookLoader.Instance().OnBack(); }
public void RemoveBook(Book book) { _container.RemoveBook(book); BookLoader.SaveBookIdList(_container.GetBookIdList()); }
void UCBook_Loaded(object sender, RoutedEventArgs e) { //MessageBox.Show("asd"); BookLoader.Instance().FirstCover(); }