protected override IGatewayHandler ProcessGatewayRequest(HttpContext objHttpContext, string strAction) { IGatewayHandler objGH = null; if (!String.IsNullOrEmpty(strAction) && strAction.Equals("FileContent")) { if (objHttpContext != null && objHttpContext != null && objHttpContext.Response != null) { // Disable cache. objHttpContext.Response.Expires = -1; // Set Headers for the Pdf attachment objHttpContext.Response.ContentType = "application/octet-stream"; objHttpContext.Response.AddHeader("Content-Disposition", string.Format("inline; filename={0};", _ReportName)); objHttpContext.Response.BinaryWrite(_BinarySource.ToArray()); objHttpContext.Response.Flush(); objHttpContext.Response.End(); } } return(objGH); }
void IGatewayComponent.ProcessRequest(IContext objContext, string strAction) { // Trt to get the gateway handler IGatewayHandler objGatewayHandler = ProcessGatewayRequest(objContext.HttpContext, strAction); if (objGatewayHandler != null) { objGatewayHandler.ProcessGatewayRequest(objContext, this); } }
protected override IGatewayHandler ProcessGatewayRequest(HttpContext objContext, string strAction) { IGatewayHandler objGH = null; int NewWidth = this.Size.Width; int MaxHeight = this.Size.Height; bool OnlyResizeIfWider = true; if (imageName.Length != 0) { if (!(File.Exists(imageName))) { imageName = Path.Combine(VWGContext.Current.Config.GetDirectory("Images"), "no_photo.jpg"); } // This allows us to resize the image. It prevents skewed images and // also vertically long images caused by trying to maintain the aspect // ratio on images who's height is larger than their width System.Drawing.Image FullsizeImage = System.Drawing.Image.FromFile(imageName); // Prevent using images internal thumbnail FullsizeImage.RotateFlip(System.Drawing.RotateFlipType.Rotate180FlipNone); FullsizeImage.RotateFlip(System.Drawing.RotateFlipType.Rotate180FlipNone); if (OnlyResizeIfWider) { if (FullsizeImage.Width <= NewWidth) { NewWidth = FullsizeImage.Width; } } int NewHeight = FullsizeImage.Height * NewWidth / FullsizeImage.Width; if (NewHeight > MaxHeight) { // Resize with height instead NewWidth = FullsizeImage.Width * MaxHeight / FullsizeImage.Height; NewHeight = MaxHeight; } System.Drawing.Image NewImage = FullsizeImage.GetThumbnailImage(NewWidth, NewHeight, null, IntPtr.Zero); // Clear handle to original file so that we can overwrite it if necessary FullsizeImage.Dispose(); // Save resized picture NewImage.Save(HttpContext.Current.Response.OutputStream, ImageFormat.Jpeg); NewImage.Dispose(); } return(objGH); }
internal void SetHandler(IGatewayHandler gatewayHandler) { _gatewayHandler = gatewayHandler; }