public EditServiceProvider( ServiceInfo Info, bool New = false )
            : this()
        {
            if( New ) Title = "Add Service Provider";

            if ( Info == null ) return;

            NameInput.Text = Info.Name;
            UriInput.Text = Info.Protocol;
            ParamInput.Text = Info.Param;
        }
Exemple #2
0
 public NotisChannel( string uuid, ServiceInfo provider )
 {
     this.uuid = uuid;
     Provider = provider;
 }
Exemple #3
0
 private void ShowServiceContext( object sender, RightTappedRoutedEventArgs e )
 {
     StackPanel Panel = sender as StackPanel;
     SelectedService = Panel.DataContext as ServiceInfo;
     FlyoutBase.ShowAttachedFlyout( Panel );
 }
Exemple #4
0
        private async void EditService( bool New )
        {
            if ( !( SelectedService == null || SelectedService.CanEdit ) )
            {
                SelectedService = null;
            }

            Pages.Dialogs.EditServiceProvider ESProvider = new Pages.Dialogs.EditServiceProvider( SelectedService, New );
            await Popups.ShowDialog( ESProvider );

            if ( ESProvider.Canceled ) return;

            Service.AddService( ESProvider.NameEx, ESProvider.ServiceEx, ESProvider.ParamEx );
        }
        public void Remove( ServiceInfo Service )
        {
            NotisChannel[] RmChannels = Channels.Where( x => x.Provider.Name == Service.Name ).ToArray();
            foreach( NotisChannel RmChannel in RmChannels ) Remove( RmChannel );

            SProvider.RemoveService( Service.Name );
            NotifyChanged( "Services" );
        }
        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();
        }
        public async void CreateChannelUri( ServiceInfo Info )
        {
            PushNotificationChannel channel = await PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync();
            HttpRequest Request = new HttpRequest( new Uri( Info.Protocol ) );

            Request.Method = "POST";
            Request.ContentType = "application/x-www-form-urlencoded";
            Request.OnRequestComplete += e => Request_OnRequestComplete( Info, channel, e );
            Request.OpenWriteAsync( Info.Param + "action=register&uri=" + Uri.EscapeDataString( channel.Uri ) );
        }
        private void RequestRemove( ServiceInfo Info, string uuid )
        {
            HttpRequest Request = new HttpRequest( new Uri( Info.Protocol ) );

            Request.Method = "POST";
            Request.ContentType = "application/x-www-form-urlencoded";

            Request.OnRequestComplete += e =>
            {
                try
                {
                    Logger.Log( ID, e.ResponseString, LogType.DEBUG );
                }
                catch ( Exception ex )
                {
                    Logger.Log( ID, ex.Message, LogType.ERROR );
                }
            };

            Request.OpenWriteAsync( Info.Param + "action=remove&id=" + uuid );
        }