Ejemplo n.º 1
0
 protected void OnCompleted(ProxyEventArgs args)
 {
     if (m_Completed != null)
     {
         m_Completed(this, args);
     }
 }
Ejemplo n.º 2
0
        private void ProxyEvents_onCompleted(ProxyEventArgs evt)
        {
            var response = evt.ProxyParams.Contents["response"] as Response;

            if (response == null)
            {
                return;
            }

            // we need content-encoding (in case server refuses to serve it in plain text)
            // content-length: final size of content sent to user may change via plugins, so it makes no sense to send old content-length
            var forwardHeaders = new List <string> {
                "content-type", "zzzcontent-length", "accept-ranges", "content-range", "content-disposition", "location", "set-cookie"
            };
            NameValueCollection col = new NameValueCollection();

            foreach (string responseHeader in response.Headers)
            {
                col.Add(responseHeader.ToLowerInvariant(), response.Headers[responseHeader]);
            }
            foreach (string forwardHeader in response.Headers)
            {
                if (forwardHeaders.IndexOf(forwardHeader) == -1)
                {
                    col.Remove(forwardHeader);
                }
            }

            response.Headers = col;
            response.Headers.Set("cache-control", "no-cache, no-store, must-revalidate");
            response.Headers.Set("pragma", "no-cache");
            response.Headers.Set("expires", "0");
        }
Ejemplo n.º 3
0
 private void GetConceptByCodeSystemCodeCompleted(object sender, ProxyEventArgs e)
 {
     if (e.Exception == null)
     {
         var results = e.LoadResult <TerminologyConcept> ();
         if (results != null)
         {
             SearchResults = results;
         }
         else
         {
             _userDialogService
             .ShowDialog(
                 "Unable to find a concept with a matching Code System Code",
                 "No results found",
                 UserDialogServiceOptions.Ok);
         }
     }
     else
     {
         _userDialogService.ShowDialog(
             "An error occurred when retrieving the Terminology Concept. Error: " + e.Exception.Message,
             "An error has occurred",
             UserDialogServiceOptions.Ok);
     }
 }
Ejemplo n.º 4
0
        private void GetConceptByCodeSystemCodeCompleted(object sender, ProxyEventArgs e)
        {
            if (e.Exception == null)
            {
                var result = e.LoadResult <TerminologyConcept> ();

                if (result != null)
                {
                    ChangeSearchState(
                        SearchState.AdvancedSearchFoundState,
                        new PagedCollectionView(MapTerminolgyConceptsToSearchResult(new List <TerminologyConcept> {
                        result
                    })),
                        1,
                        100,
                        1);
                }
                else
                {
                    ChangeSearchState(SearchState.AdvancedSearchNotFoundState, null);
                }
            }
            else
            {
                _userDialogService.ShowDialog(e.Exception.Message, "Search Failed", UserDialogServiceOptions.Ok);
            }
        }
Ejemplo n.º 5
0
        private void ProxyEvents_onCompleted(ProxyEventArgs evt)
        {
            var response    = evt.ProxyParams.Contents["response"] as Response;
            var contentType = response.Headers.Get("content-type");

            if (_doNotTouch.Any(v => v.Equals(contentType)))
            {
                return;
            }

            var          str           = response.Content;
            const string iframePattern = @"<iframe[^>]*>[^<]*<\\/iframe>";

            str = Regex.Replace(str, iframePattern, "", RegexOptions.IgnoreCase | RegexOptions.Multiline);

            str = ProxifyHead(str);
            str = ProxifyCss(str);

            const string htmlAttrPattern = @"(?:src|href)\s*=\s*(["" |\'])(.*?)\1";

            str = Regex.Replace(str, htmlAttrPattern, CallBackHtmlAttr, RegexOptions.IgnoreCase | RegexOptions.Multiline);
            const string formAction = @"<form[^>]*action=([""\'])(.*?)\1[^>]*>";

            str = Regex.Replace(str, formAction, CallBackFormAction, RegexOptions.IgnoreCase);

            response.Content = str;
        }
 // Token: 0x0600091C RID: 2332 RVA: 0x000070E9 File Offset: 0x000052E9
 protected void OnCompleted(ProxyEventArgs args)
 {
     if (this.m_Completed == null)
     {
         return;
     }
     this.m_Completed(this, args);
 }
