public override void ApplyTransform(Ecyware.GreenBlue.Engine.Scripting.WebRequest request, Ecyware.GreenBlue.Engine.Scripting.WebResponse response) { base.ApplyTransform (request, response); foreach ( SecurityTransformAction action in SecurityTransformActions ) { // TODO action.ApplySecurityTransformAction(request, response); } }
/// <summary> /// Loads the request. /// </summary> /// <param name="index"> The selected web request index.</param> /// <param name="scripting"> The scripting data.</param> /// <param name="request"> The web request.</param> public override void LoadRequest(int index, ScriptingApplication scripting ,Ecyware.GreenBlue.Engine.Scripting.WebRequest request) { base.LoadRequest (index, scripting, request); this.SuspendLayout(); tvTransforms.ContextMenu = this.mnuInputMenu; // Clear pnTransformEditor.Controls.Clear(); tvTransforms.Nodes.Clear(); // if ( index == 0 ) // { // tvTransforms.Nodes.Add(new TreeNode("There is no previous web result to process.")); // } // else // { tvTransforms.Nodes.Add(new TreeNode("Transforms")); if ( request.InputTransforms.Length > 0 ) { // Load transforms WebTransformPageUIHelper.LoadTransforms(tvTransforms.Nodes[0],request.InputTransforms); } this.Focus(); tvTransforms.ExpandAll(); // } tvTransforms.SelectedNode = tvTransforms.Nodes[0]; this.ResumeLayout(false); }
public override void ApplyTransform(Ecyware.GreenBlue.Engine.Scripting.WebRequest request, Ecyware.GreenBlue.Engine.Scripting.WebResponse response) { base.ApplyTransform (request, response); //if ( this.SupportsCallbacks ) //{ //Delegate[] callbacks = this.GetTransformCallbacks(); //Delegate useDelegate = null; HtmlTextResultEventArgs args = new HtmlTextResultEventArgs(); StringBuilder text = new StringBuilder(); // Client Request text.Append(request.RequestType.ToString()); text.Append(" "); text.Append(request.Url); text.Append(" "); text.Append("HTTP/1.1"); text.Append("\r\n\r\n"); // Request Headers text.Append("-----------------------------------------\r\n"); text.Append("Request Headers\r\n"); text.Append("-----------------------------------------\r\n"); // Append request headers AppendRequestHeaders(text, request); // Cookies text.Append("-----------------------------------------\r\n"); text.Append("Request Cookies\r\n"); text.Append("-----------------------------------------\r\n"); AppendCookies(text, request.Cookies); // Server Response text.Append("HTTP/"); text.Append(request.WebResponse.Version); text.Append(" "); text.Append(request.WebResponse.StatusCode.ToString()); text.Append(" "); text.Append(request.WebResponse.StatusDescription); text.Append("\r\n\r\n"); // Response Headers text.Append("-----------------------------------------\r\n"); text.Append("Response Headers\r\n"); text.Append("-----------------------------------------\r\n"); AppendResponseHeaders(text, request.WebResponse); // Cookies text.Append("-----------------------------------------\r\n"); text.Append("Cookies\r\n"); text.Append("-----------------------------------------\r\n"); AppendCookies(text, request.WebResponse.Cookies); // HTTP text.Append("-----------------------------------------\r\n"); text.Append("HTML\r\n"); text.Append("-----------------------------------------\r\n"); text.Append(request.WebResponse.HttpBody + "\r\n"); if ( Transport != null ) { // Send message to transport. Transport.Send(new string[] {text.ToString()}); } //} }
/// <summary> /// Updates any menu /// </summary> /// <param name="parentLink"> The shortcut to root menu.</param> /// <param name="menu"> The menu item.</param> /// <param name="enabled"> Sets the enabled state.</param> public void UpdateMenu(Shortcut parentLink, Ecyware.GreenBlue.Controls.MenuItem menu,bool enabled) { // new Arguments ApplyMenuSettingsEventArgs newArgs = new ApplyMenuSettingsEventArgs(); // identify the shortcut newArgs.RootShortcut = parentLink; menu.Enabled = enabled; newArgs.MenuItems.Add(menu.Name, menu); // update menu this.ApplyMenuSettingsEvent(this, newArgs); }
/// <summary> /// Reads a HtmlFormTag and reads the values to the current object. /// </summary> /// <param name="form"></param> public void ReadHtmlFormTag(Ecyware.GreenBlue.Engine.HtmlDom.HtmlFormTag form) { this.Action = form.Action; this.Enctype = form.Enctype; this.FormIndex = form.FormIndex; this.Method = form.Method; this.Name = form.Name; this.OnSubmit = form.OnSubmit; _elements.Clear(); // load elements for (int i = 0;i<form.AllKeys.Length;i++) { string key = form.AllKeys[i]; HtmlTagBaseList list = (HtmlTagBaseList)form[key]; HtmlTagListXml listXml = new HtmlTagListXml(key, list); _elements.Add(listXml); } }
public void GetWindowContext(out Ecyware.GreenBlue.GreenBlueMain.Interop.IOleInPlaceFrame ppFrame, out Ecyware.GreenBlue.GreenBlueMain.Interop.IOleInPlaceUIWindow ppDoc, Ecyware.GreenBlue.GreenBlueMain.Interop.COMRECT lprcPosRect, Ecyware.GreenBlue.GreenBlueMain.Interop.COMRECT lprcClipRect, Interop.tagOIFI lpFrameInfo) { // TODO: Add DocHostUIHandler.GetWindowContext implementation ppFrame = null; ppDoc = null; }
public int GetContainer(out Ecyware.GreenBlue.GreenBlueMain.Interop.IOleContainer ppContainer) { ppContainer = (Interop.IOleContainer)this; return Interop.S_OK; }
private void UpdateForm(Ecyware.GreenBlue.Engine.Scripting.WebRequest request) { if ( _form != null ) { request.ClearForm(); request.Form.ReadHtmlFormTag(_form); } }
/// <summary> /// Adds the cookie collection to the property grid. /// </summary> /// <param name="cookies"> The cookies.</param> private void SetCookies(Ecyware.GreenBlue.Engine.Scripting.Cookie[] cookies) { PropertyTable bag = new PropertyTable(); bag.Properties.Clear(); // bag.GetValue += new PropertySpecEventHandler(bag_GetValue); // bag.SetValue += new PropertySpecEventHandler(bag_SetValue); string category = "Cookies"; foreach ( Ecyware.GreenBlue.Engine.Scripting.Cookie cookie in cookies ) { PropertySpec nameItem = new PropertySpec(cookie.Name,typeof(CookieWrapper),category,"Cookie"); nameItem.ConverterTypeName = "Ecyware.GreenBlue.Controls.CookieWrapperExtended"; PropertySpec[] items = {nameItem}; bag.Properties.AddRange(items); // add values bag[cookie.Name] = new CookieWrapperExtended(cookie); } this.pgCookies.SelectedObject = bag; }
/// <summary> /// Generates a MIME multipart/form-data header. /// </summary> /// <param name="boundary"> The boundary.</param> /// <param name="formTag"> The HtmlFormTag value.</param> /// <param name="fileItems"> The UploadFileInfo items.</param> /// <returns> A MIME multipart/form-data header string.</returns> protected string GenerateMimeFormData(string boundary, Ecyware.GreenBlue.Engine.HtmlDom.HtmlFormTag formTag, UploadFileInfo[] fileItems) { // create hashtable for upload file infos. Hashtable files = new Hashtable(); foreach ( UploadFileInfo fileInfo in fileItems ) { files.Add(fileInfo.FormFieldName, fileInfo); } HtmlParser parser = new HtmlParser(); ArrayList values = parser.GetArrayList(formTag); StringBuilder mimeData = new StringBuilder(); // Create form fields foreach ( string nameValuePair in values ) { string name = EncodeDecode.UrlDecode(nameValuePair.Split('=')[0]); string value = EncodeDecode.UrlDecode(nameValuePair.Split('=')[1].Trim().Trim('\0')).Trim('\0'); // skip keys from UploadFileItems. if ( files.ContainsKey(name) ) { UploadFileInfo fileInfo = (UploadFileInfo)files[name]; //-----------------------------7d52903b1507ec //\r\n //Content-Disposition: form-data; name=\"oFile1\"; filename=\"C:\\images\\GB Splash Screen.psd\" //\r\n //Content-Type: application/octet-stream //\r\n //\r\n mimeData.Append("--"); mimeData.Append(boundary); mimeData.Append("\r\n"); mimeData.AppendFormat("Content-Disposition: form-data; name=\"{0}\"",name); mimeData.AppendFormat("; filename=\"{0}\"",fileInfo.FileName); mimeData.Append("\r\n"); mimeData.Append("Content-Type: "); mimeData.Append(fileInfo.ContentType); mimeData.Append("\r\n"); mimeData.Append("\r\n"); } else { // Example //-----------------------------7d52903b1507ec //\r\n //Content-Disposition: form-data;name="Hello23" //\r\n //\r\n //Hello //\r\n mimeData.Append("--"); mimeData.Append(boundary); mimeData.Append("\r\n"); mimeData.AppendFormat("Content-Disposition: form-data; name=\"{0}\"",name); mimeData.Append("\r\n\r\n"); mimeData.Append(value); mimeData.Append("\r\n"); } } //mimeData.Append("\0"); return mimeData.ToString(); }
/// <summary> /// Loads the request. /// </summary> /// <param name="index"> The current request index.</param> /// <param name="scripting"> The scripting application.</param> /// <param name="request"> The current web request.</param> public override void LoadRequest(int index, ScriptingApplication scripting ,Ecyware.GreenBlue.Engine.Scripting.WebRequest request) { base.LoadRequest (index, scripting, request); try { //_httpRequestType = request.RequestType; _currentRequestUri = new Uri(request.Url); if ( request.Form.Elements.Length > 0 ) { HtmlFormTagCollection forms = new HtmlFormTagCollection(1); _form = request.Form.WriteHtmlFormTag(); forms.Add(request.Form.Name, _form); // Load tree LoadFormTree(forms); } else { DisplayNoDataMessage(); } } catch ( Exception ex ) { MessageBox.Show(ex.ToString(), AppLocation.ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// Updates the http properties. /// </summary> /// <returns> A HttpProperties.</returns> private void UpdateHttpPropertiesFromPropertyGrid(Ecyware.GreenBlue.Engine.Scripting.WebRequest request) { HttpProperties settings = request.RequestHttpSettings; PropertyTable bag = (PropertyTable)pgHeaders.SelectedObject; settings.Accept = (string)bag["Accept"]; if ( settings.AuthenticationSettings.UseBasicAuthentication ) { settings.AuthenticationSettings = settings.AuthenticationSettings; } else { settings.AuthenticationSettings.UseNTLMAuthentication =settings.AuthenticationSettings.UseNTLMAuthentication; } settings.ContentLength = Convert.ToInt64(bag["Content Length"]); settings.ContentType = (string)bag["Content Type"]; settings.IfModifiedSince = Convert.ToDateTime(bag["If Modified Since"]); settings.KeepAlive = (bool)bag["Keep Alive"]; settings.MediaType = (string)bag["Media Type"]; settings.Pipeline = (bool)bag["Pipeline"]; settings.Referer = (string)bag["Referer"]; settings.SendChunked = (bool)bag["Send Chunked"]; settings.TransferEncoding = (string)bag["Transfer Encoding"]; settings.UserAgent = (string)bag["User Agent"]; // Additional Headers for (int i=0;i<settings.AdditionalHeaders.Length;i++) { // Update additional headers values. settings.SetWebHeader(settings.AdditionalHeaders[i].Name,(string)bag[settings.AdditionalHeaders[i].Name]); } request.RequestHttpSettings = settings; }
/// <summary> /// Loads the request. /// </summary> /// <param name="index"> The selected web request index.</param> /// <param name="scripting"> The scripting application.</param> /// <param name="request"> The current web request.</param> public override void LoadRequest(int index, ScriptingApplication scripting ,Ecyware.GreenBlue.Engine.Scripting.WebRequest request) { if ( request is PostWebRequest ) { chkUsePostData.Visible = true; chkUsePostData.Checked = ((PostWebRequest)request).UsePostData; } else { chkUsePostData.Visible = false; } base.LoadRequest (index, scripting, request); txtUrl.Text = request.Url; txtRequestID.Text = request.ID; this.LoadHttpProperties(request.RequestHttpSettings); }
/// <summary> /// Loads the request. /// </summary> /// <param name="request"></param> public override void LoadRequest(int index, ScriptingApplication scripting ,Ecyware.GreenBlue.Engine.Scripting.WebRequest request) { base.LoadRequest (index, scripting, request); this.SuspendLayout(); tvTransforms.ContextMenu = this.mnuOutputMenu; pnTransformEditor.Controls.Clear(); tvTransforms.Nodes.Clear(); tvTransforms.Nodes.Add(new TreeNode("Transforms")); if ( request.OutputTransforms.Length > 0 ) { // Load transforms WebTransformPageUIHelper.LoadTransforms(tvTransforms.Nodes[0],request.OutputTransforms); } tvTransforms.ExpandAll(); tvTransforms.SelectedNode = tvTransforms.Nodes[0]; this.ResumeLayout(false); }
public override object GetValue(Ecyware.GreenBlue.Engine.Scripting.WebResponse response) { string result = ExecuteQuery(response.HttpBody); if ( Prefix.Length > 0 ) { result = Prefix + result; } if ( Postfix.Length > 0 ) { result = result + Postfix; } return result; }
private void UpdateCookies(Ecyware.GreenBlue.Engine.Scripting.WebRequest request) { PropertyTable bag = (PropertyTable)this.pgCookies.SelectedObject; Ecyware.GreenBlue.Engine.Scripting.Cookies editedCookies = new Ecyware.GreenBlue.Engine.Scripting.Cookies(); foreach ( Ecyware.GreenBlue.Engine.Scripting.Cookie cky in request.Cookies) { CookieWrapperExtended cookieWrapper = (CookieWrapperExtended)bag[cky.Name]; editedCookies.CookieList().Add(cookieWrapper.GetCookie()); } request.ClearCookies(); request.Cookies = editedCookies.GetCookies(); }
// private void toolBar_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e) // { // if ( e.Button == tbSaveApplication ) // { // if ( this.Parent.Parent is ScriptingDataDesigner ) // { // ScriptingDataDesigner designer = (ScriptingDataDesigner)this.Parent.Parent; // designer.SaveApplication(); // } // } // // if ( e.Button == tbArguments ) // { // if ( this.Parent.Parent is ScriptingDataDesigner ) // { // ScriptingDataDesigner designer = (ScriptingDataDesigner)this.Parent.Parent; // designer.ShowScriptingArgumentsDesigner(); // } // } // } /// <summary> /// Loads the request. /// </summary> /// <param name="index"> The current request index.</param> /// <param name="scripting"> The scripting application.</param> /// <param name="request"> The current web request.</param> public override void LoadRequest(int index, ScriptingApplication scripting ,Ecyware.GreenBlue.Engine.Scripting.WebRequest request) { base.LoadRequest (index, scripting, request); this.EditorText = ""; string postData = string.Empty; if ( request.RequestType == HttpRequestType.POST ) { postData = ((PostWebRequest)request).PostData; request.UpdateXmlEnvelope(postData); } if ( request.RequestType == HttpRequestType.PUT ) { postData = ((PutWebRequest)request).PostData; request.UpdateXmlEnvelope(postData); } if ( request.XmlEnvelope != null ) { this.EditorText = this.IndentFormatXml(request.XmlEnvelope); } }
/// <summary> /// Loads the request. /// </summary> /// <param name="request"></param> public override void LoadRequest(int index, ScriptingApplication scripting ,Ecyware.GreenBlue.Engine.Scripting.WebRequest request) { base.LoadRequest (index, scripting, request); this.SetCookies(request.Cookies); }
public int OnPosRectChange(Ecyware.GreenBlue.GreenBlueMain.Interop.COMRECT lprcPosRect) { // TODO: Add DocHostUIHandler.OnPosRectChange implementation return 0; }
/// <summary> /// Begins a new asynchronous HTTP Post request. This function is not thread safe. /// </summary> /// <param name="context"> The HttpRequestResponseContext type.</param> public void StartAsyncHttpPostFileUpload(Ecyware.GreenBlue.Engine.Scripting.HttpRequestResponseContext context) { Ecyware.GreenBlue.Engine.Scripting.PostWebRequest postWebRequest = (Ecyware.GreenBlue.Engine.Scripting.PostWebRequest)context.Request; HtmlFormTag formTag = postWebRequest.Form.WriteHtmlFormTag(); UploadFileInfo[] fileInfoItems = UploadFileInfo.GetUploadFiles(formTag); HtmlParser parser = new HtmlParser(); httpRequestState = new HttpState(); string uriString = context.Request.Url; if ( context.DecodeUrl ) { uriString = EncodeDecode.UrlDecode(uriString); } // create webrequest try { httpRequestState.HttpRequest = (HttpWebRequest)System.Net.WebRequest.Create(uriString); // Set HttpWebRequestProperties SetHttpWebRequestProperties(httpRequestState.HttpRequest, context.Request.RequestHttpSettings); // Apply proxy settings if ( this.ProxySettings != null ) { SetProxy(httpRequestState.HttpRequest,this.ProxySettings); } // Save cookies httpRequestState.HttpRequest.CookieContainer = new CookieContainer(); if ( context.Request.Cookies != null ) { httpRequestState.HttpRequest.CookieContainer.Add(context.Request.GetCookieCollection()); } #region Post Data string boundary = "--------------" + DateTime.Now.Ticks.ToString("x"); byte[] data = null; // Build the trailing boundary string as a byte array // ensuring the boundary appears on a line by itself byte[] boundaryBytes = null; long sumFileLength = 0; foreach ( UploadFileInfo uploadFile in fileInfoItems ) { FileInfo fileInformation = new FileInfo(uploadFile.FileName); sumFileLength += fileInformation.Length; } string postdata = GenerateMimeFormData(boundary, formTag, fileInfoItems); data = Encoding.UTF8.GetBytes(postdata); long length; if ( fileInfoItems.Length == 0 ) { boundaryBytes = Encoding.ASCII.GetBytes("--" + boundary + "--\r\n\0"); length = data.Length + sumFileLength + boundaryBytes.Length; } else { boundaryBytes = Encoding.ASCII.GetBytes("\r\n--" + boundary + "--\r\n"); length = data.Length + sumFileLength + boundaryBytes.Length; } // set properties //httpRequestState.HttpRequest.AllowWriteStreamBuffering = false; httpRequestState.HttpRequest.ServicePoint.Expect100Continue = false; httpRequestState.HttpRequest.KeepAlive = true; httpRequestState.HttpRequest.Timeout = 120000; httpRequestState.HttpRequest.Method = "POST"; httpRequestState.HttpRequest.ContentType = "multipart/form-data; boundary=" + boundary; httpRequestState.HttpRequest.ContentLength = length; httpRequestState.HttpRequest.Headers.Add("Cache-Control","no-cache"); // get request stream and write header Stream stm = httpRequestState.HttpRequest.GetRequestStream(); stm.Write(data,0,data.Length); if ( fileInfoItems.Length > 0 ) { foreach ( UploadFileInfo uploadFile in fileInfoItems ) { UploadFile(uploadFile, boundaryBytes, stm); } } stm.Write(boundaryBytes, 0, boundaryBytes.Length); stm.Flush(); stm.Close(); #endregion // Get Response IAsyncResult ar = httpRequestState.HttpRequest.BeginGetResponse(new AsyncCallback(FastResponseCallback),httpRequestState); // register a timeout ThreadPool.RegisterWaitForSingleObject(ar.AsyncWaitHandle, new WaitOrTimerCallback(BaseHttpForm.RequestTimeoutCallback), httpRequestState,this.GetTimeout(), true); } catch { throw; } finally { if ( httpRequestState.HttpResponse != null ) { httpRequestState.HttpResponse.Close(); } } }
/// <summary> /// Registers the exception event handler. /// </summary> /// <param name="handler"></param> public static void RegisterExceptionEventHandler(Ecyware.GreenBlue.LicenseServices.Client.ExceptionHandler handler) { client.ExceptionEventHandler += handler; }
/// <summary> /// Creates a new CookieWrapper. /// </summary> /// <param name="cookie"> The cookie to wrap.</param> public CookieWrapperExtended(Ecyware.GreenBlue.Engine.Scripting.Cookie cookie) { _cookie = cookie; }