Ejemplo n.º 1
0
        private void CopyPages(ILibrary libManager, BookViewModel parent)
        {
            IDConversionDao idcDao  = new IDConversionDao();
            PageDao         pageDao = new PageDao();

            var pages = pageDao.FindBy(new Dictionary <string, object>()
            {
                { "BookID", parent.ID }
            }, _dataOpUnit.CurrentConnection, s_ANOTHER_DATABASE_ALIAS_NAME).OrderBy(p => p.PageIndex).ToViewModel();

            foreach (var page in pages)
            {
                if (pageDao.FindBy(new Dictionary <string, object>()
                {
                    { "ID", page.ID }
                }, _dataOpUnit.CurrentConnection).Count() > 0)
                {
                    //対象ライブラリのエンティティを新規IDでインポートする。取込側ライブラリに新規IDと旧IDを記録する。
                    Guid newGuid = Guid.NewGuid();
                    idcDao.Insert(new Data.Entity.Migration.IDConversion("Page", newGuid, page.ID), _dataOpUnit.CurrentConnection);
                    page.ID = newGuid;

                    ImportPageWithContents(libManager, parent, page);
                }
                else
                {
                    //対象ライブラリのエンティティを変更せずそのままインポートする。
                    ImportPageWithContents(libManager, parent, page);
                }
            }
        }
Ejemplo n.º 2
0
        public void UpdatePageIndexOnlyTest()
        {
            var id        = new Guid("66F5EC93-FD2C-4DCC-A76B-5FE3D00C6E58");
            var imageid   = new Guid("83506829-1661-4329-8C43-8AE858F00F02");
            var bookid    = new Guid("9277ACAF-AB93-47B2-BE04-92566DE6F190");
            var pageindex = int.MaxValue;
            var title     = "Inserted page";

            var page = new Page();

            page.ID        = id;
            page.ImageID   = imageid;
            page.BookID    = bookid;
            page.PageIndex = pageindex;
            page.Title     = title;

            PageDao dao = new PageDao();

            dao.Insert(page);

            var records = dao.FindBy(new Dictionary <string, object>()
            {
                { "ID", id }
            });

            Assert.That(records.Count(), Is.EqualTo(1));
            var record = records.Single();

            Assert.That(record.ID, Is.EqualTo(id));
            Assert.That(record.ImageID, Is.EqualTo(imageid));
            Assert.That(record.BookID, Is.EqualTo(bookid));
            Assert.That(record.PageIndex, Is.EqualTo(pageindex));
            Assert.That(record.Title, Is.EqualTo(title));

            //Change
            page.PageIndex = 1;

            dao.Update(page);

            records = dao.FindBy(new Dictionary <string, object>()
            {
                { "ID", id }
            });

            Assert.That(records.Count(), Is.EqualTo(1));
            record = records.Single();
            Assert.That(record.ID, Is.EqualTo(id));
            Assert.That(record.ImageID, Is.EqualTo(imageid));
            Assert.That(record.BookID, Is.EqualTo(bookid));
            Assert.That(record.PageIndex, Is.EqualTo(1));
            Assert.That(record.Title, Is.EqualTo(title));
        }
Ejemplo n.º 3
0
        public static PageViewModel FindByImageId(Guid imageId)
        {
            var dao = new PageDao();

            return(dao.FindBy(new Dictionary <string, object>()
            {
                { "ImageID", imageId }
            }).FirstOrDefault().ToViewModel());;
        }
Ejemplo n.º 4
0
        private void EnumeratePages(BookViewModel parent)
        {
            PageDao pageDao = new PageDao();

            _pages = pageDao.FindBy(new Dictionary <string, object>()
            {
                { "BookID", parent.ID }
            }, _dataOpUnit.CurrentConnection, s_ANOTHER_DATABASE_ALIAS_NAME).OrderBy(p => p.PageIndex).ToViewModel();
        }
Ejemplo n.º 5
0
        public static IEnumerable <PageViewModel> FindByBookId(Guid bookId, int challengeMaxCount = 3)
        {
            List <Exception> trying = new List <Exception>();

            while (trying.Count() < challengeMaxCount)
            {
                try
                {
                    PageDao dao = new PageDao();
                    return(dao.FindBy(new Dictionary <string, object>()
                    {
                        { "BookID", bookId }
                    }).ToViewModel());
                }
                catch (SQLiteException e)
                {
                    trying.Add(e);
                    Thread.Sleep(500);
                    continue;
                }
            }
            throw new QueryFailedException($"設定回数({challengeMaxCount})の問い合わせに失敗しました.", trying);
        }