Exemple #1
0
        public override async Task<ProcConvoy> Run( ProcConvoy Convoy )
        {
            await base.Run( Convoy );

            ProcConvoy UsableConvoy;

            if ( !TryGetConvoy( out UsableConvoy, ( P, C ) =>
            {
                return C.Payload is IEnumerable<IStorageFile>
                || C.Payload is string;
            } ) ) return Convoy;

            string s = "";
            if ( UsableConvoy.Payload is string )
            {
                s += UsableConvoy.Payload + "\n";
            }
            else
            {
                IEnumerable<IStorageFile> SrcFiles = UsableConvoy.Payload as IEnumerable<IStorageFile>;

                foreach ( IStorageFile ISF in SrcFiles )
                {
                    s += await ISF.ReadString() + "\n";
                }
            }

            IStorageFile tmp = await AppStorage.MkTemp();
            await tmp.WriteString( s );

            return new ProcConvoy( this, new IStorageFile[] { tmp } );
        }
Exemple #2
0
        public override async Task<ProcConvoy> Run( ProcConvoy Convoy )
        {
            await base.Run( Convoy );

            ProcConvoy UsableConvoy;
            if ( !TryGetConvoy( out UsableConvoy, ( P, C ) =>
            {
                return C.Payload is IEnumerable<IStorageFile>
                || C.Payload is string;
            }
            ) ) return Convoy;

            List<IStorageFile> TargetFiles = new List<IStorageFile>();
            if ( UsableConvoy.Payload is string )
            {
                IStorageFile ISF = await AppStorage.MkTemp();
                TargetFiles.Add( await FilterContent( ISF, UsableConvoy.Payload as string ) );
            }
            else
            {
                IEnumerable<IStorageFile> SrcFiles = UsableConvoy.Payload as IEnumerable<IStorageFile>;

                foreach ( IStorageFile ISF in SrcFiles )
                {
                    TargetFiles.Add( await FilterContent( ISF ) );
                }
            }

            return new ProcConvoy( this, TargetFiles );
        }
Exemple #3
0
        public override async Task<ProcConvoy> Run( ProcConvoy Convoy )
        {
            await base.Run( Convoy );

            HashSet<string> ConvoyUrls = null;

            if ( Incoming )
            {
                ProcManager.PanelMessage( this, () => Res.RSTR( "IncomingCheck" ), LogType.INFO );

                ProcConvoy UsableConvoy = ProcManager.TracePackage(
                    Convoy, ( P, C ) =>
                    {
                        return C.Payload is IEnumerable<string> || C.Payload is string;
                    }
                );

                if ( UsableConvoy != null )
                {
                    if ( UsableConvoy.Payload is string )
                    {
                        ConvoyUrls = new HashSet<string>();
                        ConvoyUrls.Add( ( string ) UsableConvoy.Payload );
                    }
                    else
                    {
                        ConvoyUrls = new HashSet<string>( ( IEnumerable<string> ) UsableConvoy.Payload );
                    }
                }
            }

            if ( ConvoyUrls == null && Urls.Count == 0 )
            {
                ProcManager.PanelMessage( this, () => Res.RSTR( "EmptyUrlLIst" ), LogType.WARNING );
            }

            List<IStorageFile> ISFs = new List<IStorageFile>();

            foreach ( string u in Urls )
            {
                IStorageFile ISF = await ProceduralSpider.DownloadSource( Prefix + u );
                if ( ISF != null ) ISFs.Add( ISF );
            }

            if ( ConvoyUrls != null )
            {
                foreach ( string u in ConvoyUrls )
                {
                    IStorageFile ISF = await ProceduralSpider.DownloadSource( Prefix + u );
                    if ( ISF != null ) ISFs.Add( ISF );
                }
            }

            return new ProcConvoy( this, ISFs );
        }
