Exemple #1
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 );
        }
Exemple #2
0
        private async Task <bool> _RowAction(IGRRow _Row)
        {
            GRRow <BookDisplay> Row = (GRRow <BookDisplay>)_Row;

            BookInstruction Payload = ( BookInstruction )Row.Source.Payload;

            if (Payload != null)
            {
                // Save the book here
                Payload.SaveInfo();

                // Reload the BookDisplay as Entry might changed from SaveInfo
                Row.Source = new BookDisplay(Payload.Entry);
            }

            SpiderBook Item = await SpiderBook.CreateSAsync(Row.Source.Entry.ZoneId, Row.Source.Entry.ZItemId, Payload?.BookSpiderDef);

            Item.PropertyChanged += Item_PropertyChanged;

            XParameter Metadata = Item.PSettings.Parameter("METADATA") ?? new XParameter("METADATA");

            Metadata.SetValue(new XKey("payload", Row.Source.Entry.Meta[AppKeys.GLOBAL_SSID]));
            Item.PSettings.SetParameter(Metadata);

            if (!Item.ProcessSuccess && Item.CanProcess)
            {
                await ItemProcessor.ProcessLocal(Item);
            }

            Item.PropertyChanged -= Item_PropertyChanged;

            (( BookDisplayPageExt )Extension).OpenItem(_Row);

            return(true);
        }
Exemple #3
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);
        }
Exemple #4
0
        private async void PinSpider(object sender, RoutedEventArgs e)
        {
            string TileId = await PageProcessor.PinToStart(ThisBook);

            if (!string.IsNullOrEmpty(TileId))
            {
                PinManager PM = new PinManager();
                PM.RegPin(ThisBook, TileId, true);

                SpiderBook SpDef = await SpiderBook.CreateSAsync(ThisBook.ZItemId);

                await PageProcessor.RegLiveSpider(SpDef, ( BookInstruction )ThisBook, TileId);
            }
        }
Exemple #5
0
 public void ProcessOrOpenItem(IGRRow DataContext)
 {
     if (DataContext is GRRow <IBookProcess> Row)
     {
         SpiderBook BkProc = ( SpiderBook )Row.Source;
         if (BkProc.Processed && BkProc.ProcessSuccess)
         {
             BookItem BkItem = BkProc.GetBook();
             ControlFrame.Instance.NavigateTo(PageId.BOOK_INFO_VIEW, () => new wenku10.Pages.BookInfoView(BkItem));
         }
         else
         {
             ProcessItem(DataContext);
         }
     }
 }
Exemple #6
0
        public async void ProcessItem(IGRRow DataContext)
        {
            if (DataContext is GRRow <IBookProcess> Row)
            {
                SpiderBook BkProc = ( SpiderBook )Row.Source;
                if (!BkProc.Processing)
                {
                    await ItemProcessor.ProcessLocal(BkProc);

                    if (BkProc.GetBook().Packed == true)
                    {
                        new VolumeLoader((x) => { }).Load(BkProc.GetBook());
                    }
                }
            }
        }
Exemple #7
0
        private async void Edit_Click(object sender, RoutedEventArgs e)
        {
            object DataContext = (( FrameworkElement )sender).DataContext;

            if (DataContext is GRRow <BookDisplay> BkRow)
            {
                BookItem BkItem = ItemProcessor.GetBookItem(BkRow.Source.Entry);

                SpiderBook SBk = await SpiderBook.CreateSAsync(BkItem.ZoneId, BkItem.ZItemId, null);

                if (SBk.CanProcess)
                {
                    ControlFrame.Instance.NavigateTo(PageId.PROC_PANEL, () => new ProcPanelWrapper(SBk.MetaLocation));
                }
            }
        }
Exemple #8
0
        public async Task <bool> OpenSpider(IStorageFile ISF)
        {
            try
            {
                SpiderBook SBook = await SpiderBook.ImportFile(await ISF.ReadString(), true);

                BSData.ImportItem(SBook);

                return(SBook.CanProcess || SBook.ProcessSuccess);
            }
            catch (Exception ex)
            {
                // Logger.Log( ID, ex.Message, LogType.ERROR );
            }

            return(false);
        }
