Example #1
0
        public async void Run( IBackgroundTaskInstance taskInstance )
        {
            Deferral = taskInstance.GetDeferral();

            XParameter[] Params = SavedChannels.Parameters( "channel" );

            if ( Params.Length == 0 )
            {
                Deferral.Complete();
                return;
            }

            // Associate a cancellation handler with the background task.
            taskInstance.Canceled += new BackgroundTaskCanceledEventHandler( OnCanceled );

            foreach ( XParameter Param in Params )
            {
                CurrentTask = new XParameter( DateTime.Now.ToFileTime() + "" );
                CurrentTask.SetValue( new XKey[] {
                    new XKey( "name", taskInstance.Task.Name )
                    , new XKey( "start", true )
                    , new XKey( "end", false )
                } );

                PushNotificationChannel channel = await PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync();

                if ( channel.Uri != Param.GetValue( "uri" ) )
                {
                    await RenewChannel( Param.GetValue( "provider" ), Param.Id, Uri.EscapeDataString( channel.Uri ) );
                }

            }

            Deferral.Complete();
        }
Example #2
0
 public static XParameter[] GetParameters( this XElement Root )
 {
     int l;
     IEnumerable<XElement> p = Root.Elements( XRegistry.WTAG );
     if ( 0 < ( l = p.Count() ) )
     {
         XParameter[] w = new XParameter[ l ];
         for ( int i = 0; i < l; i++ )
         {
             w[ i ] = new XParameter( p.ElementAt( i ) );
         }
         return w;
     }
     return new XParameter[ 0 ];
 }
Example #3
0
 public static void SetParameter( this XElement Root, string WIdentifier, XKey[] keys, XParameter[] Params = null )
 {
     XElement tag = Root.FindParameter( WIdentifier );
     if ( tag != null )
     {
         foreach ( XKey k in keys ) tag.SetKey( k );
         if ( Params != null ) foreach ( XParameter P in Params ) tag.SetParameter( P );
     }
     else
     {
         Root.Add( new XElement(
             XRegistry.WTAG
             , new XAttribute[] {
                 new XAttribute( XRegistry.XID, WIdentifier ) }
                 .Concat( keys ), Params )
         );
     }
 }
Example #4
0
        public static XParameter[] Parameters( this XElement Root, string key, string value = null )
        {
            IEnumerable<XElement> xe = Root.Elements( XRegistry.WTAG )
                .Where( p => p.Attribute( key ) != null );

            if ( value != null )
                xe = xe.Where( p => p.Attribute( key ).Value == value );

            if ( xe == null ) return new XParameter[ 0 ];

            xe = xe.ToArray();
            int l;
            XParameter[] ps = new XParameter[ l = xe.Count() ];
            for ( int i = 0; i < l; i++ )
            {
                ps[ i ] = new XParameter( xe.ElementAt( i ) );
            }
            return ps;
        }
Example #5
0
        public override XParameter ToXParam()
        {
            XParameter Param = base.ToXParam();

            Param.SetValue( new XKey[] {
                new XKey( "EntryPoint", EntryPoint )
                , new XKey( "Incoming", Incoming )
                , new XKey( "FirstStopSkip", FirstStopSkip )
                , new XKey( "DiscardUnmatched", DiscardUnmatched )
            } );

            int i = 0;

            XParameter NextParams = new XParameter( "NextIfs" );
            foreach( ProcFind.RegItem R in NextIfs )
            {
                XParameter RegParam = R.ToXParam();
                RegParam.Id += i;
                RegParam.SetValue( new XKey( "i", i++ ) );

                NextParams.SetParameter( RegParam );
            }

            XParameter StopParams = new XParameter( "StopIfs" );
            foreach( ProcFind.RegItem R in StopIfs )
            {
                XParameter RegParam = R.ToXParam();
                RegParam.Id += i;
                RegParam.SetValue( new XKey( "i", i++ ) );

                StopParams.SetParameter( RegParam );
            }

            Param.SetParameter( NextParams );
            Param.SetParameter( StopParams );

            return Param;
        }
Example #6
0
        public override void ReadParam( XParameter Param )
        {
            base.ReadParam( Param );

            EntryPoint = Param.GetValue( "EntryPoint" );
            Incoming = Param.GetBool( "Incoming" );
            FirstStopSkip = Param.GetBool( "FirstStopSkip" );
            DiscardUnmatched = Param.GetBool( "DiscardUnmatched" );

            XParameter NextParams = Param.Parameter( "NextIfs" );
            XParameter[] RegParams = NextParams.Parameters( "i" );
            foreach ( XParameter RegParam in RegParams )
            {
                NextIfs.Add( new ProcFind.RegItem( RegParam ) );
            }

            XParameter StopParams = Param.Parameter( "StopIfs" );
            RegParams = StopParams.Parameters( "i" );
            foreach ( XParameter RegParam in RegParams )
            {
                StopIfs.Add( new ProcFind.RegItem( RegParam ) );
            }
        }