Exemple #4
0
        private async Task<ProcConvoy> IncomingArguments( ProcConvoy UsableConvoy )
        {
            if ( UsableConvoy.Payload is string )
            {
                return new ProcConvoy( this, ApplyParams( ( ( string ) UsableConvoy.Payload ).Split( new char[] { '\n' }, ParamDefs.Count ) ) );
            }
            else if ( UsableConvoy.Payload is IStorageFile )
            {
                IStorageFile tmp = await AppStorage.MkTemp();
                await tmp.WriteString( ApplyParams( await ( ( IStorageFile ) UsableConvoy.Payload ).ReadLines( ParamDefs.Count ) ) );
                return new ProcConvoy( this, tmp );
            }
            else if ( UsableConvoy.Payload is IEnumerable<IStorageFile> )
            {
                IEnumerable<IStorageFile> Args = ( IEnumerable<IStorageFile> ) UsableConvoy.Payload;
                List<IStorageFile> TemplatedStrs = new List<IStorageFile>();

                foreach ( IStorageFile Arg in Args )
                {
                    IStorageFile tmp = await AppStorage.MkTemp();
                    await tmp.WriteString( ApplyParams( await Arg.ReadLines( ParamDefs.Count ) ) );
                    TemplatedStrs.Add( tmp );
                }

                return new ProcConvoy( this, TemplatedStrs );
            }
            else
            {
                IEnumerable<string> Args = ( IEnumerable<string> ) UsableConvoy.Payload;
                return new ProcConvoy( this, Args.Remap( x => ApplyParams( x ) ) );
            }
        }
Exemple #5
0
        private async Task<ProcConvoy> IncomingTemplates( ProcConvoy UsableConvoy )
        {
            if ( UsableConvoy.Payload is string )
            {
                return new ProcConvoy( this, FormatParams( ( string ) UsableConvoy.Payload ) );
            }
            else if ( UsableConvoy.Payload is IStorageFile )
            {
                IStorageFile tmp = await AppStorage.MkTemp();
                await tmp.WriteString( FormatParams( await ( ( IStorageFile ) UsableConvoy.Payload ).ReadString() ) );
                return new ProcConvoy( this, tmp );
            }
            else if ( UsableConvoy.Payload is IEnumerable<IStorageFile> )
            {
                IEnumerable<IStorageFile> Templates = ( IEnumerable<IStorageFile> ) UsableConvoy.Payload;
                List<IStorageFile> TemplatedStrs = new List<IStorageFile>();

                foreach ( IStorageFile Template in Templates )
                {
                    IStorageFile tmp = await AppStorage.MkTemp();
                    await tmp.WriteString( FormatParams( await Template.ReadString() ) );
                    TemplatedStrs.Add( tmp );
                }

                return new ProcConvoy( this, TemplatedStrs );
            }
            else
            {
                IEnumerable<string> Templates = ( IEnumerable<string> ) UsableConvoy.Payload;
                return new ProcConvoy( this, Templates.Remap( x => FormatParams( x ) ) );
            }
        }
Exemple #6
0
        public override async Task<ProcConvoy> Run( ProcConvoy Convoy )
        {
            await base.Run( Convoy );

            string LoadUrl = TargetUrl;
            string Content = "";

            ProcConvoy UsableConvoy = ProcManager.TracePackage(
                Convoy, ( P, C ) =>
                    C.Payload is IEnumerable<IStorageFile>
                    || C.Payload is IEnumerable<string>
                    || C.Payload is IStorageFile
                    || C.Payload is string
            );

            IStorageFile ISF = null;

            if ( UsableConvoy != null )
            {
                ProcManager.PanelMessage( this, () => Res.RSTR( "IncomingCheck" ), LogType.INFO );

                if ( UsableConvoy.Payload is IEnumerable<IStorageFile> )
                {
                    ISF = ( UsableConvoy.Payload as IEnumerable<IStorageFile> ).FirstOrDefault();
                }
                else if ( UsableConvoy.Payload is IStorageFile )
                {
                    ISF = ( IStorageFile ) UsableConvoy.Payload;
                }

                if ( Incoming )
                {
                    if ( UsableConvoy.Payload is IEnumerable<string> )
                    {
                        LoadUrl = ( UsableConvoy.Payload as IEnumerable<string> ).FirstOrDefault();
                    }
                    else if ( UsableConvoy.Payload is string )
                    {
                        LoadUrl = ( string ) UsableConvoy.Payload;
                    }

                    if ( ISF == null && string.IsNullOrEmpty( LoadUrl ) )
                    {
                        ProcManager.PanelMessage( this, () => Res.RSTR( "NoUsablePayload" ), LogType.WARNING );
                        return Convoy;
                    }

                    if ( !string.IsNullOrEmpty( LoadUrl ) )
                    {
                        LoadUrl = WebUtility.HtmlDecode( LoadUrl );
                    }
                }
                else // Incomings are Content
                {
                    if ( UsableConvoy.Payload is IEnumerable<string> )
                    {
                        Content = string.Join( "\n", ( IEnumerable<string> ) UsableConvoy.Payload );
                    }
                    else if ( UsableConvoy.Payload is string )
                    {
                        Content = ( string ) UsableConvoy.Payload;
                    }
                }
            }

            ProcConvoy BookConvoy = ProcManager.TracePackage( Convoy, ( D, C ) => C.Payload is BookItem );

            BookItem BookInst = ( BookConvoy == null )
                ? new BookInstruction()
                : ( BookConvoy.Payload as BookItem )
                ;

            if ( !string.IsNullOrEmpty( LoadUrl ) )
            {
                BookInst.ReadParam( AppKeys.BINF_ORGURL, LoadUrl );

                if ( string.IsNullOrEmpty( Content ) && ISF == null )
                {
                    ISF = await ProceduralSpider.DownloadSource( LoadUrl );
                }
            }

            if ( ISF != null ) Content = await ISF.ReadString();

            await ExtractProps( BookInst, Content );

            return new ProcConvoy( this, BookInst );
        }