Exemple #9
0
        private async void PinItemToStart(object sender, RoutedEventArgs e)
        {
            SpiderBook B = ( SpiderBook )(( FrameworkElement )sender).DataContext;

            if (B.ProcessSuccess)
            {
                BookInstruction Book   = B.GetBook();
                string          TileId = await PageProcessor.PinToStart(Book);

                if (!string.IsNullOrEmpty(TileId))
                {
                    PinManager PM = new PinManager();
                    PM.RegPin(Book, TileId, true);

                    await PageProcessor.RegLiveSpider(B, Book, TileId);
                }
            }
        }
Exemple #10
0
        private async void LoadChapterInst(Chapter C)
        {
            BookInstruction BkInst   = ( BookInstruction )CurrentBook ?? new BookInstruction(C.Book);
            XRegistry       Settings = SpiderBook.GetSettings(BkInst.ZoneId, BkInst.ZItemId);

            EpInstruction            Inst    = new EpInstruction(C, Settings);
            IEnumerable <ProcConvoy> Convoys = await Inst.Process();

            string ChapterText = "";

            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)
                {
                    ChapterText += await(( IStorageFile )Convoy.Payload).ReadString();
                }
                else if (Convoy.Payload is IEnumerable <IStorageFile> )
                {
                    foreach (IStorageFile ISF in ((IEnumerable <IStorageFile>)Convoy.Payload))
                    {
                        Shared.LoadMessage("MergingContents", ISF.Name);
                        ChapterText += (await ISF.ReadString()) + "\n";
                    }
                }
            }

            await new ContentParser().ParseAsync(ChapterText, C);

            OnComplete(C);
        }
Exemple #11
0
        public static async Task RegLiveSpider(SpiderBook SBook, BookInstruction Book, string TileId)
        {
            if (!SBook.HasChakra)
            {
                StringResources stx = StringResources.Load("Message");

                bool Confirmed = false;

                await Popups.ShowDialog(UIAliases.CreateDialog(
                                            stx.Str("TileUpdateSupport"), stx.Str("ShellTile")
                                            , () => Confirmed = true
                                            , stx.Str("Yes"), stx.Str("No")
                                            ));

                if (Confirmed)
                {
                    BackgroundProcessor.Instance.CreateTileUpdateForBookSpider(Book.GID, TileId);
                }
            }
        }
Exemple #12
0
        private async void PinToStart_Click(object sender, RoutedEventArgs e)
        {
            if ((( FrameworkElement )sender).DataContext is GRRow <BookDisplay> BkRow)
            {
                BookItem BkItem = ItemProcessor.GetBookItem(BkRow.Source.Entry);
                string   TileId = await PageProcessor.PinToStart(BkItem);

                if (!string.IsNullOrEmpty(TileId))
                {
                    PinManager PM = new PinManager();
                    PM.RegPin(BkItem, TileId, true);

                    if (BkItem is BookInstruction BInst)
                    {
                        SpiderBook SBook = await SpiderBook.CreateSAsync(BkItem.ZoneId, BkItem.ZItemId, null);

                        await PageProcessor.RegLiveSpider(SBook, BInst, TileId);
                    }
                }
            }
        }
Exemple #13
0
        private async void PickFile(object sender, RoutedEventArgs e)
        {
            if (LockedFile)
            {
                return;
            }

            Message.Text = "";
            IStorageFile ISF = await AppStorage.OpenFileAsync(".xml");

            if (ISF == null)
            {
                return;
            }

            UploadBtn.IsLoading = true;

            try
            {
                SelectedBook = await SpiderBook.ImportFile(await ISF.ReadString(), false);

                if (!SelectedBook.CanProcess)
                {
                    StringResources stx = StringResources.Load("ERROR");
                    throw new InvalidDataException(stx.Str("HS_INVALID"));
                }

                FileName.Text = ISF.Name;
                int LDot = ISF.Name.LastIndexOf('.');
                NameInput.PlaceholderText = ~LDot == 0 ? ISF.Name : ISF.Name.Substring(0, LDot);
            }
            catch (Exception ex)
            {
                Message.Text = ex.Message;
            }

            UploadBtn.IsLoading = false;
        }
