Пример #1
0
        private void TagBook(ITagManager tagMng)
        {
            foreach (var tagName in TagNames)
            {
                var tag = TagFacade.FindByTagName(tagName);
                Debug.Assert(tag != null);
                var newBookTag = new BookTagViewModel(_book, tag);

                BookTagFacade.Insert(newBookTag);
                tagMng.BookTagChains.Add(newBookTag);
            }
        }
Пример #2
0
        private void LoadBookTag()
        {
            var sw = new Stopwatch();

            s_logger.Info("Loading BookTag list...");
            sw.Start();
            try
            {
                BookTagChains = new ObservableCollection <BookTagViewModel>(BookTagFacade.FindAll());
            }
            finally
            {
                s_logger.Info($"Completed to load BookTag list. {sw.ElapsedMilliseconds}ms");
            }
        }
Пример #3
0
        public override void ConfigureTaskImplementation(AsyncTaskSequence sequence)
        {
            var bookTags = new IntermediateTableDao().FindAll().ToList();

            foreach (var chain in bookTags)
            {
                sequence.Add(() =>
                {
                    var newEntity = new BookTagViewModel(chain.BookID, chain.TagID);
                    if (!BookTagFacade.Exists(newEntity))
                    {
                        BookTagFacade.Insert(newEntity);
                    }
                });
            }
        }
Пример #4
0
        public void Load()
        {
            var id         = Guid.Parse("00000000-0000-0000-0000-000000000000");
            var appDao     = DataAccessManager.AppDao.Build <StatisticsDao>();
            var statistics = appDao.FindBy(new Dictionary <string, object>()
            {
                { "ID", id }
            }).First();

            NumberOfBoots.Value = statistics.NumberOfBoots;

            NumberOfBooks.Value = BookFacade.FindAll().Count();

            TotalFileSize.Value = ImageFacade.SumTotalFileSize();

            NumberOfPages.Value = PageFacade.CountAll();

            NumberOfAuthors.Value = AuthorFacade.CountAll();

            NumberOfTags.Value = TagFacade.CountAll();

            NumberOfBookTags.Value = BookTagFacade.CountAll();

            NumberOfImageTags.Value = ImageTagFacade.CountAll();

            NumberOfBooks5.Value = StarFacade.FindBookByStar(5).Count();

            NumberOfBooks4.Value = StarFacade.FindBookByStar(4).Count();

            NumberOfBooks3.Value = StarFacade.FindBookByStar(3).Count();

            NumberOfBooks2.Value = StarFacade.FindBookByStar(2).Count();

            NumberOfBooks1.Value = StarFacade.FindBookByStar(1).Count();

            NumberOfBooksN.Value = StarFacade.FindBookByStar(null).Count();

            NumberOfDuplicateBooks.Value = BookFacade.FindDuplicateFingerPrint().Count();

            TotalDuplicateBooksSize.Value = BookFacade.FindDuplicateFingerPrint().Where(x => x.ByteSize != null).Select(x => x.ByteSize.Value).Sum();
        }
Пример #5
0
        public override void ConfigureTaskImplementation(AsyncTaskSequence sequence)
        {
            sequence.Add(new Task(() =>
            {
                if (TagFacade.Exists(TagName))
                {
                    _tag = TagFacade.FindByTagName(TagName);
                }
                else
                {
                    _tag = new TagViewModel(Guid.NewGuid(), TagName);
                    TagFacade.Insert(_tag);
                }
            }));

            sequence.Add(new Task(() =>
            {
                _images = new List <ImageViewModel>();
            }));

            foreach (var entry in Entries)
            {
                var book = entry as BookViewModel;
                if (book != null)
                {
                    _pages = PageFacade.FindByBookId(book.ID);

                    for (int i = 0; i < _pages.Count(); ++i)
                    {
                        var p = _pages.ElementAt(i);
                        sequence.Add(new Task(() =>
                        {
                            GetPropertyIfImageIsNull(ref p);
                            _images.Add(p.Image);
                        }));
                    }
                    sequence.Add(new Task(() =>
                    {
                        var newEntity = new BookTagViewModel(book, _tag);
                        if (!BookTagFacade.Exists(newEntity))
                        {
                            BookTagFacade.Insert(newEntity);
                        }
                    }));
                    continue;
                }

                var page = entry as PageViewModel;
                if (page != null)
                {
                    sequence.Add(new Task(() =>
                    {
                        GetPropertyIfImageIsNull(ref page);
                        _images.Add(page.Image);
                    }));

                    sequence.Add(new Task(() =>
                    {
                        var newEntity = new BookTagViewModel(page.BookID, _tag.ID);
                        if (!BookTagFacade.Exists(newEntity))
                        {
                            BookTagFacade.Insert(newEntity);
                        }
                    }));
                    continue;
                }

                var image = entry as ImageViewModel;
                if (image != null)
                {
                    sequence.Add(new Task(() =>
                    {
                        _images.Add(image);
                    }));

                    sequence.Add(new Task(() =>
                    {
                        var tempPage  = PageFacade.FindByImageId(image.ID);
                        var newEntity = new BookTagViewModel(tempPage.BookID, _tag.ID);
                        if (!BookTagFacade.Exists(newEntity))
                        {
                            BookTagFacade.Insert(newEntity);
                        }
                    }));
                    continue;
                }
            }

            sequence.Add(new Task(() =>
            {
                ImageTagFacade.BatchInsert(_tag, _images);
            }));

            sequence.Add(new Task(() =>
            {
                var chains = from x in _images
                             where TagManager.Value.Chains.Count(c => c.ImageID == x.ID && c.TagID == _tag.ID) == 0
                             select new ImageTagViewModel(x.ID, _tag);

                foreach (var chain in chains)
                {
                    TagManager.Value.Chains.Add(chain);
                }
            }));

            sequence.Add(new Task(() =>
            {
                if (!TagManager.Value.Tags.Contains(_tag))
                {
                    TagManager.Value.Tags.Add(_tag);
                }
            }));

            sequence.Add(new Task(() => TagManager.Value.SelectedEntityTags = TagManager.Value.GetCommonTags()));
            sequence.Add(new Task(() => TagManager.Value.ObserveSelectedEntityTags()));
        }
