SpriteHand
Module Border
  Most recent blog entries
Module Border
Dynamic Images in Crystal Reports .NET
Andy's Blog By Andy Beaulieu on 1/27/2005 8:10 PM

You would think this is a simple task: let's say you have a Crystal Report and you want to dynamically change an image in the report by loading an image from disk. Well, as it turns out, this functionality is not available in CR for .NET!

But here is a work-around; Crystal for .NET does support displaying images from a DB. And it does support accepting a disconnected ADO DataSet as a data source. So you can trick Crystal into thinking it loaded an image from disk and presto, you have dynamic images from disk. Here's the process:

(1) Create an XSD file (you'll use this as your report data source in step 2) with a binary column definition like so:

<xs:element name="AnImage" type="xs:base64Binary" minOccurs="0" />

(2) Create your Crystal Report and use an ADO.NET (XML) DataSource as your Crystal Report Data Source.

(3) Fill your DataSet, and then set the binary “image” column to an image file from disk using a MemoryStream like so:

Dim oLogo As System.Drawing.Image
Dim msX As New MemoryStream
Dim dsReportSource As New DataSet
' TODO: Fill your DataSet, dsReportSource, with your Report Data

' Load your image from disk
oLogo = oLogo.FromFile("C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures\Blue hills.jpg")
' Save the image data to a Memory Stream
oLogo.Save(msX, System.Drawing.Imaging.ImageFormat.Bmp)
' Set the binary "image" column in your DataSet to the image data (note dsReportSource is a typed DS here)
dsReportSource.TestImage(0).AnImage = msX.GetBuffer

(4) Load your Crystal Report and assign the Data Source as usual:

Dim oRpt As New ReportDocument
oRpt.Load("CrystalReport1.rpt")
oRpt.SetDataSource(DsTestImage1)
CrystalReportViewer1.ReportSource = oRpt

Comments (9)

Streaming Crystal Output to a Browser
Andy's Blog By Andy Beaulieu on 12/14/2004 7:19 PM

This is a handy function that accepts an Export Format (i.e. PDF, Word or Excel) and streams a Crystal Report output back to the browser client.

   Private Sub ExportReport(ByVal iFormatType As ExportFormatType)
        Dim sTargetPath As String, sTargetExt As String, sContentType As String
        Dim fs As FileStream
        Dim FileSize As Long
        Dim GenDS As DataSet
        Dim oRD As New ReportDocument()
        Dim crReportObject As ReportObject
        Dim oExO As ExportOptions
        Dim oExDo As New DiskFileDestinationOptions()

        'Build Target Filename
        Select Case iFormatType
            Case ExportFormatType.Excel
                sTargetExt = ".xls"
                sContentType = "application/vnd.ms-excel"
            Case ExportFormatType.PortableDocFormat
                sTargetExt = ".pdf"
                sContentType = "application/pdf"
            Case ExportFormatType.WordForWindows
                sTargetExt = ".doc"
                sContentType = "application/msword"

        End Select

        sTargetPath = Server.MapPath("") & "\Export\" & Session.SessionID & sTargetExt

        oRD = GetReportDocument()
        'Export to PDF
        oExDo.DiskFileName = sTargetPath
        oExO = oRD.ExportOptions
        oExO.ExportDestinationType = ExportDestinationType.DiskFile
        oExO.ExportFormatType = iFormatType
        oExO.DestinationOptions = oExDo
        oRD.Export()
        oRD.Close()

        'Send the file to the user that made the request
        Response.Clear()
        Response.Buffer = True
        Response.AddHeader("Content-Type", sContentType)
        Response.AddHeader("Content-Disposition", "file;filename=" & Left(ViewState("ReportName"), Len(ViewState("ReportName")) - 4) & sTargetExt)
        fs = New FileStream(sTargetPath, FileMode.Open)
        FileSize = fs.Length
        Dim bBuffer(CInt(FileSize)) As Byte
        fs.Read(bBuffer, 0, CInt(FileSize))
        fs.Close()

        Response.BinaryWrite(bBuffer)
        Response.Flush()
        Response.Close()

    End Sub

 

Comments (3)

New Profiler in Whidbey
Andy's Blog By Andy Beaulieu on 12/7/2004 12:41 PM

I've used the .NET CLR Profiling Services to find bottlenecks in code, such as suggested by this article (which includes an implementation of a CLR Profiler):

http://msdn.microsoft.com/msdnmag/issues/01/11/NetProf/

But the nice thing is, Whidbey has a built-in profiler available, with nice graphs and reports built in - check out this article to learn more

http://msdn.microsoft.com/msdnmag/issues/04/12/EnterprisePerformance/default.aspx

Comments (0)

Woohoo
Andy's Blog By Andy Beaulieu on 10/27/2004 7:31 PM

One of my Pocket PC components - AWaveCE - got an award.

http://www.pocketpcmag.com/awards/category_2004.asp?catid=46

I created AWaveCE awhile ago as a simple wrapper for a GPL mikmod port. It's always been free and the source is available on my SpriteHand website - http://www.spritehand.com

 

ASpriteCE was a finalist in the competition - that's a component for creating Pocket PC games, and is actually much more complex than AWaveCE ;-)

Comments (0)

AWaveCE gets award, ASpriteCE finalist
Andy's Blog By Andy Beaulieu on 10/27/2004 1:12 PM
AWaveCE has won a Pocket PC Magazine Best Software Award, and ASpriteCE was a finalist.

The AWaveCE Audio Control makes it easy to add music and buffered sound to your Pocket PC apps. It is an ActiveX Control wrapper for Mikmod, an LGPL library.

The ASpriteCE Game Control is an ActiveX control which allows creation of PocketPC games using eVB and other development tools.
awaveceAward.gif
Comments (0)

Retrieving DB2 Index Info
Andy's Blog By Andy Beaulieu on 10/20/2004 9:09 AM

The Visual Studio.NET add-in for DB2, which is part of the “Stinger“ release, offers a much better implementation of the Server Explorer for DB2 users. But I recently found myself needing Index information from a DB2 database without any good schema exploration tool...

SELECT SYSCOLUMNS.TBNAME, SYSCOLUMNS.TBCREATOR, SYSKEYS.IXNAME, SYSKEYS.COLNAME, SYSKEYS.COLSEQ, SYSCOLUMNS.NAME, SYSCOLUMNS.TBNAME, SYSCOLUMNS.TBCREATOR, SYSCOLUMNS.COLNO, SYSCOLUMNS.COLTYPE, SYSCOLUMNS.LENGTH,SYSCOLUMNS.SCALE, SYSCOLUMNS.NULLS
 FROM SYSIBM.SYSKEYS SYSKEYS ,SYSIBM.SYSCOLUMNS SYSCOLUMNS INNER JOIN SYSIBM.SYSINDEXES SYSINDEXES ON SYSINDEXES.NAME = SYSKEYS.IXNAME
 WHERE SYSKEYS.IXCREATOR = SYSCOLUMNS.TBCREATOR
  AND SYSKEYS.COLNAME = SYSCOLUMNS.NAME
  AND SYSKEYS.COLNO = SYSCOLUMNS.COLNO
  AND SYSKEYS.IXCREATOR = '<CREATOR>'
  AND SYSINDEXES.TBNAME ='<TABLENAME>'
  AND SYSCOLUMNS.TBNAME = SYSINDEXES.TBNAME
  AND SYSINDEXES.CREATOR = '<CREATOR>'
ORDER BY TBNAME,IXNAME,COLSEQ

Comments (0)

Remoting DataSets
Andy's Blog By Andy Beaulieu on 10/15/2004 1:44 PM

I think this is an inside joke with the folks who coded DataSet Serialization and Remoting at Microsoft ;-)