Exemple #14
0
        private async void ConfirmScriptParse(SpiderBook Book)
        {
            StringResources stx    = StringResources.Load("Message");
            MessageDialog   MsgBox = new MessageDialog(stx.Str("ConfirmScriptParse"));

            bool Parse = false;

            MsgBox.Commands.Add(new UICommand(stx.Str("Yes"), x => { Parse = true; }));
            MsgBox.Commands.Add(new UICommand(stx.Str("No")));

            await Popups.ShowDialog(MsgBox);

            if (Parse)
            {
                ControlFrame.Instance.NavigateTo(
                    PageId.MASTER_EXPLORER, () => new MasterExplorer()
                    , P => (( MasterExplorer )P).NavigateToDataSource(
                        typeof(BookSpiderDisplayData)
                        , VS => (( BookSpiderVS )VS).Process(Book.ZoneId, Book.ZItemId)
                        )
                    );
            }
        }
Exemple #15
0
        private async void OpenSpider(HubScriptItem HSI)
        {
            BookItem Book = null;

            try
            {
                SpiderBook SBook = await SpiderBook.ImportFile(await HSI.ScriptFile.ReadString(), true);

                if (SBook.CanProcess && !SBook.Processed)
                {
                    await ItemProcessor.ProcessLocal(SBook);

                    Book = SBook.GetBook();
                }
            }
            catch (Exception ex)
            {
                Logger.Log(ID, ex.Message, LogType.WARNING);
            }

            // Should be outside of try..catch block
            OpenBook(Book);
        }
Exemple #16
0
 private async void PredefineFile( string Id )
 {
     SelectedBook = await SpiderBook.CreateAsyncSpider( Id );
     FileName.Text = SelectedBook.MetaLocation;
 }
Exemple #17
0
        private async void PredefineFile(string ZoneId, string ZItemId)
        {
            SelectedBook = await SpiderBook.CreateSAsync(ZoneId, ZItemId, null);

            FileName.Text = SelectedBook.MetaLocation;
        }