Ejemplo n.º 7
0
 private void ProxyErrorOccured(object sender, ProxyEventArgs args)
 {
     this.Dispatcher.Invoke(DispatcherPriority.Normal, (SendOrPostCallback) delegate
     {
         this.MessageLabel.Text = "Proxy Error (" + args.StatusCode + ") occured:" + args.Message;
         this.P2PEditor.GuiLogMessage(this.MessageLabel.Text.ToString(), NotificationLevel.Error);
         this.MessageLabel.Visibility = Visibility.Visible;
     }, null);
 }
Ejemplo n.º 8
0
 private void OnBeforeExecute(ProxyEventArgs proxyEventArgs)
 {
     if (BeforeExecute != null)
     {
         if (_filter(proxyEventArgs))
         {
             BeforeExecute(this, proxyEventArgs);
         }
     }
 }
Ejemplo n.º 9
0
 private void OnAfterExecute(ProxyEventArgs methodInfo)
 {
     if (AfterExecute != null)
     {
         if (_filter(methodInfo))
         {
             AfterExecute(this, methodInfo);
         }
     }
 }
Ejemplo n.º 10
0
 private void OnErrorExecuting(ProxyEventArgs methodInfo)
 {
     if (ErrorExecuting != null)
     {
         if (_filter(methodInfo))
         {
             ErrorExecuting(this, methodInfo);
         }
     }
 }
Ejemplo n.º 11
0
        private void ProxyEvents_onCompleted(ProxyEventArgs evt)
        {
            var response    = evt.ProxyParams.Contents["response"] as Response;
            var contentType = Helper.CleanContentType(response.Headers.Get("content-type") ?? "");
            var contentLen  = response.Headers.Get("content-length");
            var cLen        = 0;

            int.TryParse(contentLen, out cLen);
            evt.Handled = !string.IsNullOrWhiteSpace(contentType) && (Array.IndexOf(_outputBufferTypes, contentType) == -1 || cLen > MaxContentLen);
        }
Ejemplo n.º 12
0
 private void ProxyEvent(object sender, ProxyEventArgs e)
 {
     foreach (User user in e.GetList())
     {
         users.Add(user);
         UserEnter?.Invoke(this, new ChatEventArgs {
             User = user
         });
     }
 }
Ejemplo n.º 13
0
 private static void ProxyEvent(object sender, ProxyEventArgs e)
 {
     foreach (User user in e.GetList())
     {
         if (user.Name != User.AutoExporterServiceName)
         {
             users.Add(user);
             UserEnter?.Invoke(null, new ChatEventArgs(user));
         }
     }
 }
Ejemplo n.º 14
0
        /*
         * public void treeWindow_AfterSelect(object sender, TreeViewEventArgs e)
         * {
         *  var targetObject = this.treeWindow.SelectedNode.Tag;
         *
         *  if (targetObject is Process)
         *  {
         *      var process = (Process)targetObject;
         *      tsHookProcess.Enabled = true;
         *      tsButtonStartStop.Enabled = false;
         *      this.ModulesList.clear().add_Nodes(process.Modules.toList<ProcessModule>().Select((m)=>m.ModuleName));
         *  }
         *  if (targetObject is ControlProxy)
         *  {
         *      tsButtonStartStop.Enabled = false;
         *      tsButtonStartStop.Enabled = true;
         *  }
         *
         *
         *  this.propertyGrid.SelectedObject = targetObject;
         *
         *  this.toolStripStatusLabel1.Text = treeWindow.SelectedNode.Text;
         *
         *  StopLogging();
         *  //this.eventGrid.Rows.Clear();
         *  StartLogging();
         * }*/

        /// <summary>
        /// This is called when the selected ControlProxy raises an event
        /// </summary>
        public void ProxyEventFired(object sender, ProxyEventArgs args)
        {
            try
            {
                eventGrid.FirstDisplayedScrollingRowIndex =
                    this.eventGrid.Rows.Add(new object[] { args.eventDescriptor.Name, args.eventArgs.ToString() });
            }
            catch (Exception ex)
            {
                ex.log();
            }
        }
Ejemplo n.º 15
0
        private void ProxyEventsOnBeforeRequest(ProxyEventArgs evt)
        {
            var request = evt.ProxyParams.Contents["request"] as Request;

            if (request == null)
            {
                return;
            }
            request.Headers.Remove("connection");
            request.Headers.Set("accept-encoding", "identity"); // // tell target website that we only accept plain text without any transformations
            request.Headers.Remove("referer");                  // mask proxy referer
        }