Q: Why did the DataSet cross the Remoting Channel in Binary Format?

A: To get serialized as XML!

(crowd laughs)... When you serialize a DataSet, say through remoting, the DataSet gets serialized as XML. So if you're trying to eek out some performance by using Binary Formatting under Remoting, and you pass a DataSet, (here's the punchline), it gets passed as bloated XML.

Luckily, there are a couple of work-arounds presented in these articles ---

http://support.microsoft.com/?id=829740

http://msdn.microsoft.com/msdnmag/issues/02/12/cuttingedge/

Comments (0)

Finding the CPU Hog
Andy's Blog By Andy Beaulieu on 10/13/2004 1:38 PM

This is really a fun game. You have a bunch of services running on a box, and users are reporting sluggish response during off hours. You have a hunch that one of the services is hogging the CPU, but how do you figure out which one is the hog?

Here is a quick step-by-step on finding the CPU hog using performance monitor (XP or W2k):

(1) Goto Control Panel/Administrative Tools/Performance

(2) Select Performance Logs and Alerts, then Counter Logs.

(3) Right-click Counter Logs and select “New Log Settings...” and give the Log a name.

(4) Select Thread from Performance Object, then % Processor Time.

(5) Select the All Instances radio button, then click the Add button, then Close.

(6) For the Log File Type DropDown, you probably want to select CSV so you can toy with the data in Excel afterwards ;-)