Exemple #18
0
        private async void MessageBus_OnDelivery(Message Mesg)
        {
            switch (Mesg.Content)
            {
            case AppKeys.SH_SCRIPT_DATA:
                HubScriptItem HSI = ( HubScriptItem )Mesg.Payload;

                if ((HSI.Scope & SpiderScope.ZONE) != 0)
                {
                    ControlFrame.Instance.NavigateTo(
                        PageId.MASTER_EXPLORER, () => new MasterExplorer()
                        //  Open ZoneSpider Manager
                        , P => (( MasterExplorer )P).NavigateToDataSource(
                            typeof(ZSMDisplayData)
                            , async(ZSVS) =>
                    {
                        // Using the manager, import this script
                        ZSMDisplayData DisplayData = (( ZSManagerVS )ZSVS).ZSMData;
                        if (await DisplayData.OpenFile(HSI.ScriptFile))
                        {
                            // Open the imported script
                            ZoneSpider ZSpider = DisplayData.ZSTable.Items.Select(x => ( ZoneSpider )x.Source).FirstOrDefault(x => x.ZoneId == HSI.Id);
                            (( MasterExplorer )P).NavigateToZone(ZSpider);
                        }
                    }
                            ));
                    break;
                }

                // This will save the book
                SpiderBook SBook = await SpiderBook.ImportFile(await HSI.ScriptFile.ReadString(), true);

                if (SBook.CanProcess)
                {
                    ConfirmScriptParse(SBook);
                }
                else
                {
                    ConfirmErrorReport(HSI.Id, StatusType.HS_INVALID);
                }
                break;

            case AppKeys.HS_DECRYPT_FAIL:
                StringResources stx = StringResources.Load("Message", "ContextMenu");

                bool Place = false;

                await Popups.ShowDialog(UIAliases.CreateDialog(
                                            stx.Str("Desc_DecryptionFailed"), stx.Str("DecryptionFailed")
                                            , () => Place = true
                                            , stx.Text("PlaceRequest", "ContextMenu"), stx.Str("OK")
                                            ));

                if (Place)
                {
                    HSI = ( HubScriptItem )Mesg.Payload;
                    TransferRequest(SHTarget.KEY, HSI);
                }

                break;

            case AppKeys.HS_OPEN_COMMENT:
                InboxMessage BoxMessage = ( InboxMessage )Mesg.Payload;
                ControlFrame.Instance.NavigateTo(PageId.SCRIPT_DETAILS
                                                 , () => new ScriptDetails(BoxMessage.HubScript)
                                                 , P => (( ScriptDetails )P).OpenCommentStack(BoxMessage.CommId)
                                                 );
                break;

            case AppKeys.HS_NO_VOLDATA:
                ConfirmErrorReport((( BookInstruction )Mesg.Payload).ZItemId, StatusType.HS_NO_VOLDATA);
                break;

            case AppKeys.EX_DEATHBLOW:
                stx = StringResources.Load("Message", "ContextMenu");

                bool UseDeathblow = false;

                await Popups.ShowDialog(UIAliases.CreateDialog(
                                            stx.Str("ConfirmDeathblow")
                                            , () => UseDeathblow = true
                                            , stx.Str("Yes"), stx.Str("No")
                                            ));

                if (UseDeathblow)
                {
                    IDeathblow Deathblow = ( IDeathblow )Mesg.Payload;
                    ControlFrame.Instance.NavigateTo(PageId.W_DEATHBLOW, () => new WDeathblow(Deathblow), P => (( WDeathblow )P).Blow());
                }

                break;

            case AppKeys.PM_CHECK_TILES:
                CheckTiles();
                break;

            case AppKeys.OPEN_VIEWSOURCE:
                ControlFrame.Instance.NavigateTo(PageId.MASTER_EXPLORER, () => new MasterExplorer(), P => (( MasterExplorer )P).NavigateToViewSource(( GRViewSource )Mesg.Payload));
                break;

            case AppKeys.OPEN_ZONE:
                ControlFrame.Instance.NavigateTo(PageId.MASTER_EXPLORER, () => new MasterExplorer(), P => (( MasterExplorer )P).NavigateToZone(( ZoneSpider )Mesg.Payload));
                break;

            case AppKeys.PROMPT_LOGIN:
                (IMember Member, Action DialogClosed) = (Tuple <IMember, Action>)Mesg.Payload;
                if (!Member.IsLoggedIn)
                {
                    Login LoginDialog = new Login(Member);
                    await Popups.ShowDialog(LoginDialog);
                }
                DialogClosed();
                break;
            }
        }
Exemple #19
0
 public async void Copy(SpiderBook BkProc)
 {
     BSData.ImportItem(await BkProc.Clone());
 }
