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(); }
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(); }
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(); }
public XParameter ToXParam() { XParameter Def = new XParameter( "P" ); Def.SetValue( new XKey[] { new XKey( "label", _Label ) , new XKey( "default", _Default ) } ); return Def; }
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; }
virtual public XParameter ToXParam() { XParameter Param = new XParameter( RawName ); if( Name != TypeName ) { Param.SetValue( new XKey( "Name", Name ) ); } return Param; }
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(); }
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; }
public static IEnumerable<XParameter> ToXParam( this IEnumerable<string> StrSet, string KeyName = "Value", string Prefix = "" ) { List<XParameter> XParams = new List<XParameter>(); int i = 0; foreach ( string str in StrSet ) { XParameter Param = new XParameter( Prefix + ( i++ ) ); Param.SetValue( new XKey( KeyName, str ) ); XParams.Add( Param ); } return XParams; }
private void SaveAuth( CookieCollection Cookies ) { foreach ( Cookie cookie in Cookies ) { if ( cookie.Name == "sid" ) { Logger.Log( ID, string.Format( "Set-Cookie: {0}=...", cookie.Name ), LogType.DEBUG ); XParameter MAuth = new XParameter( "member-auth" ); MAuth.SetValue( new XKey[] { new XKey( "name", cookie.Name ) , new XKey( "domain" , cookie.Domain ) , new XKey( "path", cookie.Path ) , new XKey( "value" , cookie.Value ) } ); AuthReg.SetParameter( MAuth ); AuthReg.Save(); break; } } ValidateSession(); }