Пример #1
0
 public CommentLoader(string Id, XKey[] RequestKey, CommentXMLParser Parser)
 {
     wCache          = X.Instance <IRuntimeCache>(XProto.WRuntimeCache);
     this.Id         = Id;
     this.RequestKey = RequestKey;
     XParser         = Parser;
 }
Пример #2
0
        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
                    );
            }
        }
Пример #3
0
        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
                        );
                }
            }
        }
Пример #4
0
 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);
     }
 }
Пример #5
0
        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
                );
        }
Пример #6
0
        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
                );
        }
Пример #7
0
 /// <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() + "].";
 }
Пример #8
0
 /// <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() + "].";
 }
Пример #9
0
        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 );
            }
        }