public override void ConfigureTaskImplementation(AsyncTaskSequence sequence) { foreach (var tagName in TagNames) { var itTargets = (from it in TagManager.Value.Chains join t in TagNames on it.Tag.Name equals t select it).ToList(); foreach (var target in itTargets) { sequence.Add(new Task(() => { TagManager.Value.Chains.Remove(target); })); } var tTargets = (from t in TagManager.Value.Tags join i in TagNames on t.Name equals i select t).ToList(); foreach (var target in tTargets) { sequence.Add(new Task(() => { TagManager.Value.Tags.Remove(target); })); } sequence.Add(new Task(() => ImageTagFacade.DeleteByTagName(tagName))); sequence.Add(new Task(() => TagFacade.DeleteByTagName(tagName))); } }
public override void ConfigurePreTaskAction(AsyncTaskSequence sequence) { sequence.Add(() => s_logger.Info($"Start PageScrapping")); sequence.Add(() => s_logger.Info($" Title : {Title}")); sequence.Add(() => s_logger.Info($" MasterDirectory : {MasterDirectory}")); sequence.Add(() => s_logger.Info($" TargetPages : {TargetPages.ArrayToString()}")); }
public override void ConfigureTaskImplementation(AsyncTaskSequence sequence) { sequence.Add(() => s_logger.Info("Checking Database schema...")); sequence.Add(() => { try { Stopwatch.Start(); System.Environment.SetEnvironmentVariable("TMP", "C:\\Temp"); System.Environment.SetEnvironmentVariable("TEMP", "C:\\Temp"); DataVersionManager dvManager = new DataVersionManager(); dvManager.CurrentConnection = ConnectionManager.DefaultConnection; dvManager.Mode = VersioningStrategy.ByTick; dvManager.RegisterChangePlan(new ChangePlan_VersionOrigin()); dvManager.RegisterChangePlan(new ChangePlan_Version_1()); dvManager.GetPlan(new Version_1()).FinishedToUpgradeTo += LibraryInitializing_FinishToUpgradeTo_Version_1; dvManager.RegisterChangePlan(new ChangePlan_Version_2()); dvManager.RegisterChangePlan(new ChangePlan_Version_3()); dvManager.GetPlan(new Version_3()).FinishedToUpgradeTo += LibraryInitializing_FinishToUpgradeTo_Version_3; dvManager.RegisterChangePlan(new ChangePlan_Version_4()); dvManager.RegisterChangePlan(new ChangePlan_Version_5()); dvManager.GetPlan(new Version_5()).FinishedToUpgradeTo += LibraryInitializing_FinishedToUpgradeTo_Version_5; dvManager.FinishedToUpgradeTo += DvManager_FinishedToUpgradeTo; dvManager.UpgradeToTargetVersion(); Stopwatch.Stop(); s_logger.Info($"Completed to check Database schema. {Stopwatch.ElapsedMilliseconds}ms"); } catch (FailedOpeningDatabaseException) { throw; } catch (SQLiteException e) { s_logger.Error("Failed to check Database schema."); s_logger.Debug(e); throw; } finally { if (Stopwatch.IsRunning) { Stopwatch.Stop(); } } }); sequence.Add(() => { DirectoryNameParserManager.Load(); }); }
public override void ConfigureTaskImplementation(AsyncTaskSequence sequence) { sequence.Add(() => _index = 0); for (int i = 0; i < Target.Contents.Count; ++i) { sequence.Add(() => UpdatePageOrderIf(_index++)); } }
public override void ConfigureTaskImplementation(AsyncTaskSequence sequence) { foreach (var page in TargetPages) { ImageViewModel image = page.Image; sequence.Add(new Task(() => Delete.ThumbnailDeleting.DeleteThumbnail(image))); sequence.Add(new Task(() => ThumbnailGenerating.GenerateThumbnail(image))); sequence.Add(new Task(() => s_logger.Info($"Remade Thumbnail imageId:{image.ID}"))); } }
public override void ConfigureTaskImplementation(AsyncTaskSequence sequence) { foreach (var page in TargetPages) { sequence.Add(new Task(() => ContentsLoadTask.SetImageToPage(page))); sequence.Add(new Task(() => DeleteRecordFromStorage(page))); sequence.Add(new Task(() => DeleteFileFromStorage(page))); sequence.Add(new Task(() => RemovePageFromBook(LibraryManager.Value, page))); sequence.Add(new Task(() => s_logger.Info($"Removed Page:{page}"))); } }
public override void ConfigureTaskImplementation(AsyncTaskSequence sequence) { _importLibraryDirectory = Path.GetDirectoryName(ImportLibraryFilename); Initialize(ImportLibraryFilename); sequence.Add(new Task(() => CreateIDConversionTable())); sequence.Add(new Task(() => ImportAuthors(LibraryManager.Value))); sequence.Add(new Task(() => ImportTags(LibraryManager.Value))); sequence.AddRange(GenerateTasksToImportBooks(LibraryManager.Value)); sequence.Add(new Task(() => DropIDConversionTable())); sequence.Add(new Task(() => EndProcess())); }
private void AddTaskToProcessScrapPage(AsyncTaskSequence sequence, PageViewModel page, ImageViewModel img, string destination) { page.IsScrapped = true; sequence.Add(() => CopyFile(img.AbsoluteMasterPath, destination)); //Image Create sequence.Add(() => CreateImage(img, destination)); //Page Create sequence.Add(() => CreatePage(img)); sequence.Add(() => CountUp()); }
public override void ConfigureTaskImplementation(AsyncTaskSequence sequence) { foreach (var book in TargetBooks) { if (book.FirstPage == null) { continue; } ImageViewModel image = book.FirstPage.Image; sequence.Add(new Task(() => Delete.ThumbnailDeleting.DeleteThumbnail(image))); sequence.Add(new Task(() => ThumbnailGenerating.GenerateThumbnail(image))); sequence.Add(new Task(() => s_logger.Info($"Remade Thumbnail imageId:{image.ID}"))); } }
public override void ConfigureTaskImplementation(AsyncTaskSequence sequence) { sequence.Add(new Task(() => s_logger.Info($"Begin to Calculate Book ByteSize."))); var books = Range.FindBook(LibraryManager.Value); sequence.Add(new Task(() => s_logger.Info($"Found : {books.Count()}"))); foreach (var book in books) { sequence.AddRange(GenerateTasksToCalcBook(LibraryManager.Value, book)); } sequence.Add(new Task(() => s_logger.Info($"Finished to Calculate Book ByteSize."))); }
public override void ConfigureTaskImplementation(AsyncTaskSequence sequence) { var books = LibraryManager.Value.BookSource; sequence.Add(() => Configuration.ApplicationConfiguration.LibraryIsEncrypted = true); sequence.Add(() => Configuration.ApplicationConfiguration.Password = Password); sequence.Add(() => Directory.Delete($"{Configuration.ApplicationConfiguration.WorkingDirectory}\\{Specifications.CACHE_DIRECTORY}", true)); foreach (var book in books) { ContentsLoadTask.FillContents(LibraryManager.Value, book); var images = book.Contents; foreach (var image in images) { ContentsLoadTask.Load(image); sequence.Add(() => Encryptor.Encrypt(image.Image, $"{Configuration.ApplicationConfiguration.WorkingDirectory}\\{Specifications.MASTER_DIRECTORY}\\{image.Image.ID}{Path.GetExtension(image.Image.AbsoluteMasterPath)}", Password)); sequence.Add(() => Encryptor.DeleteOriginal(image)); } } }
public override void ConfigureTaskImplementation(AsyncTaskSequence sequence) { sequence.Add(() => CreateDirectoryIfDoesntExist(DestinationDirectory)); foreach (var book in TargetBooks) { LibraryManager.Value.RunFillContentsWithImage(book); sequence.Add(() => CreateDirectoryIfDoesntExist(DestinationDirectory, book, IncludeTag)); foreach (var page in book.Contents) { if (IncludeTag) { sequence.Add(() => CopyFileWithTag(page)); } else { sequence.Add(() => CopyFile(page)); } } } }
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); } }); } }
public override void ConfigureTaskImplementation(AsyncTaskSequence sequence) { sequence.Add(() => _stopwatch.Reset()); sequence.Add(() => s_logger.Info("Loading Book list...")); sequence.Add(() => _stopwatch.Start()); sequence.Add(() => LibraryManager.Value.BookSource.CollectionChanged -= AuthorManager.LoadedBooks_CollectionChanged); sequence.Add(() => LibraryManager.Value.BookSource = new ObservableCollection <BookViewModel>(BookFacade.FindAllWithAuthor(null))); sequence.Add(() => LibraryManager.Value.BookSource.CollectionChanged += AuthorManager.LoadedBooks_CollectionChanged); sequence.Add(() => _stopwatch.Stop()); sequence.Add(() => s_logger.Info($"Completed to load Book list. {_stopwatch.ElapsedMilliseconds}ms")); }
public override void ConfigureTaskImplementation(AsyncTaskSequence sequence) { sequence.Add(() => { LibraryManager.Value.AccessDispatcherObject(() => { LibraryManager.Value.RecentOpenedLibraryList?.Clear(); LibraryManager.Value.RecentOpenedLibraryList = new ObservableCollection <RecentOpenedLibrary>(); }); var dao = DataAccessManager.AppDao.Build <RecentOpenedLibraryDao>(); var hisotries = dao.FindAll(); var matchOrNull = hisotries.Where(h => h.Path != null && h.Path.Equals(Configuration.ApplicationConfiguration.WorkingDirectory)).SingleOrDefault(); if (matchOrNull != null) { matchOrNull.AccessOrder = 0; dao.Update(matchOrNull); } else { var newhisotry = new RecentOpenedLibrary(); newhisotry.AccessOrder = 0; newhisotry.Path = Configuration.ApplicationConfiguration.WorkingDirectory; dao.Insert(newhisotry); } var other = hisotries.Where(h => h.Path != null && !h.Path.Equals(Configuration.ApplicationConfiguration.WorkingDirectory)).OrderBy(h => h.AccessOrder).ToArray(); for (int i = 1; i < Math.Min(other.Count(), Configuration.ApplicationConfiguration.LibraryHistoryRecordCount) + 1; ++i) { var o = other.ElementAt(i - 1); o.AccessOrder = i; dao.Update(o); LibraryManager.Value.AccessDispatcherObject(() => { LibraryManager.Value.RecentOpenedLibraryList.Add(o); }); } for (int i = Configuration.ApplicationConfiguration.LibraryHistoryRecordCount; i < other.Count() - Configuration.ApplicationConfiguration.LibraryHistoryRecordCount; ++i) { var o = other.ElementAt(i); dao.Delete(new Dictionary <string, object>() { { "Path", o.Path } }); } }); }
public override void ConfigureTaskImplementation(AsyncTaskSequence sequence) { sequence.Add(() => TaskManager.Enqueue(LibraryResettingService.GetTaskSequence())); sequence.Add(() => TaskManager.Enqueue(RecentOpenedLibraryUpdating.GetTaskSequence())); sequence.Add(() => TagManager.Load()); sequence.Add(() => AuthorManager.LoadAsync()); sequence.Add(() => TaskManager.Enqueue(BookLoadingService.GetTaskSequence())); sequence.Add(() => Configuration.ApplicationConfiguration.LibraryIsEncrypted = EncryptImageFacade.AnyEncrypted()); }
public override void ConfigureTaskImplementation(AsyncTaskSequence sequence) { TargetPages = TargetPages.OrderBy(a => a.Title, new NaturalStringComparer()).ToArray(); var workingDirectory = Configuration.ApplicationConfiguration.WorkingDirectory; var now = DateTime.Now; Guid entryNameSeedGuid = Guid.NewGuid(); var bookDir = entryNameSeedGuid.ToString("N"); var copyTo = workingDirectory + "\\" + MasterDirectory + "\\" + now.Year + "\\" + now.Month.ToString("00") + "\\" + now.Day.ToString("00") + "\\" + bookDir; //保存先ディレクトリ準備 if (!Directory.Exists(copyTo)) { Directory.CreateDirectory(copyTo); s_logger.Debug($"Create directory:{copyTo}"); } sequence.Add(new System.Threading.Tasks.Task(() => CreateBook(bookDir, Title))); var page = TargetPages.ElementAt(0); var img = page.Image; var destination = copyTo + "\\" + Path.GetFileName(img.AbsoluteMasterPath); AddTaskToProcessScrapPage(sequence, page, img, destination); sequence.Add(new System.Threading.Tasks.Task(() => SetFirstPage())); sequence.Add(new System.Threading.Tasks.Task(() => LibraryManager.Value.AddToMemory(NewBook))); //ファイルコピー for (int i = 1; i < TargetPages.Count(); ++i) { page = TargetPages.ElementAt(i); img = page.Image; destination = copyTo + "\\" + Path.GetFileName(img.AbsoluteMasterPath); AddTaskToProcessScrapPage(sequence, page, img, destination); } sequence.Add(new System.Threading.Tasks.Task(() => LibraryManager.Value.FireFillContents(NewBook))); sequence.Add(new System.Threading.Tasks.Task(() => s_logger.Info($"Pages Scrapped as:{NewBook}"))); sequence.Add(new System.Threading.Tasks.Task(() => SetContentsRegistered())); }
public override void ConfigureTaskImplementation(AsyncTaskSequence sequence) { foreach (var book in TargetBooks) { LibraryManager.Value.RunFillContentsWithImage(book); book.CurrentProcessProgress.Value.TotalCount.Value = book.Contents.Count; book.IsDeleting = true; foreach (var page in book.Contents) { sequence.Add(new Task(() => RemoveImageTagByImage(LibraryManager.Value, page))); sequence.Add(new Task(() => PageRemoving.DeleteRecordFromStorage(page))); sequence.Add(new Task(() => PageRemoving.DeleteFileFromStorage(page))); sequence.Add(new Task(() => ProcessedCount++)); sequence.Add(new Task(() => book.CurrentProcessProgress.Value.Count.Value = ProcessedCount)); } sequence.Add(new Task(() => DeleteRecordFromStorage(book))); sequence.Add(new Task(() => LibraryManager.Value.RemoveFromMemory(book))); sequence.Add(new Task(() => s_logger.Info($"Removed Book:{book}"))); } }
public override void ConfigureTaskImplementation(AsyncTaskSequence sequence) { var books = LibraryManager.Value.BookSource; foreach (var book in books) { ContentsLoadTask.FillContents(LibraryManager.Value, book); var images = book.Contents; foreach (var image in images) { ContentsLoadTask.Load(image); sequence.Add(() => _TargetEncryptImage = EncryptImageFacade.FindBy(image.Image.ID)); sequence.Add(() => Encryptor.Decrypt(_TargetEncryptImage.EncryptFilePath, image.Image.AbsoluteMasterPath, Password)); sequence.Add(() => File.Delete($"{Configuration.ApplicationConfiguration.WorkingDirectory}\\{Specifications.MASTER_DIRECTORY}\\{image.Image.ID}{Path.GetExtension(image.Image.AbsoluteMasterPath)}")); sequence.Add(() => EncryptImageFacade.DeleteBy(image.Image.ID)); } } sequence.Add(() => OnmemoryImageManager.Instance.Clear()); sequence.Add(() => Configuration.ApplicationConfiguration.Password = null); sequence.Add(() => Configuration.ApplicationConfiguration.LibraryIsEncrypted = false); }
public override void ConfigurePostTaskAction(AsyncTaskSequence sequence) { sequence.Add(() => s_logger.Info($"Finish PageThumbnailRemaking")); }
public override void ConfigurePreTaskAction(AsyncTaskSequence sequence) { sequence.Add(() => s_logger.Info($"Start LibraryLoading")); }
public override void ConfigureTaskImplementation(AsyncTaskSequence sequence) { sequence.Add(() => CleanUp()); }
public override void ConfigurePostTaskAction(AsyncTaskSequence sequence) { sequence.Add(() => s_logger.Info($"Finish LibraryInitializing")); }
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())); }
public override void ConfigurePreTaskAction(AsyncTaskSequence sequence) { sequence.Add(() => s_logger.Info($"Start ImageTagAdding")); sequence.Add(() => s_logger.Info($" TagName : {TagName}")); sequence.Add(() => s_logger.Info($" Entries : {Entries.ArrayToString()}")); }
public override void ConfigurePostTaskAction(AsyncTaskSequence sequence) { sequence.Add(() => s_logger.Info($"Finish BookLoading")); }
public override void ConfigurePreTaskAction(AsyncTaskSequence sequence) { sequence.Add(() => s_logger.Info($"Start PageThumbnailRemaking")); sequence.Add(() => s_logger.Info($" TargetBooks : {TargetPages.ArrayToString()}")); }
public override void ConfigurePreTaskAction(AsyncTaskSequence sequence) { sequence.Add(() => s_logger.Info($"Start Encryption")); }
public override void ConfigurePreTaskAction(AsyncTaskSequence sequence) { sequence.Add(() => s_logger.Info($"Start BookExporting")); sequence.Add(() => s_logger.Info($" To '{DestinationDirectory}'")); sequence.Add(() => s_logger.Info($" IncludeTag : {IncludeTag}")); }
public override void ConfigurePostTaskAction(AsyncTaskSequence sequence) { sequence.Add(() => s_logger.Info($"Finish PageOrderUpdating")); }