Example #1
0
        private void cacheInfo( DRequestCompletedEventArgs e, string id )
        {
            Shared.Storage.WriteString( ThisBook.TOCPath, Manipulation.PatchSyntax( e.ResponseString ) );
            Shared.Storage.WriteString( ThisBook.TOCDatePath, ThisBook.RecentUpdateRaw );

            StepAutomation();
        }
Example #2
0
		private void PrelaodBookInfo( DRequestCompletedEventArgs e, string id )
		{
			// When download is successful
			ExtractBookInfo( e.ResponseString, id );
		}
Example #3
0
 private void SaveIntro( DRequestCompletedEventArgs e, string id )
 {
     Shared.Storage.WriteString( CurrentBook.IntroPath, Manipulation.PatchSyntax( e.ResponseString ) );
     CurrentBook.Intro = "OK";
 }
Example #4
0
        private async void SaveTemp( DRequestCompletedEventArgs e, LocalModeTxtList.DownloadBookContext Context )
        {
            StorageFile ISF = await AppStorage.MkTemp(
                Context.Id
                + ". "
                + ( string.IsNullOrEmpty( Context.Title ) ? "{ Parse Needed }" : Context.Title )
                + ".txt"
            );

            await ISF.WriteBytes( e.ResponseBytes );

            SearchSet = new LocalBook[] { new LocalBook( ISF ) };
        }
Example #5
0
 private void ClearAuth( DRequestCompletedEventArgs arg1, string arg2 ) { ClearAuth(); }
Example #6
0
 private void PlaceSuccess( DRequestCompletedEventArgs e, string Id )
 {
     try
     {
         JsonStatus.Parse( e.ResponseString );
         Canceled = false;
         Worker.UIInvoke( () => { Hide(); } );
     }
     catch( Exception ex )
     {
         Error( ex.Message );
     }
 }
Example #7
0
 private void GrantComplete( DRequestCompletedEventArgs e, string Id )
 {
     try
     {
         JsonStatus.Parse( e.ResponseString );
         SetGranted( Id );
     }
     catch( Exception ex )
     {
         Logger.Log( ID, ex.Message );
     }
 }
Example #8
0
        private void ProcessInbox( DRequestCompletedEventArgs e, string QId )
        {
            try
            {
                JsonObject JDef = JsonStatus.Parse( e.ResponseString );
                JsonArray JData = JDef.GetNamedArray( "data" );
                foreach( JsonValue JItem in JData )
                {
                    InboxMessage BoxMessage = new InboxMessage( JItem.GetObject() );
                    AddActivity( new Activity( BoxMessage.Name, BoxMessage.OpenComment )
                    {
                        TimeStamp = BoxMessage.TimeStamp
                    } );
                }

                NotifyChanged( "Activities" );
            }
            catch( Exception )
            {
            }
        }
Example #9
0
        private void RequestsStatus( DRequestCompletedEventArgs e, string QId )
        {
            try
            {
                int NGrants = 0;
                int NScripts = 0;
                JsonObject JMesg = JsonStatus.Parse( e.ResponseString );
                JsonArray JData = JMesg.GetNamedArray( "data" );

                if ( 0 < Grants.Count() )
                {
                    List<SHGrant> CurrGrants = new List<SHGrant>( Grants );
                    foreach( JsonValue JValue in JData )
                    {
                        SHGrant G = new SHGrant( JValue.GetObject() );
                        if ( Grants.Any( x => x.Id == G.Id ) ) continue;
                        CurrGrants.Add( G );
                    }
                    Grants = CurrGrants.ToArray();
                }
                else
                {
                    Grants = JData.Remap( x =>
                    {
                        SHGrant G = new SHGrant( x.GetObject() );

                        int l = G.Grants.Length;
                        if ( !G.SourceRemoved )
                        {
                            if ( 0 < l ) NScripts++;
                            NGrants += l;
                        }

                        return G;
                    } );
                }

                if ( 0 < NGrants )
                {
                    AddActivity( () =>
                    {
                        StringResources stx = new StringResources();
                        return string.Format( stx.Text( "GrantsReceived" ), NGrants, NScripts );
                    }, () => MessageBus.SendUI( typeof( SharersHub ), AppKeys.SH_SHOW_GRANTS ) );
                }
            }
            catch ( Exception ex )
            {
                Logger.Log( ID, ex.Message, LogType.WARNING );
            }
        }
