public void Load(BookItem b, bool useCache = false) { CurrentBook = b; if (b.IsLocal()) { OnComplete(b); } else if (b.IsSpider()) { Task.Run(() => LoadInstruction(( BookInstruction )b, useCache)); } else if (CurrentBook.IsEx()) { string BookId = b.ZItemId; string Mode = CurrentBook.XField <string>("Mode"); if (useCache && b.Info.Flags.Contains(Mode)) { OnComplete(b); } else { b.Info.Flags.Add(Mode); X.Instance <IRuntimeCache>(XProto.WRuntimeCache) .InitDownload( BookId, X.Call <XKey[]>(XProto.WRequest, "DoBookAction", Mode, BookId) , (e, id) => { CurrentBook.XCall("ParseXml", e.ResponseString); CurrentBook.LastCache = DateTime.Now; CurrentBook.SaveInfo(); OnComplete(CurrentBook); } , (cache, id, ex) => { b.Info.Flags.Remove(Mode); OnComplete(null); }, true ); } } }
public void Load( BookItem b, bool useCache = false ) { CurrentBook = b; if( b.IsLocal ) { OnComplete( b ); return; } if ( b is BookInstruction ) { LoadInstruction( ( BookInstruction ) b, useCache ); return; } string id = b.Id; string Mode = X.Const<string>( XProto.WProtocols, "ACTION_BOOK_INFO" ); if( CurrentBook.XTest( XProto.BookItemEx ) ) { Mode = CurrentBook.XField<string>( "Mode" ); } XKey[] ReqKeys = X.Call<XKey[]>( XProto.WRequest, "DoBookAction", Mode, id ); if ( useCache ) { string cacheName = X.Call<string>( XProto.WRuntimeCache, "GetCacheString", new object[] { ReqKeys } ); if ( Shared.Storage.FileExists( FileLinks.ROOT_CACHE + cacheName ) ) { ExtractBookInfo( Shared.Storage.GetString( FileLinks.ROOT_CACHE + cacheName ), id ); return; } } X.Instance<IRuntimeCache>( XProto.WRuntimeCache ) .InitDownload( id, ReqKeys, PrelaodBookInfo, PrelaodBookInfo, true ); }