Exemple #7
0
        public override async Task<ProcConvoy> Run( ProcConvoy Convoy )
        {
            await base.Run( Convoy );

            string LoadUrl = null;
            FirstStopped = false;

            if ( Incoming )
            {
                ProcManager.PanelMessage( this, () => Res.RSTR( "IncomingCheck" ), LogType.INFO );

                ProcConvoy UsableConvoy = ProcManager.TracePackage(
                    Convoy, ( P, C ) =>
                    {
                        return C.Payload is IEnumerable<string> || C.Payload is string;
                    }
                );

                if ( UsableConvoy != null )
                {
                    if ( UsableConvoy.Payload is string )
                    {
                        LoadUrl = UsableConvoy.Payload as string;
                    }
                    else
                    {
                        LoadUrl = ( UsableConvoy.Payload as IEnumerable<string> ).FirstOrDefault();
                    }

                    if( !string.IsNullOrEmpty( LoadUrl ) )
                    {
                        LoadUrl = WebUtility.HtmlDecode( LoadUrl );
                    }
                }
            }

            if ( string.IsNullOrEmpty( LoadUrl ) ) LoadUrl = EntryPoint;

            if( string.IsNullOrEmpty( LoadUrl ) )
            {
                ProcManager.PanelMessage( this, () => Res.RSTR( "NoEntryPoint" ), LogType.WARNING );
                return Convoy;
            }

            List<IStorageFile> ISFs = new List<IStorageFile>();
            bool Continue = true;
            Urls.Clear();
            NotifyChanged( "Urls" );

            while ( Continue )
            {
                if( string.IsNullOrEmpty( LoadUrl ) )
                {
                    ProcManager.PanelMessage( this, () => Res.RSTR( "CannotCarrieOn" ), LogType.ERROR );
                    break;
                }

                IStorageFile ISF = await ProceduralSpider.DownloadSource( LoadUrl );

                string Matchee = await ISF.ReadString();
                Continue = NextUrl( Matchee, out LoadUrl ) && !WillStop( Matchee );

                if ( Continue || !DiscardUnmatched )
                {
                    ISFs.Add( ISF );
                }
            }

            return new ProcConvoy( this, ISFs );
        }
Exemple #8
0
 public ProcPassThru( ProcConvoy Convoy, ProcType PType )
     : base( ProcType.PASSTHRU | PType )
 {
     this.Convoy = Convoy;
 }
