Dundas Gauge for ASP.NET Send comments on this topic
Managing Image Files
See Also

Glossary Item Box

Overview

This topic discusses temporary image file management, which occurs when the gauge is rendered using an image or input tag (e.g., RenderType = ImageTag or InputTag).

For more information on how to render the Gauge control see the topic on Rendering Methods.

Temporary File Management

When rendering a gauge picture as an image or input tag the gauge picture is automatically saved to a file. The ImageUrl property determines the absolute or relative location and name of this file, and the file extension will be automatically added depending on the image type specified. 

The gauge control, via the ImageUrl property, gives you a great deal of latitude when it comes to managing these image files.

Note that it is up to you to determine the amount of traffic that the gauge control needs to handle, and take action accordingly.

 

  Note
The gauge control may be prevented from inserting warning messages into the Event Log due to the security settings currently in force on your system. Please check your security settings for possible issues.

 

The following describes three possible methods which can be used to work with these temporary files: 

  1. Single Filename

    If you provide one filename for the ImageUrl property then this file may be overridden by another gauge request before the original request is sent to the client. However, if the gauge is not frequently updated then using one filename for the gauge image should suffice, such as when the gauge is updated on a daily basis. In any event, this method should only be used if the gauge picture rarely changes.

  2. Unique Filenames using UIDs

    To prevent the gauge image file from being overridden, you can use a unique filename for each generated gauge. The simplest way to create a unique filename is to insert the "#UID" string into your filename. Then when the gauge is saved to file, this string will be replaced with a unique ID. For example, if you set ImageUrl to "Temp/gaugePic_#UID.jpeg" the actual filename that will be saved becomes “Temp/gaugePic_cf5941dc-d1e9-474b-bb19-b85739585336.jpeg”. Each time you generate a new gauge it will be saved using a different and unique filename.

    Using unique filenames in this manner eliminates the possibility that the gauge image file may be overwritten before it is sent to the requesting client. However, this method also introduces a new problem. Each time you generate a gauge, a new file is also created, which will then have to be deleted at some point in time. Since this is the case, we recommend that you use the Round Robin approach described below instead.

    Using unique filenames in this manner will ensure that end-users are always sent the correct gauge image file, but keep in mind that these image files must be manually deleted from the server.

  3. Round Robin (default)

    You can define, and use, a sequence of file names for your gauge images. Each time a gauge is generated the next filename in the sequence is used, and when the end of the sequence is reached the first filename is used again. This allows for control over the lifetime of the image files, and it will not create more temporary files than the sequence length permits.

    To define your filenames sequence you must insert this string in your ImageUrl property: “#SEQ(300,5)”. The first number (300) defines the length of the sequence (i.e., maximum number of temporary image files) and the second number (5) defines the required time to live for the file in minutes (if the file is overwritten and the life span is less than this second value, a warning message will be inserted into the Event Log). For example, if you set ImageUrl to "Temp/gaugePic_#SEQ(300,5)", the actual filenames will be:
    Temp/gaugePic_000001.jpeg, Temp/gaugePic_000002.jpeg, ... , Temp/gaugePic_000300.jpeg.

    On one hand, if you reduce the sequence length there will be fewer files created, and inherently less hard drive space required. On the other hand, reducing the sequence length also means that these image files will be overwritten at a greater pace. For example, if the sequence length is 1000 and there are 500 visitors an hour at a web site, then each gauge image will exist for approximately two hours before being overwritten.

    You can also set the required time to live parameter (this is the second parameter). This does not guarantee that the file will be available (and not overwritten) for 5 minutes, but instead it checks the live time of the file just before it is overwritten, and if it was less than the specified value, a warning message will be inserted into the Application Event Log. If this occurs, the allowable number of files can be increased to handle the large amount of traffic occurring at the web site.

    To solve a caching issue within Internet Explorer, a GUID is applied to the image URL similar to: "gaugePic_000002.jpg?4ea19276-5cb8-4f55-9d8f-8fe9c542de5". To generate a gauge without the GUID appended to it, simply use the keyword #NOGUIDPARAM.

    For example, FileName#SEQ(x,y)#NOGUIDPARAM

     

      Note
    The Round Robin method does not require that you delete image files manually from the server. 

See Also