Ejemplo n.º 16
0
        void Proxy_Completed(object sender, ProxyEventArgs e)
        {
            Proxy.Completed -= new EventHandler <ProxyEventArgs>(Proxy_Completed);

            if (e.Connected)
            {
                ProcessConnect(e.Socket, null, null);
                return;
            }

            OnError(new Exception("proxy error", e.Exception));
            m_InConnecting = false;
        }
Ejemplo n.º 17
0
        private void ProxyEvents_onBeforeRequest(ProxyEventArgs evt)
        {
            var request = evt.ProxyParams.Contents["request"] as Request;

            if (string.IsNullOrEmpty(request.Post["convertGET"]))
            {
                return;
            }
            request.Post.Remove("convertGET");
            foreach (string o in request.Post)
            {
                request.Get.Set(o, request.Post[o]);
            }
            request.Post.Clear();
            request.Method = HttpMethod.Get;
        }
Ejemplo n.º 18
0
        private void GetVocabularyListCompleted(object sender, ProxyEventArgs e)
        {
            if (e.Exception == null)
            {
                var list = e.LoadResult <ObservableCollection <TerminologyVocabulary> > ();

                var snomed = list.Where(n => n.BusinessCode == "SNOMED").FirstOrDefault();

                Namespaces        = list;
                SelectedNamespace = snomed;
            }
            else
            {
                _userDialogService
                .ShowDialog(e.Exception.Message, "Could not retrieve the Vocabulary List", UserDialogServiceOptions.Ok);
            }
        }
Ejemplo n.º 19
0
        void Proxy_Completed(object sender, ProxyEventArgs e)
        {
            Proxy.Completed -= Proxy_Completed;

            if (e.Connected)
            {
                SocketAsyncEventArgs se = null;
                if (e.TargetHostName != null)
                {
                    se = new SocketAsyncEventArgs();
                    se.RemoteEndPoint = new DnsEndPoint(e.TargetHostName, 0);
                }
                ProcessConnect(e.Socket, null, se, null);
                return;
            }

            OnError(new Exception("proxy error", e.Exception));
            m_InConnecting = false;
        }
Ejemplo n.º 20
0
        public void TestMatchSecondTime()
        {
            var server      = CreateSimplyRespond(Encoding.ASCII.GetBytes("OK"));
            var proxyServer = CreateSimplyRespond(Encoding.ASCII.GetBytes("OK"));

            ManualResetEvent wait = new ManualResetEvent(false);

            var            proxy     = new HttpConnectProxy(proxyServer.LocalEndPoint);
            ProxyEventArgs eventArgs = null;

            proxy.Completed += (a, e) =>
            {
                eventArgs = e;
                wait.Set();
            };
            proxy.Connect(server.LocalEndPoint);

            Assert.True(wait.WaitOne(5000));
            Assert.Null(eventArgs.Exception);
            Assert.True(eventArgs.Connected);
        }
Ejemplo n.º 21
0
 private void HandleProxy(ProxyEventArgs args)
 {
     if (!Deployment.Current.Dispatcher.CheckAccess())
     {
         Deployment.Current.Dispatcher.BeginInvoke(() => HandleProxy(args));
         return;
     }
     HidePogressIndicator();
     if (args.Code == HttpStatusCode.OK)
     {
         PushDataToModel(args.Response);
     }
     else if (args.Code == HttpStatusCode.Unused)
     {
         MessageBox.Show(Resource.message_Exception, Resource.hint, MessageBoxButton.OK);
     }
     else
     {
         MessageBox.Show(Resource.message_WebExeption, Resource.hint, MessageBoxButton.OK);
     }
 }
Ejemplo n.º 22
0
        private void FindConceptsWithNameMatchingCompleted(object sender, ProxyEventArgs e)
        {
            if (e.Exception == null)
            {
                var result =
                    e.LoadResult <ObservableCollection <TerminologyConcept> > ();

                if (result != null)
                {
                    if (result.Count > 0)
                    {
                        ChangeSearchState(
                            SearchState.QuickSearchFoundState,
                            new PagedCollectionView(MapTerminolgyConceptsToSearchResult(result)),
                            1,
                            100,
                            result.Count);
                    }
                    else
                    {
                        ChangeSearchState(
                            SearchState.QuickSearchNotFoundState,
                            new PagedCollectionView(MapTerminolgyConceptsToSearchResult(result)),
                            1,
                            100,
                            result.Count);
                    }
                }
                else
                {
                    ChangeSearchState(SearchState.QuickSearchNotFoundState, null);
                }
            }
            else
            {
                _userDialogService.ShowDialog(e.Exception.Message, "Search Failed", UserDialogServiceOptions.Ok);
            }
        }