Example #10
0
 private void RequestComplete( DRequestCompletedEventArgs e, string QueryId )
 {
     IndicateIdle();
     try
     {
         JsonStatus.Parse( e.ResponseString );
         Canceled = false;
         Hide();
     }
     catch ( Exception ex )
     {
         ErrorMessage( ex.Message );
         Account.Focus( FocusState.Keyboard );
     }
 }
Example #11
0
 private void SListView( DRequestCompletedEventArgs e, string id )
 {
     // Write String Here
     Shared.Storage.WriteString( FileLinks.ROOT_WTEXT + id + ".xml", e.ResponseString );
     SetFrameData( e.ResponseString );
 }
Example #12
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 #13
0
 private void AvatarLoaded( DRequestCompletedEventArgs e, string id )
 {
     Shared.Storage.WriteBytes( AvatarLocation, e.ResponseBytes );
     RefreshAvatar();
 }
Example #14
0
        private void LoginResponse( DRequestCompletedEventArgs e, string id )
        {
            WillLogin = false;
            if ( e.ResponseHeaders[ "Set-Cookie" ] != null )
            {
                SaveAuth( e.Cookies );
                return;
            }

            try
            {
                JsonStatus.Parse( e.ResponseString );
            }
            catch( Exception ex )
            {
                ServerMessage = ex.Message;
            }

            UpdateStatus( MemberStatus.LOGGED_OUT );
        }
Example #15
0
 private void CoverDownloaded( DRequestCompletedEventArgs e, string id )
 {
     // Write Cache
     Shared.Storage.WriteBytes( CurrentBook.CoverPath, e.ResponseBytes );
     // Read Image
     SetCover( CurrentBook );
     // Cover cached. Call once
     OnComplete( CurrentBook );
 }
Example #16
0
        private void SearchItemUpdate( DRequestCompletedEventArgs e, string Id )
        {
            HubScriptItem Target;
            if ( TryNotGetId( Id, out Target ) ) return;

            try
            {
                JsonObject JResponse = JsonStatus.Parse( e.ResponseString );
                Target.Update( JResponse.GetNamedArray( "data" ).First().GetObject() );
            }
            catch ( Exception ex )
            {
                Target.ErrorMessage = ex.Message;
            }
        }
Example #17
0
 // Thread Complete Processor
 public static void LoadComplete( DRequestCompletedEventArgs e, TransferInst PArgs )
 {
     new ContentParser().OrganizeBookContent( e.ResponseString, PArgs.ID, PArgs.cParam );
 }
Example #18
0
        private void ReportSuccess( DRequestCompletedEventArgs e, string Id )
        {
            HubScriptItem Target;
            if ( TryNotGetId( Id, out Target ) ) return;

            try
            {
                JsonStatus.Parse( e.ResponseString );
                RCache.POST(
                    Shared.ShRequest.Server
                    , Shared.ShRequest.Search( "uuid: " + Id, 0, 1 )
                    // Pass the uuid instead of the query id
                    , ( re, q ) => SearchItemUpdate( re, Id )
                    , Utils.DoNothing
                    , true
                );
            }
            catch( Exception ex )
            {
                Target.ErrorMessage = ex.Message;
            }
        }
Example #19
0
 private void DownloadComplete( DRequestCompletedEventArgs e, string Id )
 {
     BindItem.SetScriptData( e.ResponseString );
 }
