Probably a simple question. How do you set up Rainbow to communicate through a proxy server? I have attempted to edit web.config with the following details: the details are all correct for the ISA server we are using and are the same settings as all the client
browsers. i know i cannot see the net as dilbert and news feeds do not work. Any assistance would be appreciated.
The fact is that the ProxyServer field is present in web.config, but none of the Desktop modules uses it! (It should be accessed via PortalSettings.GetProxy()) I made the changes in the DailyDilbert and XmlFeed modules. Just replace the Rainbow\DesktopModules\DailyDilbert\DailyDilbertImage.aspx.cs
and Rainbow\DesktopModules\DailyDilbert\DailyDilbertImage.aspx.cs files with the following ones and rebuild the application. Hi folks of the development team! Could you incorporate my changes? Rainbow\DesktopModules\DailyDilbert\DailyDilbertImage.aspx.cs ==========================================
using System;
using System.IO;
using System.Net;
using System.Text;
using System.Drawing;
using System.Web.Services;
using System.Drawing.Imaging;
using System.Collections;
using Rainbow.Design;
using Rainbow.Helpers;
using Rainbow.Configuration;
using Esperantus;
namespace Rainbow.DesktopModules
{
///
/// DailyDilbert Module
/// Based on VB Module Written by SnowCovered.com
/// Modifications and conversion for C# IBS Portal (c)2002 by Christopher S Judd, CDP
/// email- dotNet@HorizonsLLC.com web- www.HorizonsLLC.com/IBS
/// Modifications and conversion for Rainbow Jakob hansen
///
public class DailyDilbertImage : Rainbow.UI.ViewItemPage
{
///
/// The Page_Load server event handler on this User Control is used
/// to stream the current comic from the DailyDilbert web service
/// and output an image for use on the web control
///
/// The image returned is a thumbnail based on a % of
/// the original picture size. If no % reduction then
/// the image will be viewed at 100%. if (ModuleId cannot
/// be determined, then the image will be viewed at 100%.
/// Since when clicking on the comic from the module, ModuleID
/// is not sent, it displays the image in a new window at 100%.
///
///
///
private void Page_Load(object sender, System.EventArgs e)
{
HttpWebRequest objHTTPReq = null;
MemoryStream objMemStr = new MemoryStream();
String strAddress ;
String strImageAddress ;
String ImagePercent;
// Covert image percent to an integer, else set it to 100%
Double dblImagePercent ;
try
{
ImagePercent = moduleSettings["ImagePercent"].ToString();
dblImagePercent = Convert.ToDouble(ImagePercent);
}
catch
{
dblImagePercent = 100;
}
if (dblImagePercent == 0 )
{
dblImagePercent = 100;
}
dblImagePercent = dblImagePercent * 0.01;
// Get the image from the service and create a thumbnail for output
try
{
strAddress = "http://www.dilbert.com/comics/dilbert/archive/";
objHTTPReq = (HttpWebRequest) WebRequest.Create(strAddress);
// Check for Proxy
if (PortalSettings.GetProxy() != null) objHTTPReq.Proxy = PortalSettings.GetProxy();
StreamReader objStream = new StreamReader(objHTTPReq.GetResponse().GetResponseStream(), Encoding.ASCII);
strAddress = objStream.ReadToEnd();
objHTTPReq.GetResponse().Close();
if (strAddress.IndexOf("/comics/dilbert/archive/images/dilbert") > 0 )
{
// Setup the URL of the image to capture
strImageAddress = "http://www.dilbert.com";
strImageAddress += strAddress.Substring(strAddress.IndexOf("/comics/dilbert/archive/images/dilbert"), 56);
// Remove the & if it was added to the URL to prevent errors
strImageAddress = strImageAddress.Replace("&", "");
// Create the bitmap based on the image address
objHTTPReq = (HttpWebRequest) WebRequest.Create(strImageAddress);
// Check for Proxy
if (PortalSettings.GetProxy() != null) objHTTPReq.Proxy = PortalSettings.GetProxy();
Bitmap objDilbertImg = new Bitmap(objHTTPReq.GetResponse().GetResponseStream());
objHTTPReq.GetResponse().Close();
// Set the width and height based on the % of the current image size
int Width = Convert.ToInt32(objDilbertImg.Width * dblImagePercent);
int Height = Convert.ToInt32(objDilbertImg.Height * dblImagePercent);
// Create a thumbnail using the new size
Image myThumbnail = objDilbertImg.GetThumbnailImage(Width, Height, null, IntPtr.Zero);
// Set the output type and send image
Response.ContentType = "image/gif";
myThumbnail.Save(Response.OutputStream, ImageFormat.Gif);
}
}
catch
{
}
objMemStr = null;
objHTTPReq = null;
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}
Rainbow\DesktopModules\DailyDilbert\DailyDilbertImage.aspx.cs
==========================================
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Text.RegularExpressions;
using System.Xml;
using System.Net;
using Rainbow.UI;
using Rainbow.UI.DataTypes;
using Rainbow.UI.WebControls;
using Rainbow.Configuration;
namespace Rainbow.DesktopModules
{
///
/// XmlFeed Module
///
public abstract class XmlFeed : PortalModuleControl
{
protected System.Web.UI.WebControls.Xml xml1;
///
/// The Page_Load event handler on this User Control obtains
/// an xml document and xsl/t transform file location.
/// It then sets these properties on an <asp:Xml> server control.
///
///
///
private void Page_Load(object sender, System.EventArgs e)
{
string xmlsrc = "";
string xmlsrcType = Settings["XML Type"].ToString();
if (xmlsrcType == "File")
xmlsrc = Settings["XML File"].ToString();
else
xmlsrc = Settings["XML URL"].ToString();
string xslsrc = "";
string xslsrcType = Settings["XSL Type"].ToString();
if (xslsrcType == "File")
xslsrc = Settings["XSL File"].ToString();
else
xslsrc = Settings["XSL Predefined"].ToString();
//Timeout
int timeout = int.Parse(Settings["Timeout"].ToString());
if ((xmlsrc != null) && (xmlsrc != ""))
{
if (xmlsrcType == "File")
{
PortalUrlDataType pathXml = new PortalUrlDataType();
pathXml.Value = xmlsrc;
xmlsrc = pathXml.FullPath;
if (File.Exists(Server.MapPath(xmlsrc)))
xml1.DocumentSource = xmlsrc;
else
Controls.Add(new LiteralControl("
<div class='error'>File " + xmlsrc + " not found.
</div>"));
}
else
{
try
{
// handle on the remote ressource
HttpWebRequest wr = (HttpWebRequest) WebRequest.Create(xmlsrc);
if (PortalSettings.GetProxy() != null) wr.Proxy = PortalSettings.GetProxy();
// set the HTTP properties
wr.Timeout = timeout * 1000; // milliseconds to seconds
// Read the response
WebResponse resp = wr.GetResponse();
// Stream read the response
Stream stream = resp.GetResponseStream();
// Read XML data from the stream
XmlTextReader reader = new XmlTextReader(stream);
// ignore the DTD
reader.XmlResolver = null;
// Create a new document object
XmlDocument doc = new XmlDocument();
// Create the content of the XML Document from the XML data stream
doc.Load(reader);
// the XML control to hold the generated XML document
xml1.Document = doc;
}
catch(Exception ex)
{
// connectivity issues
Controls.Add(new LiteralControl("
<div class='error'>Error loading: " + xmlsrc + ".
" + ex.Message + "</div>"));
}
}
}
if (xslsrcType == "File")
{
PortalUrlDataType pathXsl = new PortalUrlDataType();
pathXsl.Value = xslsrc;
xslsrc = pathXsl.FullPath;
}
else
{
xslsrc = "~/DesktopModules/XmlFeed/" + xslsrc + ".xslt";
}
if ((xslsrc != null) && (xslsrc != ""))
{
if (File.Exists(Server.MapPath(xslsrc)))
xml1.TransformSource = xslsrc;
else
Controls.Add(new LiteralControl("
<div class='error'>File " + xslsrc + " not found.
</div>"));
}
}
///
/// Contsructor
///
public XmlFeed()
{
SettingItem XMLsrcType = new SettingItem(new ListDataType("URL;File"));
XMLsrcType.Required = true;
XMLsrcType.Value = "URL";
XMLsrcType.Order = 1;
this._baseSettings.Add("XML Type", XMLsrcType);
SettingItem XMLsrcUrl = new SettingItem(new UrlDataType());
XMLsrcUrl.Required = false;
XMLsrcUrl.Order = 2;
this._baseSettings.Add("XML URL", XMLsrcUrl);
SettingItem XMLsrcFile = new SettingItem(new PortalUrlDataType());
XMLsrcFile.Required = false;
XMLsrcFile.Order = 3;
this._baseSettings.Add("XML File", XMLsrcFile);
SettingItem XSLsrcType = new SettingItem(new ListDataType("Predefined;File"));
XSLsrcType.Required = true;
XSLsrcType.Value = "Predefined";
XSLsrcType.Order = 4;
this._baseSettings.Add("XSL Type", XSLsrcType);
SettingItem XSLsrcPredefined = new SettingItem(new ListDataType("RSS91;RSS2Html;KBALertz;RSSTabListWithHead;RSSTabListNoHead;RSSItemListWithHead;RSSItemListNoHead"));
XSLsrcPredefined.Required = true;
XSLsrcPredefined.Value = "RSS91";
XSLsrcPredefined.Order = 5;
this._baseSettings.Add("XSL Predefined", XSLsrcPredefined);
SettingItem XSLsrcFile = new SettingItem(new PortalUrlDataType());
XSLsrcFile.Required = false;
XSLsrcFile.Order = 6;
this._baseSettings.Add("XSL File", XSLsrcFile);
SettingItem Timeout = new SettingItem(new IntegerDataType());
Timeout.Required = true;
Timeout.Order = 7;
Timeout.Value = "15";
this._baseSettings.Add("Timeout", Timeout);
}
public override Guid GuidID
{
get
{
return new Guid("{2502DB18-B580-4F90-8CB4-C15E6E531020}");
}
}
#region Web Form Designer generated code
///
/// On init
///
///
override protected void OnInit(EventArgs e)
{
InitializeComponent();
ModuleTitle = new DesktopModuleTitle();
Controls.AddAt(0, ModuleTitle);
base.OnInit(e);
}
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}
Big_Steef
Member
40 Points
8 Posts
How to set up proxy?
Aug 12, 2003 04:17 PM|LINK
Dédé
Member
5 Points
1 Post
Re: How to set up proxy?
Aug 18, 2003 02:48 PM|LINK
using System; using System.IO; using System.Net; using System.Text; using System.Drawing; using System.Web.Services; using System.Drawing.Imaging; using System.Collections; using Rainbow.Design; using Rainbow.Helpers; using Rainbow.Configuration; using Esperantus; namespace Rainbow.DesktopModules { /// /// DailyDilbert Module /// Based on VB Module Written by SnowCovered.com /// Modifications and conversion for C# IBS Portal (c)2002 by Christopher S Judd, CDP /// email- dotNet@HorizonsLLC.com web- www.HorizonsLLC.com/IBS /// Modifications and conversion for Rainbow Jakob hansen /// public class DailyDilbertImage : Rainbow.UI.ViewItemPage { /// /// The Page_Load server event handler on this User Control is used /// to stream the current comic from the DailyDilbert web service /// and output an image for use on the web control /// /// The image returned is a thumbnail based on a % of /// the original picture size. If no % reduction then /// the image will be viewed at 100%. if (ModuleId cannot /// be determined, then the image will be viewed at 100%. /// Since when clicking on the comic from the module, ModuleID /// is not sent, it displays the image in a new window at 100%. /// /// /// private void Page_Load(object sender, System.EventArgs e) { HttpWebRequest objHTTPReq = null; MemoryStream objMemStr = new MemoryStream(); String strAddress ; String strImageAddress ; String ImagePercent; // Covert image percent to an integer, else set it to 100% Double dblImagePercent ; try { ImagePercent = moduleSettings["ImagePercent"].ToString(); dblImagePercent = Convert.ToDouble(ImagePercent); } catch { dblImagePercent = 100; } if (dblImagePercent == 0 ) { dblImagePercent = 100; } dblImagePercent = dblImagePercent * 0.01; // Get the image from the service and create a thumbnail for output try { strAddress = "http://www.dilbert.com/comics/dilbert/archive/"; objHTTPReq = (HttpWebRequest) WebRequest.Create(strAddress); // Check for Proxy if (PortalSettings.GetProxy() != null) objHTTPReq.Proxy = PortalSettings.GetProxy(); StreamReader objStream = new StreamReader(objHTTPReq.GetResponse().GetResponseStream(), Encoding.ASCII); strAddress = objStream.ReadToEnd(); objHTTPReq.GetResponse().Close(); if (strAddress.IndexOf("/comics/dilbert/archive/images/dilbert") > 0 ) { // Setup the URL of the image to capture strImageAddress = "http://www.dilbert.com"; strImageAddress += strAddress.Substring(strAddress.IndexOf("/comics/dilbert/archive/images/dilbert"), 56); // Remove the & if it was added to the URL to prevent errors strImageAddress = strImageAddress.Replace("&", ""); // Create the bitmap based on the image address objHTTPReq = (HttpWebRequest) WebRequest.Create(strImageAddress); // Check for Proxy if (PortalSettings.GetProxy() != null) objHTTPReq.Proxy = PortalSettings.GetProxy(); Bitmap objDilbertImg = new Bitmap(objHTTPReq.GetResponse().GetResponseStream()); objHTTPReq.GetResponse().Close(); // Set the width and height based on the % of the current image size int Width = Convert.ToInt32(objDilbertImg.Width * dblImagePercent); int Height = Convert.ToInt32(objDilbertImg.Height * dblImagePercent); // Create a thumbnail using the new size Image myThumbnail = objDilbertImg.GetThumbnailImage(Width, Height, null, IntPtr.Zero); // Set the output type and send image Response.ContentType = "image/gif"; myThumbnail.Save(Response.OutputStream, ImageFormat.Gif); } } catch { } objMemStr = null; objHTTPReq = null; } #region Web Form Designer generated code override protected void OnInit(EventArgs e) { // // CODEGEN: This call is required by the ASP.NET Web Form Designer. // InitializeComponent(); base.OnInit(e); } /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { this.Load += new System.EventHandler(this.Page_Load); } #endregion } } Rainbow\DesktopModules\DailyDilbert\DailyDilbertImage.aspx.cs ========================================== using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Drawing; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; using System.IO; using System.Text.RegularExpressions; using System.Xml; using System.Net; using Rainbow.UI; using Rainbow.UI.DataTypes; using Rainbow.UI.WebControls; using Rainbow.Configuration; namespace Rainbow.DesktopModules { /// /// XmlFeed Module /// public abstract class XmlFeed : PortalModuleControl { protected System.Web.UI.WebControls.Xml xml1; /// /// The Page_Load event handler on this User Control obtains /// an xml document and xsl/t transform file location. /// It then sets these properties on an <asp:Xml> server control. /// /// /// private void Page_Load(object sender, System.EventArgs e) { string xmlsrc = ""; string xmlsrcType = Settings["XML Type"].ToString(); if (xmlsrcType == "File") xmlsrc = Settings["XML File"].ToString(); else xmlsrc = Settings["XML URL"].ToString(); string xslsrc = ""; string xslsrcType = Settings["XSL Type"].ToString(); if (xslsrcType == "File") xslsrc = Settings["XSL File"].ToString(); else xslsrc = Settings["XSL Predefined"].ToString(); //Timeout int timeout = int.Parse(Settings["Timeout"].ToString()); if ((xmlsrc != null) && (xmlsrc != "")) { if (xmlsrcType == "File") { PortalUrlDataType pathXml = new PortalUrlDataType(); pathXml.Value = xmlsrc; xmlsrc = pathXml.FullPath; if (File.Exists(Server.MapPath(xmlsrc))) xml1.DocumentSource = xmlsrc; else Controls.Add(new LiteralControl(" <div class='error'>File " + xmlsrc + " not found. </div>")); } else { try { // handle on the remote ressource HttpWebRequest wr = (HttpWebRequest) WebRequest.Create(xmlsrc); if (PortalSettings.GetProxy() != null) wr.Proxy = PortalSettings.GetProxy(); // set the HTTP properties wr.Timeout = timeout * 1000; // milliseconds to seconds // Read the response WebResponse resp = wr.GetResponse(); // Stream read the response Stream stream = resp.GetResponseStream(); // Read XML data from the stream XmlTextReader reader = new XmlTextReader(stream); // ignore the DTD reader.XmlResolver = null; // Create a new document object XmlDocument doc = new XmlDocument(); // Create the content of the XML Document from the XML data stream doc.Load(reader); // the XML control to hold the generated XML document xml1.Document = doc; } catch(Exception ex) { // connectivity issues Controls.Add(new LiteralControl(" <div class='error'>Error loading: " + xmlsrc + ". " + ex.Message + "</div>")); } } } if (xslsrcType == "File") { PortalUrlDataType pathXsl = new PortalUrlDataType(); pathXsl.Value = xslsrc; xslsrc = pathXsl.FullPath; } else { xslsrc = "~/DesktopModules/XmlFeed/" + xslsrc + ".xslt"; } if ((xslsrc != null) && (xslsrc != "")) { if (File.Exists(Server.MapPath(xslsrc))) xml1.TransformSource = xslsrc; else Controls.Add(new LiteralControl(" <div class='error'>File " + xslsrc + " not found. </div>")); } } /// /// Contsructor /// public XmlFeed() { SettingItem XMLsrcType = new SettingItem(new ListDataType("URL;File")); XMLsrcType.Required = true; XMLsrcType.Value = "URL"; XMLsrcType.Order = 1; this._baseSettings.Add("XML Type", XMLsrcType); SettingItem XMLsrcUrl = new SettingItem(new UrlDataType()); XMLsrcUrl.Required = false; XMLsrcUrl.Order = 2; this._baseSettings.Add("XML URL", XMLsrcUrl); SettingItem XMLsrcFile = new SettingItem(new PortalUrlDataType()); XMLsrcFile.Required = false; XMLsrcFile.Order = 3; this._baseSettings.Add("XML File", XMLsrcFile); SettingItem XSLsrcType = new SettingItem(new ListDataType("Predefined;File")); XSLsrcType.Required = true; XSLsrcType.Value = "Predefined"; XSLsrcType.Order = 4; this._baseSettings.Add("XSL Type", XSLsrcType); SettingItem XSLsrcPredefined = new SettingItem(new ListDataType("RSS91;RSS2Html;KBALertz;RSSTabListWithHead;RSSTabListNoHead;RSSItemListWithHead;RSSItemListNoHead")); XSLsrcPredefined.Required = true; XSLsrcPredefined.Value = "RSS91"; XSLsrcPredefined.Order = 5; this._baseSettings.Add("XSL Predefined", XSLsrcPredefined); SettingItem XSLsrcFile = new SettingItem(new PortalUrlDataType()); XSLsrcFile.Required = false; XSLsrcFile.Order = 6; this._baseSettings.Add("XSL File", XSLsrcFile); SettingItem Timeout = new SettingItem(new IntegerDataType()); Timeout.Required = true; Timeout.Order = 7; Timeout.Value = "15"; this._baseSettings.Add("Timeout", Timeout); } public override Guid GuidID { get { return new Guid("{2502DB18-B580-4F90-8CB4-C15E6E531020}"); } } #region Web Form Designer generated code /// /// On init /// /// override protected void OnInit(EventArgs e) { InitializeComponent(); ModuleTitle = new DesktopModuleTitle(); Controls.AddAt(0, ModuleTitle); base.OnInit(e); } /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { this.Load += new System.EventHandler(this.Page_Load); } #endregion } }