Exemple #20
0
        private async Task UpdateSpiders()
        {
            try
            {
                XReg.SetParameter(TASK_START, CustomAnchor.TimeKey);
                XReg.Save();

                IEnumerable <XParameter> Updates;
                List <string>            Exists = new List <string>();

                if (Retrying)
                {
                    Updates = XReg.Parameters(AppKeys.BTASK_SPIDER).Where(x =>
                    {
                        int r = x.GetSaveInt(AppKeys.BTASK_RETRY);
                        return(0 < r && r < MaxRetry);
                    });
                }
                else
                {
                    Updates = XReg.Parameters(AppKeys.BTASK_SPIDER).Where(x => {
                        int r = x.GetSaveInt(AppKeys.BTASK_RETRY);
                        if (r == 0 || MaxRetry <= r)
                        {
                            return(true);
                        }
                        else
                        {
                            // Consider Retry Timer dead if LastUpdate is 20 < minutes
                            DateTime LastRun = DateTime.FromFileTimeUtc(x.GetSaveLong(AppKeys.LBS_TIME));
                            return(30 < DateTime.Now.Subtract(LastRun).TotalMinutes);
                        }
                    });
                }

                foreach (XParameter UpdateParam in Updates)
                {
                    string TileId = UpdateParam.GetValue("tileId");

                    if (!SecondaryTile.Exists(TileId))
                    {
                        UpdateParam.SetValue(new XKey[] {
                            new XKey(AppKeys.SYS_EXCEPTION, "App Tile is missing")
                            , CustomAnchor.TimeKey
                        });
                        XReg.SetParameter(UpdateParam);
                        continue;
                    }

                    string[] Keys = UpdateParam.Id.Split('.');

                    if (Keys.Length != 3)
                    {
                        XReg.RemoveParameter(UpdateParam.Id);
                        continue;
                    }

                    SpiderBook SBook = await SpiderBook.CreateSAsync(Keys[0], Keys[2], null);

                    if (!SBook.CanProcess)
                    {
                        XReg.RemoveParameter(UpdateParam.Id);
                        continue;
                    }

                    SBook.MarkUnprocessed();

                    string OHash = null, NHash = null;
                    SBook.GetBook()?.Entry.Meta.TryGetValue("TOCHash", out OHash);

                    await ItemProcessor.ProcessLocal(SBook);

                    if (SBook.ProcessSuccess)
                    {
                        BookInstruction NBook = SBook.GetBook();
                        NBook?.Entry.Meta.TryGetValue("TOCHash", out NHash);

                        if (NBook.Packed == true && (NBook.NeedUpdate || OHash != NHash))
                        {
                            await LiveTileService.UpdateTile(CanvasDevice, NBook, TileId);
                        }

                        UpdateParam.SetValue(new XKey[] {
                            new XKey(AppKeys.SYS_EXCEPTION, false)
                            , new XKey(AppKeys.BTASK_RETRY, 0)
                            , CustomAnchor.TimeKey
                        });
                    }
                    else
                    {
                        CreateRetryTimer();

                        int NRetries = UpdateParam.GetSaveInt(AppKeys.BTASK_RETRY);
                        UpdateParam.SetValue(new XKey[]
                        {
                            new XKey(AppKeys.SYS_EXCEPTION, true)
                            , new XKey(AppKeys.BTASK_RETRY, NRetries + 1)
                            , CustomAnchor.TimeKey
                        });
                    }

                    XReg.SetParameter(UpdateParam);
                    XReg.Save();
                }

                XReg.SetParameter(TASK_END, CustomAnchor.TimeKey);
                XReg.Save();
            }
            catch (Exception ex)
            {
                try
                {
                    XReg.SetParameter(AppKeys.SYS_EXCEPTION, new XKey(AppKeys.SYS_MESSAGE, ex.Message));
                    XReg.Save();
                }
                catch (Exception) { }
            }
        }