Example #7
0
        private async void AddServer()
        {
            string SrvUri = ServiceUri.Text.Trim();
            if ( string.IsNullOrEmpty( SrvUri ) ) return;

            try
            {
                new Uri( SrvUri );
            }
            catch( Exception )
            {
                await Popups.ShowDialog( new MessageDialog( "Invalid Uri" ) );
                return;
            }

            XParameter Param = new XParameter( SrvUri );
            Param.SetValue( new XKey( "uri", 1 ) );
            ServerReg.SetParameter( Param );
            ServerReg.Save();

            ServiceUri.Text = "";

            RefreshServers();
        }
Example #8
0
        public override void ReadParam( XParameter Param )
        {
            base.ReadParam( Param );

            XParameter[] RegParams = Param.Parameters( "i" );
            CodePage = Param.GetSaveInt( "CodePage" );
            DecodeHtml = Param.GetBool( "DecodeHtml" );
        }
Example #9
0
            public XParameter ToXParam()
            {
                XParameter Def = new XParameter( "P" );
                Def.SetValue( new XKey[] {
                    new XKey( "label", _Label )
                    , new XKey( "default", _Default )
                } );

                return Def;
            }
Example #10
0
            virtual public XParameter ToXParam()
            {
                XParameter Param = new XParameter( "RegItem" );
                Param.SetValue( new XKey[] {
                    // Pattern will be the key identifier
                    new XKey( "Pattern", Pattern )
                    , new XKey( "Format", Format )
                    , new XKey( "Enabled", Enabled )
                } );

                return Param;
            }
Example #11
0
        public override void ReadParam( XParameter Param )
        {
            base.ReadParam( Param );

            Incoming = Param.GetBool( "Incoming" );
            Caption = Param.GetValue( "Caption" );
            TemplateStr = Param.GetValue( "TemplateStr" );
            SetMode( Param.GetValue( "Mode" ) );

            SetParamDefs( Param );
        }
Example #12
0
        virtual public XParameter ToXParam()
        {
            XParameter Param = new XParameter( RawName );
            if( Name != TypeName )
            {
                Param.SetValue( new XKey( "Name", Name ) );
            }

            return Param;
        }
Example #13
0
 virtual public void ReadParam( XParameter Param )
 {
     string PName = Param.GetValue( "Name" );
     if ( PName != null ) Name = PName;
 }
Example #14
0
        public override void ReadParam( XParameter Param )
        {
            base.ReadParam( Param );

            VolTitle = Param.GetValue( "VolTitle" );
            VolPattern = Param.GetValue( "VolPattern" );
            VolParam = Param.GetValue( "VolParam" );
            EpTitle = Param.GetValue( "EpTitle" );
            EpPattern = Param.GetValue( "EpPattern" );
            EpParam = Param.GetValue( "EpParam" );

            VolProcs = new ProcManager( Param.Parameter( "VolProcs" ) );
            EpProcs = new ProcManager( Param.Parameter( "EpProcs" ) );
        }
Example #15
0
        public override void ReadParam( XParameter Param )
        {
            base.ReadParam( Param );

            ItemPattern = Param.GetValue( "ItemPattern" );
            ItemParam = Param.GetValue( "ItemParam" );
            BannerPath = Param.GetValue( "Banner" );

            ItemProcs = new ProcManager( Param.Parameter( "ItemProcs" ) );
            BookSpider = new ProcManager( Param.Parameter( "BookSpider" ) );
        }
Example #16
0
 public void ImportSpider( XParameter SpiderDef )
 {
     ProcManager PM = new ProcManager( SpiderDef );
     BookSpider = PM;
     NotifyChanged( "HasBookSpider" );
 }
Example #17
0
        private void Request_OnRequestComplete( ServiceInfo Info, PushNotificationChannel Channel, DRequestCompletedEventArgs DArgs )
        {
            try
            {
                string Res = DArgs.ResponseString;

                Match m = new Regex( "^[\\da-f]{8}-[\\da-f]{4}-[\\da-f]{4}-[\\da-f]{4}-[\\da-f]{12}$" ).Match( Res );
                if ( m.Success )
                {
                    XParameter Param = new XParameter( Res );
                    Param.SetValue(
                        new XKey[] {
                            new XKey( "provider", Info.Name )
                            , new XKey( "channel", 1 )
                            , new XKey( "uri", Channel.Uri )
                        } );

                    SavedChannels.SetParameter( Param );

                    SavedChannels.Save();
                    NotifyChanged( "Channels" );
                    return;
                }
            }
            catch ( Exception ) { }
            Channel.Close();
        }
Example #18
0
        public override void ReadParam( XParameter Param )
        {
            base.ReadParam( Param );

            TargetUrl = Param.GetValue( "TargetUrl" );
            Incoming = Param.GetBool( "Incoming" );

            XParameter[] ExtParams = Param.Parameters( "i" );
            foreach ( XParameter ExtParam in ExtParams )
            {
                PropDefs.Add( new PropExt( ExtParam ) );
            }
        }