Exemple #9
0
        public override async Task<ProcConvoy> Run( ProcConvoy Convoy )
        {
            await base.Run( Convoy );

            // Search for usable convoy
            ProcConvoy UsableConvoy;
            if ( !TryGetConvoy( out UsableConvoy, ( P, C ) =>
            {
                return C.Payload is IEnumerable<IStorageFile>
                || C.Payload is string;
            }
            ) ) return Convoy;

            try
            {
                if ( DoNothing() ) return new ProcConvoy( this, null );

                Encoding Enc = null;

                if ( CodePage != Encoding.UTF8.CodePage )
                {
                    Encoding.RegisterProvider( CodePagesEncodingProvider.Instance );
                    Enc = Encoding.GetEncoding( CodePage );
                }

                if ( UsableConvoy.Payload is IEnumerable<IStorageFile> )
                {
                    IEnumerable<IStorageFile> ISFs = ( IEnumerable<IStorageFile> ) UsableConvoy.Payload;

                    foreach ( IStorageFile ISF in ISFs )
                    {
                        string Content;
                        if ( Enc == null )
                        {
                            Content = await ISF.ReadString();
                        }
                        else
                        {
                            ProcManager.PanelMessage( this, Res.SSTR( "ReadEncoding", Enc.EncodingName ), LogType.INFO );

                            if ( !DecodeHtml )
                            {
                                await ISF.WriteString( await ISF.ReadString( Enc ) );
                                continue;
                            }

                            Content = await ISF.ReadString( Enc );
                        }

                        if ( DecodeHtml )
                        {
                            await ISF.WriteString( WebUtility.HtmlDecode( Content ) );
                        }

                        ProcManager.PanelMessage( this, Res.SSTR( "ConvertEncoding", ISF.Name ), LogType.INFO );

                        await ISF.WriteString( Content );
                    }

                    return new ProcConvoy( this, UsableConvoy.Payload );
                }
                else
                {
                    string Content = ( string ) UsableConvoy.Payload;
                    if ( Enc != null )
                    {
                        ProcManager.PanelMessage( this, Res.RSTR( "CantConvertStringLiterals" ), LogType.INFO );
                    }

                    if ( DecodeHtml )
                    {
                        return new ProcConvoy( this, WebUtility.HtmlDecode( Content ) );
                    }
                }
            }
            catch ( Exception ex )
            {
                ProcManager.PanelMessage( this, Res.SSTR( "EncodingFalied", ex.Message ), LogType.INFO );
            }

            return new ProcConvoy( this, null );
        }
Exemple #10
0
        protected bool TryGetConvoy( out ProcConvoy Con, Func<Procedure, ProcConvoy, bool> Tester )
        {
            // Search for usable convoy
            Con = ProcManager.TracePackage( Convoy, Tester ); 

            if( Con == null )
            {
                ProcManager.PanelMessage( this, () => Res.RSTR( "NoUsablePayload" ), LogType.WARNING );
                Faulted = true;
                return false;
            }

            return true;
        }