Ejemplo n.º 23
0
 private void GetVocabularyListCompleted(object sender, ProxyEventArgs e)
 {
     if (e.Exception == null)
     {
         var results = e.LoadResult <ObservableCollection <TerminologyVocabulary> > ();
         if (results != null)
         {
             _namspace = results.FirstOrDefault(tv => tv.BusinessCode == _namespaceToUse);
             if (_namspace == null)
             {
                 throw new Exception("Dts Vocabulary not found.");
             }
             (ManualSearchCommand as DelegateCommand).RaiseCanExecuteChanged();
         }
     }
     else
     {
         _userDialogService.ShowDialog(
             "An error occurred when retrieving the Terminology Vocabularies. Error: " + e.Exception.Message,
             "An error has occurred",
             UserDialogServiceOptions.Ok);
     }
 }
Ejemplo n.º 24
0
        private void Proxy_Completed(object sender, ProxyEventArgs e)
        {
            string str;

            this.Proxy.Completed -= new EventHandler <ProxyEventArgs>(this.Proxy_Completed);
            this.ProxyConnected   = e.Connected;
            string    targetHostName = e.TargetHostName;
            Exception exception      = e.Exception;

            if (exception != null)
            {
                str = exception.ToString();
            }
            else
            {
                str = null;
            }
            Debug.WriteLine(string.Concat("Proxy_Completed ", targetHostName, " ", str));
            if (e.Connected)
            {
                this.Socket = e.Socket;
            }
            this.WaitRes.Set();
        }
Ejemplo n.º 25
0
 // called when the user logs in
 void Lobby_ProxyEvent(object sender, ProxyEventArgs e)
 {
     // when this method gets called, it's usually not by the UI thread.
     // this codeblock ensures the correct thread is used
     if (!this.Dispatcher.CheckAccess())
     {
         this.Dispatcher.BeginInvoke(
             DispatcherPriority.Normal,
             new ProxySingletonProxyEventDelegate(Lobby_ProxyEvent),
             sender,
             new object[] { e });
         return;
     }
 }
        private void GetVocabularyListCompleted( object sender, ProxyEventArgs e )
        {
            if ( e.Exception == null )
            {
                var list = e.LoadResult<ObservableCollection<TerminologyVocabulary>> ();

                var snomed = list.Where ( n => n.BusinessCode == "SNOMED" ).FirstOrDefault ();

                Namespaces = list;
                SelectedNamespace = snomed;
            }
            else
            {
                _userDialogService
                    .ShowDialog ( e.Exception.Message, "Could not retrieve the Vocabulary List", UserDialogServiceOptions.Ok );
            }
        }
 private void FindConceptsWithNameMatchingCompleted( object sender, ProxyEventArgs e )
 {
     SearchResults = e.LoadResult<ObservableCollection<TerminologyConcept>> ();
 }
Ejemplo n.º 28
0
 private void GetVocabularyListCompleted( object sender, ProxyEventArgs e )
 {
     if ( e.Exception == null )
     {
         var results = e.LoadResult<ObservableCollection<TerminologyVocabulary>> ();
         if ( results != null )
         {
             _namspace = results.FirstOrDefault ( tv => tv.BusinessCode == _namespaceToUse );
             if ( _namspace == null )
             {
                 throw new Exception ( "Dts Vocabulary not found." );
             }
             ( ManualSearchCommand as DelegateCommand ).RaiseCanExecuteChanged ();
         }
     }
     else
     {
         _userDialogService.ShowDialog (
             "An error occurred when retrieving the Terminology Vocabularies. Error: " + e.Exception.Message,
             "An error has occurred",
             UserDialogServiceOptions.Ok );
     }
 }
Ejemplo n.º 29
0
 /// <summary>
 /// This is called when the selected ControlProxy raises an event
 /// </summary>
 private void ProxyEventFired(object sender, ProxyEventArgs args)
 {
     eventGrid.FirstDisplayedScrollingRowIndex = this.eventGrid.Rows.Add(new object[] { args.eventDescriptor.Name, args.eventArgs.ToString() });
 }