Пример #6
0
        public override void ConfigureTaskImplementation(AsyncTaskSequence sequence)
        {
            foreach (var tagName in TagNames)
            {
                foreach (var entry in Entries)
                {
                    var book = entry as BookViewModel;
                    if (book != null)
                    {
                        var pages = PageFacade.FindByBookId(book.ID);
                        for (int i = 0; i < pages.Count(); ++i)
                        {
                            var p = pages.ElementAt(i);
                            sequence.Add(new Task(() =>
                            {
                                GetPropertyIfImageIsNull(ref p);
                            }));
                            sequence.Add(new Task(() =>
                            {
                                Remove.ImageTagRemoving.Remove(TagManager.Value, p.Image, tagName);
                            }));
                        }

                        sequence.Add(new Task(() =>
                        {
                            var tag          = TagFacade.FindByTagName(tagName);
                            var deleteEntity = new BookTagViewModel(book.ID, tag.ID);
                            if (BookTagFacade.Exists(deleteEntity))
                            {
                                BookTagFacade.Delete(deleteEntity);
                            }
                        }));
                        continue;
                    }

                    var page = entry as PageViewModel;
                    if (page != null)
                    {
                        sequence.Add(new Task(() =>
                        {
                            GetPropertyIfImageIsNull(ref page);
                        }));
                        sequence.Add(new Task(() =>
                        {
                            Remove.ImageTagRemoving.Remove(TagManager.Value, page.Image, tagName);
                        }));

                        sequence.Add(new Task(() =>
                        {
                            var tag          = TagFacade.FindByTagName(tagName);
                            var deleteEntity = new BookTagViewModel(book.ID, tag.ID);

                            var pages = PageFacade.FindByBookId(page.BookID);
                            foreach (var p in pages)
                            {
                                if (p.ID.Equals(page.ID))
                                {
                                    continue;
                                }

                                var imageTags = ImageTagFacade.FindByImageId(p.ImageID);
                                foreach (var imageTag in imageTags)
                                {
                                    if (imageTag.TagID.Equals(deleteEntity.TagID))
                                    {
                                        return;
                                    }
                                }
                            }

                            if (BookTagFacade.Exists(deleteEntity))
                            {
                                BookTagFacade.Delete(deleteEntity);
                            }
                        }));
                        continue;
                    }

                    var image = entry as ImageViewModel;
                    if (image != null)
                    {
                        sequence.Add(new Task(() =>
                        {
                            Remove.ImageTagRemoving.Remove(TagManager.Value, page.Image, tagName);
                        }));

                        sequence.Add(new Task(() =>
                        {
                            var tag          = TagFacade.FindByTagName(tagName);
                            var deleteEntity = new BookTagViewModel(book.ID, tag.ID);

                            var parentPage = PageFacade.FindByImageId(image.ID);
                            var pages      = PageFacade.FindByBookId(parentPage.BookID);
                            foreach (var p in pages)
                            {
                                if (p.ID.Equals(parentPage.ID))
                                {
                                    continue;
                                }

                                var imageTags = ImageTagFacade.FindByImageId(p.ImageID);
                                foreach (var imageTag in imageTags)
                                {
                                    if (imageTag.TagID.Equals(deleteEntity.TagID))
                                    {
                                        return;
                                    }
                                }
                            }

                            if (BookTagFacade.Exists(deleteEntity))
                            {
                                BookTagFacade.Delete(deleteEntity);
                            }
                        }));
                        continue;
                    }
                }

                sequence.Add(new Task(() => TagManager.Value.SelectedEntityTags = TagManager.Value.GetCommonTags()));
                sequence.Add(new Task(() => TagManager.Value.ObserveSelectedEntityTags()));
                sequence.Add(new Task(() => TagManager.Value.ObserveTagCount()));
            }
        }