Exemple #21
0
        private async Task <Book> MigrateBookSpider(string SRoot, string ZoneId, string ZItemId)
        {
            if (!Shared.Storage.FileExists(SRoot + "METADATA.xml"))
            {
                return(null);
            }

            XRegistry  MetaDefs  = new XRegistry("<metadata />", SRoot + "METADATA.xml");
            XParameter MetaParam = MetaDefs.Parameter("METADATA");

            BookInstruction BkInst = new BookInstruction(ZoneId, ZItemId);

            BkInst.Title                = MetaParam.GetValue("Title");
            BkInst.Info.Author          = MetaParam.GetValue("Author");
            BkInst.Info.Press           = MetaParam.GetValue("Press");
            BkInst.Info.LastUpdateDate  = MetaParam.GetValue("LastUpdateDate");
            BkInst.Info.TotalHitCount   = MetaParam.GetValue("TotalHitCount");
            BkInst.Info.DailyHitCount   = MetaParam.GetValue("TodayHitCount");
            BkInst.Info.PushCount       = MetaParam.GetValue("PushCount");
            BkInst.Info.FavCount        = MetaParam.GetValue("FavCount");
            BkInst.Info.Length          = MetaParam.GetValue("Length");
            BkInst.Info.LatestSection   = MetaParam.GetValue("LatestSection");
            BkInst.Info.LongDescription = MetaParam.GetValue("Intro");

            Book Entry = BkInst.Entry;
            await Shared.BooksDb.LoadCollectionAsync(Entry, x => x.Volumes, x => x.Index);

            Entry.Volumes.Clear();

            XRegistry TOCDefs = new XRegistry("<metadata />", SRoot + "/" + "toc.txt");

            int        vi       = 0;
            XParameter VolParam = TOCDefs.Parameter("VolInst" + vi);

            while (VolParam != null)
            {
                Volume Vol = new Volume()
                {
                    Book     = Entry,
                    Title    = VolParam.GetValue("Title"),
                    Index    = VolParam.GetSaveInt("Index"),
                    Chapters = new List <Chapter>()
                };

                Vol.Meta["ProcId"]           = VolParam.GetValue("ProcId");
                Vol.Meta[AppKeys.GLOBAL_VID] = Utils.Md5(Vol.Title);

                XParameter PParam = VolParam.Parameter("0");
                for (int p = 1; PParam != null; p++)
                {
                    Vol.Meta["P" + PParam.Id] = PParam.GetValue("Value");
                    PParam = VolParam.Parameter(p.ToString());
                }

                string MVolHash = Utils.Md5(Vol.Title);

                int        ei      = 0;
                XParameter ChParam = VolParam.Parameter("EpInst" + ei);
                while (ChParam != null)
                {
                    Chapter Ch = new Chapter()
                    {
                        Book   = Entry,
                        Volume = Vol,
                        Title  = ChParam.GetValue("Title"),
                        Index  = ChParam.GetSaveInt("Index")
                    };

                    Ch.Meta["ProcId"]           = ChParam.GetValue("ProcId");
                    Ch.Meta[AppKeys.GLOBAL_CID] = Utils.Md5(Ch.Title);

                    string MChHash = Utils.Md5(Ch.Title);

                    PParam = ChParam.Parameter("0");
                    for (int p = 1; PParam != null; p++)
                    {
                        Ch.Meta["P" + PParam.Id] = PParam.GetValue("Value");
                        PParam = ChParam.Parameter(p.ToString());
                    }

                    Vol.Chapters.Add(Ch);

                    string ChLocation = SRoot + MVolHash + "/" + MChHash + ".txt";
                    if (Shared.Storage.FileExists(ChLocation))
                    {
                        ChapterContent ChCont = new ChapterContent()
                        {
                            Chapter = Ch,
                        };
                        ChCont.Data.BytesValue = Shared.Storage.GetBytes(ChLocation);
                        Shared.BooksDb.ChapterContents.Add(ChCont);
                    }

                    ChParam = VolParam.Parameter("EpInst" + (++ei));
                }

                Entry.Volumes.Add(Vol);

                VolParam = TOCDefs.Parameter("VolInst" + (++vi));
            }

            SpiderBook SBk = await SpiderBook.CreateSAsync(ZoneId, ZItemId, MetaDefs.Parameter("Procedures"));

            // Preserve the process state
            XParameter ProcState = MetaDefs.Parameter("ProcessState");

            if (ProcState != null)
            {
                SBk.PSettings.SetParameter(ProcState);
            }

            SBk.PSettings.Save();
            return(Entry);
        }
Exemple #22
0
        private async void PickFile( object sender, RoutedEventArgs e )
        {
            if ( LockedFile ) return;

            Message.Text = "";
            IStorageFile ISF = await AppStorage.OpenFileAsync( ".xml" );
            if ( ISF == null ) return;

            LoadingRing.IsActive = true;

            try
            {
                SelectedBook = await SpiderBook.ImportFile( await ISF.ReadString(), false );
                if ( !SelectedBook.CanProcess )
                {
                    StringResources stx = new StringResources( "ERROR" );
                    throw new InvalidDataException( stx.Str( "HS_INVALID" ) );
                }

                FileName.Text = ISF.Name;
                int LDot = ISF.Name.LastIndexOf( '.' );
                NameInput.PlaceholderText = ~LDot == 0 ? ISF.Name : ISF.Name.Substring( 0, LDot );
            }
            catch ( Exception ex )
            {
                Message.Text = ex.Message;
            }

            LoadingRing.IsActive = false;
        }