public CommentLoader(string Id, XKey[] RequestKey, CommentXMLParser Parser) { wCache = X.Instance <IRuntimeCache>(XProto.WRuntimeCache); this.Id = Id; this.RequestKey = RequestKey; XParser = Parser; }
public async void Load(BookItem b, bool useCache = true) { // b is null when back button is pressed before BookLoader load if (b == null) { return; } Shared.LoadMessage("LoadingVolumes"); CurrentBook = b; if (b.Volumes == null) { b.Entry.Volumes = await Shared.BooksDb.LoadCollectionAsync(b.Entry, x => x.Volumes, x => x.Index); } if (b.IsLocal() || (useCache && !b.NeedUpdate && b.Volumes.Any())) { foreach (Volume Vol in b.Volumes) { if (Vol.Chapters == null) { Vol.Chapters = await Shared.BooksDb.LoadCollectionAsync(Vol, x => x.Chapters, x => x.Index); } } OnComplete(b); } else if (b.IsSpider()) { var j = Task.Run(() => LoadInst(( BookInstruction )b)); } else if (b.IsEx()) { IRuntimeCache wCache = X.Instance <IRuntimeCache>(XProto.WRuntimeCache); // This occurs when tapping pinned book but cache is cleared wCache.InitDownload( b.ZItemId , X.Call <XKey[]>(XProto.WRequest, "GetBookTOC", b.ZItemId) , (DRequestCompletedEventArgs e, string id) => { b.XCall("ParseVolume", e.ResponseString); OnComplete(b); } , (string RequestURI, string id, Exception ex) => { OnComplete(b); } , false ); } }
public async void Load(Chapter C, bool Cache = true) { if (C.Content == null) { await Task.Run(() => Shared.BooksDb.LoadRef(C, b => b.Content)); await Task.Run(() => Shared.BooksDb.LoadRef(C, b => b.Image)); } if (Cache && C.Content != null) { OnComplete(C); } else if (C.Book.Type == BookType.S) { LoadChapterInst(C); } else if (C.Book.Type.HasFlag(BookType.W)) { if (C.Book.Type.HasFlag(BookType.L)) { IDeathblow Db = X.Instance <IDeathblow>(XProto.Deathblow, CurrentBook); MessageBus.SendUI(GetType(), AppKeys.EX_DEATHBLOW, Db); } else { IRuntimeCache wCache = X.Instance <IRuntimeCache>(XProto.WRuntimeCache); // Initiate download, precache should not be done internally. wCache.InitDownload( C.Id.ToString() , X.Call <XKey[]>(XProto.WRequest, "GetBookContent", CurrentBook.ZItemId, C.Meta[AppKeys.GLOBAL_CID]) , async(DRequestCompletedEventArgs e, string path) => { await new ContentParser().ParseAsync(Shared.Conv.Chinese.Translate(e.ResponseString), C); OnComplete(C); X.Instance <IDeathblow>(XProto.Deathblow, CurrentBook).Check(e.ResponseBytes); } , (string Request, string path, Exception ex) => { Logger.Log(ID, ex.Message, LogType.ERROR); GSystem.ActionCenter.Instance.ShowError("Download"); OnComplete(C); } , false ); } } }
private void RefreshServers() { try { IRuntimeCache wc = X.Instance <IRuntimeCache>(XProto.WRuntimeCache, 0); wc.GET( new Uri(X.Const <string>(XProto.WProtocols, "APP_PROTOCOL") + "server.list") , GotServerList, global::GR.GSystem.Utils.DoNothing, true); } catch (DllNotFoundException ex) { Logger.Log(ID, "Protocol not present: " + ex.Message, LogType.INFO); EnableSS.IsEnabled = false; } catch (Exception ex) { Logger.Log(ID, ex.Message, LogType.WARNING); } }
public void Test_AppGateDownload(TestResult t) { IRuntimeCache wc = X.Instance <IRuntimeCache>(XProto.WRuntimeCache); wc.InitDownload( "Test" , X.Call <XKey[]>(XProto.WRequest, "GetBookInfo", "20") , (DRequestCompletedEventArgs e, string id) => { t.writeLine("Download Success: " + id); t.writeLine(e.ResponseString); t.Done(true); } , (string a, string b, Exception c) => { t.writeLine(b); t.Done(false); } , false ); }
public PressList(Action <PressList> CompleteHandler) { if (Shared.Storage.FileExists(FileLinks.ROOT_WTEXT + FileLinks.PRESS_LISTF)) { CompleteHandler(this); return; } IRuntimeCache wCache = X.Instance <IRuntimeCache>(XProto.WRuntimeCache); wCache.InitDownload( "PRESSLIST" , X.Call <XKey[]>( XProto.WRequest , "GetXML" , X.Const <string>(XProto.WProtocols, "COMMAND_TLIST_PARAM_SORT")) , (DRequestCompletedEventArgs e, string id) => { Shared.Storage.WriteBytes(FileLinks.ROOT_WTEXT + FileLinks.PRESS_LISTF, e.ResponseBytes); CompleteHandler(this); }, Utils.DoNothing, false ); }
/// <summary> /// Initializes a new instance of <see cref="AspNetCache"/> /// with the specified <see cref="IRuntimeCache"/> implementation. /// </summary> /// <param name="runtimeCache"></param> public AspNetCache(IRuntimeCache runtimeCache) { _cache = runtimeCache; // noop _cacheName = typeof(AspNetCache).FullName + "[" + this.GetHashCode() + "]."; }
public AutoCache() { wCache = X.Instance<IRuntimeCache>( XProto.WRuntimeCache, 0, false, false ); // This runs when thread is being aborted when app quit if ( App.RuntimeTransfer.CurrentThread != null ) { Logger.Log( ID, "Resuming Download Sessions ...", LogType.INFO ); App.RuntimeTransfer.StartThreadCycle( LoadComplete ); } }