private void scriptingCommand_OnRequestEnd(object sender, RequestStartEndEventArgs e)
 {
     Invoke(new OnRequestEndEventHandler(DisplayRequestResponseResult), new object[] {sender, e});
 }
 private void scriptingCommand_OnRequestStart(object sender, RequestStartEndEventArgs e)
 {
     // Add request to progress.
     Invoke(new OnRequestStartEventHandler(AddRequestProgressInvoker), new object[] {sender, e});
 }
        private void DisplayRequestResponseResult(object sender, RequestStartEndEventArgs e)
        {
            try
            {
                if ( e.CurrentIndex == _requestResponseIndex )
                {
                    panel.Controls.Clear();

                    startY = 12;

                    Argument arg = new Argument();
                    arg.Name = "Response Result";
                    arg.Value = e.Request.WebResponse.HttpBody;
                    arg.DesignProperty = new ArgumentProperty();
                    arg.DesignProperty.DesignerControlType = ArgumentProperty.DesignerControl.HtmlEditor;
                    Control control = CreateDesignerControl(e.CurrentIndex,arg);
                    control.Width = 400;
                    control.Height = 400;
                    control.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Bottom;

                    // Label
                    Label label = new Label();
                    label.Location = new System.Drawing.Point(startX, startY);
                    label.Name = "lbl" + arg.Name;

                    if ( arg.DesignProperty.Label.Length > 0 )
                    {
                        label.Text = arg.DesignProperty.Label;
                    }
                    else
                    {
                        label.Text = arg.Name;
                    }

                    if ( control != null )
                    {
                        startY += control.Size.Height + 10;

                        panel.Controls.Add(label);
                        panel.Controls.Add(control);
                    }

                    ((BasicHtmlEditorControl)control).LoadDocument(e.Request.WebResponse.HttpBody);
                    ((BasicHtmlEditorControl)control).IsDesignMode = false;
                    ((BasicHtmlEditorControl)control).ToolbarVisible = false;
                    this.panel1.Text = "";
                    this.panel.Enabled = true;
                    this.btnRun.Enabled = false;
                    this.btnClose.Enabled = true;
                    this.btnNextRequest.Enabled = false;
                }
            }
            catch ( Exception ex )
            {
                MessageBox.Show(ex.Message, AppLocation.ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
 private void scriptingCommand_OnRequestEnd(object sender, RequestStartEndEventArgs e)
 {
     // Add response to tree.
     Invoke(new OnRequestEndEventHandler(AddResponseNodeInvoker), new object[] {sender, e});
 }
        private void AddResponseNodeInvoker(object sender, RequestStartEndEventArgs e)
        {
            AddResponseNode(e.Request);

            MoveProgressBar(e.CurrentIndex);
        }
        private void AddRequestProgressInvoker(object sender, RequestStartEndEventArgs e)
        {
            AddRequestProgress(e.Request);

            if ( e.CurrentIndex == 0 )
            {
                StartProgressBar(e.RequestCount, e.CurrentIndex);
            }
        }
        /// <summary>
        /// The request client result.
        /// </summary>
        /// <param name="sender"> The sender object.</param>
        /// <param name="e"> The event arguments.</param>
        private void ScriptingRequestClientResult(object sender, ScriptingResponseArgs e)
        {
            WebRequest request = e.Context.Request;

            if ( e.Context.Request.WebResponse.ErrorMessage.Length > 0 )
            {
                AbortSessionRun(e.Context.Request.WebResponse.ErrorMessage);
                _currentIndex = 0;
                return;
            }

            // Update Scripting Data
            _sessionScripting.WebRequests[e.Context.RequestIndex] = request;

            if ( OnRequestEnd != null )
            {
                RequestStartEndEventArgs args = new RequestStartEndEventArgs();
                args.CurrentIndex = e.Context.RequestIndex;
                args.RequestCount = _sessionScripting.WebRequests.Length;
                args.Request = request;

                OnRequestEnd(this, args);
            }

            // Execute Next Request
            if ( this.IsRunning )
            {
                ExecuteNextRequest();
            }
            else
            {
                _currentIndex = 0;
            }
        }
        /// <summary>
        /// Executes a request.
        /// </summary>
        /// <param name="request"> The WebRequest to execute.</param>
        /// <param name="index"> The request index.</param>
        private void ExecuteRequest(WebRequest request, int index)
        {
            InitializeHttpCommands();

            // Get Cookies
            CookieCollection cookies = null;
            cookies = _client.CookieManager.GetCookies(new Uri(request.Url));
            request.ClearCookies();
            request.AddCookies(cookies);

            // Apply Input Transforms.
            ApplyInputTransforms(request);

            if ( OnRequestStart != null )
            {
                RequestStartEndEventArgs args = new RequestStartEndEventArgs();
                args.CurrentIndex = index;
                args.RequestCount = _sessionScripting.WebRequests.Length;
                args.Request = request;

                OnRequestStart(this, args);
            }

            switch ( request.RequestType )
            {
                case HttpRequestType.GET:
                    ExecuteGetRequest((GetWebRequest)request, index);
                    break;
                case HttpRequestType.DELETE:
                    ExecuteDeleteRequest((DeleteWebRequest)request, index);
                    break;
                case HttpRequestType.PUT:
                    ExecutePutRequest((PutWebRequest)request, index);
                    break;
                case HttpRequestType.POST:
                    ExecutePostRequest((PostWebRequest)request, index);
                    break;
                case HttpRequestType.SOAPHTTP:
                    ExecuteSoapHttpRequest((SoapHttpWebRequest)request, index);
                    break;
            }
        }