示例#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 PreviewContent(object sender, SelectionChangedEventArgs e)
        {
            if (e.AddedItems.Count == 0 || TestRunning.IsActive)
            {
                return;
            }
            TestRunning.IsActive = true;

            TOCItem Item = ( TOCItem )e.AddedItems[0];
            Chapter Ch   = Item.Ch;

            if (Ch == null)
            {
                ProcManager.PanelMessage(ID, "Chapter is not available", LogType.INFO);
                return;
            }

            string                   VId     = Ch.Volume.Meta[AppKeys.GLOBAL_VID];
            string                   CId     = Ch.Meta[AppKeys.GLOBAL_CID];
            EpInstruction            EpInst  = TempInst.GetVolInsts().First(x => x.VId == VId).EpInsts.Cast <EpInstruction>().First(x => x.CId == CId);
            IEnumerable <ProcConvoy> Convoys = await EpInst.Process();

            StorageFile TempFile = await AppStorage.MkTemp();

            StringResources stx = StringResources.Load("LoadingMessage");

            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)
                {
                    await TempFile.WriteFile(( IStorageFile )Convoy.Payload, true, new byte[] { ( byte )'\n' });
                }
                else if (Convoy.Payload is IEnumerable <IStorageFile> )
                {
                    foreach (IStorageFile ISF in ((IEnumerable <IStorageFile>)Convoy.Payload))
                    {
                        ProcManager.PanelMessage(ID, string.Format(stx.Str("MergingContents"), ISF.Name), LogType.INFO);
                        await TempFile.WriteFile(ISF, true, new byte[] { ( byte )'\n' });
                    }
                }
            }

            ShowSource(TempFile);
            TestRunning.IsActive = false;
        }
示例#3
0
        private async void LoadInst(BookInstruction b)
        {
            if (!BookInstruction.OpLocks.AcquireLock(b.GID, out AsyncLocks <string, bool> .QueueToken QT))
            {
                await QT.Task;
            }

            foreach (VolInstruction VInst in b.GetVolInsts())
            {
                Shared.LoadMessage("SubProcessRun", VInst.Title);
                // This should finalize the chapter info
                var Convoy = await VInst.Process(b);
            }

            Shared.LoadMessage("CompilingTOC", b.Title);

            IEnumerable <Volume> Vols = b.GetVolInsts().Remap(x => x.ToVolume(b.Entry));

            if (Vols.Any())
            {
                List <Volume> NewVolumes = new List <Volume>();
                Vols.ExecEach(Vol =>
                {
                    string VID  = Vol.Meta[AppKeys.GLOBAL_VID];
                    Volume NVol = b.Entry.Volumes.FirstOrDefault(x => x.Meta[AppKeys.GLOBAL_VID] == VID) ?? Vol;
                    if (NVol != Vol)
                    {
                        NVol.Title     = Vol.Title;
                        NVol.Index     = Vol.Index;
                        NVol.Json_Meta = Vol.Json_Meta;
                    }

                    Shared.BooksDb.LoadCollection(NVol, x => x.Chapters, x => x.Index);

                    List <Chapter> NewChapters = new List <Chapter>();
                    Vol.Chapters.ExecEach(Ch =>
                    {
                        string CID  = Ch.Meta[AppKeys.GLOBAL_CID];
                        Chapter NCh = NVol.Chapters.FirstOrDefault(x => x.Meta[AppKeys.GLOBAL_CID] == CID) ?? Ch;
                        if (NCh != Ch)
                        {
                            NCh.Title     = Ch.Title;
                            NCh.Index     = Ch.Index;
                            NCh.Json_Meta = Ch.Json_Meta;
                        }
                        NewChapters.Add(NCh);
                    });

                    NewVolumes.Add(NVol);
                });

                b.Entry.Volumes = NewVolumes;
                b.SaveInfo();
            }
            else
            {
                MessageBus.SendUI(GetType(), AppKeys.HS_NO_VOLDATA, b);
            }

            QT.TrySetResult(true);
            OnComplete(b);
        }