Ejemplo n.º 30
0
        /*
        public void treeWindow_AfterSelect(object sender, TreeViewEventArgs e)
        {
            var targetObject = this.treeWindow.SelectedNode.Tag;

            if (targetObject is Process)
            {
                var process = (Process)targetObject;
                tsHookProcess.Enabled = true;
                tsButtonStartStop.Enabled = false;
                this.ModulesList.clear().add_Nodes(process.Modules.toList<ProcessModule>().Select((m)=>m.ModuleName));
            }
            if (targetObject is ControlProxy)
            {
                tsButtonStartStop.Enabled = false;
                tsButtonStartStop.Enabled = true;
            }

            this.propertyGrid.SelectedObject = targetObject;

            this.toolStripStatusLabel1.Text = treeWindow.SelectedNode.Text;

            StopLogging();
            //this.eventGrid.Rows.Clear();
            StartLogging();
        }*/
        /// <summary>
        /// This is called when the selected ControlProxy raises an event
        /// </summary>
        public void ProxyEventFired(object sender, ProxyEventArgs args)
        {
            try
            {
                eventGrid.FirstDisplayedScrollingRowIndex =
                    this.eventGrid.Rows.Add(new object[] { args.eventDescriptor.Name, args.eventArgs.ToString() });
            }
            catch (Exception ex)
            {
                ex.log();
            }
        }
Ejemplo n.º 31
0
        private void FindConceptsWithNameMatchingCompleted( object sender, ProxyEventArgs e )
        {
            if ( e.Exception == null )
            {
                var result =
                    e.LoadResult<ObservableCollection<TerminologyConcept>> ();

                if ( result != null )
                {
                    if ( result.Count > 0 )
                    {
                        ChangeSearchState (
                            SearchState.QuickSearchFoundState,
                            new PagedCollectionView ( MapTerminolgyConceptsToSearchResult ( result ) ),
                            1,
                            100,
                            result.Count );
                    }
                    else
                    {
                        ChangeSearchState (
                            SearchState.QuickSearchNotFoundState,
                            new PagedCollectionView ( MapTerminolgyConceptsToSearchResult ( result ) ),
                            1,
                            100,
                            result.Count );
                    }
                }
                else
                {
                    ChangeSearchState ( SearchState.QuickSearchNotFoundState, null );
                }
            }
            else
            {
                _userDialogService.ShowDialog ( e.Exception.Message, "Search Failed", UserDialogServiceOptions.Ok );
            }
        }
Ejemplo n.º 32
0
        private void GetConceptByCodeSystemCodeCompleted( object sender, ProxyEventArgs e )
        {
            if ( e.Exception == null )
            {
                var result = e.LoadResult<TerminologyConcept> ();

                if ( result != null )
                {
                    ChangeSearchState (
                        SearchState.AdvancedSearchFoundState,
                        new PagedCollectionView ( MapTerminolgyConceptsToSearchResult ( new List<TerminologyConcept> { result } ) ),
                        1,
                        100,
                        1 );
                }
                else
                {
                    ChangeSearchState ( SearchState.AdvancedSearchNotFoundState, null );
                }
            }
            else
            {
                _userDialogService.ShowDialog ( e.Exception.Message, "Search Failed", UserDialogServiceOptions.Ok );
            }
        }
Ejemplo n.º 33
0
 private void FindConceptsWithNameMatchingCompleted(object sender, ProxyEventArgs e)
 {
     SearchResults = e.LoadResult <ObservableCollection <TerminologyConcept> > ();
 }
Ejemplo n.º 34
0
 private void ProxyErrorOccured(object sender, ProxyEventArgs args)
 {
     LogMessage(String.Format(Properties.Resources.Proxy_Error_occured_, args.StatusCode, args.Message), true);
 }
Ejemplo n.º 35
0
 void ProxySingleton_ProxyEvent(object sender, ProxyEventArgs e)
 {
     throw new Exception("The method or operation is not implemented.");
 }
Ejemplo n.º 36
0
 /// <summary>
 /// This is called when the selected ControlProxy raises an event
 /// </summary>
 private void ProxyEventFired(object sender, ProxyEventArgs args)
 {
     eventGrid.FirstDisplayedScrollingRowIndex = this.eventGrid.Rows.Add(new object[] { args.eventDescriptor.Name, args.eventArgs.ToString() });
 }
Ejemplo n.º 37
0
 void Instance_ProxyEvent(object sender, ProxyEventArgs e)
 {
     if (e.lobby != null)
     {
         OnLobbyJoined(e.lobby);
     }
     else
     {
         lblCreateAccount.Content = "Login failed";
     }
 }