Exemple #11
0
        public override async Task<ProcConvoy> Run( ProcConvoy Convoy )
        {
            Convoy = await base.Run( Convoy );

            ProcConvoy UsableConvoy;
            if ( !TryGetConvoy( out UsableConvoy, ( P, C ) =>
            {
                if ( P.Type.HasFlag( ProcType.FIND ) || P.Type.HasFlag( ProcType.URLLIST ) )
                {
                    return C.Payload is IEnumerable<IStorageFile>;
                }
                return false;
            }
            ) ) return Convoy;

            IInstructionSet SpTOC = null;

            // Search for the closest Instruction Set
            ProcConvoy SpiderInst = ProcManager.TracePackage(
                Convoy
                , ( P, C ) => {
                    return C.Payload is IInstructionSet;
                }
            );

            if( SpiderInst != null )
            {
                SpTOC = SpiderInst.Payload as IInstructionSet;
            }

            if( SpTOC == null )
            {
                SpTOC = new BookInstruction();
            }

            IEnumerable<IStorageFile> ISFs = UsableConvoy.Payload as IEnumerable<IStorageFile>;

            bool VTitleAddOnce = false;
            ProcPassThru PPass = new ProcPassThru( new ProcConvoy( this, SpTOC ) );

            foreach( IStorageFile ISF in ISFs )
            {
                string Content = await ISF.ReadString();


                ProcFind.RegItem RegTitle = new ProcFind.RegItem( VolPattern, VolTitle, true );
                ProcFind.RegItem RegParam = new ProcFind.RegItem( VolPattern, VolParam, true );

                if ( !( RegTitle.Validate() || RegParam.Validate() ) ) continue;

                MatchCollection matches = RegTitle.RegExObj.Matches( Content );
                foreach ( Match match in matches )
                {
                    if ( VTitleAddOnce ) break;
                    VolInstruction VInst = null;
                    if( RegTitle.Valid )
                    {
                        string FTitle = string.Format(
                            RegTitle.Format
                            , match.Groups
                                .Cast<Group>()
                                .Select( g => g.Value )
                                .ToArray()
                        );

                        if( string.IsNullOrEmpty( RegTitle.Pattern ) )
                        {
                            VTitleAddOnce = true;
                        }

                        VInst = new VolInstruction(
                            VTitleAddOnce ? SpTOC.LastIndex : match.Index
                            , FTitle.ToCTrad()
                        );

                        VInst.ProcMan = VolProcs;
                        SpTOC.PushInstruction( VInst );
                    }
                    else
                    {
                        ProcManager.PanelMessage( this, () => Res.RSTR( "InvalidPattern" ), LogType.WARNING );
                        continue;
                    }

                    if ( HasVolProcs && RegParam.Valid )
                    {
                        string FParam = string.Format(
                            RegParam.Format
                            , match.Groups
                                .Cast<Group>()
                                .Select( g => g.Value )
                                .ToArray()
                        );

                        if( VolAsync )
                        {
                            VInst.SetProcId( VolProcs.GUID );
                            VInst.PushConvoyParam( FParam );
                        }
                        else
                        {
                            ProcConvoy VolConvoy = await VolProcs.CreateSpider().Crawl( new ProcConvoy( PPass, VInst ) );
                        }
                    }
                }

                RegTitle = new ProcFind.RegItem( EpPattern, EpTitle, true );
                RegParam = new ProcFind.RegItem( EpPattern, EpParam, true );

                if ( !( RegTitle.Validate() || RegParam.Validate() ) ) continue;

                matches = RegTitle.RegExObj.Matches( Content );
                foreach ( Match match in matches )
                {
                    EpInstruction EInst = null;
                    if( RegTitle.Valid )
                    {
                        string FTitle = string.Format(
                            RegTitle.Format
                            , match.Groups
                                .Cast<Group>()
                                .Select( g => g.Value )
                                .ToArray()
                        );

                        EInst = new EpInstruction(
                            VTitleAddOnce ? SpTOC.LastIndex : match.Index
                            , FTitle.ToCTrad()
                        );
                        EInst.ProcMan = EpProcs;
                        SpTOC.PushInstruction( EInst );
                    }
                    else
                    {
                        ProcManager.PanelMessage( this, () => Res.RSTR( "InvalidPattern" ), LogType.WARNING );
                        continue;
                    }

                    if ( HasEpProcs && RegParam.Valid )
                    {
                        string FParam = string.Format(
                            RegParam.Format
                            , match.Groups
                                .Cast<Group>()
                                .Select( g => g.Value )
                                .ToArray()
                        );

                        if( EpAsync )
                        {
                            EInst.SetProcId( EpProcs.GUID );
                            EInst.PushConvoyParam( FParam );
                        }
                        else
                        {
                            ProcConvoy EpConvoy = await EpProcs.CreateSpider().Crawl( new ProcConvoy( PPass, FParam ) );
                        }
                    }
                }
            }

            return new ProcConvoy( this, SpTOC );
        }
Exemple #12
0
        private async Task<string> GetId( ProcConvoy Convoy )
        {
            Convoy = ProcManager.TracePackage(
                Convoy, ( P, C ) =>
                    C.Payload is IEnumerable<IStorageFile>
                    || C.Payload is IEnumerable<string>
                    || C.Payload is IStorageFile
                    || C.Payload is string
            );

            if ( Convoy == null ) return null;

            if ( Convoy.Payload is IEnumerable<IStorageFile> )
            {
                IEnumerable<IStorageFile> ISFs = ( IEnumerable<IStorageFile> ) Convoy.Payload;
                return await ISFs.FirstOrDefault()?.ReadString();
            }
            else if ( Convoy.Payload is IEnumerable<string> )
            {
                IEnumerable<string> Contents = ( IEnumerable<string> ) Convoy.Payload;
                return Contents.FirstOrDefault();
            }
            else if ( Convoy.Payload is IStorageFile )
            {
                IStorageFile ISF = ( IStorageFile ) Convoy.Payload;
                return await ISF.ReadString();
            }
            else // string
            {
                return ( string ) Convoy.Payload;
            }
        }