Example #19
0
            public PropExt( XParameter Param )
                : base( Param )
            {
                string SType = Param.GetValue( "Type" );
                this.SubProc = new ProcManager();

                XParameter Sub = Param.Parameter( "SubProc" );
                if ( Sub != null ) SubProc.ReadParam( Sub );

                PType = Enum.GetValues( BINF )
                    .Cast<BookInfo>()
                    .FirstOrDefault( x => Enum.GetName(  BINF, x ) == SType );
            }
Example #20
0
 private void SetParamDefs( XParameter Param )
 {
     XParameter[] Params = Param.Parameters( "i" );
     foreach ( XParameter P in Params )
     {
         AddDef( new ParamDef( P.GetValue( "label" ), P.GetValue( "default" ) )
         {
             Indexer = this.Indexer
         } );
     }
 }
Example #21
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 );
        }
Example #22
0
        public void SetService( string Name, string Proto, string Auth )
        {
            XParameter Param = new XParameter( Name );
            Param.SetXValue( new XKey[]
            {
                new XKey( "proto", Proto )
                , new XKey( "auth", Auth )
            } );

            Settings.SetParameter( Param );
            Settings.Save();
        }
Example #23
0
 private void AssignParamDefs( XParameter Param )
 {
     int i = 0;
     foreach ( ParamDef P in ParamDefs )
     {
         XParameter Def = P.ToXParam();
         Def.Id += i;
         Def.SetValue( new XKey( "i", i++ ) );
         Param.SetParameter( Def );
     }
 }
Example #24
0
 public ProcManager( XParameter Param )
     :this()
 {
     if ( Param == null ) return;
     ReadParam( Param );
 }
Example #25
0
            public async void SetBackground( string type )
            {
                XParameter SecParam = LayoutSettings.Parameter( Section );
                if ( SecParam == null ) SecParam = new XParameter( Section );

                string value = null;
                switch ( type )
                {
                    case "Custom":
                        IStorageFolder Location = await PickDirFromPicLibrary();
                        if ( Location == null ) return;

                        value = SecParam.GetValue( "value" );
                        if ( value == null ) value = Guid.NewGuid().ToString();

                        AppStorage.FutureAccessList.AddOrReplace( value, Location );

                        break;
                    // Preset value fall offs to system as default value
                    case "Preset":
                    case "System":
                        switch ( Section )
                        {
                            case "TOC":
                                value = "ms-appx:///Assets/Samples/BgTOC.jpg";
                                break;
                            case "INFO_VIEW":
                                value = "ms-appx:///Assets/Samples/BgInfoView.jpg";
                                break;
                            case "COMMENTS":
                                value = "ms-appx:///Assets/Samples/BgComments.jpg";
                                break;
                            case "CONTENT_READER":
                                value = "ms-appx:///Assets/Samples/BgContentReader.jpg";
                                break;
                        }

                        break;
                }

                SecParam.SetValue( new XKey[] {
                    new XKey( "type", type )
                    , new XKey( "value", value )
                } );

                LayoutSettings.SetParameter( SecParam );

                ApplyBackgrounds();
                LayoutSettings.Save();
            }
Example #26
0
        public void ReadParam( XParameter List )
        {
            XParameter[] ProcParams = List.Parameters( "ProcType" );
            Async = List.GetBool( "Async", false );
            GUID = List.GetValue( "Guid" );

            Type PType = typeof( ProcType );
            IEnumerable<ProcType> P = Enum.GetValues( PType ).Cast<ProcType>();
            foreach( XParameter Param in ProcParams )
            {
                string ProcName = Param.GetValue( "ProcType" );
                ProcType Proc = P.First( x => Enum.GetName( PType, x ) == ProcName );

                Procedure NProc = NewProcedure( Proc );
                NProc.ReadParam( Param );
            }
        }
Example #27
0
 public void SetParameter( XParameter Param ) { Root.SetParameter( Param ); }
Example #28
0
        public XParameter ToXParam( string ProcId = null )
        {
            XParameter Param = new XParameter( "Procedures" );
            Param.SetValue( new XKey[] {
                new XKey( "Async", Async )
                , new XKey( "Guid", ProcId == null ? GUID : ProcId )
            } );

            int i = 0;
            foreach ( Procedure P in ProcList )
            {
                XParameter ProcParam = P.ToXParam();
                ProcParam.Id = "Proc" + ( i++ );
                ProcParam.SetValue( new XKey( "ProcType", P.RawName ) );
                Param.SetParameter( ProcParam );
            }

            return Param;
        }
Example #29
0
        private void RemoveServer( object sender, RoutedEventArgs e )
        {
            Button B = sender as Button;
            if ( B == null ) return;

            ServerChoice C = B.DataContext as ServerChoice;
            XParameter Param = new XParameter( C.Name );
            Param.SetValue( new XKey( "disabled", true ) );
            ServerReg.SetParameter( Param );
            ServerReg.Save();

            RefreshServers();
        }
Example #30
0
        public override void ReadParam( XParameter Param )
        {
            base.ReadParam( Param );

            Incoming = Param.GetBool( "Incoming" );
            Prefix = Param.GetValue( "Prefix" );

            XParameter[] Params = Param.Parameters( "url" );
            foreach( XParameter P in Params )
            {
                Urls.Add( P.GetValue( "url" ) );
            }
        }