Ejemplo n.º 1
0
        private void deleteShelfButton_Click(object sender, EventArgs e)//删除书架
        {
            BookShelf shelf = shelfBindingSource.Current as BookShelf;

            BookShelfService.RemoveBookShelf(shelf.BookShelfId);
            shelfBindingSource.DataSource = BookShelfService.GetAllShelfs();
        }
Ejemplo n.º 2
0
        void TouchAndVerify(BookShelf data, int nExpectedBooks, int optionalPayloadDataSize)
        {
            if (!VerifyAndTouch)
            {
                return;
            }

            string tmpTitle = null;
            int    tmpId    = 0;

            if (nExpectedBooks != data.Books.Count)
            {
                throw new InvalidOperationException($"Number of deserialized Books was {data.Books.Count} but expected {nExpectedBooks}. This Serializer seem to have lost data.");
            }

            for (int i = 0; i < data.Books.Count; i++)
            {
                tmpTitle = data.Books[i].Title;
                tmpId    = data.Books[i].Id;
                if (data.Books[i].Id != i + 1)
                {
                    throw new InvalidOperationException($"Book Id was {data.Books[i].Id} but exepcted {i + 1}");
                }
                if (optionalPayloadDataSize > 0 && data.Books[i].BookData.Length != optionalPayloadDataSize)
                {
                    throw new InvalidOperationException($"BookData length was {data.Books[i].BookData.Length} but expected {optionalPayloadDataSize}");
                }
            }
        }
