Ejemplo n.º 1
0
        private async Task ExtractProps( BookItem Inst, string Content )
        {
            foreach( PropExt Extr in PropDefs )
            {
                if ( !Extr.Enabled ) continue;

                string PropValue = MatchSingle( Extr, Content );

                if ( Extr.SubProc.HasProcedures )
                {
                    ProcManager.PanelMessage( this, () => Res.RSTR( "SubProcRun" ), LogType.INFO );
                    ProcPassThru PPass = new ProcPassThru( new ProcConvoy( this, Inst ) );
                    ProcConvoy SubConvoy = await Extr.SubProc.CreateSpider().Crawl( new ProcConvoy( PPass, PropValue ) );

                    // Process ReceivedConvoy
                    if ( SubConvoy.Payload is string )
                        PropValue = ( string ) SubConvoy.Payload;
                    else if ( SubConvoy.Payload is IEnumerable<string> )
                        PropValue = string.Join( "\n", ( IEnumerable<string> ) SubConvoy.Payload );
                    else if ( SubConvoy.Payload is IStorageFile )
                        PropValue = await ( ( IStorageFile ) SubConvoy.Payload ).ReadString();
                    else if ( SubConvoy.Payload is IEnumerable<IStorageFile> )
                        PropValue = await ( ( IEnumerable<IStorageFile> ) SubConvoy.Payload ).First().ReadString();
                    else continue;
                }

                // If the website split a single property into serveral pages
                // That website is stupid. Would not support.
                if( !Inst.ReadParam( Extr.PType.ToString(), PropValue.ToCTrad() ) )
                {
                    ProcManager.PanelMessage( this, () => Res.RSTR( "InvalidParam", Extr.PType ), LogType.WARNING );
                }
            }
        }