private void M0005_ReadingHistory() { XRegistry XReg = new XRegistry("<n/>", FileLinks.ROOT_SETTING + "ReadingHistory.xml"); XParameter[] XParams = XReg.Parameters(); foreach (XParameter XParam in XParams) { string Id = XParam.Id; string Name = XParam.GetValue("name"); string Date = XParam.GetValue("date"); if (int.TryParse(Id, out int aid)) { BookItem Bk = X.Instance <BookItem>(XProto.BookItemEx, Id); Bk.Title = Name; if (DateTime.TryParse(Date, out DateTime dt)) { Bk.Entry.LastAccess = dt; } } } Shared.BooksDb.SaveChanges(); }
public bool Open(XRegistry ZDef) { IsLoading = true; try { XParameter Param = ZDef.Parameter("Procedures"); PM = new ProcManager(Param); NotifyChanged("ProcList"); SetBanner(); return(true); } catch (InvalidFIleException) { ProcManager.PanelMessage(ID, Res.RSTR("InvalidXML"), LogType.ERROR); } catch (Exception ex) { Logger.Log(ID, ex.Message, LogType.ERROR); } finally { IsLoading = false; } return(false); }
private void ResetServer(object sender, RoutedEventArgs e) { ServerReg = new XRegistry("<Server />", FileLinks.ROOT_SETTING + "Server.xml", false); ServerReg.Save(); RefreshServers(); }
private void SetTemplate() { ServerReg = new XRegistry("<Server />", FileLinks.ROOT_SETTING + "Server.xml"); ToggleSettings(EnableSS.IsOn = Properties.ENABLE_SERVER_SEL); MaxPing.Value = Properties.SERVER_MAX_PING; RefreshServers(); }
public BackgroundProcessor() { if (Shared.Storage == null) { Shared.Storage = new GeneralStorage(); XRegistry.AStorage = Shared.Storage; } XReg = new XRegistry("<tasks />", FileLinks.ROOT_SETTING + FileLinks.TASKS); }
public KeyboardController(string Name) { this.Name = Name; RegKeys = new List <Action>(); KeyDesc = new Dictionary <string, List <string> >(); XReg = new XRegistry("<help />", FileLinks.ROOT_SETTING + FileLinks.HELP); Settings = XReg.Parameter("Keyboard"); if (Settings == null) { Settings = new XParameter("Keyboard"); } AddCombo("Help", ShowHelp, VirtualKey.F1); AddCombo("Help", ShowHelp, VirtualKey.Shift, ( VirtualKey )191); }
private async void LoadChapterInst(Chapter C) { BookInstruction BkInst = ( BookInstruction )CurrentBook ?? new BookInstruction(C.Book); XRegistry Settings = SpiderBook.GetSettings(BkInst.ZoneId, BkInst.ZItemId); EpInstruction Inst = new EpInstruction(C, Settings); IEnumerable <ProcConvoy> Convoys = await Inst.Process(); string ChapterText = ""; foreach (ProcConvoy Konvoi in Convoys) { ProcConvoy Convoy = ProcManager.TracePackage( Konvoi , (d, c) => c.Payload is IEnumerable <IStorageFile> || c.Payload is IStorageFile ); if (Convoy == null) { continue; } if (Convoy.Payload is IStorageFile) { ChapterText += await(( IStorageFile )Convoy.Payload).ReadString(); } else if (Convoy.Payload is IEnumerable <IStorageFile> ) { foreach (IStorageFile ISF in ((IEnumerable <IStorageFile>)Convoy.Payload)) { Shared.LoadMessage("MergingContents", ISF.Name); ChapterText += (await ISF.ReadString()) + "\n"; } } } await new ContentParser().ParseAsync(ChapterText, C); OnComplete(C); }
private void MigrateContentReaderLayout() { Shared.Storage.DeleteFile(FileLinks.ROOT_SETTING + "Layout_MainPage.xml"); Shared.Storage.DeleteFile(FileLinks.ROOT_SETTING + "Layout_NavLPage.xml"); Shared.Storage.DeleteFile(FileLinks.ROOT_SETTING + "Layout_StaffPicks.xml"); Shared.Storage.DeleteFile(FileLinks.ROOT_SETTING + "Deathblow.xml"); Shared.Storage.DeleteFile(FileLinks.ROOT_SETTING + "ReadingHistory.xml"); Shared.Storage.DeleteFile(FileLinks.ROOT_SETTING + "LocalBookStorage.xml"); Shared.Storage.DeleteFile(FileLinks.ROOT_WTEXT + "SpecialTopics.xml"); Shared.Storage.DeleteFile(FileLinks.ROOT_WTEXT + "SpecialTopics.lat"); Shared.Storage.DeleteFile(FileLinks.ROOT_WTEXT + "presslist.xml"); XRegistry XReg = new XRegistry("<xml />", FileLinks.ROOT_SETTING + "Layout_BookInfoView.xml"); GRConfig.System.TwitterConfirmed = XReg.Parameter("TwitterConfirmed")?.GetBool("val", false) == true; XParameter BgConf = XReg.Parameter("INFO_VIEW"); if (BgConf != null) { GRConfig.BookInfoView.BgContext.BgType = BgConf.GetValue("type"); GRConfig.BookInfoView.BgContext.BgValue = BgConf.GetValue("value"); } Shared.Storage.DeleteFile(XReg.Location); XReg = new XRegistry("<xml />", FileLinks.ROOT_SETTING + "Layout_ContentReader.xml"); GRConfig.ContentReader.IsRightToLeft = XReg.Parameter("IsRightToLeft")?.GetBool("enable", false) == true; GRConfig.ContentReader.IsHorizontal = XReg.Parameter("IsHorizontal")?.GetBool("enable", false) == true; BgConf = XReg.Parameter("CONTENT_READER"); if (BgConf != null) { GRConfig.BookInfoView.BgContext.BgType = BgConf.GetValue("type"); GRConfig.BookInfoView.BgContext.BgValue = BgConf.GetValue("value"); } Shared.Storage.DeleteFile(XReg.Location); }
private async Task <Book> MigrateBookSpider(string SRoot, string ZoneId, string ZItemId) { if (!Shared.Storage.FileExists(SRoot + "METADATA.xml")) { return(null); } XRegistry MetaDefs = new XRegistry("<metadata />", SRoot + "METADATA.xml"); XParameter MetaParam = MetaDefs.Parameter("METADATA"); BookInstruction BkInst = new BookInstruction(ZoneId, ZItemId); BkInst.Title = MetaParam.GetValue("Title"); BkInst.Info.Author = MetaParam.GetValue("Author"); BkInst.Info.Press = MetaParam.GetValue("Press"); BkInst.Info.LastUpdateDate = MetaParam.GetValue("LastUpdateDate"); BkInst.Info.TotalHitCount = MetaParam.GetValue("TotalHitCount"); BkInst.Info.DailyHitCount = MetaParam.GetValue("TodayHitCount"); BkInst.Info.PushCount = MetaParam.GetValue("PushCount"); BkInst.Info.FavCount = MetaParam.GetValue("FavCount"); BkInst.Info.Length = MetaParam.GetValue("Length"); BkInst.Info.LatestSection = MetaParam.GetValue("LatestSection"); BkInst.Info.LongDescription = MetaParam.GetValue("Intro"); Book Entry = BkInst.Entry; await Shared.BooksDb.LoadCollectionAsync(Entry, x => x.Volumes, x => x.Index); Entry.Volumes.Clear(); XRegistry TOCDefs = new XRegistry("<metadata />", SRoot + "/" + "toc.txt"); int vi = 0; XParameter VolParam = TOCDefs.Parameter("VolInst" + vi); while (VolParam != null) { Volume Vol = new Volume() { Book = Entry, Title = VolParam.GetValue("Title"), Index = VolParam.GetSaveInt("Index"), Chapters = new List <Chapter>() }; Vol.Meta["ProcId"] = VolParam.GetValue("ProcId"); Vol.Meta[AppKeys.GLOBAL_VID] = Utils.Md5(Vol.Title); XParameter PParam = VolParam.Parameter("0"); for (int p = 1; PParam != null; p++) { Vol.Meta["P" + PParam.Id] = PParam.GetValue("Value"); PParam = VolParam.Parameter(p.ToString()); } string MVolHash = Utils.Md5(Vol.Title); int ei = 0; XParameter ChParam = VolParam.Parameter("EpInst" + ei); while (ChParam != null) { Chapter Ch = new Chapter() { Book = Entry, Volume = Vol, Title = ChParam.GetValue("Title"), Index = ChParam.GetSaveInt("Index") }; Ch.Meta["ProcId"] = ChParam.GetValue("ProcId"); Ch.Meta[AppKeys.GLOBAL_CID] = Utils.Md5(Ch.Title); string MChHash = Utils.Md5(Ch.Title); PParam = ChParam.Parameter("0"); for (int p = 1; PParam != null; p++) { Ch.Meta["P" + PParam.Id] = PParam.GetValue("Value"); PParam = ChParam.Parameter(p.ToString()); } Vol.Chapters.Add(Ch); string ChLocation = SRoot + MVolHash + "/" + MChHash + ".txt"; if (Shared.Storage.FileExists(ChLocation)) { ChapterContent ChCont = new ChapterContent() { Chapter = Ch, }; ChCont.Data.BytesValue = Shared.Storage.GetBytes(ChLocation); Shared.BooksDb.ChapterContents.Add(ChCont); } ChParam = VolParam.Parameter("EpInst" + (++ei)); } Entry.Volumes.Add(Vol); VolParam = TOCDefs.Parameter("VolInst" + (++vi)); } SpiderBook SBk = await SpiderBook.CreateSAsync(ZoneId, ZItemId, MetaDefs.Parameter("Procedures")); // Preserve the process state XParameter ProcState = MetaDefs.Parameter("ProcessState"); if (ProcState != null) { SBk.PSettings.SetParameter(ProcState); } SBk.PSettings.Save(); return(Entry); }
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); }