Ejemplo n.º 3
0
        public async Task <ActionResult <BookShelf> > PostBookShelf(BookShelf bookShelf)
        {
            _context.BookShelf.Add(bookShelf);
            await _context.SaveChangesAsync();

            return(CreatedAtAction(nameof(GetBookShelf), new { id = bookShelf.BookShelfId }, bookShelf));
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> Edit(Guid id, [Bind("Id,BookShelfName,Description,CreateByUserId")] BookShelf bookShelf)
        {
            if (id != bookShelf.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(bookShelf);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BookShelfExists(bookShelf.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CreateByUserId"] = new SelectList(_context.Users, "Id", "Id", bookShelf.CreateByUserId);
            return(View(bookShelf));
        }
Ejemplo n.º 5
0
        // 部分兑现修改值
        public void PartialGetInfo(BookShelf shelf)
        {
            if (GetTextValue(this.textBox_roomName.Text) != null)
            {
                shelf.RoomName = GetTextValue(this.textBox_roomName.Text);
            }

            if (GetTextValue(this.textBox_shelfNo.Text) != null)
            {
                shelf.No = GetTextValue(this.textBox_shelfNo.Text);
            }

            if (GetTextValue(this.textBox_accessNoRange.Text) != null)
            {
                shelf.AccessNoRange = GetTextValue(this.textBox_accessNoRange.Text);
            }

            if (GetTextValue(this.textBox_color.Text) != null)
            {
                // TODO: 是否要验证一下颜色值?
                shelf.ColorString = GetTextValue(this.textBox_color.Text);
            }

            double v    = 0;
            bool   bRet = false;

            if (GetTextValue(this.textBox_locationX.Text) != null)
            {
                bRet = double.TryParse(this.textBox_locationX.Text, out v);
                if (bRet == false)
                {
                    throw new Exception("位置 X 值 '" + this.textBox_locationX.Text + "' 格式错误");
                }
                shelf.LocationX = v;
            }

            if (GetTextValue(this.textBox_locationZ.Text) != null)
            {
                v    = 0;
                bRet = double.TryParse(this.textBox_locationZ.Text, out v);
                if (bRet == false)
                {
                    throw new Exception("位置 Z 值 '" + this.textBox_locationZ.Text + "' 格式错误");
                }

                shelf.LocationZ = v;
            }

            if (GetTextValue(this.textBox_direction.Text) != null)
            {
                v    = 0;
                bRet = double.TryParse(this.textBox_direction.Text, out v);
                if (bRet == false)
                {
                    throw new Exception("方向 值 '" + this.textBox_direction.Text + "' 格式错误");
                }

                shelf.Direction = v;
            }
        }
Ejemplo n.º 6
0
        public void GetInfo(BookShelf shelf)
        {
            shelf.RoomName      = this.textBox_roomName.Text;
            shelf.No            = this.textBox_shelfNo.Text;
            shelf.AccessNoRange = this.textBox_accessNoRange.Text;
            shelf.ColorString   = this.textBox_color.Text;

            double v    = 0;
            bool   bRet = double.TryParse(this.textBox_locationX.Text, out v);

            if (bRet == false)
            {
                throw new Exception("位置 X 值 '" + this.textBox_locationX.Text + "' 格式错误");
            }
            shelf.LocationX = v;

            v    = 0;
            bRet = double.TryParse(this.textBox_locationZ.Text, out v);
            if (bRet == false)
            {
                throw new Exception("位置 Z 值 '" + this.textBox_locationZ.Text + "' 格式错误");
            }

            shelf.LocationZ = v;

            v    = 0;
            bRet = double.TryParse(this.textBox_direction.Text, out v);
            if (bRet == false)
            {
                throw new Exception("方向 值 '" + this.textBox_direction.Text + "' 格式错误");
            }

            shelf.Direction = v;
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 現在フォーカスされているオブジェクトの、次のオブジェクトを返却する
        /// </summary>
        /// <returns>オブジェクト</returns>
        public object Next()
        {
            Book book = BookShelf.GetBookAt(Index);

            this.Index++;
            return(book);
        }
Ejemplo n.º 8
0
    // コンソールアプリケーションで実行を確認しました
    static void Main(string[] args)
    {
        BookShelf bookShelf = new BookShelf();

        bookShelf.appendBook(new Book("Around the world in 80 days"));
        bookShelf.appendBook(new Book("Bible"));
        bookShelf.appendBook(new Book("Cinderella"));
        bookShelf.appendBook(new Book("Daddy-Long-Legs"));

        IIterator it = bookShelf.Iterator();


        while (it.HasNext())
        {
            Book book = (Book)it.Next();
            Console.WriteLine(book.Name);
        }


        // 実行結果
        // Around the world in 80 days
        // Bible
        // Cinderella
        // Daddy-Long-Legs

             // 実行が一瞬で終わって確認できないので、キーの入力を待ちます
        Console.ReadLine();
    }
Ejemplo n.º 9
0
        protected override T Deserialize(Stream stream)
        {
            T lret = default;

            if (typeof(BookShelf) == typeof(T))
            {
                var tmp = new BookShelf("This is secret")
                {
                    Books = new List <Book>()
                };

                var books = tmp.Books;

                // This will test basically the allocation performance of .NET which will when the allocation rate becomes too high put
                // Thread.Sleeps into the allocation calls.
                for (int i = 0; i < myCount; i++)
                {
                    books.Add(new Book()
                    {
                        Id    = i + 1,
                        Title = Encoding.UTF8.GetString(myUtf8Data, (int)myStartIdxAndLength[i * 2], (int)myStartIdxAndLength[i * 2 + 1])
                    });
                }

                lret = (T)(object)tmp;
            }
            else
            {
                throw new NotSupportedException("This class is only meant to be used with Bookshelf objects");
            }
            return(lret);
        }
Ejemplo n.º 10
0
        public async void Open(BookDataBrief book)
        {
            using (var bs = BookShelf.Create())
            {
                var dc        = SearchResult[book];
                var existBook = await bs.Books.FirstOrDefaultAsync(b
                                                                   => b.Title == book.Title &&
                                                                   b.Author == book.Author &&
                                                                   b.PackageFamilyName == dc.PackageFamilyName &&
                                                                   b.ExtensionId == dc.ExtensionId);

                if (existBook is null)
                {
                    existBook = new Book(book, dc);
                    bs.Books.Add(existBook);
                }
                else
                {
                    existBook.Update(book, dc);
                }
                await bs.SaveChangesAsync();

                await Navigator.GetForCurrentView().NavigateAsync(typeof(BookPage), existBook.Id.ToString());
            }
        }
Ejemplo n.º 11
0
        public async Task InitAsync(StoreAccess storeAccess)
        {
            int tryCount = 0;

            Books.Clear();
            _storeAccess = storeAccess;
            try
            {
                try
                {
                    tryCount++;
                    BookShelf = await _bookShelfService.LoadBookShelfAsync(storeAccess);
                }catch (Exception ex)
                {
                    tryCount++;
                    await Task.Delay(1000).ConfigureAwait(false);

                    BookShelf = await _bookShelfService.LoadBookShelfAsync(storeAccess);
                }

                foreach (var bookReference in BookShelf.Content)
                {
                    var bookVM = await BookViewModel.CreateAsync(_bookService, _eventAggregator, bookReference);

                    Books.Add(bookVM);
                }
            }
            catch (NoBookShelfExistsException ex)
            {
                _eventAggregator.GetEvent <NoBookShelfExistsMessage>().Publish(new Tuple <StoreAccess, string>(storeAccess, ex.Message + " - " + ex.AccessGrant + " - " + ex.AdditionalError + " - " + ex.StoreKey + " - " + tryCount.ToString() + " - " + ex.StackTrace));
            }
        }
Ejemplo n.º 12
0
    public static void ProcessTransform(Transform transform, GameObject WhoBy, bool RefreshHierarchy = false)
    {
        if (Librarian.library.TransformToBookShelves.Count == 0)
        {
            Librarian.library.TraverseHierarchy();
            RefreshHierarchy = true;
        }

        Librarian.Library.LibraryBookShelf BookShelf;
        if (Librarian.TransformToBookShelf.ContainsKey(transform))
        {
            BookShelf = Librarian.TransformToBookShelf[transform];
        }
        else
        {
            BookShelf = Librarian.Library.LibraryBookShelf.PartialGenerateLibraryBookShelf(transform);
        }



        BookShelf.PopulateBookShelf();
        SendBookShelfToClient(BookShelf, WhoBy);
        if (RefreshHierarchy)
        {
            LibraryNetMessage.Send(Librarian.library, WhoBy);
        }
    }
Ejemplo n.º 13
0
        public async Task <bool> AddBookShelf(BookShelf book)
        {
            var userId = User.Claims.Where(a => a.Type == "UserId").Select(a => a.Value);
            var a      = book;

            return(true);
        }
Ejemplo n.º 14
0
        public void loadData()
        {
            AmazonDynamoDBClient client = new AmazonDynamoDBClient(Amazon.RegionEndpoint.USEast2);
            Table  table    = Table.LoadTable(client, "Users");
            string email    = TxtUserEmail.Text;
            string password = TxtPassword.Password;

            if (string.IsNullOrEmpty(email) || string.IsNullOrEmpty(password))
            {
                MessageBox.Show("Fields can't be empty!", "Alert", MessageBoxButton.OK, MessageBoxImage.Exclamation);
            }
            else
            {
                Document doc         = table.GetItem(email);
                string   emailInput  = doc.Values.ElementAt(1);
                string   userPasword = doc.Values.ElementAt(0);
                string   result      = emailInput;
                string   pass        = userPasword;
                if (email == result & password == pass)
                {
                    bookShelf = new BookShelf();
                    this.bookShelf.UserEmail = emailInput;

                    HomePage homePage = new HomePage(this.bookShelf);
                    homePage.Show();
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Incorrect Email or Password entered!");
                }
            }
        }
Ejemplo n.º 15
0
 public BookBase(ref BookShelf currentShelf, string user)
 {
     InitializeComponent();
     this.currentShelf = currentShelf;
     CurrentUser       = user;
     LoadBooks();
 }
Ejemplo n.º 16
0
 public bool UpdateBookShelf(BookShelf bookShelf)
 {
     bookShelf.IsDeleted = false;
     _unitOfWork.BookShelfRepository.Update(bookShelf);
     _unitOfWork.SaveChanges();
     return(true);
 }
Ejemplo n.º 17
0
        private void CreateSampleData()
        {
            this.bookShelf = new BookShelf();

            this.bookShelf.Books.Add(
                new Book
            {
                Title     = "Kafka On The Shore",
                Author    = "Haruki Murakami",
                Price     = 300,
                Publisher = new Publisher
                {
                    Name          = "Kodansha",
                    PublisherType = PublisherType.Company
                }
            });
            this.bookShelf.Books.Add(
                new Book
            {
                Title     = "Norwegian Wood",
                Author    = "Haruki Murakami",
                Price     = 500,
                Publisher = new Publisher
                {
                    Name          = "Kodansha",
                    PublisherType = PublisherType.Company
                }
            });
        }
Ejemplo n.º 18
0
        private void QueryBooksList(DynamoDBContext context)
        {
            string        tabName       = "BookShelf";
            List <string> currentTables = client.ListTables().TableNames;

            if (currentTables.Contains(tabName))
            {
                IEnumerable <BookShelf> ownedBooksResult;
                ownedBooksResult = context.Scan <BookShelf>(
                    new ScanCondition("UserEmail", ScanOperator.Equal, loggedinUserId));
                Console.WriteLine("List retrieved " + ownedBooksResult);
                foreach (var result in ownedBooksResult)
                {
                    if (result != null)
                    {
                        BookShelf newShelf = new BookShelf()
                        {
                            BookId    = result.BookId,
                            BookTitle = result.BookTitle,
                            IsActive  = result.IsActive,
                            ISBN      = result.ISBN,
                            Author1   = result.Author1,
                            Author2   = result.Author2,
                            Author3   = result.Author3,
                            UserEmail = result.UserEmail,
                        };

                        booksList.Add(newShelf);
                    }
                    lstBooks.ItemsSource = null;
                    lstBooks.ItemsSource = booksList;
                }
            }
        }
Ejemplo n.º 19
0
        private void addBookButton_Click(object sender, EventArgs e)//添加书籍
        {
            BookShelf  shelf      = shelfBindingSource.Current as BookShelf;
            FormDetail formDetail = new FormDetail(this, shelf, currentClient);

            this.Hide();
            formDetail.ShowDialog();
        }
Ejemplo n.º 20
0
 public BookShelfContent(BookShelf bookShelf, string user)
 {
     InitializeComponent();
     DisplayedShelf = bookShelf;
     Title          = DisplayedShelf.Name;
     CurrentUser    = user;
     LoadBooks();
 }
Ejemplo n.º 21
0
        private static BookOnShelfDocument Map(BookOnShelf bookOnShelf, Book book, BookShelf bookShelf)
        {
            var document = Mapper.Map <BookOnShelfDocument>(bookOnShelf);

            document.Book      = Mapper.Map <BookDocument>(book);
            document.BookShelf = Mapper.Map <BookShelfDocument>(bookShelf);
            return(document);
        }
 private void ListViewBookShelfCollection_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     try
     {
         selectedShelf             = user.ShelfCollection.ElementAt(((ListView)sender).SelectedIndex).Value;
         TextBoxBookShelfName.Text = selectedShelf.Name;
     } catch { }
 }
Ejemplo n.º 23
0
        private void detailButton_Click(object sender, EventArgs e)//修改细节
        {
            BookShelf  shelf      = shelfBindingSource.Current as BookShelf;
            Book       book       = bookBindingSource.Current as Book;
            FormDetail formDetail = new FormDetail(this, book, currentClient);

            this.Hide();
            formDetail.ShowDialog();
        }
Ejemplo n.º 24
0
 public AddSnapshot(BookShelf book)
 {
     InitializeComponent();
     snapshot  = new Snapshot();
     bookShelf = book;
     context   = new DynamoDBContext();
     TxtBookTitle.IsEnabled = false;
     TxtBookTitle.Text      = book.BookTitle;
 }
Ejemplo n.º 25
0
        BookShelf Data(int nToCreate)
        {
            var lret = new BookShelf("private member value");

            lret.Books = Enumerable.Range(1, nToCreate).Select(i => new Book {
                Id = i, Title = $"Book {i}"
            }).ToList();
            return(lret);
        }
Ejemplo n.º 26
0
    public static BookShelf PopulateBookShelf(BookShelf bookShelf)
    {
        if (!bookShelf.IsPartiallyGenerated)
        {
            return(bookShelf);
        }
        MonoBehaviour[] scriptComponents = bookShelf.Shelf.GetComponents <MonoBehaviour>();
        //Logger.Log(scriptComponents.Length + "leit !!!");

        foreach (MonoBehaviour mono in scriptComponents)
        {
            if (mono != null)
            {
                bookShelf.HeldBooks.Add(PartialGeneratebook(mono));
            }
        }
        Transform[] ts = bookShelf.Shelf.GetComponentsInChildren <Transform>();
        foreach (Transform child in ts)
        {
            if (child != ts[0])
            {
                if (child.parent == bookShelf.Shelf.transform)
                {
                    BookShelf _bookShelf;
                    _bookShelf = PartialGeneratebookShelf(child);
                    bookShelf.ObscuredBookShelves.Add(_bookShelf);
                }
            }
        }
        Transform _Transform = bookShelf.Shelf.transform.parent;

        if (_Transform != null)
        {
            bookShelf.ObscuredBy = PartialGeneratebookShelf(_Transform);
        }
        else
        {
            if (TopSceneBookshelf == null)
            {
                List <BookShelf> BookShelfs = new List <BookShelf>();
                foreach (var game in UnityEngine.SceneManagement.SceneManager.GetActiveScene().GetRootGameObjects())
                {
                    var _bookShelf = PartialGeneratebookShelf(game.transform);
                    BookShelfs.Add(_bookShelf);
                }
                TopSceneBookshelf = GenerateCustomBookCase(BookShelfs);
            }
            bookShelf.ObscuredBy = TopSceneBookshelf;
            if (!TopSceneBookshelf.ObscuredBookShelves.Contains(bookShelf))
            {
                TopSceneBookshelf.ObscuredBookShelves.Add(bookShelf);
            }
        }
        bookShelf.IsPartiallyGenerated = false;
        return(bookShelf);
    }
Ejemplo n.º 27
0
 private ReadVM(int bookId)
 {
     using (var bs = BookShelf.Create())
     {
         this._Book = bs.Books.Find(bookId);
         bs.Chapters.Where(c => c.BookId == bookId).OrderBy(c => c.ChapterId).Load();
         this._BookView = this._Book.ChaptersData.CreateView();
         this._BookView.CurrentChanged += this._BookView_CurrentChanged;
     }
 }
Ejemplo n.º 28
0
 public DisplaySnapShot(BookShelf bookShelf)
 {
     InitializeComponent();
     snapshotList = new List <Snapshot>();
     bshelf       = bookShelf;
     userEmail    = bshelf.UserEmail;
     context      = new DynamoDBContext();
     client       = new AmazonDynamoDBClient();
     GetSnapshots(context);
 }
Ejemplo n.º 29
0
        public void ShouldBeEmptyWhenNoBookAdded()
        {
            //Given
            BookShelf shelf = new BookShelf();
            //When
            List <string> books = shelf.GetAllBooks();

            //Then
            Assert.Empty(books);
        }
Ejemplo n.º 30
0
        // Constructor
        public MainPage()
        {
            //calling constructor
            bookshelf = new BookShelf();
            InitializeComponent();

            //link for data to GUI
            listBox1.DataContext = bookshelf;
            // Set the data context of the listbox control to the sample data
            DataContext = App.ViewModel;
        }
 public void Init()
 {
     _storeAccess = new StoreAccess("use this access");
     _bookShelf   = new BookShelf {
         OwnerName = "Mine"
     };
     _bookServiceMock      = new Moq.Mock <IBookService>();
     _bookShelfServiceMock = new Moq.Mock <IBookShelfService>();
     _eventAggregator      = new Moq.Mock <IEventAggregator>();
     _viewModel            = new CreateBookViewModel(_bookServiceMock.Object, _bookShelfServiceMock.Object, _eventAggregator.Object);
 }
    public ActionResult Create(BookShelf book)
    {
      //try
      //{
      _bookshelfRepository.SaveOrUpdate(book);

      return RedirectToAction("Index");
      //}
      //catch (Exception exception)
      //{
      //  TempData["warning"] = exception.Message;
      //    return View();
      //}
    }
Ejemplo n.º 33
0
        static void Main()
        {
            BookShelf bookShelf = new BookShelf();
            bookShelf.AppendBook( new Book( "Around the World in 80 Days" ) );
            bookShelf.AppendBook( new Book( "Bible" ) );
            bookShelf.AppendBook( new Book( "Cinderella" ) );
            bookShelf.AppendBook( new Book( "Daddy-Long-Legs" ) );

            Iterator it = bookShelf.Iterator();
            while( it.HasNext() )
            {
                Book book = ( Book )it.Next();
                System.Console.WriteLine( book.name );
            }
        }
Ejemplo n.º 34
0
 static void Main(string[] args)
 {
     BookComponent tinGoyendaSeries = new BookType("TinGoyenda", "Written by Rokib Hasan");
     BookComponent masudRana = new BookType("MasudRana", "Written by Kazi Anawar Hossain");
     BookComponent robindroNath = new BookType("RobindroNath", "Written by Robindro Nath Tagor");
     BookComponent allBooks = new BookType("Book List", "All available books");
     allBooks.Add(robindroNath);
     robindroNath.Add(new Book("Gitanjoli", "Robindro Nath Tagor", 1905));
     robindroNath.Add(new Book("GolpoGuccho", "Robindro Nath Tagor", 1908));
     allBooks.Add(masudRana);
     masudRana.Add(new Book("Varot Nattoyom", "Kazi Anawar Hossain", 1967));
     masudRana.Add(new Book("Agni Purush", "Kazi Anawar Hossain", 1969));
     allBooks.Add(tinGoyendaSeries);
     tinGoyendaSeries.Add(new Book("Jhamela", "Rokib Hasan", 1994));
     tinGoyendaSeries.Add(new Book("TusarMeru", "Rokib Hasan", 1993));
     BookShelf myShelf = new BookShelf(allBooks);
     myShelf.GetBookList();
     Console.ReadLine();
 }
Ejemplo n.º 35
0
 public BookShelfIterator( BookShelf bookShelf )
 {
     m_BookShelf = bookShelf;
     m_Index = 0;
 }
Ejemplo n.º 36
0
        public static BookShelf GetFlatBookShelf(BookContainer shelf)
        {
            var result = new BookShelf();
            if (shelf.Files.Count > 0)
            {
                result.Folders.Add(shelf);
            }
            result.Title = shelf.Title;

            foreach (var item in shelf.Folders)
            {
                result.Folders.AddRange(GetFlatBookShelf(item).Folders);
            }
            shelf.Folders = new List<BookContainer>();
            return result;
        }
Ejemplo n.º 37
0
 public void Should_tell_me_how_many_books_can_fit_into_it()
 {
     BookShelf bookShelf = new BookShelf(100);
     var book = new PhysicalBook("123", "", "", 100, 20);
     Assert.That(bookShelf.HowManyBooksCanFit(book), Is.EqualTo(5));
 }