示例#1
0
        private void MessageBus_OnDelivery(Message Mesg)
        {
            ProcConvoy Convoy = Mesg.Payload as ProcConvoy;

            if (Mesg.Content == "RUN_RESULT" &&
                Convoy != null &&
                Convoy.Dispatcher == EditTarget)
            {
                TempInst = Convoy.Payload as BookInstruction;

                ProcConvoy ProcCon = ProcManager.TracePackage(Convoy, (P, C) => P is ProcParameter);
                if (ProcCon != null)
                {
                    ProcParameter PPClone = new ProcParameter();
                    PPClone.ReadParam(ProcCon.Dispatcher.ToXParam());
                    ProcCon = new ProcConvoy(PPClone, null);
                }

                TempInst.PackVolumes(ProcCon);

                Preview.Navigate(
                    typeof(TableOfContents)
                    , new Tuple <Volume[], SelectionChangedEventHandler>(TempInst.GetVolInsts().Remap(x => x.ToVolume(TempInst.Entry)), PreviewContent)
                    );
                Preview.BackStack.Clear();
                TestRunning.IsActive = false;
            }
        }
示例#2
0
        private async void LoadInstruction(BookInstruction B, bool useCache)
        {
            if (!BookInstruction.OpLocks.AcquireLock(B.GID, out AsyncLocks <string, bool> .QueueToken QT))
            {
                await QT.Task;
            }

            SpiderBook SBook = await SpiderBook.CreateSAsync(B.ZoneId, B.ZItemId, B.BookSpiderDef);

            if (Shared.Storage.FileExists(SBook.MetaLocation))
            {
                B.LastCache = Shared.Storage.FileTime(SBook.MetaLocation).LocalDateTime;
            }

            if (useCache && (B.Packed == true || Shared.BooksDb.Volumes.Any(x => x.Book == B.Entry)))
            {
                if (B.Packed != true)
                {
                    B.PackSavedVols(SBook.PSettings);
                }
            }
            else
            {
                bool UpdateFailed = true;

                await SBook.Process();

                if (SBook.Processed && SBook.ProcessSuccess)
                {
                    B.LastCache = DateTime.Now;
                    BookInstruction BUpdate = SBook.GetBook();

                    if (BUpdate.Packable && BUpdate.Packed != true)
                    {
                        BUpdate.PackVolumes(SBook.GetPPConvoy());
                        B.Update(BUpdate);
                        UpdateFailed = false;
                    }
                }

                // Cannot download content, use cache if available
                if (UpdateFailed && Shared.BooksDb.Volumes.Any(x => x.Book == B.Entry))
                {
                    Logger.Log(ID, "Spider failed to produce instructions, using cache instead", LogType.WARNING);
                    B.PackSavedVols(SBook.PSettings);
                }
            }

            QT.TrySetResult(true);
            OnComplete(B);
        }
示例#3
0
        public async void LoadInstruction( BookInstruction B, bool useCache )
        {
            SpiderBook SBook = new SpiderBook( B );

            if ( useCache && Shared.Storage.FileExists( B.TOCPath ) )
            {
                B.PackSavedVols( SBook.PSettings );
            }
            else
            {
                await SBook.Process();

                // Cannot download content, use cache if available
                if ( !( B.Packed == true || B.Packable ) && Shared.Storage.FileExists( B.TOCPath ) )
                {
                    Logger.Log( ID, "Spider failed to produce instructions, using cache instead", LogType.WARNING );
                    B.PackSavedVols( SBook.PSettings );
                }
            }

            if ( B.Packed != true && B.Packable )
            {
                B.PackVolumes( SBook.GetPPConvoy() );
            }

            await CacheCover( B );

            OnComplete( B );
        }