private void LoadBookInfo( LocalTextDocument Doc ) { IEnumerable<UIElement> Modules = MasterContainer.Children; SetTemplateTOC( ThisBook = X.Instance<BookItem>( XProto.BookItemEx, Doc ) ); }
private async Task M0004_Books_TypeL() { string LRoot = "shared/transfers/LVolumes/"; if (!Shared.Storage.DirExist(LRoot)) { return; } string[] Ids = Shared.Storage.ListDirs(LRoot); int l = Ids.Length; List <Book> Entries = new List <Book>(); await Ids.ExecEach(async ( Id, i ) => { MesgR(stx.Text("MightTakeAWhile") + string.Format("{1}/{2} ( {0} )", Id, i + 1, l)); Book Entry = null; if (int.TryParse(Id, out int k) && X.Exists) { BookItem Item = X.Instance <BookItem>(XProto.BookItemEx, Id); Entry = Item.Entry; Entry.Type = Entry.Type | BookType.L; } else { BookItem Item = new LocalTextDocument(Id); Entry = Item.Entry; } await Shared.BooksDb.LoadCollectionAsync(Entry, x => x.Volumes, x => x.Index); Entry.Volumes.Clear(); string BRoot = LRoot + Id + "/"; string MetaLoc = BRoot + "METADATA.xml"; XRegistry XMeta = new XRegistry("<Meta />", MetaLoc); XParameter[] VolDefs = XMeta.Parameters("vid"); VolDefs.ExecEach((VolDef, vi) => { Volume Vol = new Volume() { Book = Entry, Title = VolDef.GetValue("name"), Chapters = new List <Chapter>(), Index = vi }; Vol.Meta[AppKeys.GLOBAL_VID] = VolDef.Id; XRegistry ChReg = new XRegistry("<ch />", BRoot + VolDef.Id + ".vol"); XParameter[] ChDefs = ChReg.Parameters("cid"); ChDefs.ExecEach((ChDef, ei) => { Chapter Ch = new Chapter() { Book = Entry, Volume = Vol, Title = ChDef.GetValue("name"), Index = ei }; Ch.Meta[AppKeys.GLOBAL_CID] = ChDef.Id; string ChLocation = BRoot + VolDef.Id + "/" + ChDef.Id + ".txt"; if (Shared.Storage.FileExists(ChLocation)) { ChapterContent ChCont = new ChapterContent() { Chapter = Ch, }; ChCont.Data.BytesValue = Shared.Storage.GetBytes(ChLocation); Shared.BooksDb.ChapterContents.Add(ChCont); } Vol.Chapters.Add(Ch); }); Entry.Volumes.Add(Vol); }); Entries.Add(Entry); }); MesgR(stx.Text("SavingRecords")); Shared.BooksDb.SaveBooks(Entries.ToArray()); Purge(LRoot); }