Example #20
0
		private void GetResponseCallback( IAsyncResult AsyncResult )
		{
			HttpWebRequest Request = ( HttpWebRequest ) AsyncResult.AsyncState;
			string RefUrl = 0 < PostData.Length
				// Mostly PostData
				? Encoding.UTF8.GetString( PostData, 0, PostData.Length )
				// Rarely GET Requests
				: ReqUri.ToString()
				;
			try
			{
				HttpWebResponse Response = ( HttpWebResponse ) Request.EndGetResponse( AsyncResult );
				StatusCode = Response.StatusCode;

				if ( DRequestCompleted != null )
				{
					byte[] rBytes;
					using ( Stream ResponseStream = Response.GetResponseStream() )
					{
						// Read stream in to byte
						byte[] buffer = new byte[16 * 1024];

						using ( MemoryStream ms = new MemoryStream() )
						{
							int read;
							while ( 0 < ( read = ResponseStream.Read( buffer, 0, buffer.Length ) ) )
							{
								ms.Write( buffer, 0, read );
							}
							rBytes = ms.ToArray();
						}
					}
					DRequestCompletedEventArgs RArgs
						= new DRequestCompletedEventArgs( Response, RefUrl, rBytes );
					if ( EN_UITHREAD )
						// Raise event in the Main UI thread
						Worker.UIInvoke( () => DRequestCompleted( RArgs ) );
					else
						DRequestCompleted( RArgs );
				}

				// Close HttpWebResponse
				Response.Dispose();
			}
			catch ( Exception ex )
			{
                if ( EN_UITHREAD )
                {
                    Worker.UIInvoke( () =>
                    {
                        // Throw Exception to CompletedArgs
                        DRequestCompleted( new DRequestCompletedEventArgs( RefUrl, ex ) );
                    } );
                }
                else
                {
                    DRequestCompleted( new DRequestCompletedEventArgs( RefUrl, ex ) );
                }
            }
		}
Example #21
0
 private void CommentSuccess( DRequestCompletedEventArgs e, string Id )
 {
     try
     {
         JsonStatus.Parse( e.ResponseString );
         CommentInput.Document.SetText( Windows.UI.Text.TextSetOptions.None, "" );
         DiscardComment();
         ReloadComments();
     }
     catch( Exception ex )
     {
         CommentError.Text = ex.Message;
     }
 }
Example #22
0
 private void PostSuccess( DRequestCompletedEventArgs e, string id )
 {
     CC_Cancel();
     CC_Reload();
 }
Example #23
0
        private void GotServerList( DRequestCompletedEventArgs e, string key )
        {
            IEnumerable<ServerChoice> SC = null;

            XParameter[] Params = ServerReg.Parameters( "uri" );

            try
            {
                IEnumerable<string> Servers = X.Call<IEnumerable<string>>( XProto.ServerSelector, "ExtractList", e.ResponseString );

                SC = Servers.Remap( x =>
                {
                    string[] s = x.Split( new char[] { ',' } );
                    return new ServerChoice( s[ 0 ], s[ 1 ] );
                } );

                var j = Task.Run( async () =>
                {
                    await X.Call<Task>( XProto.ServerSelector, "ProcessList", Servers );

                    foreach( ServerChoice C in SC )
                    {
                        C.Preferred = X.Static<IEnumerable<Weight<string>>>( XProto.ServerSelector, "ServerList" ).Any( x =>
                        {
                            if ( x.Freight == C.Name )
                            {
                                C.Desc = x.Factor + "";
                                return true;
                            }

                            return false;
                        } );

                        C.IsLoading = false;
                    }
                } );
            }
            catch( Exception ex )
            {
                Logger.Log( ID, ex.Message, LogType.ERROR );
            }

            AvailableServers.ItemsSource = SC;
        }
Example #24
0
 private void CheckResponse( DRequestCompletedEventArgs e, string QueryId )
 {
     try
     {
         JsonStatus.Parse( e.ResponseString );
         IsLoggedIn = true;
         UpdateStatus( MemberStatus.LOGGED_IN );
     }
     catch( Exception ex )
     {
         Logger.Log( ID, ex.Message, LogType.DEBUG );
         ClearAuth();
         UpdateStatus( MemberStatus.RE_LOGIN_NEEDED );
     }
 }