Comments (0)

Web Services: What happened to HTTP GET and POST?
Andy's Blog By Andy Beaulieu on 10/12/2004 6:15 PM

Back in the day... well, back in .NET Framework 1.0, you could execute a web service from a  browser using HTTP GET, for example:

http://webservername/vdir/webservicename.asmx/MethodName?parameter=value

But for security reasons, Microsoft disabled this by default in Framework version 1.1. This article explains the situation - http://support.microsoft.com/default.aspx?scid=kb;en-us;819267

Comments (0)

New CodeSmith article on MSDN
Andy's Blog By Andy Beaulieu on 9/28/2004 9:54 AM
I've been a longtime fan of code generation for an application's Data Access Layer. There is a new article on MSDN that gives a quick overview of Codesmith, probably the most popular code generation tool for .NET - http://msdn.microsoft.com/vstudio/default.aspx?pull=/library/en-us/dnhcvs04/html/vs04e5.asp
Comments (0)

Module Border Module Border
Module Border
  Subscribe
Module Border
RSS   Twitter
Module Border Module Border
Module Border
  Diversions
Module Border

TALKING RAGDOLL
This Windows Phone 7 App was created using Silverlight, the  Physics Helper Library,  and the Farseer Physics Engine. It gets interesting when you import your friends photos and have your way with them!

MORE INFO



DROPPYPOP
This Windows Phone 7 game was created using Silverlight, the  Physics Helper Library,  and the Farseer Physics Engine.
DEMO

MORE INFO



BOSS LAUNCH
This physics game won first place in the Server Quest Contest. Created using Silverlight 2, the Physics Helper Library,  and the Farseer Physics Engine.
PLAY IT

MORE INFO



DESTROY ALL INVADERS
A scrolling shooter game where the objective is to destroy the invading UFO's flying over a neighborhood of your choosing. Imagery provided by Microsoft Virtual Earth. Created using Silverlight 2.
PLAY IT

INFO AND CODE



PHYSICS HELPER DEMOS
These demos were created for the Physics Helper Library, which makes it easy to create physics games and simulations using Expression Blend, Silverlight, and the Farseer Physics Engine.
PLAY IT

INFO AND CODE



HOOK SHOT
This little basketball game took first place in the TeamZoneSports Silverlight Contest. Created using Silverlight 2 and the Farseer Physics engine.
PLAY IT

MORE INFO



SORT THE FOOBARS
A game where you need to sort the good foobars from the bad ones. Created using Silverlight 2 and the Farseer Physics engine.
PLAY IT

MORE INFO



POLYGON PHYSICS DEMO
A demo showing polygon physics where the user draws physics objects with the mouse. Created using Silverlight 2 and the Farseer Physics engine.
PLAY IT

MORE INFO



SILVERLIGHT ROCKS!
Destroy the asteroids before they destroy your ship! Created using Silverlight 2.
PLAY IT

INFO AND CODE



FISH GAME
A simple game of harpoon-the-fish. Written using the AJAX Sprite Toolkit.
PLAY IT

INFO AND CODE

Module Border Module Border
Module Border
  Search_Blog
Module Border
Module Border Module Border
Module Border
  Blog_Archive
Module Border
Module Border Module Border
Copyright (c) 2014 andy.beaulieu.com - Login