Exemple #13
0
        private async Task SearchBooks( List<BookInstruction> ItemList, ProcPassThru PPass, ProcConvoy KnownBook, string Content )
        {
            ProcFind.RegItem RegParam = new ProcFind.RegItem( ItemPattern, ItemParam, true );

            if ( !RegParam.Validate() ) return;

            MatchCollection matches = RegParam.RegExObj.Matches( Content );
            foreach ( Match match in matches )
            {
                if ( HasSubProcs && RegParam.Valid )
                {
                    string FParam = string.Format(
                        RegParam.Format
                        , match.Groups
                            .Cast<Group>()
                            .Select( g => g.Value )
                            .ToArray()
                    );

                    ProcConvoy ItemConvoy = await ItemProcs.CreateSpider().Crawl( new ProcConvoy( PPass, FParam ) );

                    string Id = await GetId( ItemConvoy );
                    if ( string.IsNullOrEmpty( Id ) )
                    {
                        ProcManager.PanelMessage( this, () =>
                        {
                            StringResources stx = new StringResources( "Error" );
                            return stx.Str( "NoIdForBook" );
                        }, LogType.WARNING );
                        continue;
                    }

                    ItemConvoy = ProcManager.TracePackage( ItemConvoy, ( P, C ) => C.Payload is BookInstruction );

                    if ( !( ItemConvoy == null || ItemConvoy == KnownBook ) )
                    {
                        BookInstruction BInst = ( BookInstruction ) ItemConvoy.Payload;
                        ItemList.Add( BInst );

                        if ( HasBookSpider ) BInst.PlaceDefs( Id, BookSpider );
                    }
                    else
                    {
                        ProcManager.PanelMessage( this, () =>
                        {
                            StringResources stx = new StringResources( "Error" );
                            return stx.Str( "NotABook" );
                        }, LogType.WARNING );
                    }
                }
            }
        }
Exemple #14
0
        public override async Task<ProcConvoy> Run( ProcConvoy Convoy )
        {
            Convoy = await base.Run( Convoy );

            ProcConvoy UsableConvoy;
            if ( !TryGetConvoy(
                out UsableConvoy
                , ( P, C ) =>
                    C.Payload is IEnumerable<IStorageFile>
                    || C.Payload is IEnumerable<string>
                    || C.Payload is IStorageFile
                    || C.Payload is string
                ) ) return Convoy;

            List<BookInstruction> SpItemList = null;

            // Search for the closest Instruction Set
            ProcConvoy SpiderInst = ProcManager.TracePackage(
                Convoy
                , ( P, C ) => C.Payload is IEnumerable<BookInstruction>
            );

            if ( SpiderInst != null )
            {
                SpItemList = ( List<BookInstruction> ) SpiderInst.Payload;
            }

            if ( SpItemList == null )
            {
                SpItemList = new List<BookInstruction>();
            }

            ProcPassThru PPass = new ProcPassThru( new ProcConvoy( this, SpItemList ) );
            ProcConvoy KnownBook = ProcManager.TracePackage( Convoy, ( P, C ) => C.Payload is BookInstruction );

            if ( UsableConvoy.Payload is IEnumerable<IStorageFile> )
            {
                IEnumerable<IStorageFile> ISFs = ( IEnumerable<IStorageFile> ) UsableConvoy.Payload;

                foreach ( IStorageFile ISF in ISFs )
                {
                    string Content = await ISF.ReadString();
                    await SearchBooks( SpItemList, PPass, KnownBook, Content );
                }
            }
            else if ( UsableConvoy.Payload is IEnumerable<string> )
            {
                IEnumerable<string> Contents = ( IEnumerable<string> ) UsableConvoy.Payload;

                foreach ( string Content in Contents )
                {
                    await SearchBooks( SpItemList, PPass, KnownBook, Content );
                }
            }
            else if ( UsableConvoy.Payload is IStorageFile )
            {
                IStorageFile ISF = ( IStorageFile ) UsableConvoy.Payload;

                string Content = await ISF.ReadString();
                await SearchBooks( SpItemList, PPass, KnownBook, Content );
            }
            else // string
            {
                await SearchBooks( SpItemList, PPass, KnownBook, ( string ) UsableConvoy.Payload );
            }

            return new ProcConvoy( this, SpItemList );
        }
Exemple #15
0
        public static void StoreParams( ProcConvoy Convoy, XRegistry Settings )
        {
            ProcParameter Defs = ( ProcParameter ) ProcManager.TracePackage( Convoy, ( P, C ) => P is ProcParameter )?.Dispatcher;
            if ( Defs == null ) return;

            XParameter PDefs = new XParameter( "PPValues" );
            Defs.AssignParamDefs( PDefs );

            Settings.SetParameter( PDefs );
        }
