public override void ApplyTransform(WebRequest request, WebResponse response)
        {
            //base.ApplyTransform(request, response);
            string httpBody = response.HttpBody;

            QueryCommandAction[] queryActions = this.QueryCommandActions;

            bool sumMatches = true;

            for (int i = 0; i < queryActions.Length; i++)
            {
                QueryCommandAction action = queryActions[i];

                if ( (action.Value is RegExQueryCommand) )
                {
                    string regex = ((RegExQueryCommand)action.Value).Expression;

                    // Apply regular expression
                    sumMatches &= CheckMatches(httpBody, regex);
                }
            }

            // if matches, send message
            if ( sumMatches == _matchType )
            {
                if (this.Transport != null)
                {
                    this.Transport.Send(new string[] {httpBody});
                }
            }
        }
        /// <summary>
        /// Gets the value from the web response.
        /// </summary>
        /// <param name="response"> The web response.</param>
        /// <returns> An object.</returns>
        public override object GetValue(WebResponse response)
        {
            string result = string.Empty;

            foreach ( Ecyware.GreenBlue.Engine.Scripting.Cookie cookie in response.Cookies )
            {
                if ( cookie.Name.CompareTo(this.CookieName)  == 0 )
                {
                    result = cookie.Value;
                    break;
                }
            }

            return result;
        }
        public override void ApplyTransform(WebRequest request, WebResponse response)
        {
            base.ApplyTransform (request, response);

            if ( request.XmlEnvelope != null )
            {
                XmlDocument document = new XmlDocument();
                XmlNode n = document.ImportNode(request.XmlEnvelope,true);
                document.AppendChild(n);

                XmlNamespaceManager nsmgr = new XmlNamespaceManager(document.NameTable);
                nsmgr = HtmlParser.ResolveNamespaces(new StringReader(request.XmlEnvelope.OuterXml),nsmgr);

                foreach ( XmlElementField field in XmlElementFields )
                {
                    // Get Xml Element Location
                    XmlNode selectedNode = document.SelectSingleNode(field.Location, nsmgr);

                    // Generate TransformValue
                    string result = Convert.ToString(field.TransformValue.GetValue(response));

                    // Set value
                    if ( selectedNode.NodeType == XmlNodeType.Element )
                    {
                        selectedNode.InnerText = result;
                    }
                    if ( selectedNode.NodeType == XmlNodeType.Attribute )
                    {
                        selectedNode.Value = result;
                    }
                }

                if ( request.RequestType == HttpRequestType.PUT )
                {
                    ((PutWebRequest)request).PostData = document.DocumentElement.OuterXml;
                }
                if ( request.RequestType == HttpRequestType.POST )
                {
                    ((PostWebRequest)request).PostData = document.DocumentElement.OuterXml;
                }
                if ( request.RequestType == HttpRequestType.SOAPHTTP )
                {
                    request.XmlEnvelope = document.DocumentElement;
                }
            }
        }
 public void ApplySecurityTransformAction(WebRequest request, WebResponse response)
 {
     switch ( this.RequestStateDataType )
     {
         case  RequestStateDataType.Form:
             ApplyFormTest(request);
             break;
         case  RequestStateDataType.Cookies:
             //ApplyCookiesTest();
             break;
         case  RequestStateDataType.PostData:
             //ApplyPostDataTest();
             break;
         case  RequestStateDataType.Url:
             //ApplyUrlTest();
             break;
     }
 }
        /// <summary>
        /// Applies the transform to the request.
        /// </summary>		
        /// <param name="request"> The web request.</param>
        /// <param name="response"> The web response.</param>
        public override void ApplyTransform(WebRequest request, WebResponse response)
        {
            base.ApplyTransform (request, response);

            // Apply TransformAction
            object value = _updateTransformAction.ApplyTransformAction(response);

            switch ( this.RequestFieldName )
            {
                case "ChangeUrlHostname":
                    string hostname =  Convert.ToString(value);
                    Uri ur = new Uri(request.Url);
                    Uri temp = new Uri(ur.Scheme + "://" + hostname + "/");
                    Uri temp1 = new Uri(temp, ur.AbsolutePath);
                    request.Url = temp1.ToString();
                    break;
                case "ChangeUrlPath":
                    string path =  Convert.ToString(value).TrimStart('/');
                    Uri _ur = new Uri(request.Url);
                    Uri _temp = new Uri(_ur.Scheme + "://" + _ur.Host + "/" + path);
                    request.Url = _temp.ToString();
                    break;
                case "Username":
                    request.RequestHttpSettings.UseBasicAuthentication = true;
                    request.RequestHttpSettings.Username = Convert.ToString(value);
                    break;
                case "Password":
                    request.RequestHttpSettings.UseBasicAuthentication = true;
                    request.RequestHttpSettings.Password = Convert.ToString(value);
                    break;
                default:
                    Type requestType = request.GetType();
                    PropertyInfo pi = requestType.GetProperty(RequestFieldName);

                    if ( pi != null )
                    {
                        pi.SetValue(request,value,null);
                    }

                    break;
            }
        }
 /// <summary>
 /// Appends the response headers.
 /// </summary>
 /// <param name="text"> The StringBuilder.</param>
 /// <param name="response"> The web response.</param>
 public static void AppendResponseHeaders(StringBuilder text, WebResponse response)
 {
     text.AppendFormat("{0}: {1}\r\n",
         "Accept",
         response.ResponseHttpSettings.Accept);
     text.AppendFormat("{0}: {1}\r\n",
         "Character Set",
         response.CharacterSet);
     text.AppendFormat("{0}: {1}\r\n",
         "Content Encoding",
         response.ContentEncoding);
     text.AppendFormat("{0}: {1}\r\n",
         "Content Length",
         response.ResponseHttpSettings.ContentLength);
     text.AppendFormat("{0}: {1}\r\n",
         "Content Type",
         response.ResponseHttpSettings.ContentType);
     text.AppendFormat("{0}: {1}\r\n",
         "If Modified Since",
         response.ResponseHttpSettings.IfModifiedSince);
     text.AppendFormat("{0}: {1}\r\n",
         "Keep Alive",
         response.ResponseHttpSettings.KeepAlive);
     text.AppendFormat("{0}: {1}\r\n",
         "Referer",
         response.ResponseHttpSettings.Referer);
     text.AppendFormat("{0}: {1}\r\n",
         "Send Chunked",
         response.ResponseHttpSettings.SendChunked);
     text.AppendFormat("{0}: {1}\r\n",
         "Transfer Encoding",
         response.ResponseHttpSettings.TransferEncoding);
     text.AppendFormat("{0}: {1}\r\n",
         "User Agent",
         response.ResponseHttpSettings.UserAgent);
     foreach ( WebHeader header in response.ResponseHttpSettings.AdditionalHeaders )
     {
         text.AppendFormat("{0}: {1}\r\n", header.Name, header.Value);
     }
 }
        /// <summary>
        /// Applies the transform to the request.
        /// </summary>
        /// <param name="request"> The web request.</param>
        /// <param name="response"> The web response.</param>
        public override void ApplyTransform(WebRequest request, WebResponse response)
        {
            base.ApplyTransform (request, response);

            Hashtable cookieTable = new Hashtable();
            foreach ( Ecyware.GreenBlue.Engine.Scripting.Cookie cookie in request.Cookies )
            {
                cookieTable.Add(cookie.Name, cookie);
            }

            try
            {
                int i = 0;
                foreach ( TransformAction transformAction in _actions )
                {
                    // Add Cookie
                    if ( transformAction is AddTransformAction )
                    {
                        AddTransformAction add = (AddTransformAction)transformAction;

                        object result = add.Value.GetValue(response);

                        if ( result != null )
                        {
                            // add cookie
                            Cookie ck = GetCookie(add.Name);
                            ck.Value = result.ToString();

                            if ( !cookieTable.ContainsKey(add.Name) )
                            {
                                cookieTable.Add(add.Name, ck);
                            }
                        }
                    }

                    // Update Cookie
                    if ( transformAction is UpdateTransformAction )
                    {
                        UpdateTransformAction update = (UpdateTransformAction)transformAction;

                        object result = update.Value.GetValue(response);

                        if ( cookieTable[update.Name] != null )
                        {
                            // Update cookie
                            Cookie ck = (Cookie)cookieTable[update.Name];
                            ck.Value = result.ToString();
                            cookieTable[update.Name] = ck;
                        }
                    }

                    // Remove Cookie
                    if ( transformAction is RemoveTransformAction )
                    {
                        RemoveTransformAction remove = (RemoveTransformAction)transformAction;

                        if ( cookieTable.ContainsKey(remove.Name) )
                        {
                            cookieTable.Remove(remove.Name);
                        }
                    }

                    i++;
                }

                ArrayList cks = new ArrayList();
                foreach ( DictionaryEntry de in cookieTable )
                {
                    cks.Add(de.Value);
                }

                // update request
                request.Cookies = (Ecyware.GreenBlue.Engine.Scripting.Cookie[])cks.ToArray(typeof(Ecyware.GreenBlue.Engine.Scripting.Cookie));
            }
            catch ( Exception ex )
            {
                ExceptionManager.Publish(ex);
            }
        }
        public override object ApplyTransformAction(WebResponse response)
        {
            base.ApplyTransformAction(response);

            return Value.GetValue(response);
        }
        private void tvResponses_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e)
        {
            StringBuilder text = new StringBuilder();
            string selectedNodeText = tvResponses.SelectedNode.Text;
            currentWebResponse = null;

            switch ( selectedNodeText )
            {
                case "Request Information":
                    WebRequest request = (WebRequest)tvResponses.SelectedNode.Parent.Tag;
                    text.Append("-------------------------------\r\n");
                    text.Append("Request Headers\r\n");
                    text.Append("-------------------------------\r\n");
                    ResponseResultTransform.AppendRequestHeaders(text, request);
                    text.Append("-------------------------------\r\n");
                    text.Append("Request Cookies\r\n");
                    text.Append("-------------------------------\r\n");
                    ResponseResultTransform.AppendCookies(text, request.Cookies);
                    EditorText = text.ToString();
                    ViewHTML(text.ToString());
                    break;
                case "Response Headers":
                    text.Append("-------------------------------\r\n");
                    text.Append("Response Headers\r\n");
                    text.Append("-------------------------------\r\n");
                    ResponseResultTransform.AppendResponseHeaders(text, ((WebRequest)tvResponses.SelectedNode.Parent.Tag).WebResponse);
                    EditorText = text.ToString();
                    ViewHTML(text.ToString());
                    break;
                case "Response Cookies":
                    text.Append("-------------------------------\r\n");
                    text.Append("Response Cookies\r\n");
                    text.Append("-------------------------------\r\n");
                    ResponseResultTransform.AppendCookies(text, ((WebRequest)tvResponses.SelectedNode.Parent.Tag).WebResponse.Cookies);
                    EditorText = text.ToString();
                    ViewHTML(text.ToString());
                    break;
                case "HTML Body":
                    currentWebResponse = ((WebRequest)tvResponses.SelectedNode.Parent.Tag).WebResponse;
                    EditorText = currentWebResponse.HttpBody;
                    ViewHTML(currentWebResponse.HttpBody);
                    //panel1.Enabled = true;
                    break;
            }
        }
        public override void ApplyTransform(WebRequest request, WebResponse response)
        {
            base.ApplyTransform (request, response);

            if ( request.Form != null )
            {
                HtmlFormTag formTag = request.Form.WriteHtmlFormTag();

                #region Fill Form
                foreach ( FormField formField in FormFields )
                {
                    string result = Convert.ToString(formField.TransformValue.GetValue(response));

                    HtmlTagBaseList tagList = formTag[formField.FieldName];
                    HtmlTagBase tagBase = tagList[formField.Index];

                    if ( tagBase is HtmlInputTag )
                    {
                        ((HtmlInputTag)tagBase).Value = result;
                    }
                    if ( tagBase is HtmlButtonTag)
                    {
                        HtmlButtonTag button = (HtmlButtonTag)tagBase;
                        button.Value = result;
                    }
                    if ( tagBase is HtmlSelectTag )
                    {
                        HtmlSelectTag select = (HtmlSelectTag)tagBase;
                        if  ( select.Multiple )
                        {
                            foreach ( HtmlOptionTag opt in select.Options )
                            {
                                //HtmlOptionTag opt = tag;
                                if ( opt.Selected )
                                {
                                    opt.Value = result;
                                }
                            }
                        }
                        else
                        {
                            select.Value = result;
                        }
                    }
                    if  ( tagBase is HtmlTextAreaTag )
                    {
                        ((HtmlTextAreaTag)tagBase).Value = result;
                    }
                }
                #endregion

                // Update request
                request.Form.ReadHtmlFormTag(formTag);
            }
        }
 public override object GetValue(WebResponse response)
 {
     return _value;
 }
 /// <summary>
 /// Generates the value.
 /// </summary>
 /// <param name="response"> The web response.</param>
 /// <returns> An object with the value.</returns>
 public virtual object GetValue(WebResponse response)
 {
     return null;
 }
 public override object GetValue(WebResponse response)
 {
     return ScriptingApplication.Session[_name];
 }
 /// <summary>
 /// Adds a WebResponse.
 /// </summary>
 /// <param name="index"> The web request index.</param>
 /// <param name="response"> The web response.</param>
 public void AddWebResponse(int index,WebResponse response)
 {
     ((WebRequest)_list[index]).WebResponse = response;
 }
 /// <summary>
 /// Gets the value from the web response.
 /// </summary>
 /// <param name="response"> The web response.</param>
 /// <returns> An object.</returns>
 public override object GetValue(WebResponse response)
 {
     Type clientSettingsType = typeof(HttpProperties);
     object value = clientSettingsType.GetProperty(_name).GetValue(response.ResponseHttpSettings, null);
     return value;
 }
 /// <summary>
 /// Applies the current transform to a web request.
 /// </summary>
 public virtual void ApplyTransform(WebRequest request, WebResponse response)
 {
     ValidateLicense();
 }
        public override void ApplyTransform(WebRequest request, WebResponse response)
        {
            // base.ApplyTransform (request, response);
            string result = response.HttpBody;

            try
            {
                // Apply transform value and append each value.
                foreach ( QueryCommandAction action in this.QueryCommandActions )
                {
                    if (( action.Value is XPathQueryCommand ) || ( action.Value is RegExQueryCommand ))
                    {
                        result = action.ApplyQueryCommandAction(result);
                    }
                }

                if ( Transport != null )
                {
                    // Send message to transport.
                    Transport.Send(new string[] {result});
                }

            }
            catch ( Exception ex )
            {
                throw ex;
            }
        }
        /// <summary>
        /// Gets the value associated with the web response.
        /// </summary>
        /// <param name="response"> The WebResponse type.</param>
        /// <returns> The result to return.</returns>
        public override object GetValue(WebResponse response)
        {
            string htmlContent = response.HttpBody;
            NameObjectCollection tagCollection = HtmlLightParser.CreateHtmlElement(htmlContent, this.Tag);

            //string rawElement;
            HtmlLightParserElement liteElement = null;

            if ( TagNameId.Length > 0 )
            {
                liteElement = (HtmlLightParserElement)tagCollection[this.TagNameId];
            }
            else
            {
                // get by index
                liteElement = (HtmlLightParserElement)tagCollection[Tag];
            }

            if ( this.AttributeName.Length > 0 )
            {
                if ( HasAttributeDelimiter )
                {
                    string value = liteElement.GetAttribute(Index, AttributeName);
                    return HtmlLightParser.GetSubAttributeValue(value, this.Delimiter, this.DelimiterIndex);
                }
                else
                {
                    // Get Attribute.
                    return liteElement.GetAttribute(Index, AttributeName);
                }
            }
            else
            {
                return string.Empty;
            }
        }
        /// <summary>
        /// Gets the value from the web response.
        /// </summary>
        /// <param name="response"> The web response.</param>
        /// <returns> An object.</returns>
        public override object GetValue(WebResponse response)
        {
            object result = string.Empty;
            switch ( _name )
            {
                case "Accept":
                    result = response.ResponseHttpSettings.Accept;
                    break;
                case "ContentLength":
                    result = response.ResponseHttpSettings.ContentLength;
                    break;
                case "ContentType":
                    result =  response.ResponseHttpSettings.ContentType;
                    break;
                case "CharacterSet":
                    result = response.CharacterSet;
                    break;
                case "ContentEncoding":
                    result = response.ContentEncoding;
                    break;
                case "IfModifiedSince":
                    result =  response.ResponseHttpSettings.IfModifiedSince;
                    break;
                case "KeepAlive":
                    result =  response.ResponseHttpSettings.KeepAlive;
                    break;
                case "MediaType":
                    result =  response.ResponseHttpSettings.MediaType;
                    break;
                case "Referer":
                    result = response.ResponseHttpSettings.Referer;
                    break;
                case "SendChunked":
                    result = response.ResponseHttpSettings.SendChunked;
                    break;
                case "TransferEncoding":
                    result = response.ResponseHttpSettings.TransferEncoding;
                    break;
                case "UserAgent":
                    result =  response.ResponseHttpSettings.UserAgent;
                    break;
                case "ResponseUri":
                    result = response.ResponseUri;
                    break;
                case "StatusCode":
                    result = response.StatusCode;
                    break;
                case "StatusDescription":
                    result = response.StatusDescription;
                    break;
                case "Version":
                    result = response.Version;
                    break;
                default:
                    try
                    {
                        System.Net.WebHeaderCollection headers = new System.Net.WebHeaderCollection();
                        WebHeader.FillWebHeaderCollection(headers, response.ResponseHttpSettings.AdditionalHeaders);
                        result =  headers[_name];
                    }
                    catch ( Exception ex )
                    {
                        ExceptionManager.Publish(ex);
                    }
                    break;
            }

            return result;
        }
        /// <summary>
        /// Applies the transform to the request.
        /// </summary>
        /// <param name="request"> The web request.</param>
        /// <param name="response"> The web response.</param>
        public override void ApplyTransform(WebRequest request, WebResponse response)
        {
            base.ApplyTransform (request, response);

            try
            {
                System.Net.WebHeaderCollection headers = new System.Net.WebHeaderCollection();
                WebHeader.FillWebHeaderCollection(headers,request.RequestHttpSettings.AdditionalHeaders);

                foreach ( TransformAction transformAction in _actions )
                {
                    // Add Header
                    if ( transformAction is AddTransformAction )
                    {
                        AddTransformAction add = (AddTransformAction)transformAction;

                        object result = add.Value.GetValue(response);

                        if ( headers[add.Name] == null )
                        {
                            headers.Add(add.Name, Convert.ToString(result));
                        }
                    }

                    // Update Header
                    if ( transformAction is UpdateTransformAction )
                    {
                        UpdateTransformAction update = (UpdateTransformAction)transformAction;

                        object result = update.Value.GetValue(response);
                        SetHeaderValue(request, update.Name, Convert.ToString(result), headers);
                    }

                    // Remove Header
                    if ( transformAction is RemoveTransformAction )
                    {
                        RemoveTransformAction remove = (RemoveTransformAction)transformAction;

                        if ( headers[remove.Name] != null )
                        {
                            headers.Remove(remove.Name);
                        }
                    }
                }

                // update request
                request.RequestHttpSettings.AdditionalHeaders = WebHeader.ToArray(headers);
            }
            catch ( Exception ex )
            {
                ExceptionManager.Publish(ex);
            }
        }
 /// <summary>
 /// Applies the transform action.
 /// </summary>
 /// <param name="response"> The web response.</param>
 /// <returns> An object with the value.</returns>
 public virtual object ApplyTransformAction(WebResponse response)
 {
     return null;
 }