Exemple #16
0
        public override async Task<ProcConvoy> Run( ProcConvoy Convoy )
        {
            await base.Run( Convoy );

            ProcConvoy UsableConvoy;

            bool IsFeedRun = ( ProcManager.TracePackage( Convoy, ( P, C ) => ( P.Type & ProcType.FEED_RUN ) != 0 ) != null );

            ProcManager.PanelMessage( this, () => Res.RSTR( "RunMode", ModeName ), LogType.INFO );

            switch ( Mode )
            {
                case RunMode.FEEDBACK:
                    if ( !IsFeedRun )
                    {
                        ProcManager.PanelMessage( this, () => Res.RSTR( "NotAFeedRun" ), LogType.INFO );
                        return Convoy;
                    }

                    goto case RunMode.DEFINE;

                case RunMode.DEFINE:
                    UsableConvoy = ProcManager.TracePackage( Convoy, ( P, C ) =>
                        C.Payload is IEnumerable<IStorageFile>
                        || C.Payload is IEnumerable<string>
                        || C.Payload is IStorageFile
                        || C.Payload is string
                    );

                    if ( Incoming )
                    {
                        if ( UsableConvoy == null )
                        {
                            ProcManager.PanelMessage( this, () => Res.RSTR( "NoUsableConvoy" ), LogType.WARNING );
                            return Convoy;
                        }
                        return await IncomingTemplates( UsableConvoy );
                    }
                    else if ( UsableConvoy != null )
                    {
                        return await IncomingArguments( UsableConvoy );
                    }

                    goto DEFAULT_PARAMS;

                /*** Belows only accepts incoming templates ***/
                case RunMode.INPUT:
                    if ( IsFeedRun )
                    {
                        ProcManager.PanelMessage( this, () => Res.RSTR( "FeedRunning" ), LogType.INFO );
                        return Convoy;
                    }

                    ProcConvoy Con = ProcManager.TracePackage( Convoy, ( P, C ) => ( P.Type & ProcType.TEST_RUN ) != 0 );
                    if ( Con != null )
                    {
                        ProcManager.PanelMessage( this, () => Res.RSTR( "TestRun_UseDefault" ), LogType.INFO );
                        break;
                    }

                    Dialogs.InputProcParam InputDialog = new Dialogs.InputProcParam( this );
                    await Popups.ShowDialog( InputDialog );

                    if ( InputDialog.Canceled )
                    {
                        throw new OperationCanceledException( "Canceled by user" );
                    }

                    // Input sets the dafault values
                    break;

                case RunMode.SOURCE_AVAIL:
                    if ( !TryGetConvoy( out UsableConvoy, ( P, C ) => P is ProcParameter ) )
                        return Convoy;

                    ProcParameter Proc = ( ProcParameter ) UsableConvoy.Dispatcher;
                    ParamDefs = Proc.ParamDefs;
                    break;
            }

            if ( Incoming )
            {
                if ( !TryGetConvoy( out UsableConvoy, ( P, C ) =>
                    C.Payload is IEnumerable<IStorageFile>
                    || C.Payload is IEnumerable<string>
                    || C.Payload is IStorageFile
                    || C.Payload is string
                ) ) return Convoy;

                return await IncomingTemplates( UsableConvoy );
            }

            DEFAULT_PARAMS:
            return new ProcConvoy( this, ApplyParams() );
        }
Exemple #17
0
 virtual public async Task<ProcConvoy> Run( ProcConvoy Convoy )
 {
     return await Task.Run( () => this.Convoy = Convoy );
 }
Exemple #18
0
        private void MessageBus_OnDelivery( Message Mesg )
        {
            ProcConvoy Convoy = Mesg.Payload as ProcConvoy;
            if ( Mesg.Content == "RUN_RESULT"
                && Convoy != null
                && Convoy.Dispatcher == EditTarget )
            {
                BookInstruction TInst = 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 );
                }

                TInst.PackVolumes( ProcCon );

                Preview.Navigate(
                    typeof( TableOfContents )
                    , new Tuple<Volume[], SelectionChangedEventHandler>( TInst.GetVolumes(), PreviewContent )
                );
                Preview.BackStack.Clear();
                TestRunning.IsActive = false;
            }
        }
Exemple #19
0
 public ProcPassThru( ProcConvoy Convoy )
     : base( ProcType.PASSTHRU )
 {
     this.Convoy = Convoy;
 }